Beispiel #1
0
 PowerCard(MethodBase methodBase, GeneratesContextAttribute targetAttr)
 {
     this.methodBase = methodBase;
     this.targetAttr = targetAttr;
     cardAttr        = methodBase.GetCustomAttributes <CardAttribute>().VerboseSingle("Couldn't find CardAttribute on PowerCard targeting a space");
     speedAttr       = methodBase.GetCustomAttribute <SpeedAttribute>(false) ?? throw new InvalidOperationException("Missing Speed attribute for " + methodBase.DeclaringType.Name);
     this.repeatAttr = methodBase.GetCustomAttribute <RepeatAttribute>();
 }
Beispiel #2
0
    internal InnatePower(Type actionType, GeneratesContextAttribute targetAttr)
    {
        innatePowerAttr = actionType.GetCustomAttribute <InnatePowerAttribute>();
        speedAttr       = actionType.GetCustomAttribute <SpeedAttribute>(false)
                          ?? throw new InvalidOperationException("Missing Speed attribute for " + actionType.Name);
        this.targetAttr = targetAttr;
        this.repeatAttr = actionType.GetCustomAttribute <RepeatAttribute>();

        Name = innatePowerAttr.Name;
        GeneralInstructions = innatePowerAttr.GeneralInstructions;

        // try static method (spirit / major / minor)
        var elementListByMethod = actionType
                                  .GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
                                  .Select(m => new MethodTuple(m))
                                  .Where(x => x.Attr != null)
                                  .ToList();

        executionGroups = elementListByMethod
                          // filter first - so we only have groups that have matches
                          .Where(x => x.Attr.Group.HasValue)
                          .GroupBy(x => x.Attr.Group.Value)
                          .Select(x => x.ToArray())
                          .ToArray();

        var drawableOptions = elementListByMethod
                              .Select(x => x.Attr)
                              .Cast <IDrawableInnateOption>()
                              .ToList();

        if (this.repeatAttr != null)
        {
            drawableOptions.AddRange(repeatAttr.Thresholds);
        }
        DrawableOptions = drawableOptions;
    }