public void PlayerFiveAdvancePhaseTest() { Player p = mocks.Stub <Player>(0); Player p2 = mocks.Stub <Player>(0); Player p3 = mocks.Stub <Player>(0); IGame fakegame = mocks.Stub <IGame>(); PhaseList ls; Phase phase; phase = new PlayerTurn(p); ls = phase.advance(null, fakegame); Assert.AreEqual(typeof(JudgePhase), ls.pop().GetType()); Assert.AreEqual(typeof(PlayerTurn), ls.pop().GetType()); Assert.IsTrue(ls.isEmpty()); phase = new JudgePhase(p); ls = phase.advance(null, fakegame); Assert.IsNull(ls); ls = phase.advance(null, fakegame); Assert.AreEqual(typeof(DrawingPhase), ls.pop().GetType()); Assert.AreEqual(typeof(ActionPhase), ls.pop().GetType()); Assert.IsTrue(ls.isEmpty()); ls = (new JudgePhase(p)).advance(new YesOrNoAction(true), fakegame); Assert.AreEqual(typeof(DrawingPhase), ls.pop().GetType()); Assert.AreEqual(typeof(ActionPhase), ls.pop().GetType()); Assert.IsTrue(ls.isEmpty()); ls = (new JudgePhase(p)).advance(new YesOrNoAction(false), fakegame); Assert.AreEqual(typeof(DrawingPhase), ls.pop().GetType()); Assert.AreEqual(typeof(ActionPhase), ls.pop().GetType()); Assert.IsTrue(ls.isEmpty()); phase = new DrawingPhase(p); ls = phase.advance(null, fakegame); Assert.IsNull(ls); ls = phase.advance(null, fakegame); Assert.IsTrue(ls.isEmpty()); ls = (new DrawingPhase(p)).advance(new YesOrNoAction(true), fakegame); Assert.IsTrue(ls.isEmpty()); ls = (new DrawingPhase(p)).advance(new YesOrNoAction(false), fakegame); Assert.IsTrue(ls.isEmpty()); phase = new ActionPhase(p); ls = phase.advance(null, fakegame); Assert.IsNull(ls); ls = (new ActionPhase(p)).advance(new YesOrNoAction(true), fakegame); Assert.IsNull(ls); ls = (new ActionPhase(p)).advance(new YesOrNoAction(false), fakegame); Assert.AreEqual(typeof(DiscardPhase), ls.pop().GetType()); Assert.IsTrue(ls.isEmpty()); ls = (new DiscardPhase(p)).advance(null, fakegame); Assert.IsTrue(ls.isEmpty()); // in the future this will be changed to true ls = (new DiscardPhase(p)).advance(new YesOrNoAction(true), fakegame); Assert.IsTrue(ls.isEmpty()); ls = (new DiscardPhase(p)).advance(new YesOrNoAction(false), fakegame); Assert.IsTrue(ls.isEmpty()); }
private Phase randomPhase() { Phase phase; int r = random.Next(); switch (r % 10) { case 1: phase = new JudgePhase(randomPlayer()); break; case 2: phase = new DrawingPhase(randomPlayer()); break; case 3: phase = new ActionPhase(randomPlayer()); break; case 4: phase = new DiscardPhase(randomPlayer()); break; case 5: phase = new HarmPhase(randomPlayer(), randomPlayer(), random.Next(), randomAttack()); break; case 6: phase = new AskForHelpPhase(randomPlayer(), new HarmPhase(randomPlayer(), randomPlayer(), random.Next(), randomAttack())); break; case 7: phase = new RecoverPhase(randomPlayer(), random.Next()); break; default: phase = new DeadPhase(randomPlayer(), new HarmPhase(randomPlayer(), randomPlayer(), random.Next(), randomAttack())); break; } return(phase); }