Beispiel #1
0
        /// <summary>
        /// Process income
        /// </summary>
        /// <param name="battleReport">Battle reports</param>
        /// <param name="deaths">Number of gangers who've died in the last battle.</param>
        /// <returns>Income report</returns>
        public IncomeReport ProcessIncome(BattleReport battleReport, int deaths)
        {
            var gang        = _gangManager.GetGang(battleReport.GangId);
            var territories = _territoryManager.GetTerritoriesByGangId(battleReport.GangId).ToList();

            territories.Sort();
            var gangers = GetGangers(battleReport.GangId).ToList();
            var gross   = new List <TerritoryIncomeReport>();

            for (int i = 0; i < gangers.Count() && i < territories.Count && i < MaximumTerritoriesWorked; i++)
            {
                var status = new TerritoryWorkStatus()
                {
                    TerritoryName      = territories[i].Name,
                    Deaths             = deaths,
                    Ganger             = gangers[i],
                    GangId             = battleReport.GangId,
                    Objectives         = battleReport.GangBattleStats.Select(stats => stats.Objectives).Sum(),
                    PreviousBattleType = battleReport.GameType,
                    Roll = _diceRoller.ParseDiceString(territories[i].Income),
                };

                gross.Add(territories[i].WorkTerritory(status));
            }

            int territoryGross    = gross.Select(territoryReport => territoryReport.Income).Sum();
            int giantKillerBonus  = GetGiantKillerBonus(gang.GangRating, battleReport.OpponentGangRating);
            int incomeAfterUpkeep = GetGangUpkeep(GetNumberOfGangMembers(battleReport.GangId), territoryGross + giantKillerBonus);

            var report = new IncomeReport()
            {
                Gross            = gross,
                GiantKillerBonus = giantKillerBonus,
                Upkeep           = territoryGross + giantKillerBonus - incomeAfterUpkeep,
                Income           = incomeAfterUpkeep,
            };

            gang.Credits += report.Income;
            _gangManager.UpdateGang(gang);

            return(report);
        }
Beispiel #2
0
 public Gang UpdateGang(Gang gang)
 {
     // TODO: validate request
     return(_gangManager.UpdateGang(gang));
 }