public void Update(string property, TargetOption option, string valueList)
        {
            Guard.IsNotNullOrEmpty(property, "Invalid property");
            Guard.IsNotNullOrEmpty(valueList, "Invalid userList");

            Option     = option;
            Property   = property;
            ValuesList = ValuesList.NewList(valueList);
        }
Example #2
0
        public async Task UpdatePerUser(Guid id, string property, string valuesList, TargetOption option)
        {
            var userId         = authService.CurrentUserId();
            var userTargetings = unitOfWork.Repository <UserTargeting, Guid>();
            var userTarget     = await userTargetings.FirstOrDefaultAsync(UserTargeting.ById(id), "TargetRule");

            Guard.IsTrue(await hasEnvironmentPermission.ToWrite(userId, userTarget.EnvironmentId), "You don't have permissions to update");

            (userTarget.TargetRule as TargetSpecificUsers).Update(property, option, valuesList);

            await unitOfWork.SaveAsync();
        }
            private static List <TargetOption> EvaluateOptions(Ability ability, List <FieldBlock> options)
            {
                List <TargetOption> optionsList = new List <TargetOption>();

                foreach (FieldBlock block in options)
                {
                    TargetOption op = new TargetOption(block);
                    op.score = AIRule.EvaluateTarget.Evaluate(block, ability);
                    optionsList.Add(op);
                }

                return(optionsList);
            }
            private static void SelectTargets(SelectTargetInfoGetter select, List <TargetOption> optionsList)
            {
                select.Reset();
                select.EnemySelect = true;
                for (int i = 0; i < select.m_Num; i++)
                {
                    TargetOption target = Common.RandomOptionOfBest <TargetOption>(optionsList);

                    select.m_Blocks.Add(target.block);

                    if (!select.m_CanRepeat)
                    {
                        optionsList.Remove(target);
                    }
                }
            }
Example #5
0
        public bool Apply(string value, TargetOption option)
        {
            if (option == TargetOption.Contains)
            {
                return(Values.Any(x => x.Contains(value)));
            }

            if (option == TargetOption.NotContains)
            {
                return(Values.Any(x => !x.Contains(value)));
            }

            if (option == TargetOption.IsIn)
            {
                return(Values.Contains(value));
            }

            if (option == TargetOption.IsNotIn)
            {
                return(!Values.Contains(value));
            }

            return(false);
        }
Example #6
0
        public async Task CreatePerUser(Guid applicationId, Guid environmentId, Guid featureToggleId, string property, string userList, TargetOption option)
        {
            var userId = authService.CurrentUserId();

            Guard.IsTrue(await hasEnvironmentPermission.ToWrite(userId, environmentId), "You don't have permissions to create");


            var userTargetings = unitOfWork.Repository <UserTargeting, Guid>();

            Guard.IsFalse(await userTargetings.AnyAsync(UserTargeting.ByEnvironment(environmentId).And(UserTargeting.ByToggle(featureToggleId))), "Already exists a rule for this environment and this feature toggle");


            var target = UserTargeting.PerUser(environmentId, featureToggleId, option, property, userList);

            userTargetings.Insert(target);

            await unitOfWork.SaveAsync();
        }
Example #7
0
 public void ConfirmDelayedSkillTarget(TargetOption tgo)
 {
     if(AwaitingTargetOption) {
         for(int i = 0; i < targets.Count; i++) {
             Target t = targets[i];
             TargetSettings ts = this.TargetSettings[i];
             if(!ts.allowsCharacterTargeting) {
                 continue;
             }
             if(t.path != null && t.character != null) {
                 if(tgo == TargetOption.Path) {
                     t.character = null;
                 } else if(tgo == TargetOption.Character) {
                     t.path = null;
                 }
             }
         }
         ApplySkill();
     } else {
         Debug.LogError("ConfirmDelayedSkillTarget called when skill "+this+" was not expecting target changes");
     }
 }
Example #8
0
 internal void InternalAdd(string key, object v)
 {
     d[key] = new TargetOption(v);
 }
        public static TargetSpecificUsers New(UserTargeting userTargeting, string property, TargetOption option, string valueList)
        {
            Guard.IsNotNullOrEmpty(property, "Invalid property");
            Guard.IsNotNullOrEmpty(valueList, "Invalid userList");

            return(new TargetSpecificUsers
            {
                Option = option,
                Property = property.ToLower(),
                UserTargetingId = userTargeting.Id,
                UserTargeting = userTargeting,
                ValuesList = ValuesList.NewList(valueList)
            });
        }
Example #10
0
        public static UserTargeting PerUser(Guid environmentId, Guid featureToggleId, TargetOption option, string property, string users)
        {
            var userTargeting = new UserTargeting
            {
                Id              = Guid.NewGuid(),
                EnvironmentId   = environmentId,
                FeatureToggleId = featureToggleId,
            };

            var target = TargetSpecificUsers.New(userTargeting, property, option, users);

            userTargeting.TargetRule = target;

            return(userTargeting);
        }