コード例 #1
0
    def test_game_deals_new_player_when_round_is_providing(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        self.game.add_round()
        Play.play_for_round(self.game.current_round, storyteller, storyteller._pick_card(), 'story')

        player2 = self.game.add_player(self.user2, 'player2')
        self.assertEqual(player2.cards.count(), settings.GAME_HAND_SIZE)
コード例 #2
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_round_is_voting_when_all_players_have_provided_a_card(self):
        Play.play_for_round(self.current, self.game.storyteller, self.game.storyteller._pick_card(), 'story')
        players = self.game.players.all().exclude(id=self.game.storyteller.id)
        for player in players:
            Play.play_for_round(self.current, player, player._pick_card())

        self.assertEqual(self.current.status, RoundStatus.VOTING)
コード例 #3
0
    def test_game_with_voting_round_is_ongoing(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        game_round = self.game.add_round()
        Play.play_for_round(game_round, storyteller, storyteller._pick_card(), 'test')

        player2 = self.game.add_player(self.user2, 'player2')
        Play.play_for_round(self.game.current_round, player2, player2._pick_card())
        self.assertEqual(self.game.status, GameStatus.ONGOING)
コード例 #4
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_players_can_not_choose_own_card(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)
        with self.assertRaises(GameInvalidPlay):
            play2.vote_card(card2)
コード例 #5
0
    def test_game_can_not_advance_round_when_previous_is_not_complete(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        game_round = self.game.add_round()
        Play.play_for_round(game_round, storyteller, storyteller._pick_card(), 'test')

        with self.assertRaises(GameRoundIncomplete):
            self.game.next_round()
        self.assertEqual(self.game.rounds.count(), 1)
コード例 #6
0
 def test_providing_round_can_not_be_closed(self):
     story_card = self.current.turn._pick_card()
     story_play = Play.play_for_round(self.current, self.current.turn,
                                      story_card, 'test')
     Play.play_for_round(self.current, self.player2,
                         self.player2._pick_card())
     self.assertEqual(self.current.status, RoundStatus.PROVIDING)
     self.assertRaises(GameRoundIncomplete, self.current.close)
コード例 #7
0
    def test_round_is_voting_when_all_players_have_provided_a_card(self):
        Play.play_for_round(self.current, self.game.storyteller,
                            self.game.storyteller._pick_card(), 'story')
        players = self.game.players.all().exclude(id=self.game.storyteller.id)
        for player in players:
            Play.play_for_round(self.current, player, player._pick_card())

        self.assertEqual(self.current.status, RoundStatus.VOTING)
コード例 #8
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_round_is_providing_until_all_players_have_provided(self):
        story_card = self.game.storyteller._pick_card()
        Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')

        players = self.game.players.exclude(id=self.game.storyteller.id)
        for player in players[1:]:
            Play.play_for_round(self.current, player, player._pick_card())

        self.assertEqual(self.current.status, RoundStatus.PROVIDING)
コード例 #9
0
ファイル: card.py プロジェクト: jminuscula/dixit-online
    def test_can_identify_cards_played_in_a_round(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.game.current_round, self.game.storyteller, story_card, 'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.game.current_round, self.player2, card2)

        round_cards = {self.game.current_round.card, story_card, card2}
        self.assertEqual(set(Card.objects.played_for_round(self.game.current_round)), round_cards)
コード例 #10
0
    def test_players_can_not_choose_own_card(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.current, self.game.storyteller,
                                         story_card, 'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)
        with self.assertRaises(GameInvalidPlay):
            play2.vote_card(card2)
コード例 #11
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_players_can_choose_played_card(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')

        play2 = Play.play_for_round(self.current, self.player2, self.player2._pick_card())
        play3 = Play.play_for_round(self.current, self.player3, self.player3._pick_card())

        self.assertEqual(self.current.status, RoundStatus.VOTING)
        play2.vote_card(story_card)
コード例 #12
0
ファイル: card.py プロジェクト: jminuscula/dixit-online
    def test_can_identify_cards_chosen_in_a_round(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.game.current_round, self.game.storyteller, story_card, 'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.game.current_round, self.player2, card2)
        # import ipdb; ipdb.set_trace()
        play2.vote_card(story_card)

        self.assertEqual(set(Card.objects.chosen_for_round(self.game.current_round)), {story_card, })
コード例 #13
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_players_can_not_choose_unplayed_card(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        with self.assertRaises(GameInvalidPlay):
            other_card = Card.objects.available_for_game(self.game)[0]
            play2.vote_card(other_card)
コード例 #14
0
    def test_started_game_without_players_is_abandoned(self):
        g = Game.new_game(name='test', user=self.user, player_name='storyteller')
        storyteller = g.current_round.turn
        Play.play_for_round(g.current_round, storyteller, storyteller._pick_card(), 'story')

        player2 = g.add_player(self.user2, 'player2')
        Play.play_for_round(g.current_round, player2, player2._pick_card())

        g.players.all().delete()
        self.assertEqual(g.status, GameStatus.ABANDONED)
コード例 #15
0
    def test_game_does_not_deal_new_player_when_round_is_voting(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        game_round = self.game.add_round()
        Play.play_for_round(self.game.current_round, storyteller, storyteller._pick_card(), 'story')

        player2 = self.game.add_player(self.user2, 'player2')
        Play.play_for_round(self.game.current_round, player2, player2._pick_card())

        player3 = self.game.add_player(self.user3, 'player3')
        self.assertEqual(player3.cards.count(), 0)
コード例 #16
0
    def test_round_is_providing_until_all_players_have_provided(self):
        story_card = self.game.storyteller._pick_card()
        Play.play_for_round(self.current, self.game.storyteller, story_card,
                            'story')

        players = self.game.players.exclude(id=self.game.storyteller.id)
        for player in players[1:]:
            Play.play_for_round(self.current, player, player._pick_card())

        self.assertEqual(self.current.status, RoundStatus.PROVIDING)
コード例 #17
0
    def test_players_can_not_choose_unplayed_card(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.current, self.game.storyteller,
                                         story_card, 'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        with self.assertRaises(GameInvalidPlay):
            other_card = Card.objects.available_for_game(self.game)[0]
            play2.vote_card(other_card)
コード例 #18
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_round_is_complete_when_all_players_have_voted(self):
        story_card = self.current.turn._pick_card()
        Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')
        players = self.game.players.all().exclude(id=self.game.storyteller.id)
        for player in players:
            Play.play_for_round(self.current, player, player._pick_card())

        plays = self.current.plays.all().exclude(player=self.game.storyteller)
        for play in plays:
            play.vote_card(story_card)

        self.assertEqual(self.current.status, RoundStatus.COMPLETE)
コード例 #19
0
    def test_players_can_choose_played_card(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.current, self.game.storyteller,
                                         story_card, 'story')

        play2 = Play.play_for_round(self.current, self.player2,
                                    self.player2._pick_card())
        play3 = Play.play_for_round(self.current, self.player3,
                                    self.player3._pick_card())

        self.assertEqual(self.current.status, RoundStatus.VOTING)
        play2.vote_card(story_card)
コード例 #20
0
    def test_game_with_complete_round_is_finished(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        player2 = self.game.add_player(self.user2, 'player2')
        game_round = self.game.add_round()

        story_card = storyteller._pick_card()
        play1 = Play.play_for_round(game_round, storyteller, story_card, 'test')

        card2 = player2._pick_card()
        play2 = Play.play_for_round(game_round, player2, card2)
        play2.vote_card(story_card)

        self.assertEqual(self.game.status, GameStatus.FINISHED)
コード例 #21
0
    def test_game_deals_new_player_when_round_is_complete(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        self.game.add_round()

        story_card = storyteller._pick_card()
        Play.play_for_round(self.game.current_round, storyteller, story_card, 'story')

        player2 = self.game.add_player(self.user2, 'player2')
        player2_play = Play.play_for_round(self.game.current_round, player2, player2._pick_card())
        player2_play.vote_card(story_card)

        player3 = self.game.add_player(self.user3, 'player3')
        self.assertEqual(player3.cards.count(), 0)
コード例 #22
0
    def test_round_is_complete_when_all_players_have_voted(self):
        story_card = self.current.turn._pick_card()
        Play.play_for_round(self.current, self.game.storyteller, story_card,
                            'story')
        players = self.game.players.all().exclude(id=self.game.storyteller.id)
        for player in players:
            Play.play_for_round(self.current, player, player._pick_card())

        plays = self.current.plays.all().exclude(player=self.game.storyteller)
        for play in plays:
            play.vote_card(story_card)

        self.assertEqual(self.current.status, RoundStatus.COMPLETE)
コード例 #23
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_voting_round_can_not_be_closed(self):
        story_card = self.current.turn._pick_card()
        Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')
        players = self.game.players.all().exclude(id=self.game.storyteller.id)
        for player in players:
            Play.play_for_round(self.current, player, player._pick_card())

        plays = self.current.plays.all().exclude(player=self.game.storyteller)
        for play in plays[1:]:
            play.vote_card(story_card)

        self.assertEqual(self.current.status, RoundStatus.VOTING)
        self.assertRaises(GameRoundIncomplete, self.current.close)
コード例 #24
0
    def test_game_can_advance_round_when_previous_is_complete(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        player2 = self.game.add_player(self.user2, 'player2')
        game_round = self.game.add_round()

        story_card = storyteller._pick_card()
        Play.play_for_round(game_round, storyteller, story_card, 'test')

        play2 = Play.play_for_round(game_round, player2, player2._pick_card())
        play2.vote_card(story_card)

        next_round = self.game.next_round()
        self.assertTrue(next_round is not None)
        self.assertEqual(self.game.rounds.count(), 2)
コード例 #25
0
ファイル: card.py プロジェクト: zoemy/dixit-online
    def test_can_identify_cards_played_in_a_round(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.game.current_round,
                                         self.game.storyteller, story_card,
                                         'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.game.current_round, self.player2,
                                    card2)

        round_cards = {self.game.current_round.card, story_card, card2}
        self.assertEqual(
            set(Card.objects.played_for_round(self.game.current_round)),
            round_cards)
コード例 #26
0
    def test_voting_round_can_not_be_closed(self):
        story_card = self.current.turn._pick_card()
        Play.play_for_round(self.current, self.game.storyteller, story_card,
                            'story')
        players = self.game.players.all().exclude(id=self.game.storyteller.id)
        for player in players:
            Play.play_for_round(self.current, player, player._pick_card())

        plays = self.current.plays.all().exclude(player=self.game.storyteller)
        for play in plays[1:]:
            play.vote_card(story_card)

        self.assertEqual(self.current.status, RoundStatus.VOTING)
        self.assertRaises(GameRoundIncomplete, self.current.close)
コード例 #27
0
ファイル: card.py プロジェクト: zoemy/dixit-online
    def test_can_identify_cards_chosen_in_a_round(self):
        story_card = self.game.storyteller._pick_card()
        story_play = Play.play_for_round(self.game.current_round,
                                         self.game.storyteller, story_card,
                                         'story')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.game.current_round, self.player2,
                                    card2)
        # import ipdb; ipdb.set_trace()
        play2.vote_card(story_card)

        self.assertEqual(
            set(Card.objects.chosen_for_round(self.game.current_round)), {
                story_card,
            })
コード例 #28
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_storyteller_doesnt_score_when_all_players_guess(self):
        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn, story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        play2.vote_card(story_card)
        play3.vote_card(story_card)

        self.current.close()

        self.current.turn.refresh_from_db()
        self.assertEqual(self.current.turn.score, 0)
コード例 #29
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_storyteller_scores_when_player_guessed(self):
        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn, story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        play2.vote_card(story_card)
        play3.vote_card(card2)

        self.current.close()

        self.current.turn.refresh_from_db()
        self.assertEqual(self.current.turn.score, settings.GAME_STORY_SCORE)
コード例 #30
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_players_score_when_their_card_is_chosen(self):
        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn, story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        play2.vote_card(card3)
        play3.vote_card(card2)

        self.current.close()

        self.player2.refresh_from_db()
        self.assertEqual(self.player2.score, settings.GAME_CONFUSED_GUESS_SCORE)
コード例 #31
0
    def test_storyteller_scores_when_player_guessed(self):
        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn,
                                         story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        play2.vote_card(story_card)
        play3.vote_card(card2)

        self.current.close()

        self.current.turn.refresh_from_db()
        self.assertEqual(self.current.turn.score, settings.GAME_STORY_SCORE)
コード例 #32
0
    def test_storyteller_doesnt_score_when_all_players_guess(self):
        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn,
                                         story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        play2.vote_card(story_card)
        play3.vote_card(story_card)

        self.current.close()

        self.current.turn.refresh_from_db()
        self.assertEqual(self.current.turn.score, 0)
コード例 #33
0
    def test_players_score_when_their_card_is_chosen(self):
        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn,
                                         story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        play2.vote_card(card3)
        play3.vote_card(card2)

        self.current.close()

        self.player2.refresh_from_db()
        self.assertEqual(self.player2.score,
                         settings.GAME_CONFUSED_GUESS_SCORE)
コード例 #34
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
    def test_players_score_max_bound(self):
        player4 = self.game.add_player(self.user4, 'player4')

        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn, story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        card4 = player4._pick_card()
        play4 = Play.play_for_round(self.current, player4, card4)

        play2.vote_card(story_card)
        play3.vote_card(card2)
        play4.vote_card(card2)

        self.current.close()

        self.player2.refresh_from_db()
        self.assertEqual(self.player2.score, settings.GAME_MAX_ROUND_SCORE)
コード例 #35
0
    def test_players_score_max_bound(self):
        player4 = self.game.add_player(self.user4, 'player4')

        story_card = self.current.turn._pick_card()
        story_play = Play.play_for_round(self.current, self.current.turn,
                                         story_card, 'test')

        card2 = self.player2._pick_card()
        play2 = Play.play_for_round(self.current, self.player2, card2)

        card3 = self.player3._pick_card()
        play3 = Play.play_for_round(self.current, self.player3, card3)

        card4 = player4._pick_card()
        play4 = Play.play_for_round(self.current, player4, card4)

        play2.vote_card(story_card)
        play3.vote_card(card2)
        play4.vote_card(card2)

        self.current.close()

        self.player2.refresh_from_db()
        self.assertEqual(self.player2.score, settings.GAME_MAX_ROUND_SCORE)
コード例 #36
0
    def test_game_with_storyteller_play_is_new(self):
        storyteller = self.game.add_player(self.user, 'storyteller')
        game_round = self.game.add_round()
        Play.play_for_round(game_round, storyteller, storyteller._pick_card(), 'test')

        self.assertEqual(self.game.status, GameStatus.NEW)
コード例 #37
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
 def test_round_is_new_when_only_storyteller_has_played(self):
     story_card = self.game.storyteller._pick_card()
     Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')
     self.assertEqual(self.current.status, RoundStatus.NEW)
コード例 #38
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
 def test_providing_round_can_not_be_closed(self):
     story_card = self.current.turn._pick_card()
     story_play = Play.play_for_round(self.current, self.current.turn, story_card, 'test')
     Play.play_for_round(self.current, self.player2, self.player2._pick_card())
     self.assertEqual(self.current.status, RoundStatus.PROVIDING)
     self.assertRaises(GameRoundIncomplete, self.current.close)
コード例 #39
0
 def test_players_can_provide_card_after_storyteller(self):
     Play.play_for_round(self.current, self.game.storyteller,
                         self.game.storyteller._pick_card(), 'story')
     Play.play_for_round(self.current, self.player2,
                         self.player2._pick_card())
     self.assertEqual(self.current.plays.count(), 2)
コード例 #40
0
 def test_players_cant_provide_card_before_storyteller(self):
     with self.assertRaises(GameInvalidPlay):
         Play.play_for_round(self.current, self.player2,
                             self.player2._pick_card())
コード例 #41
0
 def test_storyteller_can_provide_card(self):
     story_play = Play(game_round=self.current,
                       player=self.game.storyteller)
     story_play.provide_card(self.game.storyteller._pick_card(), 'story')
     self.assertEqual(self.current.plays.count(), 1)
コード例 #42
0
 def test_play_can_be_performed_for_round(self):
     story_card = self.game.storyteller._pick_card()
     Play.play_for_round(self.current, self.game.storyteller, story_card,
                         'story')
     self.assertEqual(self.current.plays.count(), 1)
コード例 #43
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
 def test_players_can_provide_card_after_storyteller(self):
     Play.play_for_round(self.current, self.game.storyteller, self.game.storyteller._pick_card(), 'story')
     Play.play_for_round(self.current, self.player2, self.player2._pick_card())
     self.assertEqual(self.current.plays.count(), 2)
コード例 #44
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
 def test_players_cant_provide_card_before_storyteller(self):
     with self.assertRaises(GameInvalidPlay):
         Play.play_for_round(self.current, self.player2, self.player2._pick_card())
コード例 #45
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
 def test_storyteller_can_provide_card(self):
     story_play = Play(game_round=self.current, player=self.game.storyteller)
     story_play.provide_card(self.game.storyteller._pick_card(), 'story')
     self.assertEqual(self.current.plays.count(), 1)
コード例 #46
0
ファイル: round.py プロジェクト: jminuscula/dixit-online
 def test_play_can_be_performed_for_round(self):
     story_card = self.game.storyteller._pick_card()
     Play.play_for_round(self.current, self.game.storyteller, story_card, 'story')
     self.assertEqual(self.current.plays.count(), 1)
コード例 #47
0
 def test_round_is_new_when_only_storyteller_has_played(self):
     story_card = self.game.storyteller._pick_card()
     Play.play_for_round(self.current, self.game.storyteller, story_card,
                         'story')
     self.assertEqual(self.current.status, RoundStatus.NEW)