Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public ItemModel(IOwner owner, ICardTemplate template)
     : base(owner, template)
 {
 }
Ejemplo n.º 6
0
 public bool Has(ICardTemplate card)
 {
     return(Has(card.Id));
 }
Ejemplo n.º 7
0
 public SpellModel(IOwner owner, ICardTemplate template)
     : base(owner, template)
 {
 }
Ejemplo n.º 8
0
 public ICardModel NewCardModel(IPlayerModel owner, ICardTemplate tmpl)
 {
     return(Registry.New <ICardModel>(tmpl, owner));
 }
Ejemplo n.º 9
0
 public ICardModel NewCardModel(IPlayerModel owner, ICardTemplate tmpl)
 => Registry.Get <ICardModel>(tmpl, owner);