Inheritance: IStartActions
コード例 #1
0
        /// <summary>
        /// Let the players place their starting settlements and roads and receive resources
        /// from all neighboring tiles from the last placed settlement (rules p. 7 top)
        /// </summary>
        private void PlaceStarts()
        {
            foreach (Player p in players)
            {
                var state   = CurrentGamestate();
                var actions = new StartActions(players[turn], this);
                players[turn].Agent.PlaceStart(state, actions);
                if (!actions.IsComplete())
                {
                    throw new AgentActionException("Agent " + p.Agent.GetType().Name + " did not place the correct amount of start pieces (1/2)", true);
                }
                var spos = actions.GetSettlementPosition();
                Log(new BuildPieceLogEvent(p.Id, Token.Settlement, spos));
                var rpos = actions.GetRoadPosition();
                Log(new BuildRoadLogEvent(p.Id, rpos));

                NextTurn();
            }
            foreach (Player p in players.Reverse())
            {
                PrevTurn();
                var state   = CurrentGamestate();
                var actions = new StartActions(players[turn], this);
                players[turn].Agent.PlaceStart(state, actions);
                if (!actions.IsComplete())
                {
                    throw new AgentActionException("Agent " + p.Agent.GetType().Name + " did not place the correct amount of start piece (2/2)", true);
                }
                var spos = actions.GetSettlementPosition();
                Log(new BuildPieceLogEvent(p.Id, Token.Settlement, spos));
                var rpos = actions.GetRoadPosition();
                Log(new BuildRoadLogEvent(p.Id, rpos));

                //Hand out resources
                foreach (var pos in actions.GetSettlementPosition().ToArray())
                {
                    Terrain terrain = board.GetTile(pos).Terrain;
                    if (terrain == Terrain.Desert || terrain == Terrain.Water)
                    {
                        continue; //can't get desert or water
                    }
                    GetResource(players[turn], (Resource)board.GetTile(pos).Terrain);
                }
            }
        }
コード例 #2
0
ファイル: GameController.cs プロジェクト: rasmusgreve/catan
        /// <summary>
        /// Let the players place their starting settlements and roads and receive resources 
        /// from all neighboring tiles from the last placed settlement (rules p. 7 top)
        /// </summary>
        private void PlaceStarts()
        {
            foreach (Player p in players)
            {
                var state = CurrentGamestate();
                var actions = new StartActions(players[turn], this);
                players[turn].Agent.PlaceStart(state, actions);
                if (!actions.IsComplete())
                {
                    throw new AgentActionException("Agent " + p.Agent.GetType().Name + " did not place the correct amount of start pieces (1/2)", true);
                }
                var spos = actions.GetSettlementPosition();
                Log(new BuildPieceLogEvent(p.Id,Token.Settlement,spos));
                var rpos = actions.GetRoadPosition();
                Log(new BuildRoadLogEvent(p.Id, rpos));

                NextTurn();
            }
            foreach (Player p in players.Reverse())
            {
                PrevTurn();
                var state = CurrentGamestate();
                var actions = new StartActions(players[turn], this);
                players[turn].Agent.PlaceStart(state, actions);
                if (!actions.IsComplete())
                {
                    throw new AgentActionException("Agent " + p.Agent.GetType().Name + " did not place the correct amount of start piece (2/2)", true);
                }
                var spos = actions.GetSettlementPosition();
                Log(new BuildPieceLogEvent(p.Id, Token.Settlement, spos));
                var rpos = actions.GetRoadPosition();
                Log(new BuildRoadLogEvent(p.Id, rpos));

                //Hand out resources
                foreach (var pos in actions.GetSettlementPosition().ToArray())
                {
                    Terrain terrain = board.GetTile(pos).Terrain;
                    if (terrain == Terrain.Desert || terrain == Terrain.Water)
                        continue; //can't get desert or water
                    GetResource(players[turn], (Resource)board.GetTile(pos).Terrain);
                }
            }
        }