From 558b6452747841f4e6af45e9859053c4e4cb5eaf Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 17 Feb 2024 19:40:26 -0600 Subject: [PATCH] erro log fix and zerg mechanic manager --- src/engine/gameManager/ZergManager.java | 161 +++++++++++++++++ .../handlers/ManageCityAssetMsgHandler.java | 2 +- src/engine/objects/Mine.java | 168 +----------------- 3 files changed, 166 insertions(+), 165 deletions(-) create mode 100644 src/engine/gameManager/ZergManager.java diff --git a/src/engine/gameManager/ZergManager.java b/src/engine/gameManager/ZergManager.java new file mode 100644 index 00000000..caae2a9e --- /dev/null +++ b/src/engine/gameManager/ZergManager.java @@ -0,0 +1,161 @@ +package engine.gameManager; + +public class ZergManager { + public static float getMultiplier5Man(int count){ + float multiplier = 1.0f; + switch(count){ + case 1: + case 2: + multiplier += 0.8f; + break; + case 3: + multiplier += 0.5f; + break; + case 4: + multiplier += 0.2f; + break; + case 5: + multiplier += 0.0f; + break; + case 6: + multiplier -= 0.2f; + break; + case 7: + multiplier -= 0.4f; + break; + case 8: + multiplier -= 0.6f; + break; + default: + multiplier -= 0.80f; + break; + } + return multiplier; + } + + public static float getMultiplier10Man(int count){ + float multiplier = 1.0f; + switch(count){ + case 1: + multiplier += 1.0f; + break; + case 2: + multiplier += 1.0f; + break; + case 3: + multiplier += 1.0f; + break; + case 4: + multiplier += 1.0f; + break; + case 5: + multiplier += 0.8f; + break; + case 6: + multiplier += 0.55f; + break; + case 7: + multiplier += 0.35f; + break; + case 8: + multiplier += 0.2f; + break; + case 9: + multiplier += 0.1f; + break; + case 10: + multiplier += 0.0f; + break; + case 11: + multiplier -= 0.1f; + break; + case 12: + multiplier -= 0.2f; + break; + case 13: + multiplier -= 0.35f; + break; + case 14: + multiplier -= 0.55f; + break; + default: + multiplier -= 0.75f; + break; + } + return multiplier; + } + + public static float getMultiplier20Man(int count){ + float multiplier = 1.0f; + if(count < 10){ + multiplier += 1.25f; + }else { + switch (count) { + case 10: + multiplier += 0.8f; + break; + case 11: + multiplier += 0.65f; + break; + case 12: + multiplier += 0.54f; + break; + case 13: + multiplier += 0.46f; + break; + case 14: + multiplier += 0.36f; + break; + case 15: + multiplier += 0.28f; + break; + case 16: + multiplier += 0.21f; + break; + case 17: + multiplier += 0.15f; + break; + case 18: + multiplier += 0.09f; + break; + case 19: + multiplier += 0.04f; + break; + case 20: + multiplier += 0.00f; + break; + case 21: + multiplier -= 0.04f; + break; + case 22: + multiplier -= 0.09f; + break; + case 23: + multiplier -= 0.15f; + break; + case 24: + multiplier -= 0.21f; + break; + case 25: + multiplier -= 0.28f; + break; + case 26: + multiplier -= 0.36f; + break; + case 27: + multiplier -= 0.46f; + break; + case 28: + multiplier -= 0.54f; + break; + case 29: + multiplier -= 0.65f; + break; + default: + multiplier -= 0.75f; + break; + } + } + return multiplier; + } +} diff --git a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java index e2b0af01..0fe3c58d 100644 --- a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java +++ b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java @@ -294,7 +294,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { // Owner is obviously allowed to upgrade his own buildings - if (building.getOwner().equals(player)) { + if (building.getOwner() != null && building.getOwner().equals(player)) { // Players cannot destroy or transfer a TOL. diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 4958ddad..0d87b125 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -11,14 +11,10 @@ package engine.objects; import engine.Enum; import engine.InterestManagement.WorldGrid; -import engine.gameManager.BuildingManager; -import engine.gameManager.ChatManager; -import engine.gameManager.DbManager; -import engine.gameManager.ZoneManager; +import engine.gameManager.*; import engine.net.ByteBufferWriter; import engine.net.client.msg.ErrorPopupMsg; import engine.server.MBServerStatics; -import org.joda.time.DateTime; import org.pmw.tinylog.Logger; import java.net.UnknownHostException; @@ -27,7 +23,6 @@ import java.sql.SQLException; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; import static engine.gameManager.DbManager.MineQueries; import static engine.gameManager.DbManager.getObject; @@ -652,13 +647,13 @@ public class Mine extends AbstractGameObject { int count = this.dividedPlayers.get(player.getGuild().getNation()).size(); switch(this.capSize){ case 5: - player.ZergMultiplier = getMultiplier5Man(count); + player.ZergMultiplier = ZergManager.getMultiplier5Man(count); break; case 10: - player.ZergMultiplier = getMultiplier10Man(count); + player.ZergMultiplier = ZergManager.getMultiplier10Man(count); break; case 20: - player.ZergMultiplier = getMultiplier20Man(count); + player.ZergMultiplier = ZergManager.getMultiplier20Man(count); break; } } else{ @@ -710,159 +705,4 @@ public class Mine extends AbstractGameObject { } } - public static float getMultiplier5Man(int count){ - float multiplier = 1.0f; - switch(count){ - case 1: - case 2: - multiplier += 0.8f; - break; - case 3: - multiplier += 0.5f; - break; - case 4: - multiplier += 0.2f; - break; - case 5: - multiplier += 0.0f; - break; - case 6: - multiplier -= 0.2f; - break; - case 7: - multiplier -= 0.4f; - break; - case 8: - multiplier -= 0.6f; - break; - default: - multiplier -= 0.80f; - break; - } - return multiplier; - } - public static float getMultiplier10Man(int count){ - float multiplier = 1.0f; - switch(count){ - case 1: - multiplier += 1.0f; - break; - case 2: - multiplier += 1.0f; - break; - case 3: - multiplier += 1.0f; - break; - case 4: - multiplier += 1.0f; - break; - case 5: - multiplier += 0.8f; - break; - case 6: - multiplier += 0.55f; - break; - case 7: - multiplier += 0.35f; - break; - case 8: - multiplier += 0.2f; - break; - case 9: - multiplier += 0.1f; - break; - case 10: - multiplier += 0.0f; - break; - case 11: - multiplier -= 0.1f; - break; - case 12: - multiplier -= 0.2f; - break; - case 13: - multiplier -= 0.35f; - break; - case 14: - multiplier -= 0.55f; - break; - default: - multiplier -= 0.75f; - break; - } - return multiplier; - } - public static float getMultiplier20Man(int count){ - float multiplier = 1.0f; - if(count < 10){ - multiplier += 1.25f; - }else { - switch (count) { - case 10: - multiplier += 0.8f; - break; - case 11: - multiplier += 0.65f; - break; - case 12: - multiplier += 0.54f; - break; - case 13: - multiplier += 0.46f; - break; - case 14: - multiplier += 0.36f; - break; - case 15: - multiplier += 0.28f; - break; - case 16: - multiplier += 0.21f; - break; - case 17: - multiplier += 0.15f; - break; - case 18: - multiplier += 0.09f; - break; - case 19: - multiplier += 0.04f; - break; - case 20: - multiplier += 0.00f; - break; - case 21: - multiplier -= 0.04f; - break; - case 22: - multiplier -= 0.09f; - break; - case 23: - multiplier -= 0.15f; - break; - case 24: - multiplier -= 0.21f; - break; - case 25: - multiplier -= 0.28f; - break; - case 26: - multiplier -= 0.36f; - break; - case 27: - multiplier -= 0.46f; - break; - case 28: - multiplier -= 0.54f; - break; - case 29: - multiplier -= 0.65f; - break; - default: - multiplier -= 0.75f; - break; - } - } - return multiplier; - } }