fucked up perms, players db without cryps

This commit is contained in:
ntr
2018-11-29 23:46:24 +11:00
parent 38af55aacd
commit e29842ffc1
12 changed files with 13 additions and 51 deletions
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
+13 -19
View File
@@ -592,27 +592,22 @@ pub fn game_get(tx: &mut Transaction, id: Uuid) -> Result<Game, Error> {
return Ok(game);
}
/// write a row for every cryp in a team when added to a battle
pub fn players_write(team: &Team, game_id: Uuid, tx: &mut Transaction) -> Result<(), Error> {
pub fn players_write(account: &Account, game_id: Uuid, tx: &mut Transaction) -> Result<(), Error> {
// pve
if !team.id.is_nil() {
for cryp in &team.cryps {
let id = Uuid::new_v4();
let id = Uuid::new_v4();
let query = "
INSERT INTO players (id, game, cryp, account)
VALUES ($1, $2, $3, $4)
RETURNING id, account;
";
let query = "
INSERT INTO players (id, game, account)
VALUES ($1, $2, $3)
RETURNING id, account;
";
let result = tx
.query(query, &[&id, &game_id, &cryp.id, &team.id])?;
let result = tx
.query(query, &[&id, &game_id, &account.id])?;
let _returned = result.iter().next().expect("no row written");
let _returned = result.iter().next().expect("no row written");
println!("wrote player entry game:{:?} cryp:{:?} account:{:?}", game_id, cryp.id, team.id);
}
}
println!("wrote player {:?} joined game: {:?}", account.name, game_id);
return Ok(());
}
@@ -695,7 +690,6 @@ pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account)
// persist
game_new(&game, tx)?;
// players_write(&game.team_by_id(account.id), game_id, tx)?;
Ok(game)
}
@@ -723,7 +717,7 @@ pub fn game_pvp(params: GamePvpParams, tx: &mut Transaction, account: &Account)
// persist
game_new(&game, tx)?;
players_write(&game.team_by_id(account.id), game_id, tx)?;
players_write(account, game_id, tx)?;
Ok(game)
}
@@ -757,7 +751,7 @@ pub fn game_join(params: GameJoinParams, tx: &mut Transaction, account: &Account
}
game_update(&game, tx)?;
players_write(&game.team_by_id(account.id), game_id, tx)?;
players_write(account, game_id, tx)?;
Ok(game)
}
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File