示例#1
0
 public Task <IAddModiEventArg> addModifier(IGame game, PropModifier modifier)
 {
     if (game != null && game.triggers != null)
     {
         return(game.triggers.doEvent <IAddModiEventArg>(new AddModiEventArg()
         {
             game = game, card = this, modifier = modifier, valueBefore = getProp(game, modifier.getPropName())
         }, async arg =>
         {
             Card card = arg.card as Card;
             modifier = arg.modifier as PropModifier;
             if (modifier == null)
             {
                 throw new ArgumentNullException(nameof(modifier));
             }
             object beforeValue = card.getProp(game, modifier.getPropName());
             await modifier.beforeAdd(game, card);
             card.modifierList.Add(modifier);
             await modifier.afterAdd(game, card);
             object value = card.getProp(game, modifier.getPropName());
             (arg as AddModiEventArg).valueAfter = value;
             game?.logger?.logTrace(nameof(PropModifier), card + "获得属性修正" + modifier + "=>" + StringHelper.propToString(value));
             await game.triggers.doEvent(new PropChangeEventArg()
             {
                 game = game, card = card, propName = modifier.getPropName(), beforeValue = beforeValue, value = value
             }, arg2 =>
             {
                 arg2.game?.logger?.logTrace(nameof(Card), arg2.card + "的属性" + arg2.propName + "=>" + StringHelper.propToString(arg2.value));
                 return Task.CompletedTask;
             });
         }));
     }
     else
     {
         if (modifier == null)
         {
             throw new ArgumentNullException(nameof(modifier));
         }
         modifier.beforeAdd(game, this);
         modifierList.Add(modifier);
         modifier.afterAdd(game, this);
         object prop       = getProp(game, modifier.getPropName());
         string propString = StringHelper.propToString(prop);
         return(Task.FromResult <IAddModiEventArg>(default));
示例#2
0
 public Task <IAddModiEventArg> addModifier(IGame game, PropModifier modifier)
 {
     if (game != null && game.triggers != null)
     {
         return(game.triggers.doEvent <IAddModiEventArg>(new AddModiEventArg()
         {
             game = game, card = this, modifier = modifier, valueBefore = getProp(game, modifier.propName)
         },
                                                         arg =>
         {
             Card card = arg.card as Card;
             modifier = arg.modifier as PropModifier;
             if (modifier == null)
             {
                 throw new ArgumentNullException(nameof(modifier));
             }
             modifier.beforeAdd(game, card);
             card.modifierList.Add(modifier);
             modifier.afterAdd(game, card);
             object prop = card.getProp(game, modifier.propName);
             (arg as AddModiEventArg).valueAfter = prop;
             game?.logger?.log("PropModifier", card + "获得属性修正" + modifier + "=>" + propToString(prop));
             return Task.CompletedTask;
         }));
     }
     else
     {
         if (modifier == null)
         {
             throw new ArgumentNullException(nameof(modifier));
         }
         modifier.beforeAdd(game, this);
         modifierList.Add(modifier);
         modifier.afterAdd(game, this);
         object prop       = getProp(game, modifier.propName);
         string propString = propToString(prop);
         return(Task.FromResult <IAddModiEventArg>(default));
 public GeneratedBuff(int id, PropModifier modifier, params IPassiveEffect[] effects)
 {
     this.id      = id;
     modifiers    = new PropModifier[] { modifier };
     this.effects = effects;
 }
示例#4
0
 public CodeBuff(int id, PropModifier modifier, params IPassiveEffect[] effects)
 {
     this.id      = id;
     modifiers    = (new PropModifier[] { modifier });
     this.effects = effects;
 }