public void UnitUpgrateAbility(int unitId, int abilityId) { var(data, unit) = _units.GetUnit(unitId); if (!data.Abilities.ContainsKey(abilityId)) { throw new Exception($"Ability missing. Unit id = {unitId} ability id = {abilityId}"); } var currentLevel = data.Abilities[abilityId]; if (currentLevel >= data.Level) { throw new Exception($"Impossible to upgrade the ability. Unit id = {unitId} current level = {data.Level}"); } var abilityType = _units.Static.Abilities[abilityId].Params.Mode; var prices = _units.GetAbilityPrices(currentLevel, abilityType); foreach (var price in prices) { _scorers.Spend(price, _formuls); } data.Abilities[abilityId]++; LogicLog.UpgradeAbilityLevel(unitId, abilityId, data.Abilities[abilityId]); _impact.ExecuteContextImpact(unit.ImpactUpdrade, unitId); }