public static void DefectKingdomDebug(Clan clan, Kingdom kingdom)
        {
            if (!SettingsHelper.SystemDebugEnabled(AOSystems.EnsuredLoyalty, DebugType.General, new List <IFaction>()
            {
                clan, kingdom
            }))
            {
                return;
            }

            InDebugBranch = true;
            JoinKingdomAsClanBarterable asClanBarterable = new JoinKingdomAsClanBarterable(clan.Leader, kingdom);
            int  ClanBarterableValueForClan    = asClanBarterable.GetValueForFaction(clan);
            int  ClanBarterableValueForKingdom = asClanBarterable.GetValueForFaction(kingdom);
            bool NativeDecision = ClanBarterableValueForClan + ClanBarterableValueForKingdom <= 0;

            TextObject ResultTextObject = new TextObject(Debug_Defect);

            StringHelper.SetEntitiyProperties(ResultTextObject, "LEAVING_CLAN", clan, true);
            StringHelper.SetEntitiyProperties(ResultTextObject, "TARGET_KINGDOM", kingdom);
            StringHelper.SetNumericVariable(ResultTextObject, "CURRENT_BARTERABLE", ClanBarterableValueForClan, "N0");
            StringHelper.SetNumericVariable(ResultTextObject, "TARGET_BARTERABLE", ClanBarterableValueForKingdom, "N0");
            ResultTextObject.SetTextVariable("CLAN_DECISION", NativeDecision ? StayDecision : LeaveDecision);

            bool IsLoyaltyEnsured = LoyaltyManager.CheckLoyalty(clan, out TextObject LoyaltyTextObject, kingdom);

            LoyaltyTextObject.SetTextVariable("TRANSITION_PART", NativeDecision == IsLoyaltyEnsured ? LoyaltyManager.TransitionFromSame : LoyaltyManager.TransitionFromDifferent);
            ResultTextObject.SetTextVariable("ENSURED_LOYALTY_RESULT", LoyaltyTextObject);

            MessageHelper.SimpleMessage(ResultTextObject);
            InDebugBranch = false;
        }
        public static void LeaveKingdomDebug(Clan clan)
        {
            if (!SettingsHelper.SystemDebugEnabled(AOSystems.EnsuredLoyalty, DebugType.General, clan))
            {
                return;
            }

            InDebugBranch = true;
            LeaveKingdomAsClanBarterable asClanBarterable = new LeaveKingdomAsClanBarterable(clan.Leader, null);
            int  ClanBarterableValueForFaction            = asClanBarterable.GetValueForFaction(clan);
            int  StayThreshold  = (Settings.Instance.FixMinorFactionVassals ? clan.IsUnderMercenaryService : clan.IsMinorFaction) ? 500 : 0;
            bool NativeDecision = ClanBarterableValueForFaction <= StayThreshold;

            TextObject ResultTextObject = new TextObject(Debug_Leave);

            StringHelper.SetEntitiyProperties(ResultTextObject, "LEAVING_CLAN", clan, true);
            StringHelper.SetNumericVariable(ResultTextObject, "LEAVE_BARTERABLE", ClanBarterableValueForFaction, "N0");
            StringHelper.SetNumericVariable(ResultTextObject, "LEAVE_THRESHOLD", StayThreshold, "N0");
            ResultTextObject.SetTextVariable("CLAN_DECISION", NativeDecision ? StayDecision : LeaveDecision);

            bool IsLoyaltyEnsured = LoyaltyManager.CheckLoyalty(clan, out TextObject LoyaltyTextObject);

            LoyaltyTextObject.SetTextVariable("TRANSITION_PART", NativeDecision == IsLoyaltyEnsured ? LoyaltyManager.TransitionFromSame : LoyaltyManager.TransitionFromDifferent);
            ResultTextObject.SetTextVariable("ENSURED_LOYALTY_RESULT", LoyaltyTextObject);

            MessageHelper.SimpleMessage(ResultTextObject);
            InDebugBranch = false;
        }
        public void GetSpecificUserTest()
        {
            var loyalty     = new LoyaltyManager(_context);
            var createdUser = loyalty.CreateUser("George", "Bush", "*****@*****.**");

            var queriedUser = loyalty.GetUser(createdUser.UserId);

            Assert.AreEqual("George", queriedUser.FirstName);
            Assert.AreEqual("Bush", queriedUser.LastName);
            Assert.AreEqual("*****@*****.**", queriedUser.Email);
        }
        public void TransferPointsInsufficientPointsTest()
        {
            var loyalty = new LoyaltyManager(_context);
            var user    = loyalty.CreateUser("George", "Clooney", "*****@*****.**");

            Assert.AreEqual(0, user.Points);

            loyalty.TransferPoints(user.UserId, -10);
            var queriedUser = loyalty.GetUser(user.UserId);

            Assert.AreEqual(10, user.Points);
        }
        public void GetUsersTest()
        {
            var loyalty = new LoyaltyManager(_context);

            var users = loyalty.EnumerateUsers();

            Assert.AreEqual(0, users.Count());

            loyalty.CreateUser("George", "Washington", "*****@*****.**");

            users = loyalty.EnumerateUsers();
            Assert.AreEqual(1, users.Count());
        }
        public void TransferPointsTest()
        {
            var loyalty = new LoyaltyManager(_context);
            var user    = loyalty.CreateUser("George", "Orwell", "*****@*****.**");

            Assert.AreEqual(0, user.Points);

            var transfer    = loyalty.TransferPoints(user.UserId, 10);
            var queriedUser = loyalty.GetUser(user.UserId);

            Assert.AreEqual(10, user.Points);
            Assert.AreEqual(10, transfer.Amount);

            var queriedTransfer = loyalty.EnumerateTransfers(user.UserId).Last();

            Assert.AreEqual(transfer.TransferId, queriedTransfer.TransferId);
            Assert.AreEqual(10, queriedTransfer.Amount);
        }
        public static void UpdateTooltipPatch(TooltipVM tooltipVM, Hero hero)
        {
            try
            {
                if (hero.Clan is null || !SettingsHelper.SubSystemEnabled(SubSystemType.LoyaltyTooltips, hero.Clan))
                {
                    return;
                }

                if (hero.Clan.Kingdom != null && hero.Clan.Kingdom.RulingClan != hero.Clan && hero == hero.Clan.Leader)
                {
                    int RelationWithLiege = hero.GetRelation(hero.Clan.Kingdom.Ruler);
                    tooltipVM.TooltipPropertyList.Add(new TooltipProperty(TooltipHelper.GetTooltipRelationHeader(hero.Clan.Kingdom.Ruler), RelationWithLiege.ToString("N0"), 0, RelationWithLiege < -10 ? Colors.Red : RelationWithLiege > 10 ? Colors.Green : TooltipHelper.DefaultTooltipColor, false, TooltipProperty.TooltipPropertyFlags.None));

                    LoyaltyManager.GetLoyaltyTooltipInfo(hero.Clan, out string LoyaltyText, out Color LoyaltyTextColor);
                    tooltipVM.TooltipPropertyList.Add(new TooltipProperty(TooltipHelper.GetTooltipLoyaltyHeader(), LoyaltyText, 0, LoyaltyTextColor, false, TooltipProperty.TooltipPropertyFlags.None));
                }
            }
            catch (Exception ex)
            {
                MethodInfo?methodInfo = MethodBase.GetCurrentMethod() as MethodInfo;
                DebugHelper.HandleException(ex, methodInfo, "Harmony patch for TooltipVMExtensions.UpdateTooltip");
            }
        }
예제 #8
0
 /// <inheritdoc />
 public LoyaltyController()
 {
     _loyaltyManager = new LoyaltyManager();
 }
예제 #9
0
 public Task <PagedResult <LoyaltyCard> > GetCustomerLoyaltyCards(string accountNumber, QueryResultSettings queryResultSettings)
 {
     return(Task.Run(() => LoyaltyManager.Create(CommerceRuntimeManager.Runtime).GetCustomerLoyaltyCards(accountNumber, queryResultSettings)));
 }
예제 #10
0
 public Task <LoyaltyCard> GetLoyaltyCard(string cardNumber)
 {
     return(Task.Run(() => LoyaltyManager.Create(CommerceRuntimeManager.Runtime).GetLoyaltyCardStatus(cardNumber)));
 }
예제 #11
0
 public Task <LoyaltyCard> IssueLoyaltyCard(LoyaltyCard loyaltyCard)
 {
     return(Task.Run(() => LoyaltyManager.Create(CommerceRuntimeManager.Runtime).IssueLoyaltyCard(loyaltyCard.CardNumber, loyaltyCard.CustomerAccount, loyaltyCard.CardTenderType)));
 }
 public UsersController(LoyaltyManager database)
 {
     _database = database;
 }