From 0fa042cece2aad582da533da7a77fb7a8c710092 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 23 Mar 2024 19:22:14 -0400 Subject: [PATCH] Final CombatManager --- ...alCombatManager.java => CombatManager.java} | 5 ++++- src/engine/jobs/AttackJob.java | 4 ++-- src/engine/mobileAI/MobAI.java | 18 +++++++++--------- src/engine/net/client/ClientMessagePump.java | 4 ++-- .../client/handlers/AttackCmdMsgHandler.java | 13 ++++++++----- src/engine/objects/AbstractCharacter.java | 10 +++++----- .../powers/poweractions/StealPowerAction.java | 4 ++-- 7 files changed, 32 insertions(+), 26 deletions(-) rename src/engine/gameManager/{FinalCombatManager.java => CombatManager.java} (99%) diff --git a/src/engine/gameManager/FinalCombatManager.java b/src/engine/gameManager/CombatManager.java similarity index 99% rename from src/engine/gameManager/FinalCombatManager.java rename to src/engine/gameManager/CombatManager.java index 6c847fe9..a98b4df5 100644 --- a/src/engine/gameManager/FinalCombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -19,7 +19,10 @@ import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; -public class FinalCombatManager { +public enum CombatManager { + + COMBAT_MANAGER; + public static void combatCycle(AbstractCharacter attacker, AbstractWorldObject target) { //early exit checks diff --git a/src/engine/jobs/AttackJob.java b/src/engine/jobs/AttackJob.java index 572884d9..f2bb394b 100644 --- a/src/engine/jobs/AttackJob.java +++ b/src/engine/jobs/AttackJob.java @@ -9,7 +9,7 @@ package engine.jobs; -import engine.gameManager.FinalCombatManager; +import engine.gameManager.CombatManager; import engine.job.AbstractJob; import engine.objects.AbstractCharacter; @@ -28,7 +28,7 @@ public class AttackJob extends AbstractJob { @Override protected void doJob() { - FinalCombatManager.combatCycle(this.source,this.source.combatTarget); + CombatManager.combatCycle(this.source, this.source.combatTarget); } public boolean success() { diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 77903b22..e3e04491 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -125,7 +125,7 @@ public class MobAI { ItemBase offHand = mob.getWeaponItemBase(false); if (mainHand == null && offHand == null) { - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); int delay = 3000; if (mob.isSiege()) delay = 11000; @@ -134,13 +134,13 @@ public class MobAI { int delay = 3000; if (mob.isSiege()) delay = 11000; - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); mob.setLastAttackTime(System.currentTimeMillis() + delay); } else if (mob.getWeaponItemBase(false) != null) { int attackDelay = 3000; if (mob.isSiege()) attackDelay = 11000; - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); } } @@ -179,7 +179,7 @@ public class MobAI { ItemBase offHand = mob.getWeaponItemBase(false); if (mainHand == null && offHand == null) { - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); int delay = 3000; if (mob.isSiege()) delay = 15000; @@ -188,13 +188,13 @@ public class MobAI { int attackDelay = 3000; if (mob.isSiege()) attackDelay = 15000; - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); } else if (mob.getWeaponItemBase(false) != null) { int attackDelay = 3000; if (mob.isSiege()) attackDelay = 15000; - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); } @@ -222,7 +222,7 @@ public class MobAI { ItemBase offHand = mob.getWeaponItemBase(false); if (mainHand == null && offHand == null) { - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); int delay = 3000; if (mob.isSiege()) delay = 11000; @@ -231,13 +231,13 @@ public class MobAI { int attackDelay = 3000; if (mob.isSiege()) attackDelay = 11000; - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); } else if (mob.getWeaponItemBase(false) != null) { int attackDelay = 3000; if (mob.isSiege()) attackDelay = 11000; - FinalCombatManager.combatCycle(mob, target); + CombatManager.combatCycle(mob, target); mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); if (target.getCombatTarget() == null) { target.setCombatTarget(mob); diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 45619f25..32765679 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1445,10 +1445,10 @@ public class ClientMessagePump implements NetMsgHandler { social((SocialMsg) msg, origin); break; case COMBATMODE: - FinalCombatManager.toggleCombat(((ToggleCombatMsg) msg).toggleCombat(),origin); + CombatManager.toggleCombat(((ToggleCombatMsg) msg).toggleCombat(), origin); break; case ARCCOMBATMODEATTACKING: - FinalCombatManager.toggleCombat(((SetCombatModeMsg) msg).getToggle(),origin); + CombatManager.toggleCombat(((SetCombatModeMsg) msg).getToggle(), origin); break; case MODIFYGUILDSTATE: ToggleLfgRecruitingMsg tlrm = (ToggleLfgRecruitingMsg) msg; diff --git a/src/engine/net/client/handlers/AttackCmdMsgHandler.java b/src/engine/net/client/handlers/AttackCmdMsgHandler.java index 76460144..82f3a5f3 100644 --- a/src/engine/net/client/handlers/AttackCmdMsgHandler.java +++ b/src/engine/net/client/handlers/AttackCmdMsgHandler.java @@ -3,12 +3,15 @@ package engine.net.client.handlers; import engine.Enum; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; -import engine.gameManager.FinalCombatManager; +import engine.gameManager.CombatManager; import engine.net.client.ClientConnection; import engine.net.client.msg.AttackCmdMsg; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.TargetedActionMsg; -import engine.objects.*; +import engine.objects.AbstractWorldObject; +import engine.objects.Mob; +import engine.objects.NPC; +import engine.objects.PlayerCharacter; /* * @Author: @@ -72,14 +75,14 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { if (!playerCharacter.isCombat()) { //CombatManager.toggleCombat(true, origin); - FinalCombatManager.toggleCombat(true,origin); + CombatManager.toggleCombat(true, origin); } //make character stand if sitting if (playerCharacter.isSit()) - FinalCombatManager.toggleSit(false, origin); + CombatManager.toggleSit(false, origin); - FinalCombatManager.combatCycle(playerCharacter,target); + CombatManager.combatCycle(playerCharacter, target); return true; } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 5588c688..e3c75b54 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -1328,7 +1328,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { //TODO why is Handle REtaliate and cancelontakedamage in modifyHealth? shouldnt this be outside this method? if (value < 0f && !fromCost) { this.cancelOnTakeDamage(); - FinalCombatManager.handleRetaliate(this, attacker); + CombatManager.handleRetaliate(this, attacker); } if(this.getObjectType().equals(GameObjectType.Mob)){ @@ -1395,7 +1395,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } if (value < 0f && !fromCost) { this.cancelOnTakeDamage(); - FinalCombatManager.handleRetaliate(this, attacker); + CombatManager.handleRetaliate(this, attacker); } return newMana - oldMana; } @@ -1434,7 +1434,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } if (value < 0f && !fromCost) { this.cancelOnTakeDamage(); - FinalCombatManager.handleRetaliate(this, attacker); + CombatManager.handleRetaliate(this, attacker); } return newStamina - oldStamina; } @@ -1469,7 +1469,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } if (oldMana > newMana && !fromCost) { this.cancelOnTakeDamage(); - FinalCombatManager.handleRetaliate(this, attacker); + CombatManager.handleRetaliate(this, attacker); } return newMana - oldMana; } @@ -1504,7 +1504,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } if (oldStamina > newStamina && !fromCost) { this.cancelOnTakeDamage(); - FinalCombatManager.handleRetaliate(this, attacker); + CombatManager.handleRetaliate(this, attacker); } return newStamina - oldStamina; diff --git a/src/engine/powers/poweractions/StealPowerAction.java b/src/engine/powers/poweractions/StealPowerAction.java index 7fb5b14e..35775449 100644 --- a/src/engine/powers/poweractions/StealPowerAction.java +++ b/src/engine/powers/poweractions/StealPowerAction.java @@ -12,7 +12,7 @@ package engine.powers.poweractions; import engine.Enum; import engine.Enum.ItemType; import engine.gameManager.ChatManager; -import engine.gameManager.FinalCombatManager; +import engine.gameManager.CombatManager; import engine.math.Vector3fImmutable; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -132,7 +132,7 @@ public class StealPowerAction extends AbstractPowerAction { ownerPC.setLastPlayerAttackTime(); //Handle target attacking back if in combat and has no other target - FinalCombatManager.handleRetaliate(ownerAC, sourcePlayer); + CombatManager.handleRetaliate(ownerAC, sourcePlayer); } else return;