void ActivateFearCard(IFearOptions fearCard) { ctx.GameState.Fear.Deck.Pop(); ctx.GameState.Fear.ActivatedCards.Push(new PositionFearCard { FearOptions = fearCard, Text = "FearCard" }); }
public void AddCard(IFearOptions fearCard) { if (Deck.Count >= 9) { throw new InvalidOperationException("Fear deck is full."); } var labels = new string[] { "1-A", "1-B", "1-C", "2-A", "2-B", "2-C", "3-A", "3-B", "3-C" }; int index = 9 - Deck.Count - 1; var td = new PositionFearCard { FearOptions = fearCard, Text = "Lvl " + labels[index] }; Deck.Push(td); }
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}"; }
static public string GetFearCardName(IFearOptions card) { Type type = card.GetType(); return((string)type.GetField("Name").GetValue(null)); }
public ActivatedFearCard(IFearOptions options) { FearOptions = options; Name = GetFearCardName(options); Text = Name; }