Esempio n. 1
0
 public void addDefine(CardDefine define)
 {
     if (cardDefineDic.ContainsKey(define.id))
     {
         throw new ConflictDefineException(cardDefineDic[define.id], define);
     }
     cardDefineDic.Add(define.id, define);
 }
Esempio n. 2
0
        public Card createCardById(int id)
        {
            CardDefine define = getDefine(id);

            if (define == null)
            {
                throw new NoCardDefineException(id);
            }
            return(createCard(define));
        }
Esempio n. 3
0
 public Card(CardDefine define)
 {
     if (define != null)
     {
         this.define = define;
     }
     else
     {
         throw new ArgumentNullException(nameof(define));
     }
 }
Esempio n. 4
0
        public virtual Card createCard(CardDefine define)
        {
            int id = cardDic.Count + 1;

            while (cardDic.ContainsKey(id))
            {
                id++;
            }
            Card card = new Card(id, define);

            cardDic.Add(id, card);
            return(card);
        }
Esempio n. 5
0
 public Task <SetDefineEventArg> setDefine(IGame game, CardDefine define)
 {
     return(game.triggers.doEvent(new SetDefineEventArg()
     {
         card = this, beforeDefine = this.define, afterDefine = define
     }, async arg =>
     {
         Card card = arg.card;
         define = arg.afterDefine;
         //禁用被动
         foreach (var effect in card.define.getEffects().OfType <IPassiveEffect>())
         {
             await effect.onDisable(game, card, null);
         }
         //更换define
         card.define = define;
         //激活被动
         foreach (var effect in card.define.getEffects().OfType <IPassiveEffect>())
         {
             await effect.onEnable(game, card, null);
         }
     }));
 }
Esempio n. 6
0
 public ConflictDefineException(CardDefine a, CardDefine b) : base(a + "和" + b + "具有相同的ID:" + a.id)
 {
 }