コード例 #1
0
 private static void endTurn(IFightableObject fightable, IFightableObject fightable2)
 {
     Console.WriteLine("turn over");
     fightable.endTurn();
     fightable2.endTurn();
     Console.WriteLine("\nnext turn");
 }
コード例 #2
0
        virtual public float dealDamage(IFightableObject target, float multiplicator = 1)
        {
            float effectiveDamage = Math.Max(0, multiplicator * (minDamage + maxDamage) / 2);

            Console.WriteLine($"{name} attacks opponent for {effectiveDamage} potential damage.");
            float damageDealt = target.receiveDamage(effectiveDamage);

            return(damageDealt);
        }
コード例 #3
0
        // Removes the first decorator (that is not given decorator) of a given role.
        public static EffectDecorator removeRole(EffectDecorator eff, string role)
        {
            EffectDecorator parent = recursiveSearch(eff, role);

            if (parent == null)
            {
                return(null);
            }
            EffectDecorator  toRemove     = (EffectDecorator)parent.fighter;
            IFightableObject afterDeleted = toRemove.fighter;

            parent.fighter = afterDeleted;
            return(toRemove);
        }
コード例 #4
0
        public override float dealDamage(IFightableObject target, float multiplicator = 1)
        {
            foreach (IEffect attackEffect in effects["att"])
            {
                if (attackEffect is IAttackEffect)
                {
                    multiplicator = ((IAttackEffect)attackEffect).modifyAttack(multiplicator);
                }
                else
                {
                    Console.WriteLine("There is an invalid effect in attack effects");
                }
            }

            return(base.dealDamage(target, multiplicator));
        }
コード例 #5
0
        static void Main(string[] args)
        {
            IFightableObject player = new Player(100f, 3f, 5f), mob = new NPC(40f, 2f, 3f);
            // Over time effect role name:
            string oteRoleName = EffectDecorator.overTimeEffectRoleName;

            EffectDecorator playerBuffs = new EffectDecorator(
                new DamageBuffDecorator(
                    new DefenceBuffDecorator(player, 1, 0.2f),
                    3, 1.4f),
                9999),
                            mobBuffs = new EffectDecorator(
                new DamageBuffDecorator(mob, 3, 5f),
                9999);

            IFightableObject buffedPlayer = playerBuffs,
                             buffedMob    = mobBuffs;

            // turn 1:
            buffedPlayer.dealDamage(buffedMob);
            buffedMob.dealDamage(buffedPlayer);
            endTurn(buffedMob, buffedPlayer);

            // turn 2:
            Console.WriteLine("Player uses a healing skill on himself");
            EffectDecorator.addEffect(new HotDecorator(null, 3, 10f, oteRoleName), playerBuffs);
            Console.WriteLine("Mob causes the player to bleed");
            EffectDecorator.addEffect(new DotDecorator(null, 3, 15f, oteRoleName), playerBuffs);
            endTurn(buffedMob, buffedPlayer);

            // turn 3:
            Console.WriteLine("Player becomes invulnerable for 1 turn");
            EffectDecorator.addEffect(new InvulnerabilityDecorator(null, 1, 5, 10, "godmode"), playerBuffs);
            buffedMob.dealDamage(buffedPlayer);
            endTurn(buffedMob, buffedPlayer);

            Console.Read();
        }
コード例 #6
0
 public ShieldEffectDecorator(IFightableObject fightable, int duration, int stacks, float maxShielding = 10f,
                              float shieldedPercentage = 0.5f, string roleName = "ot") : base(fightable, duration, stacks, roleName)
 {
     this.maxShielding       = maxShielding;
     this.shieldedPercentage = shieldedPercentage;
 }
コード例 #7
0
 public HotEffect(int duration, float tickHeal, IFightableObject target) : base(duration)
 {
     this.tickHeal = tickHeal;
     this.target   = target;
 }
コード例 #8
0
 public DefenceBuffDecorator(IFightableObject fightable, int duration, float reductionFraction)
     : base(fightable, duration)
 {
     this.reductionFraction = reductionFraction;
 }
コード例 #9
0
 public OverTimeEffectDecorator(IFightableObject fightable, int duration, string roleName = "ot")
     : base(fightable, duration, roleName)
 {
 }
コード例 #10
0
 public BuffWithStacksDecorator(IFightableObject fightable, int duration, int stacks, string roleName = "ot")
     : base(fightable, duration, roleName)
 {
     this.stacks = stacks;
 }
コード例 #11
0
 public DotDecorator(IFightableObject fightable, int duration, float tickDamage, string roleName = "dot")
     : base(fightable, duration, roleName)
 {
     this.tickDamage = tickDamage;
 }
コード例 #12
0
 public EffectDecorator(IFightableObject fighter, int duration, string roleName = "main")
 {
     this.fighter  = fighter;
     this.roleName = roleName;
     this.duration = duration;
 }
コード例 #13
0
 // Effectively, resulting damage will be an arithmetic equation, consisting of addition and multiplication.
 virtual public float dealDamage(IFightableObject target, float multiplicator = 1)
 {
     return(fighter.dealDamage(target, multiplicator));
 }
コード例 #14
0
 public HotDecorator(IFightableObject fightable, int duration, float tickHeal, string roleName = "hot")
     : base(fightable, duration, roleName)
 {
     this.tickHeal = tickHeal;
 }
コード例 #15
0
 public DamageBuffDecorator(IFightableObject fightable, int duration, float boostPercentage)
     : base(fightable, duration)
 {
     this.boostPercentage = boostPercentage;
 }
コード例 #16
0
 public StatusEffect(int duration, IFightableObject target) : base(duration)
 {
     this.target = target;
 }
コード例 #17
0
 override public float dealDamage(IFightableObject target, float multiplicator)
 {
     return(fighter.dealDamage(target, multiplicator * boostPercentage));
 }
コード例 #18
0
 public VulnerabilityDecorator(IFightableObject fightable, int duration, float boostPercentage)
     : base(fightable, duration)
 {
     this.damageIncrease = boostPercentage;
 }
コード例 #19
0
 public InvulnerabilityDecorator(IFightableObject fightable, int duration, int stacks, float ignoredDamage = 1f, string roleName = "ot")
     : base(fightable, duration, stacks, roleName)
 {
     this.ignoredDamage = ignoredDamage;
 }
コード例 #20
0
 public DefenceEffect(int duration, IFightableObject target, float damageReductionPercent) : base(duration, target)
 {
     this.damageReductionPercent = damageReductionPercent;
 }
コード例 #21
0
 public BuffDecorator(IFightableObject fightable, int duration, string roleName = "buff")
     : base(fightable, duration, roleName)
 {
 }
コード例 #22
0
 public AttackEffect(int duration, IFightableObject target, float damageMultiplicator) : base(duration, target)
 {
     this.damageMultiplicator = damageMultiplicator;
 }