first round vbox
This commit is contained in:
parent
37acbaedfd
commit
29c2781622
@ -193,7 +193,7 @@ impl Instance {
|
||||
|
||||
fn bot_vbox_phase(&mut self) -> &mut Instance {
|
||||
for bot in self.players.iter_mut().filter(|p| p.bot) {
|
||||
bot.vbox.fill();
|
||||
bot.vbox.fill(false);
|
||||
bot.set_ready(true);
|
||||
}
|
||||
|
||||
@ -400,7 +400,8 @@ pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account:
|
||||
return Err(format_err!("incorrect team size. ({:})", 3));
|
||||
}
|
||||
|
||||
let player = Player::new(account.id, instance.id, cryps);
|
||||
let mut player = Player::new(account.id, instance.id, cryps);
|
||||
player.vbox.fill(true);
|
||||
player_create(tx, &player, account)?;
|
||||
|
||||
instance.add_player(player.clone());
|
||||
@ -495,7 +496,7 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu
|
||||
.iter()
|
||||
.filter(|p| !p.bot) {
|
||||
let mut player = player_get(tx, player.account, instance_id)?;
|
||||
player.vbox.fill();
|
||||
player.vbox.fill(false);
|
||||
player_update(tx, player)?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ impl Vbox {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fill(&mut self) -> &mut Vbox {
|
||||
pub fn fill(&mut self, init: bool) -> &mut Vbox {
|
||||
let colours = vec![
|
||||
(Var::Red, 1),
|
||||
(Var::Green, 1),
|
||||
@ -177,6 +177,13 @@ impl Vbox {
|
||||
free.push(vars[dist.sample(&mut rng)].0);
|
||||
}
|
||||
|
||||
// make sure there are 3 attacks in the first round
|
||||
if init {
|
||||
free[6] = Var::Attack;
|
||||
free[7] = Var::Attack;
|
||||
free[8] = Var::Attack;
|
||||
}
|
||||
|
||||
self.free = free;
|
||||
|
||||
self
|
||||
@ -302,7 +309,7 @@ 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();
|
||||
player.vbox.fill(false);
|
||||
return player_update(tx, player);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user