def test_clone_overwrite(): """クローン(上書き).""" ps = players.Players() add_count = 5 for i in range(add_count): p = debug_player.DebugPlayer() if i == 0: p.set(hand_constant.HandConstant.SCISSORS) if i == 1: p.set(hand_constant.HandConstant.PAPER) if i == 2: p.set(hand_constant.HandConstant.ROCK) if i == 3: p.set(hand_constant.HandConstant.PAPER) if i == 4: p.set(hand_constant.HandConstant.SCISSORS) ps.add(p) clone = players.Players() clone.add(debug_player.DebugPlayer()) clone.clone(ps) assert clone.length() == add_count assert clone.get_hand(0) == hand_constant.HandConstant.SCISSORS assert clone.get_hand(1) == hand_constant.HandConstant.PAPER assert clone.get_hand(2) == hand_constant.HandConstant.ROCK assert clone.get_hand(3) == hand_constant.HandConstant.PAPER assert clone.get_hand(4) == hand_constant.HandConstant.SCISSORS
def test_judge_rock_multi_paper_multi(): """ジャンケンの判定(rock複数, paper複数).""" s = standard_judge.StandardJudge() p = players.Players() player_count = 5 for i in range(player_count): pl = debug_player.DebugPlayer() if i == 0: pl.set(hand_constant.HandConstant.PAPER) if i == 1: pl.set(hand_constant.HandConstant.ROCK) if i == 2: pl.set(hand_constant.HandConstant.ROCK) if i == 3: pl.set(hand_constant.HandConstant.PAPER) if i == 4: pl.set(hand_constant.HandConstant.ROCK) p.add(pl) s.set(p) result = s.judge() assert result[0] == result_constant.ResultConstant.WIN assert result[1][0] == 0 assert result[1][1] == 3 assert len(result) == 2 assert len(result[1]) == 2
def test_judge_paper_multi_scissors_multi(): """ジャンケンの判定(papaer複数, scissors複数).""" s = standard_judge.StandardJudge() p = players.Players() player_count = 7 for i in range(player_count): pl = debug_player.DebugPlayer() if i == 0: pl.set(hand_constant.HandConstant.SCISSORS) if i == 1: pl.set(hand_constant.HandConstant.PAPER) if i == 2: pl.set(hand_constant.HandConstant.PAPER) if i == 3: pl.set(hand_constant.HandConstant.SCISSORS) if i == 4: pl.set(hand_constant.HandConstant.PAPER) if i == 5: pl.set(hand_constant.HandConstant.SCISSORS) if i == 6: pl.set(hand_constant.HandConstant.PAPER) p.add(pl) s.set(p) result = s.judge() assert result[0] == result_constant.ResultConstant.WIN assert result[1][0] == 0 assert result[1][1] == 3 assert result[1][2] == 5 assert len(result) == 2 assert len(result[1]) == 3
def test_get_range(): """手の公開の範囲チェック(rock,paper,scissorsのいずれかが出る).""" p = debug_player.DebugPlayer() p.start_showdown() result = p.get() assert (result == hand_constant.HandConstant.ROCK or result == hand_constant.HandConstant.PAPER or result == hand_constant.HandConstant.SCISSORS)
def test_set_call(): """判定のためにプレイヤーを設定.""" s = standard_judge.StandardJudge() p = players.Players() player_count = 1 for _ in range(player_count): pl = debug_player.DebugPlayer() pl.set(hand_constant.HandConstant.ROCK) p.add(pl) s.set(p)
def test_get_index_zero(): """プレイヤーの取得(indexが0).""" ps = players.Players() add_count = 1 for _ in range(add_count): p = debug_player.DebugPlayer() p.set(hand_constant.HandConstant.SCISSORS) p.start_showdown() ps.add(p) p = ps.get(0) assert p.get() == hand_constant.HandConstant.SCISSORS
def test_clone_one_player(): """クローン(プレイヤー1人).""" ps = players.Players() add_count = 1 for _ in range(add_count): p = debug_player.DebugPlayer() p.set(hand_constant.HandConstant.PAPER) ps.add(p) clone = players.Players() clone.clone(ps) assert clone.length() == add_count assert clone.get_hand(0) == hand_constant.HandConstant.PAPER
def test_judge_scissors_two(): """ジャンケン判定(scissorsあいこ).""" s = standard_judge.StandardJudge() p = players.Players() player_count = 2 for _ in range(player_count): pl = debug_player.DebugPlayer() pl.set(hand_constant.HandConstant.SCISSORS) p.add(pl) s.set(p) result = s.judge() assert result[0] == result_constant.ResultConstant.DRAW assert result[1] == 0 assert len(result) == 2
def test_clone_two_player(): """クローン(プレイヤー2人).""" ps = players.Players() add_count = 2 for i in range(add_count): p = debug_player.DebugPlayer() if i == 0: p.set(hand_constant.HandConstant.PAPER) if i == 1: p.set(hand_constant.HandConstant.ROCK) ps.add(p) clone = players.Players() clone.clone(ps) assert clone.length() == add_count assert clone.get_hand(0) == hand_constant.HandConstant.PAPER assert clone.get_hand(1) == hand_constant.HandConstant.ROCK
def test_judge_paper_scissors(): """ジャンケンの判定(paper, scissors).""" s = standard_judge.StandardJudge() p = players.Players() player_count = 2 for i in range(player_count): pl = debug_player.DebugPlayer() if i == 0: pl.set(hand_constant.HandConstant.PAPER) if i == 1: pl.set(hand_constant.HandConstant.SCISSORS) p.add(pl) s.set(p) result = s.judge() assert result[0] == result_constant.ResultConstant.WIN assert result[1][0] == 1 assert len(result) == 2
def test_judge_all_type(): """ジャンケン判定(全ての種類であいこ).""" s = standard_judge.StandardJudge() p = players.Players() player_count = 3 for i in range(player_count): pl = debug_player.DebugPlayer() if i == 0: pl.set(hand_constant.HandConstant.ROCK) if i == 1: pl.set(hand_constant.HandConstant.PAPER) if i == 2: pl.set(hand_constant.HandConstant.SCISSORS) p.add(pl) s.set(p) result = s.judge() assert result[0] == result_constant.ResultConstant.DRAW assert result[1] == 0 assert len(result) == 2
def test_get_three(): """プレイヤーの取得(3人分).""" ps = players.Players() add_count = 3 for i in range(add_count): p = debug_player.DebugPlayer() if i == 0: p.set(hand_constant.HandConstant.ROCK) if i == 1: p.set(hand_constant.HandConstant.PAPER) if i == 2: p.set(hand_constant.HandConstant.SCISSORS) p.start_showdown() ps.add(p) p = ps.get(0) assert p.get() == hand_constant.HandConstant.ROCK p = ps.get(1) assert p.get() == hand_constant.HandConstant.PAPER p = ps.get(2) assert p.get() == hand_constant.HandConstant.SCISSORS
def test_judge_rock_scissors_multi(): """ジャンケンの判定(rock, scissors複数).""" s = standard_judge.StandardJudge() p = players.Players() player_count = 4 for i in range(player_count): pl = debug_player.DebugPlayer() if i == 0: pl.set(hand_constant.HandConstant.SCISSORS) if i == 1: pl.set(hand_constant.HandConstant.SCISSORS) if i == 2: pl.set(hand_constant.HandConstant.SCISSORS) if i == 3: pl.set(hand_constant.HandConstant.ROCK) p.add(pl) s.set(p) result = s.judge() assert result[0] == result_constant.ResultConstant.WIN assert result[1][0] == 3 assert len(result) == 2
def test_set_rock(): """手の設定(rock).""" p = debug_player.DebugPlayer() p.set(hand_constant.HandConstant.ROCK) assert p.get() == hand_constant.HandConstant.ROCK
def test_set_paper(): """手の設定(paper).""" p = debug_player.DebugPlayer() p.set(hand_constant.HandConstant.PAPER) assert p.get() == hand_constant.HandConstant.PAPER
def test_start_showdown(): """手の公開開始(何もしないのでcallできることだけ確認).""" p = debug_player.DebugPlayer() p.start_showdown()
def test_set_scissors(): """手の設定(scissors).""" p = debug_player.DebugPlayer() p.set(hand_constant.HandConstant.SCISSORS) assert p.get() == hand_constant.HandConstant.SCISSORS