public CardModel(IOwner owner, ICardTemplate template) : base(owner) { Template = template; _player = new ReactiveProperty <IPlayerModel>(owner as IPlayerModel); _power = new IntReactiveProperty(Template.Power); _health = new IntReactiveProperty(Template.Health); _manaCost = new IntReactiveProperty(Template.ManaCost); _items = new ReactiveCollection <IItemModel>(Template.Items); _abilities = new ReactiveCollection <EAbility>(Template.Abilities); _effects = new ReactiveCollection <IEffectModel>(Template.Effects); _health.Subscribe(h => { if (h <= 0) { Die(); } }); _effects.ObserveAdd().Subscribe(e => Info($"Added Effect {e} from {this}")).AddTo(this); _items.ObserveAdd().Subscribe(e => Info($"Added Item {e} from {this}")).AddTo(this); _abilities.ObserveAdd().Subscribe(e => Info($"Added Ability {e} from {this}")).AddTo(this); _effects.ObserveRemove().Subscribe(e => Info($"Removed Effect {e} from {this}")).AddTo(this); _items.ObserveRemove().Subscribe(e => Info($"Removed Item {e} from {this}")).AddTo(this); _abilities.ObserveRemove().Subscribe(e => Info($"Removed Ability {e} from {this}")).AddTo(this); }
public bool Add(ICardTemplate card) { Assert.IsNotNull(card); if (_cards.Count(c => c.Id == card.Id) > 2) { Warn($"Cannot have more than three instances of {card} in your library"); return(false); } _cards.Add(card); return(true); }
public Card(ICardTemplate cardTemplate,Player player, Game game) : base() { CardTemplate = cardTemplate; Player = player; Owner = Player; Location = LOCATION.Library; Game = game; Game.AddCard(this); EventHub.AddObserver(EventConstants.StartOfStep,untapHandler); }
public bool Remove(ICardTemplate card) { var templ = card; if (templ == null) { Warn($"{card} is of type {card.GetType()}, but should be a {typeof(ICardTemplate)}"); return(false); } if (!Has(card)) { return(false); } _cards.Remove(templ); return(true); }
public ItemModel(IOwner owner, ICardTemplate template) : base(owner, template) { }
public bool Has(ICardTemplate card) { return(Has(card.Id)); }
public SpellModel(IOwner owner, ICardTemplate template) : base(owner, template) { }
public ICardModel NewCardModel(IPlayerModel owner, ICardTemplate tmpl) { return(Registry.New <ICardModel>(tmpl, owner)); }
public ICardModel NewCardModel(IPlayerModel owner, ICardTemplate tmpl) => Registry.Get <ICardModel>(tmpl, owner);