private static void endTurn(IFightableObject fightable, IFightableObject fightable2) { Console.WriteLine("turn over"); fightable.endTurn(); fightable2.endTurn(); Console.WriteLine("\nnext turn"); }
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); }
// 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); }
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)); }
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; }
public HotEffect(int duration, float tickHeal, IFightableObject target) : base(duration) { this.tickHeal = tickHeal; this.target = target; }
public DefenceBuffDecorator(IFightableObject fightable, int duration, float reductionFraction) : base(fightable, duration) { this.reductionFraction = reductionFraction; }
public OverTimeEffectDecorator(IFightableObject fightable, int duration, string roleName = "ot") : base(fightable, duration, roleName) { }
public BuffWithStacksDecorator(IFightableObject fightable, int duration, int stacks, string roleName = "ot") : base(fightable, duration, roleName) { this.stacks = stacks; }
public DotDecorator(IFightableObject fightable, int duration, float tickDamage, string roleName = "dot") : base(fightable, duration, roleName) { this.tickDamage = tickDamage; }
public EffectDecorator(IFightableObject fighter, int duration, string roleName = "main") { this.fighter = fighter; this.roleName = roleName; this.duration = duration; }
// 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)); }
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; }
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; }
public InvulnerabilityDecorator(IFightableObject fightable, int duration, int stacks, float ignoredDamage = 1f, string roleName = "ot") : base(fightable, duration, stacks, roleName) { this.ignoredDamage = ignoredDamage; }
public DefenceEffect(int duration, IFightableObject target, float damageReductionPercent) : base(duration, target) { this.damageReductionPercent = damageReductionPercent; }
public BuffDecorator(IFightableObject fightable, int duration, string roleName = "buff") : base(fightable, duration, roleName) { }
public AttackEffect(int duration, IFightableObject target, float damageMultiplicator) : base(duration, target) { this.damageMultiplicator = damageMultiplicator; }