Exemplo n.º 1
0
    public ActivatedFearCard(IFearOptions options, int activation)
    {
        FearOptions = options ?? throw new ArgumentNullException(nameof(options));
        Name        = GetFearCardName(options);

        var memberName = "Level" + activation;

        // This does not find interface methods declared as: void IFearCardOption.Level2(...)
        var member = FearOptions.GetType().GetMethod(memberName)
                     ?? throw new Exception(memberName + " not found on " + options.GetType().Name);

        var attr = (FearLevelAttribute)member.GetCustomAttributes(typeof(FearLevelAttribute)).Single();

        Text = $"{Name} : {activation} : {attr.Description}";
    }
Exemplo n.º 2
0
    static public string GetFearCardName(IFearOptions card)
    {
        Type type = card.GetType();

        return((string)type.GetField("Name").GetValue(null));
    }