Exemplo n.º 1
0
        public void responseCardActionTest()
        {
            Player p1 = mocks.Stub <Player>(0);

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

            Card attack = new Attack(CardSuit.Spade, 1);
            Miss miss   = new Miss(CardSuit.Diamond, 2);
            // ActionPhase produces attackPhase
            UserActionPhase a = new DiscardPhase(p1);

            Assert.IsInstanceOfType(a.responseCardAction(attack, game), typeof(PhaseList));
        }
Exemplo n.º 2
0
        public void autoAdvanceTest()
        {
            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 DiscardPhase(p1);

            Assert.IsInstanceOfType(a.autoAdvance(game), typeof(PhaseList));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void VisiblePhaseSuntest()
        {
            Player p1     = new Player(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>();

            Player[] p = new Player[1];
            p[0] = p1;

            // ActionPhase produces attackPhase
            UserActionPhase a = new DiscardPhase(p1);

            Assert.AreEqual(a.responseAbilityActionSun(new AbilityActionSun(new Attack(CardSuit.Spade, (byte)1)), game), null);
        }
Exemplo n.º 5
0
        public void resAdvanceTest5()
        {
            Player p1     = new Player(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 DiscardPhase(p1);

            Player[] p = new Player[1];
            p[0] = p1;
            Assert.AreEqual(a.responseUseCardAction(miss, p, game), null);
        }
Exemplo n.º 6
0
    public void Initialize(int numRounds, Player.PlayerType[] playerTypes, string[] names, List <TileSetupData.TileSetupEntry> tileSetupEntries)
    {
        this.numberOfRounds = numRounds;
        this.curRound       = 1;

        this.tileSetupEntries = tileSetupEntries;
        foreach (TileSetupData.TileSetupEntry entry in this.tileSetupEntries)
        {
            this.tilesInGame.Add(new Tile.TileProp(entry.type, entry.id));
        }

        for (int i = 0; i < playerTypes.Length; ++i)
        {
            Player player = new Player(playerTypes[i], i, names[i]);
            this.players.Add(player);
        }

        this.players[UnityEngine.Random.Range(0, this.players.Count)].IsBoss = true;

        foreach (TileSetupData.TileSetupEntry setupEntry in tileSetupEntries)
        {
            for (int i = 0; i < setupEntry.numberInDeck; ++i)
            {
                Tile tile = new Tile(setupEntry.type, setupEntry.id);
                this.deck.AddTile(tile);
            }
        }

        PhaseNode roundStartPhase         = new RoundStartPhase();
        PhaseNode drawPhase               = new DrawPhase();
        PhaseNode completeHandPhase       = new CompleteHandPhase();
        PhaseNode discardPhase            = new DiscardPhase();
        PhaseNode stealPhase              = new StealPhase();
        PhaseNode changeActivePlayerPhase = new ChangeActivePlayerPhase();
        PhaseNode roundEndPhase           = new RoundEndPhase();

        roundStartPhase.Next         = drawPhase;
        drawPhase.Next               = completeHandPhase;
        completeHandPhase.Next       = discardPhase;
        discardPhase.Next            = stealPhase;
        stealPhase.Next              = changeActivePlayerPhase;
        changeActivePlayerPhase.Next = drawPhase;

        this.phaseNodes[roundStartPhase.PhaseId]         = roundStartPhase;
        this.phaseNodes[drawPhase.PhaseId]               = drawPhase;
        this.phaseNodes[completeHandPhase.PhaseId]       = completeHandPhase;
        this.phaseNodes[discardPhase.PhaseId]            = discardPhase;
        this.phaseNodes[stealPhase.PhaseId]              = stealPhase;
        this.phaseNodes[changeActivePlayerPhase.PhaseId] = changeActivePlayerPhase;
        this.phaseNodes[roundEndPhase.PhaseId]           = roundEndPhase;

        this.handCombinations.Add(new AllSameColorCombination());
        this.handCombinations.Add(new AllSameCombination());
        this.handCombinations.Add(new AllSameIdCombination());
        this.handCombinations.Add(new OneColorAndWhitesCombination());
        this.handCombinations.Add(new ThreeColorCombination());
        this.handCombinations.Add(new ReachHandCombination());
        this.handCombinations.Add(new NoStealsCombination());
        this.handCombinations.Add(new CompleteWithDrawCombination());
        this.handCombinations.Add(new IppatsuCombination());
        // TODO: Implement the bottom hand combination AIs.
        foreach (TileSetupData.TileSetupEntry entry in tileSetupEntries)
        {
            if (entry.type == Tile.TileType.Dragon)
            {
                this.handCombinations.Add(new DragonCombination(entry.id));
            }
        }
        this.handCombinations.Add(new TwoIdenticalCombination());
    }