package main; public class Effect { public String getDesc() { return ""; } public void apply(final Player p) { } public void unapply(final Player p) { } public static class AttackSpeed extends Effect { private double percent; public AttackSpeed(final Double percent) { this.percent = percent; } public double getPercent() { return this.percent; } @Override public String getDesc() { if (this.getPercent() >= 1.0) { return "Increases attack speed by " + Math.round(100.0 * (this.getPercent() - 1.0)) + "%"; } return "Decreases attack speed by " + Math.round(100.0 * (1.0 - this.getPercent())) + "%"; } @Override public void apply(final Player p) { p.attackSpeedMod *= this.percent; Direction[] values; for (int length = (values = Direction.values()).length, i = 0; i < length; ++i) { final Direction dir = values[i]; p.getModel().getAnimation(dir, Action.Attacking).drawInterval = (int)(p.getBaseAttackSpeed() * p.getAttackSpeed()); } } @Override public void unapply(final Player p) { p.attackSpeedMod /= this.percent; Direction[] values; for (int length = (values = Direction.values()).length, i = 0; i < length; ++i) { final Direction dir = values[i]; p.getModel().getAnimation(dir, Action.Attacking).drawInterval = (int)(p.getBaseAttackSpeed() * p.getAttackSpeed()); } } } public static class MoveSpeed extends Effect { private double percent; public MoveSpeed(final Double percent) { this.percent = percent; } public double getPercent() { return this.percent; } @Override public String getDesc() { if (this.getPercent() >= 1.0) { return "Increases move speed by " + Math.round(100.0 * (this.getPercent() - 1.0)) + "%"; } return "Decreases move speed by " + Math.round(100.0 * (1.0 - this.getPercent())) + "%"; } @Override public void apply(final Player p) { p.moveSpeedMod *= this.percent; Direction[] values; for (int length = (values = Direction.values()).length, i = 0; i < length; ++i) { final Direction dir = values[i]; p.getModel().getAnimation(dir, Action.Walking).drawInterval = (int)(p.getBaseMoveSpeed() / p.moveSpeedMod); } p.speed = (int)(p.getBasePixelSpeed() * p.moveSpeedMod); } @Override public void unapply(final Player p) { p.moveSpeedMod /= this.percent; Direction[] values; for (int length = (values = Direction.values()).length, i = 0; i < length; ++i) { final Direction dir = values[i]; p.getModel().getAnimation(dir, Action.Walking).drawInterval = (int)(p.getBaseMoveSpeed() / p.moveSpeedMod); } p.speed = (int)(p.getBasePixelSpeed() * p.moveSpeedMod); } } public static class Damage extends Effect { private int damage; public Damage(final int damage) { this.damage = damage; } public int getDamage() { return this.damage; } @Override public String getDesc() { if (this.getDamage() > 0) { return "Increases damage by " + this.getDamage(); } return "Decreases damage by " + Math.abs(this.getDamage()); } @Override public void apply(final Player p) { p.damageMod += this.damage; } @Override public void unapply(final Player p) { p.damageMod -= this.damage; } } public static class Hitpoints extends Effect { private int mod; public Hitpoints(final int mod) { this.mod = mod; } public int getMod() { return this.mod; } @Override public String getDesc() { if (this.getMod() > 0) { return "Increases hitpoints by " + this.getMod(); } return "Decreases hitpoints by " + Math.abs(this.getMod()); } @Override public void apply(final Player p) { p.hpMod += this.mod; p.propagateStatChanges(); } @Override public void unapply(final Player p) { p.hpMod -= this.mod; p.propagateStatChanges(); } } public static class Manapoints extends Effect { private int mod; public Manapoints(final int mod) { this.mod = mod; } public int getMod() { return this.mod; } @Override public String getDesc() { if (this.getMod() > 0) { return "Increases manapoints by " + this.getMod(); } return "Decreases manapoints by " + Math.abs(this.getMod()); } @Override public void apply(final Player p) { p.mpMod += this.mod; p.propagateStatChanges(); } @Override public void unapply(final Player p) { p.mpMod -= this.mod; p.propagateStatChanges(); } } }