Beispiel #1
0
        public void DropArmies(Country country, int armyCount)
        {
            if (country.OccupyingPlayer == null)
            {
                throw new Exception($"Unable to place army for {Name} in {country.Name} because it is not owned by anybody.");
            }

            if (country.OccupyingPlayer.Name != Name)
            {
                throw new Exception($"Unable to place army for {Name} in {country.Name} because it is owned by {country.OccupyingPlayer.Name}.");
            }

            if (Countries.All(c => c.Name != country.Name))
            {
                throw new Exception($"Unable to place army for {Name} in {country.Name} because it is not in their country list.");
            }

            if (armyCount > ArmiesToDistribute)
            {
                throw new Exception($"Unable to drop {armyCount} armies for {Name} because only {ArmiesToDistribute} are available.");
            }

            country.OccupyingArmyCount += armyCount;
            ArmiesToDistribute         -= armyCount;

            _logger.LogLine($"* {Name} drops {armyCount} armies into {country.Name} for a total of {country.OccupyingArmyCount}.  {ArmiesToDistribute} armies left to drop.");
        }