Example #1
0
        // this should be called when the logic has assigned a ship to a particular cell
        public static void AddNegativeShip(Ship ship, MapCell targetCell)
        {
            int haliteNegative = (int)(1000 - ship.halite);
            int layers         = 0;

            while (haliteNegative > 0 && layers < 2)
            {
                var cells = GameInfo.GetXLayersExclusive(targetCell.position, layers);
                int sum   = cells.Sum(c => Mapping[c].Value);
                var ratio = Math.Min(((double)haliteNegative / (double)sum), .7);
                cells.ForEach(c => Mapping[c].ReduceValue((int)(Mapping[c].Value * ratio)));
                haliteNegative -= (int)(sum * .7) + 1;
                layers++;
            }
        }