public ActionResult GetWarDeclareInformation(int attackerID, int defenderID) { try { var attacker = countryRepository.GetById(attackerID); var defender = countryRepository.GetById(defenderID); if (attacker == null || defender == null) { throw new UserReadableException("Country does not exist!"); } var goldNeeded = warService.GetNeededGoldToStartWar(attacker, defender); var attackerAllies = countryRepository.GetAllies(attackerID); var defenderAllies = countryRepository.GetAllies(defenderID); var vm = new DeclareWarInformationsViewModel(attacker, goldNeeded, attackerAllies, defenderAllies); return(PartialView(vm)); } catch (UserReadableException e) { throw; } catch (Exception) { return(Content("")); } }
public TransactionResult PayForWar(Country attacker, Country defender, IWarService warService) { var adminCurrency = Persistent.Currencies.Gold; var attEntity = attacker.Entity; var defEntity = defender.Entity; var adminMoney = new Money() { Amount = (decimal)warService.GetNeededGoldToStartWar(attacker, defender), Currency = adminCurrency }; var adminTransaction = new Transaction() { Arg1 = "War fee", Arg2 = string.Format("{0}({1}) Attacked {2}({3})", attEntity.Name, attEntity.EntityID, defEntity.Name, defEntity.EntityID), DestinationEntityID = null, Money = adminMoney, SourceEntityID = attEntity.EntityID, TransactionType = TransactionTypeEnum.WarFee }; return(MakeTransaction(adminTransaction)); }