Example #1
0
class TestWar(unittest.TestCase):
    def setUp(self):
        self.game = War()

    def test_play(self):
        self.assertIsInstance(self.game.play(), int)

    def test_game_is_over(self):
        self.assertFalse(self.game.game_is_over())
        self.game.play()
        self.assertTrue(self.game.game_is_over())
Example #2
0
class TestWar(unittest.TestCase):

    def setUp(self):
        self.game = War()

    def test_play(self):
        self.assertIsInstance(self.game.play(), int)

    def test_game_is_over(self):
        self.assertFalse(self.game.game_is_over())
        self.game.play()
        self.assertTrue(self.game.game_is_over())
Example #3
0
def main():
    parser = argparse.ArgumentParser(description='Play a game of War.')
    parser.add_argument('--players',
                        type=int,
                        nargs='?',
                        required=True,
                        help='a count of players')
    parser.add_argument('--suits',
                        type=int,
                        nargs='?',
                        required=True,
                        help='a count of suits')
    parser.add_argument('--ranks',
                        type=int,
                        nargs='?',
                        required=True,
                        help='a count of ranks')
    parser.add_argument("--verbose",
                        help="show game in progress",
                        action="store_true")
    parser.add_argument("--slow",
                        help='wait for a second between turns',
                        action="store_true")
    args = parser.parse_args()

    w = War(count_of_players=args.players,
            count_of_suits=args.suits,
            count_of_ranks=args.ranks)
    winning_player = w.play(verbose=args.verbose, slow=args.slow)

    print "Winner: {0}".format(winning_player.name)
Example #4
0
def run_game():
    war_game = War()
    war_game.play()