Esempio n. 1
0
        public AbundanceActivity(Player player, List <Chit> availableChits, List <Chit> validChitLocations) : base(player)
        {
            AvailableChits     = availableChits;
            ValidChitLocations = validChitLocations;

            SelectedElementType = Chit.ElementType.None;
        }
Esempio n. 2
0
        internal int Adapt(Chit.ElementType e)
        {
            if (!CanAdapt())
            {
                throw new System.Exception("Already fully adapted.");
            }

            var adapted = adaptation[e] + 1;

            adaptation[e] = adapted;
            return(adapted);
        }
Esempio n. 3
0
        public Chit DrawChit(Chit.ElementType e)
        {
            if (ChitsLeft() == 0)
            {
                return(null);
            }

            Chit chit = chits.Find(c => c.Element == e);

            chits.Remove(chit);
            return(chit);
        }
Esempio n. 4
0
        public void TestNeighboringChitsForTile()
        {
            Game g = new Game();

            var chits = new Chit.ElementType[] {
                Chit.ElementType.Grass,
                Chit.ElementType.Grub,
                Chit.ElementType.Meat,
                Chit.ElementType.Seed,
                Chit.ElementType.Sun,
                Chit.ElementType.Water
            };

            var tile = g.map.tiles[3, 3];

            Assert.AreEqual(Tile.TerrainType.Sea, tile.Terrain);
            CollectionAssert.AreEquivalent(chits, g.map.ChitsFor(tile).Select(chit => chit.Element));
        }
Esempio n. 5
0
        public int AdaptationTo(Chit.ElementType e)
        {
            if (e == Chit.ElementType.None || e == Chit.ElementType.Invalid)
            {
                return(0);
            }

            int adapted = adaptation[e];

            if (bonus[Animal] == e)
            {
                adapted += 2;

                if (Animal == Animal.Amphibian)
                {
                    adapted++;
                }
            }
            return(adapted);
        }
Esempio n. 6
0
        public void TestNeighboringChitsForTile()
        {
            Game g = new Game();

            var chits = new Chit.ElementType[] {
                Chit.ElementType.Grass,
                Chit.ElementType.Grub,
                Chit.ElementType.Meat,
                Chit.ElementType.Seed,
                Chit.ElementType.Sun,
                Chit.ElementType.Water};

            var tile = g.map.tiles[3, 3];
            Assert.AreEqual( Tile.TerrainType.Sea, tile.Terrain );
            CollectionAssert.AreEquivalent( chits, g.map.ChitsFor(tile).Select(chit => chit.Element) );
        }
Esempio n. 7
0
 public SpeciationActionSpace(Chit.ElementType element)
     : base(ActionType.Speciation)
 {
     Element = element;
 }
Esempio n. 8
0
 public void AddElementToPlayer(Player player, Chit.ElementType element)
 {
     player.Adapt(element);
 }
Esempio n. 9
0
 public void PlaceChit(Chit chit, Chit.ElementType elementType)
 {
     chit.Element = elementType;
 }
Esempio n. 10
0
        public IEnumerable <Activity> GetActivities(Game g)
        {
            var actionSpaces = g.ActionDisplay.ActionSpaces;

            // Initiative
            if (actionSpaces[ActionType.Initiative][0].Player != null)
            {
                yield return(new DummyActivity(ActivityType.InitiativeSpace));
            }

            // Action phase activities related to the player's adaptation scale.
            foreach (AdaptationActionSpace a in actionSpaces[ActionType.Adaptation])
            {
                if (a.Player == null)
                {
                    continue;
                }
                yield return(new AdaptationActivity(a.Player, g.ActionDisplay.AdaptationChits));
            }

            var regressionProtection = new Dictionary <Player, Chit.ElementType> {
            };

            foreach (RegressionActionSpace a in actionSpaces[ActionType.Regression])
            {
                if (a.Player == null)
                {
                    continue;
                }
                yield return(new RegressionActivity(a.Player, g.ActionDisplay.RegressionChits));
            }

            if (g.PlayerFor(Animal.Reptile) != null)
            {
                yield return(new RegressionActivity(g.PlayerFor(Animal.Reptile), g.ActionDisplay.RegressionChits));
            }

            // TODO: model protection from regression somehow.
            yield return(new RegressionExecutionActivity(g.ActionDisplay.RegressionChits, regressionProtection));

            // Board chit placement / removal
            foreach (AbundanceActionSpace a in actionSpaces[ActionType.Abundance])
            {
                if (a.Player == null)
                {
                    continue;
                }

                List <Chit> validChitLocations = g.map.Chits.All.FindAll(chit => chit.Element == Chit.ElementType.None).ToList();

                yield return(new AbundanceActivity(a.Player, g.ActionDisplay.AbundanceChits, validChitLocations));
            }

            foreach (WastelandActionSpace a in actionSpaces[ActionType.Wasteland])
            {
                if (a.Player == null)
                {
                    continue;
                }
                yield return(new WastelandActivity(a.Player, g.ActionDisplay.WastelandChits));
            }

            yield return(new WastelandExecutionActivity(g.map, g.ActionDisplay.WastelandChits));

            foreach (DepletionActionSpace a in actionSpaces[ActionType.Depletion])
            {
                if (a.Player == null)
                {
                    continue;
                }

                List <Chit.ElementType> validElementTypesForRemoval = g.ActionDisplay.DepletionChits.ConvertAll(chit => chit.Element);

                List <Chit> validChitsForRemoval = g.map.Chits.All.FindAll(chit => validElementTypesForRemoval.Contains(chit.Element));

                yield return(new DepletionActivity(a.Player, validChitsForRemoval));
            }

            // Glaciation
            var activeGlaciationActionSpace = actionSpaces[ActionType.Glaciation][0];

            if (activeGlaciationActionSpace.Player != null)
            {
                // find all tundra tiles
                List <Tile> tundraTiles = g.map.Tiles.All.FindAll(tile => tile.Tundra);

                HashSet <Tile> eligibleTiles = new HashSet <Tile>();
                tundraTiles.ForEach(delegate(Tile tile)
                {
                    eligibleTiles.UnionWith(g.map.AdjacentTiles(tile));
                });

                yield return(new GlaciationActivity(activeGlaciationActionSpace.Player, tundraTiles));
            }

            // Speciation
            foreach (SpeciationActionSpace a in actionSpaces[ActionType.Speciation])
            {
                if (a.Player == null)
                {
                    continue;
                }

                // XXX FIXME: hardcoded
                Chit.ElementType selectedElement     = Chit.ElementType.Grass;
                List <Chit>      selectableLocations = g.map.Chits.All.FindAll(chit => chit.Element == selectedElement);

                yield return(new SpeciationActivity(a.Player, selectableLocations));
            }

            // Special speciation for the insect player
            var insect = g.PlayerFor(Animal.Insect);

            if (insect != null)
            {
                yield return(new InsectSpeciationActivity(insect, g.map.Tiles.All.FindAll(t => t.Terrain != Tile.TerrainType.Empty && t.Terrain != Tile.TerrainType.Invalid)));
            }

            // Wanderlust (tile placement)
            foreach (WanderlustActionSpace a in actionSpaces[ActionType.Wanderlust])
            {
                if (a.Player == null)
                {
                    continue;
                }
                yield return(new WanderlustActivity(a.Player, g.map, new List <Tile> {
                }));
            }

            // Migration (move species cubes)
            foreach (MigrationActionSpace a in actionSpaces[ActionType.Migration])
            {
                if (a.Player == null)
                {
                    continue;
                }
                // XXX FIXME: hardcoded
                int         count     = 7;
                List <Tile> locations = g.map.Tiles.All.FindAll(tile =>
                                                                tile.Species[(int)a.Player.Animal] > 0);
                yield return(new MigrationActivity(a.Player, count, locations));
            }

            // Special competition for the arachnid player
            var arachnid = g.PlayerFor(Animal.Arachnid);

            if (g.PlayerFor(Animal.Arachnid) != null)
            {
                // XXX FIXME: can only compete on tiles where another player is, really
                List <Tile> locations = g.map.Tiles.All.FindAll(tile => {
                    return(tile.Species[(int)arachnid.Animal] > 0);
                });
                yield return(new CompetitionActivity(arachnid, locations));
            }

            // Competition (remove other player's cubes)
            foreach (CompetitionActionSpace a in actionSpaces[ActionType.Competition])
            {
                if (a.Player == null)
                {
                    continue;
                }
                // XXX FIXME: can only compete on tiles where another player is, really
                List <Tile> locations = g.map.Tiles.All.FindAll(tile => {
                    return(tile.Species[(int)a.Player.Animal] > 0);
                });
                yield return(new CompetitionActivity(a.Player, locations));
            }

            // Domination. Scoring!
            foreach (DominationActionSpace a in actionSpaces[ActionType.Domination])
            {
                if (a.Player == null)
                {
                    continue;
                }
                yield return(new DominationActivity(a.Player, g.map.Tiles.All));
            }
        }
Esempio n. 11
0
 public SpeciationActionSpace(Chit.ElementType element) : base(ActionType.Speciation)
 {
     Element = element;
 }