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(); }
// 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)); }