Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
 public MethodResult CanRefuseMPP(MilitaryProtectionPactOffer offer, Entity entity)
 {
     return(haveRightsToMPPOffer(offer, entity));
 }