Пример #1
0
        public void Res3Phasetest()
        {
            // ActionPhase produces attackPhase

            Player p1   = mocks.Stub <Player>(0);
            Player p2   = mocks.Stub <Player>(1);
            IGame  game = mocks.Stub <IGame>();

            Card attack = new Attack(CardSuit.Spade, 1);

            // ActionPhase produces attackPhase
            ActionPhase a    = new ActionPhase(p1);
            PhaseList   ret  = a.advance(new UseCardAction(attack, p2), game);
            Phase       b    = ret.pop();
            AttackPhase b2   = b as AttackPhase;
            Miss        miss = new Miss(CardSuit.Diamond, 2);

            p1.handCards.Add(attack);
            p1.handCards.Add(miss);
            p1.health = 1;

            Player[] p = new Player[1];
            p[0] = p1;
            // AttackPhase produces responsePhase
            ret = b.advance(null, game);
            Phase         c  = ret.pop();
            ResponsePhase c_ = c as ResponsePhase;

            Assert.AreEqual(c_.ToString(), "Response Phase of 1");
        }
Пример #2
0
        public void Res5Phasetest()
        {
            SunQuan     p1 = new SunQuan(0);
            LiuBei      p2 = new LiuBei(1);
            List <Card> x  = new List <Card>();

            Player[] p = new SunQuan[1];
            p[0] = p1;
            Miss miss   = new Miss(CardSuit.Diamond, 2);
            Card attack = new Attack(CardSuit.Spade, 1);

            x.Add(miss);
            x.Add(attack);
            Game game = new Game(p, new CardSet(x));



            // ActionPhase produces attackPhase
            ActionPhase a   = new ActionPhase(p1);
            PhaseList   ret = a.advance(new UseCardAction(attack, p2), game);
            Phase       b   = ret.pop();
            AttackPhase b2  = b as AttackPhase;

            p1.handCards.Add(attack);
            p1.handCards.Add(miss);
            p1.health = 1;

            // AttackPhase produces responsePhase
            ret = b.advance(null, game);
            Phase         c  = ret.pop();
            ResponsePhase c_ = c as ResponsePhase;


            Assert.IsInstanceOfType(a.responseAbilityActionSun(new AbilityActionSun(attack), game), typeof(PhaseList));
        }
Пример #3
0
        public void ResPhasetest()
        {
            Player p1   = new Player(0);
            Player p2   = new Player(1);
            IGame  game = mocks.Stub <IGame>();

            Card attack = new Attack(CardSuit.Spade, 1);

            Phase       a    = new ActionPhase(p1);
            PhaseList   ret  = a.advance(new UseCardAction(attack, p2), game);
            Phase       b    = ret.pop();
            AttackPhase b2   = b as AttackPhase;
            Miss        miss = new Miss(CardSuit.Diamond, 2);

            p1.handCards.Add(attack);
            p2.handCards.Add(miss);
            p1.health = 1;

            Player[] p = new Player[1];
            p[0] = p1;
            ret  = b.advance(null, game);
            Phase         c  = ret.pop();
            ResponsePhase c_ = c as ResponsePhase;

            Assert.IsNull(c_.responseYesOrNo(true, game));
        }
Пример #4
0
        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());
        }
Пример #5
0
        public void AttackHitTest()
        {
            Player p1   = mocks.Stub <Player>(0);
            Player p2   = mocks.Stub <Player>(1);
            IGame  game = mocks.Stub <IGame>();

            Card attack = new Attack(CardSuit.Spade, 1);

            // ActionPhase produces attackPhase
            Phase     a   = new ActionPhase(p1);
            PhaseList ret = a.advance(new UseCardAction(attack, p2), game);
            Phase     b   = ret.pop();

            Assert.IsInstanceOfType(b, typeof(AttackPhase));
            AttackPhase b2 = b as AttackPhase;

            Assert.AreEqual(attack, b2.attack);
            Assert.AreEqual(a, b2.actionPhase);
            Assert.AreEqual(p1, b2.player);
            Assert.AreEqual(p2, b2.targets[0]);
            Assert.AreEqual(a, ret.pop());
            Assert.IsTrue(ret.isEmpty());
            // AttackPhase produces responsePhase
            ret = b.advance(null, game);
            Phase c = ret.pop();

            Assert.IsInstanceOfType(c, typeof(ResponsePhase));
            ResponsePhase c_ = c as ResponsePhase;

            Assert.AreEqual(p2, c_.player);
            Phase c2 = ret.pop();

            Assert.IsInstanceOfType(c2, typeof(AttackPhase));
            Assert.AreEqual(b, c2);
            Assert.IsTrue(ret.isEmpty());

            // response with cancel
            ret = c.advance(new YesOrNoAction(false), game);
            Assert.IsTrue(ret.isEmpty());

            // attackPhase produces harmPhase
            ret = c2.advance(null, game);
            Phase d = ret.pop();

            Assert.IsInstanceOfType(d, typeof(HarmPhase));
            HarmPhase d2 = d as HarmPhase;

            Assert.AreEqual(p2, d2.player);
            Assert.AreEqual(p1, d2.source);
            Assert.AreEqual(1, d2.harm);
            Assert.IsTrue(ret.isEmpty());

            ret = d.advance(null, game);
            Assert.IsTrue(ret.isEmpty());
        }
Пример #6
0
        public void AttackMissTest()
        {
            Player p1 = mocks.Stub <Player>(0);
            Player p2 = mocks.Stub <Player>(1);

            IGame game = mocks.Stub <IGame>();

            Card attack = new Attack(CardSuit.Spade, 1);
            Miss miss   = new Miss(CardSuit.Diamond, 2);
            // ActionPhase produces attackPhase
            Phase     a   = new ActionPhase(p1);
            PhaseList ret = a.advance(new UseCardAction(attack, p2), game);
            Phase     b   = ret.pop();

            Assert.IsInstanceOfType(b, typeof(AttackPhase));
            AttackPhase b2 = b as AttackPhase;

            Assert.AreEqual(attack, b2.attack);
            Assert.AreEqual(a, b2.actionPhase);
            Assert.AreEqual(p1, b2.player);
            Assert.AreEqual(p2, b2.targets[0]);
            Assert.AreEqual(a, ret.pop());
            Assert.IsTrue(ret.isEmpty());
            // AttackPhase produces responsePhase
            ret = b.advance(null, game);
            Phase c = ret.pop();

            Assert.IsInstanceOfType(c, typeof(ResponsePhase));
            ResponsePhase c_ = c as ResponsePhase;

            Assert.AreEqual(p2, c_.player);
            Phase c2 = ret.pop();

            Assert.IsInstanceOfType(c2, typeof(AttackPhase));
            Assert.AreEqual(b, c2);
            Assert.IsTrue(ret.isEmpty());

            // response with cancel
            ret = c.advance(new CardAction(miss), game);
            Assert.IsTrue(ret.isEmpty());

            // attackPhase produces nothing
            ret = c2.advance(null, game);
            Assert.IsTrue(ret.isEmpty());
        }