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_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_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_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_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_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_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_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_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_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 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_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_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_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_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_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
def test_length_case_zero(): """プレイヤーデータ数の取得(0).""" ps = players.Players() assert ps.length() == 0
def __init__(self): """コンストラクタ.""" self.__players = players.Players() self.__scene = scene.Scene()