join play and account team change'

This commit is contained in:
ntr
2019-07-30 13:18:47 +10:00
parent 97b3943d18
commit 3fcbedb5e3
6 changed files with 177 additions and 6 deletions
+2 -2
View File
@@ -296,7 +296,7 @@ pub fn constructs(tx: &mut Transaction, account: &Account) -> Result<Vec<Constru
return Ok(constructs);
}
pub fn account_team(tx: &mut Transaction, account: &Account) -> Result<Vec<Construct>, Error> {
pub fn team(tx: &mut Transaction, account: &Account) -> Result<Vec<Construct>, Error> {
let query = "
SELECT data
FROM constructs
@@ -350,7 +350,7 @@ pub fn set_team(tx: &mut Transaction, account: &Account, ids: Vec<Uuid>) -> Resu
let _updated = tx
.execute(query, &[&account.id, &ids])?;
account_team(tx, account)
team(tx, account)
}
pub fn account_instances(tx: &mut Transaction, account: &Account) -> Result<Vec<Instance>, Error> {
+2 -2
View File
@@ -676,7 +676,7 @@ pub fn instance_practice(tx: &mut Transaction, account: &Account) -> Result<Inst
.set_time_control(TimeControl::Practice)
.set_name(bot.name.clone())?;
let constructs = account::account_team(tx, account)?;
let constructs = account::team(tx, account)?;
let player = Player::new(account.id, &account.name, constructs);
instance.add_player(player.clone())?;
@@ -700,7 +700,7 @@ pub fn pvp(tx: &mut Transaction, a: &Account, b: &Account) -> Result<Instance, E
instance = instance_create(tx, instance)?;
for account in [a, b].iter() {
let constructs = account::account_team(tx, account)?;
let constructs = account::team(tx, account)?;
let player = player_create(tx, Player::new(account.id, &account.name, constructs), instance.id, account)?;
instance.add_player(player)?;
}
+1 -1
View File
@@ -159,7 +159,7 @@ pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, const
};
construct_write(tx, construct)?;
account::constructs(tx, account)
account::team(tx, account)
}
pub fn select(tx: &mut Transaction, variant: MtxVariant, account: Uuid) -> Result<Mtx, Error> {
+1 -1
View File
@@ -237,7 +237,7 @@ impl Handler for Connection {
let shop = mtx::account_shop(&mut tx, &a).unwrap();
self.ws.send(RpcMessage::AccountShop(shop)).unwrap();
let team = account::account_team(&mut tx, &a).unwrap();
let team = account::team(&mut tx, &a).unwrap();
self.ws.send(RpcMessage::AccountTeam(team)).unwrap();
// tx should do nothing