Пример #1
0
 public ActorFieldSide(CardGameControllerBase cardGameController, ParameterScope parentScope = null)
     : base(ParameterScopeLevel.Actor, parentScope ?? cardGameController)
 {
     Deck        = new FieldRegion <TCard, TCardDefinition>(cardGameController, this);
     Hand        = new FieldRegion <TCard, TCardDefinition>(cardGameController, this);
     DiscardPile = new FieldRegion <TCard, TCardDefinition>(cardGameController, this);
 }
Пример #2
0
 private void ProcessParameters(
     ParameterScope scope,
     IDictionary <string, string> parameters,
     IDictionary <string, IParameter> existingParameters,
     ISafeRepository safeRepository)
 {
     foreach (string name in parameters.Keys)
     {
         if (existingParameters.ContainsKey(name))
         {
             if (existingParameters[name].Value != parameters[name])
             {
                 safeRepository.SetParameterValue(
                     existingParameters[name].Id, parameters[name]);
             }
             existingParameters.Remove(name);
         }
         else
         {
             safeRepository.CreateParameter(
                 new Parameter(
                     Guid.NewGuid(),
                     scope.DestinationSystemId,
                     scope.EntityTypeId,
                     scope.SourceSystemId,
                     name,
                     parameters[name]));
         }
     }
 }
Пример #3
0
 public void ActivateEffect(ParameterScope thisScope, CardEffectActivationContextBase context)
 {
     foreach (var e in effects)
     {
         e.ActivateEffects(context, thisScope as CardBase);
     }
 }
Пример #4
0
                private ParameterScope(RemoteQueryableVisitor visitor, ParameterScope parent)
                {
                    _parent = parent;
                    _count  = parent?._count ?? 0;

                    _visitor = visitor;
                    _visitor._parameterScope = this;
                }
Пример #5
0
 /// <summary>
 /// Fügt ein Parameter hinzu.
 /// </summary>
 /// <param name="name">Der Name des Parametern</param>
 /// <param name="value">Der Wert</param>
 /// <param name="scope">Der Gültigkeitsbereich des Parameters</param>
 public void AddParam(string name, string value, ParameterScope scope = ParameterScope.Global)
 {
     if (!string.IsNullOrWhiteSpace(value))
     {
         AddParam(new Parameter(name, value)
         {
             Scope = scope
         });
     }
 }
Пример #6
0
        public bool CheckConditions(CardGameEvent e, ParameterScope thisScope)
        {
            var targetScope = scopeSelectionType == ScopeSelectionType.This ? thisScope.GetHigherScope(parameterScopeLevel) : e.GetFromHeirachyAtLevel(parameterScopeLevel);

            if (targetScope == null)
            {
                return(false);
            }
            return(conditions.TrueForAll(c => c.CheckCondition(targetScope)));
        }
Пример #7
0
 private IDictionary <string, string> GetParameters(
     DeploymentContext context, ParameterScope scope)
 {
     if (context.Parameters.TryGetValue(
             scope, out IDictionary <string, string> parameters) == false)
     {
         parameters = new Dictionary <string, string>();
     }
     return(parameters);
 }
        private static IEnumerable <TResult> SubqueryMaterialize <TResult>(IEnumerable <TResult> materializedSequence, ParameterContext parameterContext)
        {
            ParameterScope scope         = null;
            var            batchSequence = materializedSequence
                                           .Batch(BatchFastFirstCount, BatchMinSize, BatchMaxSize)
                                           .ApplyBeforeAndAfter(
                () => scope = parameterContext.Activate(),
                () => scope.DisposeSafely());

            return(batchSequence.SelectMany(batch => batch));
        }
Пример #9
0
 protected virtual bool CompareParameter(ParameterExpression a, ParameterExpression b)
 {
     if (ParameterScope == null)
     {
         return(a == b);
     }
     if (ParameterScope.TryGetValue(a, out var mapped))
     {
         return(mapped == b);
     }
     return(a == b);
 }
Пример #10
0
 private IDictionary <string, IParameter> GetExistingParameters(
     IDictionary <
         ParameterScope,
         Dictionary <string, IParameter> > existingParametersByScope,
     ParameterScope scope)
 {
     if (existingParametersByScope.TryGetValue(
             scope, out Dictionary <string, IParameter> existingParameters) == false)
     {
         existingParameters = new Dictionary <string, IParameter>();
     }
     return(existingParameters);
 }
Пример #11
0
        public bool CheckConditions(CardGameEvent e, ParameterScope thisScope)
        {
            if (triggerFilterType == TriggerFilterType.This && e.callingHeirachy[0] != thisScope)
            {
                return(false);
            }
            if (triggerFilterType == TriggerFilterType.NotThis && e.callingHeirachy[0] == thisScope)
            {
                return(false);
            }

            return(triggerConditions.TrueForAll(c => c.CheckConditions(e, thisScope)));
        }
        public void RaiseEvent(CardGameEvent cardGameEvent, ParameterScope topLevelScope)
        {
            Debug.Log("Processing event: " + cardGameEvent);
            var effects = topLevelScope.GetAllTriggeredEffectsForEvent(cardGameEvent);
            var context = CreateContextFromEvent(cardGameEvent);

            Debug.Log($"{effects.Count} effects triggered");

            for (int i = 0; i < effects.Count; i++)
            {
                effects[i].effect.ActivateEffect(effects[i].scope, context);
                if (context.wasActionCancelled)
                {
                    // RaiseEvent() - raise cancellation event
                    cardGameEvent.CancelEvent();
                    break;
                }
            }
        }
Пример #13
0
            private void SetParameterValue(
                Guid?destinationSystemId,
                Guid?entityTypeId,
                Guid?sourceSystemId,
                string name,
                string value)
            {
                this.ValidateParameterArguments(
                    destinationSystemId,
                    entityTypeId,
                    sourceSystemId,
                    name,
                    value);
                var scope = new ParameterScope(
                    destinationSystemId, entityTypeId, sourceSystemId);

                if (this.parameters.ContainsKey(scope) == false)
                {
                    this.parameters[scope] = new Dictionary <string, string>();
                }
                parameters[scope][name] = value;
            }
Пример #14
0
        /** Get the arg, return value, or predefined property for this rule */
        public virtual AttributeScope GetLocalAttributeScope(string name)
        {
            AttributeScope scope = null;

            if (ReturnScope != null && ReturnScope.GetAttribute(name) != null)
            {
                scope = ReturnScope;
            }
            else if (ParameterScope != null && ParameterScope.GetAttribute(name) != null)
            {
                scope = ParameterScope;
            }
            else
            {
                AttributeScope rulePropertiesScope =
                    RuleLabelScope.grammarTypeToRulePropertiesScope[(int)Grammar.type];
                if (rulePropertiesScope.GetAttribute(name) != null)
                {
                    scope = rulePropertiesScope;
                }
            }
            return(scope);
        }
Пример #15
0
 /// <summary>
 /// Fügt ein Parameter hinzu. Der Wert wird aus dem Request ermittelt
 /// </summary>
 /// <param name="name">Der Name des Parametern</param>
 /// <param name="scope">Der Gültigkeitsbereich des Parameters</param>
 public void AddParam(string name, ParameterScope scope = ParameterScope.Global)
 {
     Page.AddParam(name.ToLower(), scope);
 }
 public bool TestAboveThreshold <TCard, TCardDefinition>(FieldRegion <TCard, TCardDefinition> fieldRegion, ParameterScope scope, CompositeValueThreshold modifier = null)
     where TCard : CardBase <TCardDefinition>
     where TCardDefinition : CardDefinitionBase
 {
     return(CompositeValue.GetValue(fieldRegion) >= GetThresholdValue(scope) + (modifier?.GetThresholdValue(scope) ?? 0));
 }
 public int GetThresholdValue(ParameterScope scope)
 {
     return(thresholdInt + (backingParameter != null ? backingParameter.Evaluate(scope) : 0));
 }
 public void Activate()
 {
     scope = parameterContext.Activate();
 }
Пример #19
0
 public abstract bool CheckCondition(ParameterScope scope);
Пример #20
0
        public sealed override TCard2 CreateCard <TCard2, TCardDefinition2>(TCardDefinition2 cardDefinition, ParameterScope parent)
        {
            if (!(cardDefinition is TCardDefinition2))
            {
                throw new Exception("Input cardDefinition is not the correct type");
            }
            var card = CreateCard(cardDefinition as TCardDefinition, parent);

            if (!(card is TCard2))
            {
                throw new Exception("Created card is not the correct type");
            }
            return(card as TCard2);
        }
Пример #21
0
 public FieldRegion(CardGameControllerBase cardGameController, ParameterScope parentScope = null)
     : base(ParameterScopeLevel.Region, parentScope ?? cardGameController)
 {
     cardStacks = new List <CardStack <TCard, TCardDefinition> >();
 }
Пример #22
0
 /// <summary>
 /// Fügt ein Parameter hinzu. Der Wert wird aus dem Request ermittelt
 /// </summary>
 /// <param name="name">Der Name des Parametern</param>
 /// <param name="scope">Der Gültigkeitsbereich des Parameters</param>
 public void AddParam(string name, ParameterScope scope = ParameterScope.Global)
 {
     AddParam(name, Request.GetParam(name), scope);
 }
Пример #23
0
 protected abstract TCard CreateCard(TCardDefinition cardDefinition, ParameterScope parent);
Пример #24
0
 public RemoteQueryableVisitor()
 {
     _parameterScope = new ParameterScope(this);
 }
Пример #25
0
 public CardBase(ParameterScope parent)
     : base(ParameterScopeLevel.Card, parent)
 {
 }
Пример #26
0
        public static CardFactory cardFactory; // TECH DEBT - public access

        public abstract TCard CreateCard <TCard, TCardDefinition>(TCardDefinition cardDefinition, ParameterScope parent)
            where TCard : CardBase <TCardDefinition>
            where TCardDefinition : CardDefinitionBase;