public void CancelMPP(MilitaryProtectionPactOffer offer) { var otherLink = EntityLinkCreator.Create(offer.FirstCountry.Entity); var msg = $"{otherLink} has canceled military pact proposal"; warningService.AddWarning(offer.SecondCountryID, msg); transactionsService.GetGoldForDeclineMPP(offer.FirstCountry, offer.SecondCountry, offer.ReservedGold); militaryProtectionPactOfferRepository.Remove(offer); militaryProtectionPactOfferRepository.SaveChanges(); }
public void RefuseMPP(MilitaryProtectionPactOffer offer) { transactionsService.GetGoldForDeclineMPP(offer.FirstCountry, offer.SecondCountry, offer.ReservedGold); var otherLink = EntityLinkCreator.Create(offer.SecondCountry.Entity); var msg = $"{otherLink} declined your MPP offer."; warningService.AddWarning(offer.FirstCountryID, msg); militaryProtectionPactOfferRepository.Remove(offer); militaryProtectionPactOfferRepository.SaveChanges(); }
public MethodResult CanCancelMPP(MilitaryProtectionPactOffer offer, Entity entity) { if (offer == null) { return(new MethodResult("Offer does not exist!")); } if (countryService.IsPresident(offer.FirstCountry, entity) == false) { return(new MethodResult("You cannot do that!")); } return(MethodResult.Success); }
private MethodResult haveRightsToMPPOffer(MilitaryProtectionPactOffer offer, Entity entity) { if (offer == null) { return(new MethodResult("Offer does not exist!")); } if (countryService.IsPresident(offer.SecondCountry, entity) == false) { return(new MethodResult("You cannot do that!")); } return(MethodResult.Success); }
public MPPViewModel(MilitaryProtectionPactOffer offer, bool isProposal) { IsProposal = isProposal; IsProposed = !isProposal; var firstCountry = Persistent.Countries.GetById(offer.FirstCountryID); var secondCountry = Persistent.Countries.GetById(offer.SecondCountryID); FirstCountryName = firstCountry.Entity.Name; FirstCountryID = firstCountry.ID; SecondCountryName = secondCountry.Entity.Name; SecondCountryID = secondCountry.ID; ID = offer.ID; StartDay = offer.Day; }
public void OfferMPP(Entity entity, Country proposingCountry, Country secondCountry, int days) { var goldCost = CalculateMPPCost(days); transactionsService.PayForMPPOffer(proposingCountry, secondCountry, goldCost); var offer = new MilitaryProtectionPactOffer() { Day = GameHelper.CurrentDay, FirstCountryID = proposingCountry.ID, SecondCountryID = secondCountry.ID, Length = days, ReservedGold = goldCost }; militaryProtectionPactOfferRepository.Add(offer); militaryProtectionPactOfferRepository.SaveChanges(); }
public void AcceptMPP(MilitaryProtectionPactOffer offer) { var otherLink = EntityLinkCreator.Create(offer.SecondCountry.Entity); var msg = $"{otherLink} accepted your MPP offer."; warningService.AddWarning(offer.FirstCountryID, msg); var pact = new MilitaryProtectionPact() { Active = true, StartDay = GameHelper.CurrentDay, EndDay = GameHelper.CurrentDay + offer.Length, FirstCountryID = offer.FirstCountryID, SecondCountryID = offer.SecondCountryID }; militaryProtectionPactRepository.Add(pact); militaryProtectionPactOfferRepository.Remove(offer); militaryProtectionPactOfferRepository.SaveChanges(); }
public MethodResult CanRefuseMPP(MilitaryProtectionPactOffer offer, Entity entity) { return(haveRightsToMPPOffer(offer, entity)); }