Ejemplo n.º 1
0
 private static void endTurn(IFightableObject fightable, IFightableObject fightable2)
 {
     Console.WriteLine("turn over");
     fightable.endTurn();
     fightable2.endTurn();
     Console.WriteLine("\nnext turn");
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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();
        }
 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;
 }
Ejemplo n.º 7
0
 public HotEffect(int duration, float tickHeal, IFightableObject target) : base(duration)
 {
     this.tickHeal = tickHeal;
     this.target   = target;
 }
Ejemplo n.º 8
0
 public DefenceBuffDecorator(IFightableObject fightable, int duration, float reductionFraction)
     : base(fightable, duration)
 {
     this.reductionFraction = reductionFraction;
 }
Ejemplo n.º 9
0
 public OverTimeEffectDecorator(IFightableObject fightable, int duration, string roleName = "ot")
     : base(fightable, duration, roleName)
 {
 }
Ejemplo n.º 10
0
 public BuffWithStacksDecorator(IFightableObject fightable, int duration, int stacks, string roleName = "ot")
     : base(fightable, duration, roleName)
 {
     this.stacks = stacks;
 }
Ejemplo n.º 11
0
 public DotDecorator(IFightableObject fightable, int duration, float tickDamage, string roleName = "dot")
     : base(fightable, duration, roleName)
 {
     this.tickDamage = tickDamage;
 }
Ejemplo n.º 12
0
 public EffectDecorator(IFightableObject fighter, int duration, string roleName = "main")
 {
     this.fighter  = fighter;
     this.roleName = roleName;
     this.duration = duration;
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 14
0
 public HotDecorator(IFightableObject fightable, int duration, float tickHeal, string roleName = "hot")
     : base(fightable, duration, roleName)
 {
     this.tickHeal = tickHeal;
 }
 public DamageBuffDecorator(IFightableObject fightable, int duration, float boostPercentage)
     : base(fightable, duration)
 {
     this.boostPercentage = boostPercentage;
 }
Ejemplo n.º 16
0
 public StatusEffect(int duration, IFightableObject target) : base(duration)
 {
     this.target = target;
 }
 override public float dealDamage(IFightableObject target, float multiplicator)
 {
     return(fighter.dealDamage(target, multiplicator * boostPercentage));
 }
 public VulnerabilityDecorator(IFightableObject fightable, int duration, float boostPercentage)
     : base(fightable, duration)
 {
     this.damageIncrease = boostPercentage;
 }
Ejemplo n.º 19
0
 public InvulnerabilityDecorator(IFightableObject fightable, int duration, int stacks, float ignoredDamage = 1f, string roleName = "ot")
     : base(fightable, duration, stacks, roleName)
 {
     this.ignoredDamage = ignoredDamage;
 }
Ejemplo n.º 20
0
 public DefenceEffect(int duration, IFightableObject target, float damageReductionPercent) : base(duration, target)
 {
     this.damageReductionPercent = damageReductionPercent;
 }
Ejemplo n.º 21
0
 public BuffDecorator(IFightableObject fightable, int duration, string roleName = "buff")
     : base(fightable, duration, roleName)
 {
 }
Ejemplo n.º 22
0
 public AttackEffect(int duration, IFightableObject target, float damageMultiplicator) : base(duration, target)
 {
     this.damageMultiplicator = damageMultiplicator;
 }