Esempio n. 1
0
File: game.cs Progetto: pvh/dominate
        public Player DominatedBy(Tile t)
        {
            var scoredPlayers = Players.OrderByDescending(p => {
            // highest domination score for a player with >0 species
            return (t.Species[(int)p.Animal] == 0) ? 0 : p.DominationScoreOn(map, t);
              });

              // Doesn't count if you have a score of 0
              if (scoredPlayers.First().DominationScoreOn(map, t) == 0) {
            return null;
              }

              // Ties go to nobody.
              if (scoredPlayers.First().DominationScoreOn(map, t) ==
              scoredPlayers.ElementAt(1).DominationScoreOn(map, t))
            return null;

              // Otherwise, highest wins
              return scoredPlayers.First();
        }
Esempio n. 2
0
File: game.cs Progetto: pvh/dominate
        public Dictionary<Player, int> ScoreFor(Tile t)
        {
            var delta = new Dictionary<Player, int> {};

              var ranks = t.ScoreValues;
              var currentRank = 0;

              // rank the players by their species, breaking ties by food chain order
              // (animals are enumed in foodchain order)
              var itr = Players.OrderByDescending(p => t.Species[(int) p.Animal]).ThenBy(p => (int) p.Animal);

              foreach (var player in itr) {
            // Stop if we've given out all the points or run out of players
            if (currentRank >= ranks.Length) break;
            if (t.Species[(int) player.Animal] == 0) break;

            delta.Add(player, ranks[currentRank++]);
              }

              return delta;
        }
Esempio n. 3
0
 public int DominationScoreOn(Map m, Tile t)
 {
     return m.ChitsFor(t).Sum(chit => AdaptationTo(chit.Element));
 }
Esempio n. 4
0
        public void SpeciationActivity()
        {
            AddActionPawnFor(g.Players[0], ActionType.Speciation);

            SpeciationActivity activity = GetNextActivity<SpeciationActivity>();

            Assert.IsInstanceOfType(typeof(SpeciationActivity), activity);

            activity.SelectedLocation = activity.SelectableLocations[0];

            Tile t1 = new Tile { Terrain = Tile.TerrainType.Desert };
            Tile t2 = new Tile { Terrain = Tile.TerrainType.Sea };
            Tile t3 = new Tile { Terrain = Tile.TerrainType.Jungle, Tundra = true };

            g.TilesFor(activity.SelectedLocation).Returns(new Tile[] { t1, t2, t3 });

            g.ResolveActivity(activity);

            Assert.AreEqual(2, t1.Species[(int)g.Players[0].Animal]);
            Assert.AreEqual(4, t2.Species[(int)g.Players[0].Animal]);
            Assert.AreEqual(1, t3.Species[(int)g.Players[0].Animal]);
        }
Esempio n. 5
0
        public void SetUp()
        {
            // no default setup
            g = new Game(false);
            tile = g.map.tiles[3, 3];
            chits = g.map.ChitsFor(tile);

            // Be sure we're dealing with a tile that has nothing configured on it
            Assert.IsTrue(chits.All(chit =>
                                    (chit.Element == Chit.ElementType.None
                                     ||
                                     chit.Element == Chit.ElementType.Invalid)));
            Assert.AreEqual(Tile.TerrainType.Empty, tile.Terrain);
        }
Esempio n. 6
0
 public CompetitionActionSpace(Tile.TerrainType[] terrains)
     : base(ActionType.Competition)
 {
     Terrains = terrains;
 }