diff --git a/src/game.rs b/src/game.rs index 282efba..3c0c7e0 100644 --- a/src/game.rs +++ b/src/game.rs @@ -358,9 +358,9 @@ pub fn discard( Player::B => &mut game_state.hands[1], }; gen_event!(game_state.events, Event::Discard(player.clone())); - if None == player_hand.cards.get(hand_index) { - return Err(format!("Discard index out of bounds: {}", hand_index)); - } + if None == player_hand.cards.get(hand_index) { + return Err(format!("Discard index out of bounds: {}", hand_index)); + } let card = player_hand.cards.remove(hand_index); if shadow { game_state.shadow_realm.push(card); @@ -386,7 +386,7 @@ pub fn undiscard( &mut game_state.discard_pile }; if None == pile.get(pile_index) { - return Err(format!("Discard index out of bounds: {}", pile_index)); + return Err(format!("Discard index out of bounds: {}", pile_index)); } gen_event!(game_state.events, Event::Undiscard(player.clone())); player_hand.cards.push(pile.remove(pile_index)); @@ -422,7 +422,7 @@ pub fn unkill( &mut game_state.discard_pile }; if None == pile.get(pile_index) { - let pile_name = if shadow { + let pile_name = if shadow { "shadow realm" } else { "discard pile" @@ -430,7 +430,7 @@ pub fn unkill( return Err(format!( "Transfer index out of bounds: {} ({})", pile_index, pile_name - )); + )); } let card = pile.remove(pile_index); gen_event!(game_state.events, Event::Unkill(card, shadow)); @@ -460,7 +460,7 @@ pub fn transfer_dead_card( (&mut game_state.discard_pile, &mut game_state.shadow_realm) }; - if pile_index >= source.len() { + if None == source.get(pile_index) { let direction = if shadow_to_discard { "shadow realm -> discard pile" } else {