diff --git a/server/src/player.rs b/server/src/player.rs index b0988a3a..612e1ce8 100644 --- a/server/src/player.rs +++ b/server/src/player.rs @@ -184,6 +184,7 @@ impl Player { // do we have any colours in store? let colours = self.vbox.store[&ItemType::Colours].keys() .cloned() + .take(2) .collect::>(); // how about a base skill? @@ -193,11 +194,13 @@ impl Player { }; // if no: try to refill and start again - match colours.len() < 2 || base.is_none() { - true => match self.vbox_refill() { - Ok(_) => continue, - Err(_) => break, // give up - }, + match colours.len() != 2 || base.is_none() { + true => { + match self.vbox_refill() { + Ok(_) => continue, + Err(_) => break, // give up + }; + } false => { let mut vbox_items = HashMap::new(); vbox_items.insert(ItemType::Colours, colours); @@ -230,7 +233,7 @@ impl Player { // there's a bad bug here where if this apply fails // the item in question will be silently dropped let item = self.vbox.stash.remove(&i).unwrap(); - self.vbox_apply(item, construct_id).ok(); + self.vbox_apply(item, construct_id).unwrap(); continue; } // need to buy one @@ -238,6 +241,7 @@ impl Player { // do we have any colours in store? let colours = self.vbox.store[&ItemType::Colours].keys() .cloned() + .take(2) .collect::>(); // how about a base spec? @@ -247,7 +251,7 @@ impl Player { }; // if no: try to refill and start again - match colours.len() < 2 || base.is_none() { + match colours.len() != 2 || base.is_none() { true => match self.vbox_refill() { Ok(_) => continue, Err(_) => break, // give up @@ -446,9 +450,11 @@ mod tests { let mut player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true); player.vbox.fill(); + player.vbox.bits = 100; player.autobuy(); - assert!(player.constructs.iter().all(|c| c.skills.len() >= 1)); + assert!(player.constructs.iter().all(|c| c.skills.len() > 1)); + assert!(player.constructs.iter().all(|c| c.specs.len() >= 1)); } #[test]