SwordsManager cleaning

This commit is contained in:
GJ 2013-02-27 23:18:17 -05:00
parent 499411f6a2
commit 8fb8c67148
4 changed files with 36 additions and 135 deletions

View File

@ -1,56 +0,0 @@
package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Users;
public class BleedEventHandler {
private McMMOPlayer mcMMOPlayer;
private int skillLevel;
private LivingEntity defender;
protected int skillModifier;
protected BleedEventHandler(SwordsManager manager, LivingEntity defender) {
this.mcMMOPlayer = manager.getMcMMOPlayer();
this.skillLevel = manager.getSkillLevel();
this.defender = defender;
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = SkillTools.skillCheck(skillLevel, Swords.bleedMaxBonusLevel);
}
protected void addBleedTicks() {
int bleedTicks;
if (skillLevel >= Swords.bleedMaxBonusLevel) {
bleedTicks = Swords.bleedMaxTicks;
}
else {
bleedTicks = Swords.bleedBaseTicks;
}
BleedTimer.add(defender, bleedTicks);
}
protected void sendAbilityMessages() {
if (mcMMOPlayer.getProfile().useChatNotifications()) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
if (defender instanceof Player) {
Player defendingPlayer = (Player) defender;
if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) {
defendingPlayer.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
}
}
}
}

View File

@ -1,37 +0,0 @@
package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class CounterAttackEventHandler {
private SwordsManager manager;
private LivingEntity attacker;
private int damage;
protected int skillModifier;
protected CounterAttackEventHandler(SwordsManager manager, LivingEntity attacker, int damage) {
this.manager = manager;
this.attacker = attacker;
this.damage = damage;
}
protected void calculateSkillModifier() {
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Swords.counterAttackMaxBonusLevel);
}
protected void dealDamage() {
CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier);
}
protected void sendAbilityMessages() {
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
}
}
}

View File

@ -1,24 +0,0 @@
package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillType;
public class SerratedStrikesEventHandler {
private SwordsManager manager;
private LivingEntity target;
private int damage;
protected SerratedStrikesEventHandler(SwordsManager manager, LivingEntity target, int damage) {
this.manager = manager;
this.target = target;
this.damage = damage;
}
protected void applyAbilityEffects() {
CombatTools.applyAbilityAoE(manager.getMcMMOPlayer().getPlayer(), target, damage / Swords.serratedStrikesModifier, SkillType.SWORDS);
BleedTimer.add(target, Swords.serratedStrikesBleedTicks);
}
}

View File

@ -1,11 +1,16 @@
package com.gmail.nossr50.skills.swords; package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Users;
public class SwordsManager extends SkillManager { public class SwordsManager extends SkillManager {
public SwordsManager(McMMOPlayer mcMMOPlayer) { public SwordsManager(McMMOPlayer mcMMOPlayer) {
@ -15,35 +20,48 @@ public class SwordsManager extends SkillManager {
/** /**
* Check for Bleed effect. * Check for Bleed effect.
* *
* @param defender The defending entity * @param target The defending entity
*/ */
public void bleedCheck(LivingEntity defender) { public void bleedCheck(LivingEntity target) {
BleedEventHandler eventHandler = new BleedEventHandler(this, defender); Player player = getPlayer();
float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * getSkillLevel()); if (SkillTools.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
if (chance > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance;
if (chance > Misc.getRandom().nextInt(activationChance)) { if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
eventHandler.addBleedTicks(); BleedTimer.add(target, Swords.bleedMaxTicks);
eventHandler.sendAbilityMessages(); }
else {
BleedTimer.add(target, Swords.bleedBaseTicks);
}
if (getProfile().useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
if (target instanceof Player) {
Player defender = (Player) target;
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
}
}
} }
} }
public void counterAttackChecks(LivingEntity attacker, int damage) { public void counterAttackChecks(LivingEntity attacker, int damage) {
CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage); if (SkillTools.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
eventHandler.calculateSkillModifier(); CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier);
float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * getSkillLevel()); getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (chance > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance;
if (chance > Misc.getRandom().nextInt(activationChance)) { if (attacker instanceof Player) {
eventHandler.dealDamage(); ((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
eventHandler.sendAbilityMessages(); }
} }
} }
public void serratedStrikes(LivingEntity target, int damage) { public void serratedStrikes(LivingEntity target, int damage) {
SerratedStrikesEventHandler eventHandler = new SerratedStrikesEventHandler(this, target, damage); CombatTools.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
eventHandler.applyAbilityEffects(); BleedTimer.add(target, Swords.serratedStrikesBleedTicks);
} }
} }