Made condition more consistent📄
This commit is contained in:
12
src/game.rs
12
src/game.rs
@ -358,9 +358,9 @@ pub fn discard(
|
|||||||
Player::B => &mut game_state.hands[1],
|
Player::B => &mut game_state.hands[1],
|
||||||
};
|
};
|
||||||
gen_event!(game_state.events, Event::Discard(player.clone()));
|
gen_event!(game_state.events, Event::Discard(player.clone()));
|
||||||
if None == player_hand.cards.get(hand_index) {
|
if None == player_hand.cards.get(hand_index) {
|
||||||
return Err(format!("Discard index out of bounds: {}", hand_index));
|
return Err(format!("Discard index out of bounds: {}", hand_index));
|
||||||
}
|
}
|
||||||
let card = player_hand.cards.remove(hand_index);
|
let card = player_hand.cards.remove(hand_index);
|
||||||
if shadow {
|
if shadow {
|
||||||
game_state.shadow_realm.push(card);
|
game_state.shadow_realm.push(card);
|
||||||
@ -386,7 +386,7 @@ pub fn undiscard(
|
|||||||
&mut game_state.discard_pile
|
&mut game_state.discard_pile
|
||||||
};
|
};
|
||||||
if None == pile.get(pile_index) {
|
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()));
|
gen_event!(game_state.events, Event::Undiscard(player.clone()));
|
||||||
player_hand.cards.push(pile.remove(pile_index));
|
player_hand.cards.push(pile.remove(pile_index));
|
||||||
@ -422,7 +422,7 @@ pub fn unkill(
|
|||||||
&mut game_state.discard_pile
|
&mut game_state.discard_pile
|
||||||
};
|
};
|
||||||
if None == pile.get(pile_index) {
|
if None == pile.get(pile_index) {
|
||||||
let pile_name = if shadow {
|
let pile_name = if shadow {
|
||||||
"shadow realm"
|
"shadow realm"
|
||||||
} else {
|
} else {
|
||||||
"discard pile"
|
"discard pile"
|
||||||
@ -460,7 +460,7 @@ pub fn transfer_dead_card(
|
|||||||
(&mut game_state.discard_pile, &mut game_state.shadow_realm)
|
(&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 {
|
let direction = if shadow_to_discard {
|
||||||
"shadow realm -> discard pile"
|
"shadow realm -> discard pile"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user