def main(): """エントリーポイント.""" print('main') rps = rock_paper_scissors.RockPaperScissors() ps = players.Players() ps.add(cpu_player.CpuPlayer()) ps.add(cpu_player.CpuPlayer()) rps.initialize_game(ps) while not rps.is_finished(): rps.task()
def test_length_case_one_hundred(): """プレイヤーデータ数の取得(100).""" ps = players.Players() add_count = 100 for _ in range(add_count): p = cpu_player.CpuPlayer() ps.add(p) assert ps.length() == add_count
def test_clear_case_one(): """プレイヤーデータのクリア.""" ps = players.Players() p = cpu_player.CpuPlayer() ps.add(p) assert ps.length() == 1 ps.clear() assert ps.length() == 0
def test_add_case_two(): """プレイヤーの追加(2人).""" ps = players.Players() add_count = 2 for _ in range(add_count): p = cpu_player.CpuPlayer() ps.add(p) assert ps.length() == add_count
def test_get_range(): """手の公開の範囲チェック(rock,paper,scissorsのいずれかが出る).""" c = cpu_player.CpuPlayer() c.start_showdown() result = c.get() assert (result == hand_constant.HandConstant.ROCK or result == hand_constant.HandConstant.PAPER or result == hand_constant.HandConstant.SCISSORS)
def test_get_hand_rock_or_paper_or_scissors(): """プレイヤーの手の取得.""" ps = players.Players() p = cpu_player.CpuPlayer() p.start_showdown() ps.add(p) h = ps.get_hand(0) assert (h == hand_constant.HandConstant.ROCK or h == hand_constant.HandConstant.PAPER or h == hand_constant.HandConstant.SCISSORS)
def test_start_showdown_rock(): """手の公開(ランダムなので複数回実施してrockが出ることを確認).""" c = cpu_player.CpuPlayer() try_count = 100 find_rock = False for _ in range(try_count): c.start_showdown() result = c.get() if result == hand_constant.HandConstant.ROCK: find_rock = True break assert find_rock
def test_start_showdown_scissors(): """手の公開(ランダムなので複数回実施してscissorsが出ることを確認).""" c = cpu_player.CpuPlayer() try_count = 100 find_scissors = False for _ in range(try_count): c.start_showdown() result = c.get() if result == hand_constant.HandConstant.SCISSORS: find_scissors = True break assert find_scissors
def test_get_hand_index_one(): """プレイヤーの手の取得(indexが1).""" ps = players.Players() add_count = 2 for _ in range(add_count): p = cpu_player.CpuPlayer() p.start_showdown() ps.add(p) h = ps.get_hand(1) assert (h == hand_constant.HandConstant.ROCK or h == hand_constant.HandConstant.PAPER or h == hand_constant.HandConstant.SCISSORS)
def test_add_case_one(): """プレイヤーの追加(1人).""" ps = players.Players() p = cpu_player.CpuPlayer() ps.add(p) assert ps.length() == 1
def test_length_case_one(): """プレイヤーデータ数の取得(1).""" ps = players.Players() p = cpu_player.CpuPlayer() ps.add(p) assert ps.length() == 1