Exemplo n.º 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");
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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());
        }
        public void TestAddPop()
        {
            PhaseList ls = new PhaseList();

            ls.add(new PhaseSimple(0));
            ls.add(new PhaseSimple(1));
            ls.add(new PhaseSimple(2));
            ls.add(new PhaseSimple(3));
            ls.add(new PhaseSimple(4));
            Assert.AreEqual(ls.pop().playerID, 0);
            Assert.AreEqual(ls.pop().playerID, 1);
            Assert.AreEqual(ls.pop().playerID, 2);
            Assert.AreEqual(ls.pop().playerID, 3);
            Assert.AreEqual(ls.pop().playerID, 4);
            Assert.IsTrue(ls.isEmpty());
        }
        public void TestPushOneStageList()
        {
            PhaseList ls = new PhaseList();

            ls.add(new PhaseSimple(0));
            Assert.AreEqual(ls.pop().playerID, 0);
            Assert.IsTrue(ls.isEmpty());
        }
Exemplo n.º 7
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());
        }
        public void TestPushStageList()
        {
            PhaseList ls = new PhaseList();

            ls.add(new PhaseSimple(0));
            ls.add(new PhaseSimple(1));
            ls.add(new PhaseSimple(2));
            PhaseList ls2 = new PhaseList();

            ls2.add(new PhaseSimple(3));
            ls2.add(new PhaseSimple(4));
            ls.pushList(ls2);
            Assert.AreEqual(ls.pop().playerID, 3);
            Assert.AreEqual(ls.pop().playerID, 4);
            Assert.AreEqual(ls.pop().playerID, 0);
            Assert.AreEqual(ls.pop().playerID, 1);
            Assert.AreEqual(ls.pop().playerID, 2);
        }
Exemplo n.º 9
0
        public void HarmDyingTest()
        {
            Attack    card   = new Attack(CardSuit.Club, 1);
            IGame     game   = mocks.Stub <IGame>();
            int       health = 5;
            int       harm   = 10;
            Player    p      = new Player(0, "Name", "Descript", health);
            PhaseList ret    = p.harm(new HarmPhase(p, null, harm, card), game);

            Phase x = ret.pop();

            Assert.IsInstanceOfType(x, typeof(AskForHelpPhase));
            Assert.IsTrue(ret.isEmpty());

            Assert.AreEqual(health - harm, p.health);
        }
Exemplo n.º 10
0
        public void resAdvanceTest3()
        {
            ZhangFei p1     = new ZhangFei(0);
            Card     attack = new Attack(CardSuit.Spade, 1);
            Miss     miss   = new Miss(CardSuit.Diamond, 2);

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

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


            // ActionPhase produces attackPhase
            UserActionPhase a  = new ActionPhase(p1);
            PhaseList       ls = a.timeOutAdvance(game);

            Assert.IsInstanceOfType(ls.pop(), typeof(DiscardPhase));
            Assert.IsTrue(ls.isEmpty());
        }
Exemplo n.º 11
0
        public void phaselistpop()
        {
            PhaseList p = new PhaseList();

            p.pop();
        }