update scores ignores phase
This commit is contained in:
parent
c036750a4b
commit
52cf570a70
@ -70,9 +70,9 @@ impl Instance {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn player_update(mut self, player: Player) -> Result<Instance, Error> {
|
||||
if self.phase != InstancePhase::Vbox {
|
||||
return Err(format_err!("instance not in vbox phase {:?}", self.phase));
|
||||
pub fn player_update(mut self, player: Player, ignore_phase: bool) -> Result<Instance, Error> {
|
||||
if !ignore_phase && self.phase != InstancePhase::Vbox {
|
||||
return Err(format_err!("instance not in vbox phase ({:?})", self.phase));
|
||||
}
|
||||
|
||||
let i = self.players
|
||||
@ -447,7 +447,7 @@ pub fn instance_ready(params: InstanceReadyParams, tx: &mut Transaction, account
|
||||
}
|
||||
};
|
||||
|
||||
player_update(tx, player)?;
|
||||
player_update(tx, player, false)?;
|
||||
instance_update(tx, instance)?;
|
||||
return Ok(game);
|
||||
}
|
||||
@ -476,7 +476,7 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu
|
||||
false => player.add_loss(),
|
||||
};
|
||||
println!("{:?}", player);
|
||||
player_update(tx, player)?;
|
||||
player_update(tx, player, true)?;
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -497,7 +497,7 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu
|
||||
.filter(|p| !p.bot) {
|
||||
let mut player = player_get(tx, player.account, instance_id)?;
|
||||
player.vbox.fill();
|
||||
player_update(tx, player)?;
|
||||
player_update(tx, player, false)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -113,12 +113,12 @@ pub fn player_create(tx: &mut Transaction, player: &Player, account: &Account) -
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn player_update(tx: &mut Transaction, player: Player) -> Result<Player, Error> {
|
||||
pub fn player_update(tx: &mut Transaction, player: Player, ignore_phase: bool) -> Result<Player, Error> {
|
||||
// update the instance this player is associated with
|
||||
// if not a global player
|
||||
if player.instance != Uuid::nil() {
|
||||
let instance = instance_get(tx, player.instance)?
|
||||
.player_update(player.clone())?;
|
||||
.player_update(player.clone(), ignore_phase)?;
|
||||
instance_update(tx, instance)?;
|
||||
}
|
||||
|
||||
@ -181,5 +181,5 @@ pub fn player_cryps_set(params: PlayerCrypsSetParams, tx: &mut Transaction, acco
|
||||
|
||||
player.cryps = cryps;
|
||||
|
||||
player_update(tx, player)
|
||||
player_update(tx, player, false)
|
||||
}
|
||||
|
||||
@ -387,25 +387,25 @@ impl Vbox {
|
||||
pub fn vbox_discard(params: VboxDiscardParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
||||
let mut player = player_get(tx, account.id, params.instance_id)?;
|
||||
player.vbox.fill();
|
||||
return player_update(tx, player);
|
||||
return player_update(tx, player, false);
|
||||
}
|
||||
|
||||
pub fn vbox_accept(params: VboxAcceptParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
||||
let mut player = player_get(tx, account.id, params.instance_id)?;
|
||||
player.vbox.accept(params.group, params.index)?;
|
||||
return player_update(tx, player);
|
||||
return player_update(tx, player, false);
|
||||
}
|
||||
|
||||
pub fn vbox_combine(params: VboxCombineParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
||||
let mut player = player_get(tx, account.id, params.instance_id)?;
|
||||
player.vbox.combine(params.indices)?;
|
||||
return player_update(tx, player);
|
||||
return player_update(tx, player, false);
|
||||
}
|
||||
|
||||
pub fn vbox_drop(params: VboxDropParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
||||
let mut player = player_get(tx, account.id, params.instance_id)?;
|
||||
player.vbox.drop(params.index)?;
|
||||
return player_update(tx, player);
|
||||
return player_update(tx, player, false);
|
||||
}
|
||||
|
||||
pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
|
||||
@ -432,7 +432,7 @@ pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Accou
|
||||
},
|
||||
}
|
||||
|
||||
return player_update(tx, player);
|
||||
return player_update(tx, player, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user