示例#1
0
        public static GameState CreateDefaultGameState(this GameState gameState)
        {
            var vertices = Enumerable.Range(1, 6).Select(x => new BoardVertex()
            {
                PlayerOwner = new Player(),
                Resources   = new Dictionary <ResourceConstants, int>(),
                Type        = VertexTypeConstants.Empty
            }).ToList();

            var edges = Enumerable.Range(1, 6).Select(x =>
            {
                BoardVertex source = vertices.ElementAt(x - 1);
                BoardVertex target = vertices.ElementAt(x < 6 ? x : 0);

                return(new BoardEdge(source, target));
            }).ToList();

            gameState.AdjacencyGraph.AddVerticesAndEdgeRange(edges);

            var hexagon = new Hexagon()
            {
                HasRobber  = false,
                Resource   = ResourceConstants.Brick,
                RollNumber = 7,
                Vertices   = vertices
            };

            gameState.Hexagons = gameState.Hexagons.Append(hexagon);

            return(gameState);
        }
示例#2
0
        public bool CreateSettlement(ref Player player, ref BoardVertex vertex, bool isStartupPhase)
        {
            if (vertex.Type != VertexTypeConstants.Empty)
            {
                return(false);
            }
            // if (isStartupPhase != true && economyService.CanAffordCost(player, CostConstants.SettlementResourceCost)) return false;
            if (player.Structures[StructureConstants.Settlement] == 0)
            {
                return(false);
            }

            //TODO: Add check to make sure there are no adjacent settlements.
            //TODO: Add check to make sure settlements are being place on a road owned by the player.

            vertex.Type        = VertexTypeConstants.Settlement;
            vertex.PlayerOwner = player;
            player.Structures[StructureConstants.Settlement] = player.Structures[StructureConstants.Settlement] - 1;

            return(true);
        }