Skip to content

Commit

Permalink
fix: revealed card's value is not displayed if 0 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
axeleroy committed Feb 2, 2023
1 parent 7deee42 commit fbe77b6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="d-flex flex-column align-items-center m-2 m-sm-5">
<div class="card-border"
[class.card-disabled]="playerState.spectator"
[class.picked]="playerState.hasPicked"
[class.dashed]="playerState.spectator || (!playerState.hand && !playerState.hasPicked)">
<div class="card-value" *ngIf="playerState.hand && deck">
[class.face-down]="playerState.hasPicked && playerState.hand === undefined"
[class.dashed]="playerState.spectator || !playerState.hasPicked">
<div class="card-value" *ngIf="playerState.hand !== undefined && deck">
{{ displayCardValue(deck, playerState.hand) }}
</div>
<div class="card-value" *ngIf="playerState.spectator">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.picked {
.face-down {
background-color: cornflowerblue;
outline-offset: -5px;
outline-color: white;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ export class PlayerHandComponent {
@Input() deck?: Deck;

displayCardValue = displayCardValue;
isNan(input: any) {
return Number.isNaN(Number(input));
}
}
3 changes: 2 additions & 1 deletion flask/gamestate/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ def state_with_hand(self) -> dict:
return {
'name': self.name,
'spectator': self.spectator,
'hand': self.__hand
'hand': self.__hand,
'hasPicked': self.has_picked_card()
}
6 changes: 3 additions & 3 deletions flask/test/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ def test_state_when_revealed_is_false(self):
def test_state_when_revealed_is_true(self):
game = Game('PBR Team Pizza')
player_1 = Mock()
player1_state = {'name': 'John', 'spectator': False, 'hand': 3}
player1_state = {'name': 'John', 'spectator': False, 'hand': 3, 'hasPicked': True}
player_1.configure_mock(**{'state_with_hand.return_value': player1_state})
game.player_joins('j', player_1)
player_2 = Mock()
player2_state = {'name': 'Peter', 'spectator': False, 'hasPicked': None}
player2_state = {'name': 'Peter', 'spectator': False, 'hand': None, 'hasPicked': False}
player_2.configure_mock(**{'state_with_hand.return_value': player2_state})
game.player_joins('p', player_2)
spectator_1 = Mock()
spectator1_state = {'name': 'Daisy', 'spectator': True, 'hasPicked': None}
spectator1_state = {'name': 'Daisy', 'spectator': True, 'hand': None, 'hasPicked': False}
spectator_1.configure_mock(**{'state_with_hand.return_value': spectator1_state})
game.player_joins('d', spectator_1)

Expand Down
6 changes: 3 additions & 3 deletions flask/test/test_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def test_state(self):
def test_state_with_hand(self):
name1 = "John"
player1 = Player(name1, False)
self.assertEqual(player1.state_with_hand(), {'name': name1, 'spectator': False, 'hand': None})
self.assertEqual(player1.state_with_hand(), {'name': name1, 'spectator': False, 'hand': None, 'hasPicked': False})
player1.set_hand(3)
self.assertEqual(player1.state_with_hand(), {'name': name1, 'spectator': False, 'hand': 3})
self.assertEqual(player1.state_with_hand(), {'name': name1, 'spectator': False, 'hand': 3, 'hasPicked': True})
name2 = "Peter"
player2 = Player(name2, True)
self.assertEqual(player2.state_with_hand(), {'name': name2, 'spectator': True, 'hand': None})
self.assertEqual(player2.state_with_hand(), {'name': name2, 'spectator': True, 'hand': None, 'hasPicked': False})


if __name__ == '__main__':
Expand Down

0 comments on commit fbe77b6

Please sign in to comment.