Ejemplo n.º 1
0
        public void InitializeState(List<Seat> seats)
        {
            tableId = seats[0].TableId;
            playerContexts = new List<MechtonicPlayerContext>();
            foreach (Seat seat in seats)
            {
                MechtonicPlayerContext playerContext = new MechtonicPlayerContext();
                playerContext.playerId = seat.PlayerId;
                playerContext.name = seat.Player.Name;
                playerContext.hand = new List<MechtonicCard>();
                playerContext.money = 0;
                playerContext.eliminated = false;
                playerContext.totalLightMechs = 0;
                playerContexts.Add(playerContext);

            }
            logs = new List<string>();
            playerContexts[0].color = "Red";
            playerContexts[1].color = "Blue";
            if (playerContexts.Count > 2) playerContexts[2].color = "Yellow";
            if (playerContexts.Count > 3) playerContexts[3].color = "Green";
            activePlayerIndex = 0;
            activePlayerId = playerContexts[activePlayerIndex].playerId;

            Random r = new Random();

            #region marketSetup
            purchaseCards = new List<MechtonicPurchaseCard>();
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Light Mech", cost = 1, url = "/content/images/mechtonic/buy_lightmech.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Scout", cost = 2, url = "/content/images/mechtonic/buy_scout.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Miner", cost = 3, url = "/content/images/mechtonic/buy_miner.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Heavy Mech", cost = 6, url = "/content/images/mechtonic/buy_heavymech.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Launcher", cost = 6, url = "/content/images/mechtonic/buy_launcher.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Hover Tank", cost = 7, url = "/content/images/mechtonic/buy_hover.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Colossus", cost = 11, url = "/content/images/mechtonic/buy_colossus.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Card", cost = 4, url = "/content/images/mechtonic/buy_card.png" });
            purchaseCards.Add(new MechtonicPurchaseCard { name = "Skip", cost = 0, url = "/content/images/mechtonic/buy_skip.png" });
            #endregion

            #region boardSetup

            sideLength = 6;

            detonatorA = 3*(sideLength-1)-1;

            int detonatorC = sideLength;
            detonatorB = 6 * (sideLength - 1) - detonatorA - detonatorC;

            board = new List<List<MechtonicTile>>();
            for (int a = 0; a <= 3*(sideLength - 1); a++)
            {
                board.Add(new List<MechtonicTile>());
                for (int b = 0; b <= 3*(sideLength - 1); b++)
                {
                    int c = 6*(sideLength-1) - a - b;
                    if (c >= sideLength-1 && c <= 3*(sideLength - 1))
                    {
                        board[a].Add(new MechtonicTile());
                        if (a < sideLength || b < sideLength || c < sideLength || a >= 3 * (sideLength - 1) || b >= 3 * (sideLength - 1) || c >= 3 * (sideLength - 1))
                        {
                            board[a][b].type = "Core";
                            board[a][b].url = "/content/images/mechtonic/tile_core.png";
                        }
                        else if (r.Next(15) < 2)
                        {
                            board[a][b].type = "Mountain";
                            if(a == detonatorA && b == detonatorB)
                                board[a][b].url = "/content/images/mechtonic/tile_mountain_detonate.png";
                            else
                                board[a][b].url = "/content/images/mechtonic/tile_mountain.png";
                        }
                        else
                        {
                            board[a][b].type = "Normal";
                            if (a == detonatorA && b == detonatorB)
                                board[a][b].url = "/content/images/mechtonic/tile_normal_detonate.png";
                            else
                                board[a][b].url = "/content/images/mechtonic/tile_normal.png";
                        }
                    }
                    else
                    {
                        board[a].Add(null);
                    }
                }
            }
            #endregion

            #region deckSetup
            MechtonicCard coreSpasm = new MechtonicCard{name = "Core Spasm", description = "Destroy next 4 tiles.", url = "/content/images/mechtonic/card_corespasm.png"};
            MechtonicCard nanoTransformation = new MechtonicCard{name = "Nanotransformation", description = "Transform unit into heavy mech.", url = "/content/images/mechtonic/card_nanotransform.png"};
            MechtonicCard overload = new MechtonicCard{name = "Overload", description = "Destroy friendly unit and all adjacent units.", url = "/content/images/mechtonic/card_overload.png"};
            MechtonicCard tactics = new MechtonicCard { name = "Tactics", description = "Play two cards this turn.", url = "/content/images/mechtonic/card_tactics.png" };
            MechtonicCard advance = new MechtonicCard { name = "Advance", description = "Units may move an extra space this turn.", url = "/content/images/mechtonic/card_advance.png" };
            MechtonicCard blackMarket = new MechtonicCard { name = "Black Market", description = "You may buy a unit immediately.", url = "/content/images/mechtonic/card_blackmarket.png" };

            deck = new List<MechtonicCard>();
            deck.Add(coreSpasm);
            deck.Add(coreSpasm);
            deck.Add(nanoTransformation);
            deck.Add(nanoTransformation);
            deck.Add(overload);
            deck.Add(overload);
            deck.Add(tactics);
            deck.Add(tactics);
            deck.Add(advance);
            deck.Add(advance);
            deck.Add(blackMarket);
            deck.Add(blackMarket);

            discard = new List<MechtonicCard>();

            foreach (MechtonicPlayerContext playerContext in playerContexts)
            {
                playerContext.hand.Add(DrawCard(r));
                playerContext.hand.Add(DrawCard(r));
            }
            #endregion

            state = "StartPlace";
            MarkEmpty();
        }
Ejemplo n.º 2
0
        public MechtonicState GetClientState(int playerId)
        {
            this.sourcePlayerId = playerId;
            MechtonicState clientState = new MechtonicState();
            clientState.board = this.board;
            clientState.activePlayerId = this.activePlayerId;
            clientState.activePlayerIndex = this.activePlayerIndex;
            clientState.deck = null;
            clientState.discard = null;
            clientState.gameOver = this.gameOver;
            clientState.playedCard = this.playedCard;
            clientState.purchaseItem = this.purchaseItem;
            clientState.sideLength = this.sideLength;

            clientState.selectA = this.selectA;
            clientState.selectB = this.selectB;
            clientState.state = this.state;
            clientState.tableId = this.tableId;
            clientState.sourcePlayerId = playerId;
            clientState.targetA = this.targetA;
            clientState.targetB = this.targetB;
            clientState.purchaseCards = this.purchaseCards;
            clientState.playerContexts = new List<MechtonicPlayerContext>();
            clientState.logs = this.logs;
            foreach (MechtonicPlayerContext context in playerContexts)
            {
                MechtonicPlayerContext clientContext = new MechtonicPlayerContext();
                clientContext.playerId = context.playerId;
                clientContext.name = context.name;
                clientContext.color = context.color;
                clientContext.strongSide = context.strongSide;
                clientContext.money = context.money;
                if (clientContext.playerId == playerId)
                {
                    clientContext.hand = context.hand;

                }
                clientState.playerContexts.Add(clientContext);
            }
            return clientState;
        }