From 00fe1bf9d13bd92b57f5a1706fcb3cf35e67a641 Mon Sep 17 00:00:00 2001 From: staeminba Date: Mon, 18 Feb 2019 00:23:41 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[debugging]=20debuging=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/monster/board/StrategyBoard.java | 2 +- .../org/monster/bootstrap/GameCommander.java | 3 + .../org/monster/debugger/PreBotUXManager.java | 3298 +++++++++-------- .../org/monster/debugger/chat/ChatBot.java | 19 +- .../monster/debugger/chat/ChatExecuter.java | 6 +- .../debugger/chat/impl/UxDrawConfig.java | 136 + .../debugger/chat/impl/UxListAddMinus.java | 39 + 7 files changed, 1937 insertions(+), 1566 deletions(-) create mode 100644 src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java create mode 100644 src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java diff --git a/src/main/java/org/monster/board/StrategyBoard.java b/src/main/java/org/monster/board/StrategyBoard.java index de1f76d..d30cfbf 100644 --- a/src/main/java/org/monster/board/StrategyBoard.java +++ b/src/main/java/org/monster/board/StrategyBoard.java @@ -20,7 +20,7 @@ public class StrategyBoard { - private static StrategyBoard instance = new StrategyBoard(); + public static StrategyBoard instance = new StrategyBoard(); public static StrategyBoard Instance() { return instance; diff --git a/src/main/java/org/monster/bootstrap/GameCommander.java b/src/main/java/org/monster/bootstrap/GameCommander.java index 87694f9..8604f34 100644 --- a/src/main/java/org/monster/bootstrap/GameCommander.java +++ b/src/main/java/org/monster/bootstrap/GameCommander.java @@ -5,6 +5,9 @@ import bwapi.Position; import bwapi.TilePosition; import bwapi.Unit; + +import java.lang.reflect.Field; + import org.monster.board.StrategyBoard; import org.monster.build.base.BuildManager; import org.monster.build.base.ConstructionManager; diff --git a/src/main/java/org/monster/debugger/PreBotUXManager.java b/src/main/java/org/monster/debugger/PreBotUXManager.java index ff2262a..c413e7c 100644 --- a/src/main/java/org/monster/debugger/PreBotUXManager.java +++ b/src/main/java/org/monster/debugger/PreBotUXManager.java @@ -1,21 +1,18 @@ package org.monster.debugger; -import bwapi.Bullet; -import bwapi.BulletType; -import bwapi.Color; -import bwapi.Force; -import bwapi.Game; -import bwapi.Player; -import bwapi.Position; -import bwapi.Race; -import bwapi.TilePosition; -import bwapi.Unit; -import bwapi.UnitType; -import bwta.BWTA; -import bwta.BaseLocation; -import bwta.Chokepoint; -import bwta.Polygon; -import bwta.Region; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + import org.monster.board.StrategyBoard; import org.monster.bootstrap.GameManager; import org.monster.build.base.BuildManager; @@ -39,10 +36,9 @@ import org.monster.common.util.TimeUtils; import org.monster.common.util.UnitTypeUtils; import org.monster.common.util.UnitUtils; +import org.monster.debugger.chat.impl.UxDrawConfig; import org.monster.micro.CombatManager; import org.monster.micro.MicroDecision; -import org.monster.strategy.manage.EnemyStrategyAnalyzer; -import org.monster.worker.Minerals; import org.monster.micro.squad.Squad; import org.monster.micro.squad.WatcherSquad; import org.monster.strategy.StrategyManager; @@ -52,31 +48,42 @@ import org.monster.strategy.manage.AirForceTeam; import org.monster.strategy.manage.ClueManager; import org.monster.strategy.manage.EnemyBuildTimer; +import org.monster.strategy.manage.EnemyStrategyAnalyzer; +import org.monster.worker.Minerals; import org.monster.worker.WorkerData; import org.monster.worker.WorkerManager; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; +import bwapi.Bullet; +import bwapi.BulletType; +import bwapi.Color; +import bwapi.Force; +import bwapi.Game; +import bwapi.Player; +import bwapi.Position; +import bwapi.Race; +import bwapi.TilePosition; +import bwapi.Unit; +import bwapi.UnitType; +import bwta.BWTA; +import bwta.BaseLocation; +import bwta.Chokepoint; +import bwta.Polygon; +import bwta.Region; /// 봇 프로그램 개발의 편의성 향상을 위해 게임 화면에 추가 정보들을 표시하는 class
/// 여러 Manager 들로부터 정보를 조회하여 Screen 혹은 Map 에 정보를 표시합니다 public class PreBotUXManager { - private static PreBotUXManager instance = new PreBotUXManager(); - private final int dotRadius = 2; + private static final int JW = 2; + private static final int KK = 3; + + private static PreBotUXManager instance = new PreBotUXManager(); + + private final int dotRadius = 2; public Unit leader = null; - private int uxOption = 0; - private boolean hasSavedBWTAInfo = false; - private int[][] blue = null; + private int uxOption = 0; + private boolean hasSavedBWTAInfo = false; + private int[][] blue = null; private int[][] cyan = null; private int[][] orange = null; private int[][] purple = null; @@ -87,1563 +94,1738 @@ public class PreBotUXManager { private List red2 = new ArrayList(); private String bulletTypeName = ""; private String tempUnitName = ""; - + private Game Broodwar; + private Player player; + private int L = UxDrawConfig.posMap.get("L"); + private int M = UxDrawConfig.posMap.get("M"); + private int R = UxDrawConfig.posMap.get("R"); + private UxDrawConfig uxDrawConfig; + + public ArrayList[] drawStrategyListOrigin = new ArrayList[9]; + public HashMap> drawStrategyListMap = new HashMap>(); + public ArrayList drawStrategyLeftList = new ArrayList(); + public ArrayList drawStrategyMidList = new ArrayList(); + public ArrayList drawStrategyRightList = new ArrayList(); + private UnitType factorySelected = UnitType.None; private Map decisionListForUx = new HashMap<>(); - - /// static singleton 객체를 리턴합니다 - public static PreBotUXManager Instance() { - return instance; - } - - public void setUxOption(int uxOption) { - this.uxOption = uxOption; - } - - private Game Broodwar; - /// 경기가 시작될 때 일회적으로 추가 정보를 출력합니다 - public void onStart(Game Broodwar) { + + public PreBotUXManager() { + initDisplay0(); + initDisplay1(); + } + + public void onStart(Game Broodwar) throws ClassNotFoundException, NoSuchFieldException, SecurityException, NoSuchMethodException { + for (int i = 0; i(); + } this.Broodwar = Broodwar; + player = Broodwar.self(); + System.out.println("player.getName() : " + player.getName()); + } - /// 경기 진행 중 매 프레임마다 추가 정보를 출력하고 사용자 입력을 처리합니다 - public void update() { - if (uxOption == 0) { - UXManager.Instance().update(); -// drawDebugginUxMenu(); - } else { - - if (uxOption == 1) { - drawGameInformationOnScreen(5, 5); - drawBWTAResultOnMap(); - drawBuildOrderQueueOnScreen(500, 50); - drawBuildStatusOnScreen(370, 50); - drawConstructionQueueOnScreenAndMap(200, 150); - drawReservedBuildingTilesOnMap(); - drawTilesToAvoidOnMap(); - drawWorkerMiningStatusOnMap(); - drawUnitTargetOnMap(); - drawnextPoints(); - drawTurretMap(); - drawManagerTimeSpent(490, 200); - - // draw tile position of mouse cursor - int mouseX = Broodwar.getMousePosition().getX() + Broodwar.getScreenPosition().getX(); - int mouseY = Broodwar.getMousePosition().getY() + Broodwar.getScreenPosition().getY(); - Broodwar.drawTextMap(mouseX + 20, mouseY, - "(" + (int) (mouseX / 32) + ", " + (int) (mouseY / 32) + ")"); - Broodwar.drawTextMap(mouseX + 20, mouseY + 10, "(" + (int) (mouseX) + ", " + (int) (mouseY) + ")"); - // 미네랄PATH - } else if (uxOption == 2) { - drawStrategy(); - - } else if (uxOption == 3) { - drawEnemyBuildTimer(); - // drawCCtoScvCount(); - } else if (uxOption == 4) { - drawSquadInfoOnMap(20, 30); - drawManagerTimeSpent(490, 200); - drawDecision(); - drawEnemyAirDefenseRange(); - drawAirForceInformation(); - drawVulturePolicy(); - - } else if (uxOption == 5) { - drawEnemyBaseToBaseTime(); - - } else if (uxOption == 6) { - drawBigWatch(); - drawManagerTimeSpent(490, 200); - } else if (uxOption == 7) { - drawTurretMap(); - drawTilesToAvoidOnMap(); - drawReservedBuildingTilesOnMap(); - } else if (uxOption == 8) { -// drawExpectedResource(); - //drawExpectedResource2(); - } - - drawMineralIdOnMap(); - drawUnitIdOnMap(); - drawPositionInformation(); - drawTimer(); - drawPathData(); - drawSquadUnitTagMap(); - } - - clearDecisionListForUx(); - -// if (TimeUtils.executeRotation(1, 11)) { -//// System.out.println("execute debugBuildLocationSet"); -// ConstructionPlaceFinder.Instance().debugBuildLocationSet(); -// } -// -// if (TimeUtils.executeRotation(1, 233)) { -//// System.out.println("execute debugBuildLocationPrint"); -// ConstructionPlaceFinder.Instance().debugBuildLocationPrint(); -// } - } - - -// private void drawExpectedResource2() { -// int m = 190; -// //Broodwar.drawTextScreen(190, 10, "EnemyPredictedUnitLIst: " + AttackDecisionMaker.Instance().predictedTotalEnemyAttackUnit.size()); -// System.out.println("EnemyPredictedUnitLIst: " + AttackDecisionMaker.Instance().predictedTotalEnemyAttackUnit.size()); -// int l = 10; -// for (Entry enenmy : AttackDecisionMaker.Instance().predictedTotalEnemyAttackUnit.entrySet()) { -// float cnt = enenmy.getValue().get(); -// UnitType unitType = enenmy.getKey(); -// System.out.println(unitType.toString().substring(7, 14) + " : " + cnt); -// //Broodwar.drawTextScreen(m, l+=10, unitType.toString().substring(7, 14)+" : "+cnt); -// } -// } -// -// private void drawExpectedResource() { -// Map enemyCommandInfoMap = AttackDecisionMaker.Instance().enemyResourceDepotInfoMap; -// -// int y = 0; -// Broodwar.drawTextScreen(10, y += 10, "this mymineral : " + Broodwar.self().gatheredMinerals()); -// Broodwar.drawTextScreen(10, y += 10, "total enemy cnt : " + enemyCommandInfoMap.size()); -// Broodwar.drawTextScreen(10, y += 10, "mygas : " + Broodwar.self().gatheredGas()); -// Broodwar.drawTextScreen(10, y += 10, "mywrkcnt(real) : " + UnitUtils.getCompletedUnitCount(UnitType.Terran_SCV)); -// Broodwar.drawTextScreen(10, y += 10, "frame ==== " + TimeUtils.getFrame()); -// -// y = drawCalculation(10, y); -// -// -// y += 10; -// if (enemyCommandInfoMap.size() == 0) { -// Broodwar.drawTextScreen(10, y += 10, "No enemy base info"); -// } else { -// -// int k = 1; -// int x = 10; -// int temp = y; -// for (Map.Entry entry : enemyCommandInfoMap.entrySet()) { -// y = temp; -// UnitInfo unitInfo = entry.getKey(); -// EnemyCommandInfo enemyCommandInfo = entry.getValue(); -// -// if (AttackDecisionMaker.Instance().skipResourceDepot.size() == 0) { -// Broodwar.drawTextScreen(10, y += 10, "skipped base : no skipped base"); -// } else { -// for (UnitInfo skip : AttackDecisionMaker.Instance().skipResourceDepot) { -// Broodwar.drawTextScreen(10, y += 10, "skipped base : " + skip.getLastPosition()); -// } -// } -// -// Broodwar.drawTextScreen(x, y += 10, k++ + " base" + unitInfo.getLastPosition() + ", " + enemyCommandInfo.mineralCalculator.getMineralCount()); -// Broodwar.drawTextScreen(x, y += 10, "isMainBase : " + enemyCommandInfo.isMainBase); -// Broodwar.drawTextScreen(x, y += 10, "has gas : " + enemyCommandInfo.gasCalculator.hasGasBuilding()); -// Broodwar.drawTextScreen(x, y += 10, "mineral(real) : " + ((int) enemyCommandInfo.mineralCalculator.getFullCheckMineral() + (int) 50)); -// Broodwar.drawTextScreen(x, y += 10, "mineral(r+p): : " + ((int) enemyCommandInfo.uxmineral + (int) 50)); -// Broodwar.drawTextScreen(x, y += 10, "gas(real) : " + enemyCommandInfo.gasCalculator.getRealGas()); -// Broodwar.drawTextScreen(x, y += 10, "gas(r+p) : " + enemyCommandInfo.gasCalculator.getGas()); -// Broodwar.drawTextScreen(x, y += 10, "fullWorkerFrame : " + enemyCommandInfo.fullWorkerFrame); -// Broodwar.drawTextScreen(x, y += 10, "halfWorkerFrame : " + enemyCommandInfo.halfWorkerFrame); -// Broodwar.drawTextScreen(x, y += 10, "wrkcnt(real) : " + enemyCommandInfo.workerCounter.realWorkerCount); -// Broodwar.drawTextScreen(x, y += 10, "wrkcnt(r+p) : " + ((int) enemyCommandInfo.workerCounter.getWorkerCount(enemyCommandInfo.lastFullCheckFrame))); -// Broodwar.drawTextScreen(x, y += 10, "fwrkcnt : " + ((int) enemyCommandInfo.lastFullCheckWorkerCount)); -// Broodwar.drawTextScreen(x, y += 10, "last full check : " + enemyCommandInfo.lastFullCheckFrame); -// x += 140; -// } -// -// } -// -// } -// -// private int drawCalculation(int x, int y) { -// y += 10; -// Broodwar.drawTextScreen(x, y += 10, UxColor.CHAR_RED + "Decision : " + AttackDecisionMaker.Instance().decision + ", phase3: " + EnemyStrategyAnalyzer.Instance().getPhase() + ", strategy" + StrategyBoard.currentStrategy.name()); -// Broodwar.drawTextScreen(x, y += 10, "MineralToPredict: " + AttackDecisionMaker.Instance().UXMineralToPredict); -// Broodwar.drawTextScreen(x, y += 10, "GasToPredict : " + AttackDecisionMaker.Instance().UXGasToPredict); -// Broodwar.drawTextScreen(x, y += 10, "MineralMinus: : " + AttackDecisionMaker.Instance().UXMinusMineralToPredict); -// Broodwar.drawTextScreen(x, y += 10, "GasMinus : " + AttackDecisionMaker.Instance().UXMinusGasToPredict); -// -// Broodwar.drawTextScreen(x, y += 10, "my point : " + AttackDecisionMaker.Instance().tempMypoint); -// Broodwar.drawTextScreen(x, y += 10, "enemy point : " + AttackDecisionMaker.Instance().tempEnemypoint); -// return y; -// } - - private void drawDecision() { - for (Integer unitId : decisionListForUx.keySet()) { - Unit unit = Broodwar.getUnit(unitId); - MicroDecision decision = decisionListForUx.get(unitId); - Broodwar.drawTextMap(unit.getPosition(), UxColor.CHAR_YELLOW + decision.toString()); - if (decision.eui != null) { - Broodwar.drawLineMap(unit.getPosition(), decision.eui.getLastPosition(), Color.Yellow); - } - } - } - - public void addDecisionListForUx(Unit unit, MicroDecision decision) { - decisionListForUx.put(unit.getID(), decision); - } - - public void clearDecisionListForUx() { - decisionListForUx.clear(); - } - - private void drawTimer() { - char battleColor = UxColor.CHAR_WHITE; - if (StrategyBoard.initiated) { - battleColor = UxColor.CHAR_RED; - } - Broodwar.drawTextScreen(170, 353, battleColor + StrategyBoard.mainSquadMode.toString() + ": " + DrawingUtils.framesToTimeString(TimeUtils.getFrame()) + "(" + TimeUtils.getFrame() + ")"); - - char apmColor = UxColor.CHAR_WHITE; - int apm = Broodwar.getAPM(); - if (apm > 3000) { - apmColor = UxColor.CHAR_RED; - } else if (apm > 2000) { - apmColor = UxColor.CHAR_YELLOW; - } else if (apm > 1000) { - apmColor = UxColor.CHAR_GREEN; - } else { - apmColor = UxColor.CHAR_WHITE; - } - Broodwar.drawTextScreen(395, 353, apmColor + "APM : " + Broodwar.getAPM()); - } - - private void drawEnemyBuildTimer() { - - Map buildTimeExpectMap = EnemyBuildTimer.Instance().buildTimeExpectMap; - Map buildTimeMinimumMap = EnemyBuildTimer.Instance().buildTimeMinimumMap; - Set buildTimeCertain = EnemyBuildTimer.Instance().buildTimeCertain; - - int y = 20; - Broodwar.drawTextScreen(20, y += 15, "engine Build Frame : " + DrawingUtils.framesToTimeString(StrategyBoard.engineeringBayBuildStartFrame)); - Broodwar.drawTextScreen(20, y += 15, "turret Build Frame : " + DrawingUtils.framesToTimeString(StrategyBoard.turretBuildStartFrame)); - Broodwar.drawTextScreen(20, y += 15, "turret Need Frame : " + DrawingUtils.framesToTimeString(StrategyBoard.turretNeedFrame)); - y += 15; - - Broodwar.drawTextScreen(20, y += 15, "academy Build Frame : " + DrawingUtils.framesToTimeString(StrategyBoard.academyFrame)); - Broodwar.drawTextScreen(20, y += 15, "comsat Build Frame : " + DrawingUtils.framesToTimeString(StrategyBoard.academyFrame + UnitType.Terran_Academy.buildTime())); - y += 15; - - Broodwar.drawTextScreen(20, y += 15, "darkTemplarInMyBaseFrame : " + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().darkTemplarInMyBaseFrame)); - Broodwar.drawTextScreen(20, y += 15, "reaverInMyBaseFrame : " + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().reaverInMyBaseFrame)); - Broodwar.drawTextScreen(20, y += 15, "mutaliskInMyBaseFrame : " + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().mutaliskInMyBaseFrame)); - Broodwar.drawTextScreen(20, y += 15, "lurkerInMyBaseFrame : " + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().lurkerInMyBaseFrame)); - y += 15; - - for (UnitType unitType : buildTimeExpectMap.keySet()) { - Integer buildTimeExpect = buildTimeExpectMap.get(unitType); - if (buildTimeExpect != null && buildTimeExpect != CommonCode.UNKNOWN) { - String expect = DrawingUtils.framesToTimeString(buildTimeExpect); - String minimum = ""; - Integer buildMinimum = buildTimeMinimumMap.get(unitType); - if (buildMinimum != null && buildMinimum != CommonCode.UNKNOWN) { - minimum = DrawingUtils.framesToTimeString(buildMinimum); - } - - Broodwar.drawTextScreen(20, y += 15, unitType + " : " + expect + " - min: " + minimum + " (" + buildTimeCertain.contains(unitType) + ")"); - } - } - } - - private void drawDebugginUxMenu() { - Broodwar.drawTextScreen(20, 20, "1. Default Information"); - Broodwar.drawTextScreen(20, 35, "2. Strategy Information"); - Broodwar.drawTextScreen(20, 50, "3. Position Finder Test"); - Broodwar.drawTextScreen(20, 65, "4. Air Micro Test"); - Broodwar.drawTextScreen(20, 80, "5. Unit Bast To Base"); - } - - // 게임 개요 정보를 Screen 에 표시합니다 - public void drawGameInformationOnScreen(int x, int y) { -// Broodwar.drawTextScreen(x, y, white + "Players : "); -// Broodwar.drawTextScreen(x + 50, y, Broodwar.self().getTextColor() + Broodwar.self().getName() + "(" + InformationManager.Instance().selfRace + ") " + white + " vs. " + -// PlayerUtils.enemyPlayer().getTextColor() + PlayerUtils.enemyPlayer().getName() + "(" + PlayerUtils.enemyRace() + ")"); -// y += 12; -// -// Broodwar.drawTextScreen(x, y, white + "Map : "); -// Broodwar.drawTextScreen(x + 50, y, white + Broodwar.mapFileName() + " (" + Broodwar.mapWidth() + " x " + Broodwar.mapHeight() + " size)"); -// Broodwar.setTextSize(); -// y += 12; - -// Broodwar.drawTextScreen(x, y, white + "Time : "); -// Broodwar.drawTextScreen(x + 50, y, "" + white + TimeUtils.getFrame()); -// Broodwar.drawTextScreen(x + 90, y, "" + white + (int)(TimeUtils.getFrame() / (23.8 * 60)) + ":" + (int)((int)(TimeUtils.getFrame() / 23.8) % 60)); -// y += 11; - - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Current Strategy : "); - Broodwar.drawTextScreen(x + 100, y, "" + UxColor.CHAR_WHITE + StrategyBoard.currentStrategy.name()); - y += 11; - - String history = ""; - for (int i = StrategyBoard.strategyHistory.size() - 1; i >= 0; i--) { - if (i == StrategyBoard.strategyHistory.size() - 3) { - history = "... " + history; - break; - } else { - history = StrategyBoard.strategyHistory.get(i).name() + " -> " + history; - } - } - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Strategy History : "); - Broodwar.drawTextScreen(x + 100, y, "" + UxColor.CHAR_WHITE + history); - y += 11; - - int vultureCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Vulture); - int tankCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Siege_Tank_Tank_Mode, UnitType.Terran_Siege_Tank_Siege_Mode); - int goliathCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Goliath); - -// UnitType selected = BuildQueueProvider.Instance().getFactoryUnitSelector().getSelected(); -// if (selected != UnitType.None) { -// factorySelected = selected; -// } - - - Broodwar.drawTextScreen(x + 100, y + 5, UxColor.CHAR_TEAL + "" + vultureCount + " " + tankCount + " " + goliathCount); - Broodwar.drawTextScreen(x, y, "" + UxColor.CHAR_WHITE + StrategyBoard.factoryRatio + ", selected=" + factorySelected); - y += 11; - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Wraith Count : "); - Broodwar.drawTextScreen(x + 75, y, "" + UxColor.CHAR_WHITE + StrategyBoard.wraithCount + " / " + UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_Wraith)); - y += 11; - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Valkyrie Count : "); - Broodwar.drawTextScreen(x + 75, y, "" + UxColor.CHAR_WHITE + StrategyBoard.valkyrieCount + " / " + UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_Valkyrie)); - y += 11; - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_RED + "MYKillScore : "); - Broodwar.drawTextScreen(x + 70, y, "" + UxColor.CHAR_RED + Broodwar.self().getKillScore()); - y += 11; - Broodwar.drawTextScreen(x, y, UxColor.CHAR_RED + "MYRazingScore : "); - Broodwar.drawTextScreen(x + 85, y, "" + UxColor.CHAR_RED + Broodwar.self().getRazingScore()); - y += 11; - Broodwar.drawTextScreen(x, y, UxColor.CHAR_PURPLE + "EnemyKillScore : "); - Broodwar.drawTextScreen(x + 85, y, "" + UxColor.CHAR_PURPLE + Broodwar.enemy().getKillScore()); - y += 11; - Broodwar.drawTextScreen(x, y, UxColor.CHAR_PURPLE + "EnemyRazingScore : "); - Broodwar.drawTextScreen(x + 100, y, "" + UxColor.CHAR_PURPLE + Broodwar.enemy().getRazingScore()); - y += 11; - Broodwar.drawTextScreen(x, y, UxColor.CHAR_TEAL + "Reserved Resource : " + ConstructionManager.Instance().getReservedMinerals() + " / " + ConstructionManager.Instance().getReservedGas()); - y += 11; - } - - /// APM (Action Per Minute) 숫자를 Screen 에 표시합니다 - public void drawAPM(int x, int y) { - int bwapiAPM = Broodwar.getAPM(); - Broodwar.drawTextScreen(x, y, "APM : " + bwapiAPM); - } + private void initDisplay0() { + Displayer displayer = new Displayer(); + displayers.add(displayer); + } + + private void initDisplay1() { + Displayer displayer = new Displayer(); + displayers.add(displayer); + } + + // TestUxManager.getJwDisplayer(); + // TestUxManager.getDisplayer(1); + // TestUxManager.getDisplayer(2); + + // 0..1 : default + // 2..3 : custom + private List displayers = new ArrayList<>(); + + public Displayer getJwDisplayer() { + return displayers.get(JW); + } + + public Displayer getkKDisplayer() { + return displayers.get(KK); + } + + + + /// static singleton 객체를 리턴합니다 + public static PreBotUXManager Instance() { + return instance; + } + + public int option = 0; + + public void update() { + + if(player.getName().equals("staeminba")){ + getSMDisplay(); + } - /// Players 정보를 Screen 에 표시합니다 - public void drawPlayers() { - for (Player p : Broodwar.getPlayers()) { - Broodwar.sendText("Player [" + p.getID() + "]: " + p.getName() + " is in force: " + p.getForce().getName()); - } + } + + public void setUxOption(int uxOption) { + this.uxOption = uxOption; } - - /// Player 들의 팀 (Force) 들의 정보를 Screen 에 표시합니다 - public void drawForces() { - for (Force f : Broodwar.getForces()) { - Broodwar.sendText("Force " + f.getName() + " has the following players:"); - for (Player p : f.getPlayers()) { - Broodwar.sendText(" - Player [" + p.getID() + "]: " + p.getName()); - } - } + + public int getUxOption() { + return uxOption; } + + + + + private void drawUxInfo() { + // TODO Auto-generated method stub + int y = 10; + //setting + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","/*****************************************************************************",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","*",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 2) UX Type Change : d + num ex) d1=?, d0=prebot1 display",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 3) Change Strategy : $ + Strategy Name ex) $ INIT",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + //uxDrawConfig= new UxDrawConfig("* 4) 레이쓰 공격레벨 변경 : w + 숫자 ex) w1"); + //drawStrategyList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 4) add Var : a + pos + class + var ex) a L(R/M) strategyBoard startStrategy",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 5) minus Var : m + var ex) m startStrategy",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + //uxDrawConfig= new UxDrawConfig("* 6) 디버깅 초기화"); + //drawStrategyList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","*",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","*****************************************************************************///",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } - /// Unit 의 HitPoint 등 추가 정보를 Map 에 표시합니다 - public void drawUnitExtendedInformationOnMap() { - int verticalOffset = -10; - - for (UnitInfo ui : UnitUtils.getEnemyUnitInfoList()) { - - UnitType type = ui.getType(); - int hitPoints = ui.getLastHealth(); - int shields = ui.getLastShields(); - - Position pos = ui.getLastPosition(); - - int left = pos.getX() - type.dimensionLeft(); - int right = pos.getX() + type.dimensionRight(); - int top = pos.getY() - type.dimensionUp(); - int bottom = pos.getY() + type.dimensionDown(); - - // 적 유닛이면 주위에 박스 표시 - if (!Broodwar.isVisible(ui.getLastPosition().toTilePosition())) { - Broodwar.drawBoxMap(new Position(left, top), new Position(right, bottom), Color.Grey, false); - Broodwar.drawTextMap(new Position(left + 3, top + 4), ui.getType().toString()); - } - - // 유닛의 HitPoint 남아있는 비율 표시 - if (!type.isResourceContainer() && type.maxHitPoints() > 0) { - double hpRatio = (double) hitPoints / (double) type.maxHitPoints(); - - Color hpColor = Color.Green; - if (hpRatio < 0.66) hpColor = Color.Orange; - if (hpRatio < 0.33) hpColor = Color.Red; - - int ratioRight = left + (int) ((right - left) * hpRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // 유닛의 Shield 남아있는 비율 표시 - if (!type.isResourceContainer() && type.maxShields() > 0) { - double shieldRatio = (double) shields / (double) type.maxShields(); - - int ratioRight = left + (int) ((right - left) * shieldRatio); - int hpTop = top - 3 + verticalOffset; - int hpBottom = top + 1 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - } - - // draw neutral units and our units - for (Unit unit : Broodwar.getAllUnits()) { - if (unit.getPlayer() == PlayerUtils.enemyPlayer()) { - continue; - } - - final Position pos = unit.getPosition(); - - int left = pos.getX() - unit.getType().dimensionLeft(); - int right = pos.getX() + unit.getType().dimensionRight(); - int top = pos.getY() - unit.getType().dimensionUp(); - int bottom = pos.getY() + unit.getType().dimensionDown(); - - //Monster.game.drawBoxMap(BWAPI.Position(left, top), BWAPI.Position(right, bottom), Color.Grey, false); - - // 유닛의 HitPoint 남아있는 비율 표시 - if (!unit.getType().isResourceContainer() && unit.getType().maxHitPoints() > 0) { - double hpRatio = (double) unit.getHitPoints() / (double) unit.getType().maxHitPoints(); - - Color hpColor = Color.Green; - if (hpRatio < 0.66) hpColor = Color.Orange; - if (hpRatio < 0.33) hpColor = Color.Red; - - int ratioRight = left + (int) ((right - left) * hpRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), hpColor.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // 유닛의 Shield 남아있는 비율 표시 - if (!unit.getType().isResourceContainer() && unit.getType().maxShields() > 0) { - double shieldRatio = (double) unit.getShields() / (double) unit.getType().maxShields(); - - int ratioRight = left + (int) ((right - left) * shieldRatio); - int hpTop = top - 3 + verticalOffset; - int hpBottom = top + 1 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + private void clearList() { + // TODO Auto-generated method stub + drawStrategyLeftList.clear(); + drawStrategyMidList.clear(); + drawStrategyRightList.clear(); + } - int ticWidth = 3; + private void drawDecision() { + for (Integer unitId : decisionListForUx.keySet()) { + Unit unit = Broodwar.getUnit(unitId); + MicroDecision decision = decisionListForUx.get(unitId); + Broodwar.drawTextMap(unit.getPosition(), UxColor.CHAR_YELLOW + decision.toString()); + if (decision.eui != null) { + Broodwar.drawLineMap(unit.getPosition(), decision.eui.getLastPosition(), Color.Yellow); + } + } + } + + public void addDecisionListForUx(Unit unit, MicroDecision decision) { + decisionListForUx.put(unit.getID(), decision); + } + + public void clearDecisionListForUx() { + decisionListForUx.clear(); + } + + private void drawTimer() { + char battleColor = UxColor.CHAR_WHITE; + if (StrategyBoard.initiated) { + battleColor = UxColor.CHAR_RED; + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",StrategyBoard.mainSquadMode.toString() + ": " + DrawingUtils.framesToTimeString(TimeUtils.getFrame()) + "(" + TimeUtils.getFrame() + ")",battleColor); + drawStrategyMidList.add(uxDrawConfig); + + char apmColor = UxColor.CHAR_WHITE; + int apm = Broodwar.getAPM(); + if (apm > 3000) { + apmColor = UxColor.CHAR_RED; + } else if (apm > 2000) { + apmColor = UxColor.CHAR_YELLOW; + } else if (apm > 1000) { + apmColor = UxColor.CHAR_GREEN; + } else { + apmColor = UxColor.CHAR_WHITE; + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","APM : " + Broodwar.getAPM(),apmColor); + drawStrategyRightList.add(uxDrawConfig); + } + + private void drawEnemyBuildTimer(){ + + Map buildTimeExpectMap = EnemyBuildTimer.Instance().buildTimeExpectMap; + Map buildTimeMinimumMap = EnemyBuildTimer.Instance().buildTimeMinimumMap; + Set buildTimeCertain = EnemyBuildTimer.Instance().buildTimeCertain; + + int y = 20; + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","engine Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.engineeringBayBuildStartFrame),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","turret Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretBuildStartFrame),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","turret Need Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretNeedFrame),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","darkTemplarInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().darkTemplarInMyBaseFrame),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","reaverInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().reaverInMyBaseFrame),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","mutaliskInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().mutaliskInMyBaseFrame),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","lurkerInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().lurkerInMyBaseFrame),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + for (UnitType unitType : buildTimeExpectMap.keySet()) { + Integer buildTimeExpect = buildTimeExpectMap.get(unitType); + if (buildTimeExpect != null && buildTimeExpect != CommonCode.UNKNOWN) { + String expect = DrawingUtils.framesToTimeString(buildTimeExpect); + String minimum = ""; + Integer buildMinimum = buildTimeMinimumMap.get(unitType); + if (buildMinimum != null && buildMinimum != CommonCode.UNKNOWN) { + minimum = DrawingUtils.framesToTimeString(buildMinimum); + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","",unitType + " : " + expect + " - min: " + minimum + " (" + buildTimeCertain.contains(unitType) + ")",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } + } + + /*for(UxDrawConfig uxDraw : drawStrategyLeftList){ + int lineCnt = 1; + int fromIndex = -1; + while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { + lineCnt++; + } + Broodwar.drawTextScreen(L, y, UxColor.CHAR_YELLOW + uxDraw.getClassFieldName()); + y += (lineCnt*12); + }*/ + + + } + + private void drawDebugginUxMenu() { + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","1. Default Information",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","2. Strategy Information",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","3. Position Finder Test",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","4. Air Micro Test",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","5. Unit Bast To Base",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } + + // 게임 개요 정보를 Screen 에 표시합니다 + public void drawGameInformationOnScreen(int x, int y) { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","Current Strategy",StrategyBoard.currentStrategy.name(),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + y = 10; + + String history = ""; + for (int i = StrategyBoard.strategyHistory.size() - 1; i >= 0; i--) { + if (i == StrategyBoard.strategyHistory.size() - 3) { + history = "... " + history; + break; + } else { + history = StrategyBoard.strategyHistory.get(i).name() + " -> " + history; + } + } + + /*int vultureCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Vulture); + int tankCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Siege_Tank_Tank_Mode, UnitType.Terran_Siege_Tank_Siege_Mode); + int goliathCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Goliath);*/ + +// UnitType selected = BuildQueueProvider.Instance().getFactoryUnitSelector().getSelected(); +// if (selected != UnitType.None) { +// factorySelected = selected; +// } + + + /* Broodwar.drawTextScreen(x + 100, y + 5, UxColor.CHAR_TEAL + "" + vultureCount + " " + tankCount + " " + goliathCount); + Broodwar.drawTextScreen(x, y, "" + UxColor.CHAR_WHITE + StrategyBoard.factoryRatio + ", selected=" + factorySelected); + y += 11; + + Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Wraith Count : "); + Broodwar.drawTextScreen(x + 75, y, "" + UxColor.CHAR_WHITE + StrategyBoard.wraithCount + " / " + UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_Wraith)); + y += 11; + + Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Valkyrie Count : "); + Broodwar.drawTextScreen(x + 75, y, "" + UxColor.CHAR_WHITE + StrategyBoard.valkyrieCount + " / " + UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_Valkyrie)); + y += 11;*/ + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","MYKillScore",Broodwar.self().getKillScore(),UxColor.CHAR_RED); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","MYRazingScore",Broodwar.self().getRazingScore(),UxColor.CHAR_RED); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","EnemyKillScore",Broodwar.enemy().getKillScore(),UxColor.CHAR_PURPLE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","EnemyRazingScore",Broodwar.enemy().getRazingScore(),UxColor.CHAR_PURPLE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","Reserved Resource",ConstructionManager.Instance().getReservedMinerals()+ " / " + ConstructionManager.Instance().getReservedGas(),UxColor.CHAR_TEAL); + drawStrategyLeftList.add(uxDrawConfig); + + } + + /// Players 정보를 Screen 에 표시합니다 + public void drawPlayers() { + for (Player p : Broodwar.getPlayers()) { + Broodwar.sendText("Player [" + p.getID() + "]: " + p.getName() + " is in force: " + p.getForce().getName()); + } + } + + /// Player 들의 팀 (Force) 들의 정보를 Screen 에 표시합니다 + public void drawForces() { + for (Force f : Broodwar.getForces()) { + Broodwar.sendText("Force " + f.getName() + " has the following players:"); + for (Player p : f.getPlayers()) { + Broodwar.sendText(" - Player [" + p.getID() + "]: " + p.getName()); + } + } + } + + /// Unit 의 HitPoint 등 추가 정보를 Map 에 표시합니다 + public void drawUnitExtendedInformationOnMap() { + int verticalOffset = -10; + + for (UnitInfo ui : UnitUtils.getEnemyUnitInfoList()) { + + UnitType type = ui.getType(); + int hitPoints = ui.getLastHealth(); + int shields = ui.getLastShields(); + + Position pos = ui.getLastPosition(); + + int left = pos.getX() - type.dimensionLeft(); + int right = pos.getX() + type.dimensionRight(); + int top = pos.getY() - type.dimensionUp(); + int bottom = pos.getY() + type.dimensionDown(); + + // 적 유닛이면 주위에 박스 표시 + if (!Broodwar.isVisible(ui.getLastPosition().toTilePosition())) { + Broodwar.drawBoxMap(new Position(left, top), new Position(right, bottom), Color.Grey, false); + Broodwar.drawTextMap(new Position(left + 3, top + 4), ui.getType().toString()); + } + + // 유닛의 HitPoint 남아있는 비율 표시 + if (!type.isResourceContainer() && type.maxHitPoints() > 0) { + double hpRatio = (double) hitPoints / (double) type.maxHitPoints(); + + Color hpColor = Color.Green; + if (hpRatio < 0.66) hpColor = Color.Orange; + if (hpRatio < 0.33) hpColor = Color.Red; + + int ratioRight = left + (int) ((right - left) * hpRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + + // 유닛의 Shield 남아있는 비율 표시 + if (!type.isResourceContainer() && type.maxShields() > 0) { + double shieldRatio = (double) shields / (double) type.maxShields(); + + int ratioRight = left + (int) ((right - left) * shieldRatio); + int hpTop = top - 3 + verticalOffset; + int hpBottom = top + 1 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + } + + // draw neutral units and our units + for (Unit unit : Broodwar.getAllUnits()) { + if (unit.getPlayer() == PlayerUtils.enemyPlayer()) { + continue; + } + + final Position pos = unit.getPosition(); + + int left = pos.getX() - unit.getType().dimensionLeft(); + int right = pos.getX() + unit.getType().dimensionRight(); + int top = pos.getY() - unit.getType().dimensionUp(); + int bottom = pos.getY() + unit.getType().dimensionDown(); + + //Monster.game.drawBoxMap(BWAPI.Position(left, top), BWAPI.Position(right, bottom), Color.Grey, false); + + // 유닛의 HitPoint 남아있는 비율 표시 + if (!unit.getType().isResourceContainer() && unit.getType().maxHitPoints() > 0) { + double hpRatio = (double) unit.getHitPoints() / (double) unit.getType().maxHitPoints(); + + Color hpColor = Color.Green; + if (hpRatio < 0.66) hpColor = Color.Orange; + if (hpRatio < 0.33) hpColor = Color.Red; + + int ratioRight = left + (int) ((right - left) * hpRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), hpColor.Black, false); - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } + int ticWidth = 3; - // Mineral / Gas 가 얼마나 남아있는가 - if (unit.getType().isResourceContainer() && unit.getInitialResources() > 0) { - double mineralRatio = (double) unit.getResources() / (double) unit.getInitialResources(); + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } - int ratioRight = left + (int) ((right - left) * mineralRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; + // 유닛의 Shield 남아있는 비율 표시 + if (!unit.getType().isResourceContainer() && unit.getType().maxShields() > 0) { + double shieldRatio = (double) unit.getShields() / (double) unit.getType().maxShields(); + + int ratioRight = left + (int) ((right - left) * shieldRatio); + int hpTop = top - 3 + verticalOffset; + int hpBottom = top + 1 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Cyan, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + // Mineral / Gas 가 얼마나 남아있는가 + if (unit.getType().isResourceContainer() && unit.getInitialResources() > 0) { + double mineralRatio = (double) unit.getResources() / (double) unit.getInitialResources(); - int ticWidth = 3; + int ratioRight = left + (int) ((right - left) * mineralRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - } - } + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Cyan, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - /// UnitType 별 통계 정보를 Screen 에 표시합니다 - public void drawUnitStatisticsOnScreen1(int x, int y) { - int currentY = y; - - // 아군이 입은 피해 누적값 - currentY += 10; - - // 아군 모든 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " allUnitCount: " + UnitUtils.getUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 건설/훈련 완료한 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " completedUnitCount: " + UnitUtils.getCompletedUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 건설/훈련중인 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " incompleteUnitCount: " + Broodwar.self().incompleteUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 유닛 파괴/사망 숫자 누적값 - //Broodwar.drawTextScreen(x, currentY, white + " deadUnitCount: " + Broodwar.self().deadUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 상대방 유닛을 파괴/사망 시킨 숫자 누적값 - //Broodwar.drawTextScreen(x, currentY, white + " killedUnitCount: " + Broodwar.self().killedUnitCount(UnitType.AllUnits)); - //currentY += 10; - - //Broodwar.drawTextScreen(x, currentY, white + " UnitScore: " + Broodwar.self().getUnitScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " RazingScore: " + Broodwar.self().getRazingScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " BuildingScore: " + Broodwar.self().getBuildingScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " KillScore: " + Broodwar.self().getKillScore()); - //currentY += 10; - } + int ticWidth = 3; + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + } + } + + /// UnitType 별 통계 정보를 Screen 에 표시합니다 + public void drawUnitStatisticsOnScreen1(int x, int y) { + int currentY = y; + + // 아군이 입은 피해 누적값 + currentY += 10; + + // 아군 모든 유닛 숫자 합계 + //Broodwar.drawTextScreen(x, currentY, white + " allUnitCount: " + UnitUtils.getUnitCount(UnitType.AllUnits)); + //currentY += 10; + + // 아군 건설/훈련 완료한 유닛 숫자 합계 + //Broodwar.drawTextScreen(x, currentY, white + " completedUnitCount: " + UnitUtils.getCompletedUnitCount(UnitType.AllUnits)); + //currentY += 10; + + // 아군 건설/훈련중인 유닛 숫자 합계 + //Broodwar.drawTextScreen(x, currentY, white + " incompleteUnitCount: " + Broodwar.self().incompleteUnitCount(UnitType.AllUnits)); + //currentY += 10; + + // 아군 유닛 파괴/사망 숫자 누적값 + //Broodwar.drawTextScreen(x, currentY, white + " deadUnitCount: " + Broodwar.self().deadUnitCount(UnitType.AllUnits)); + //currentY += 10; + + // 상대방 유닛을 파괴/사망 시킨 숫자 누적값 + //Broodwar.drawTextScreen(x, currentY, white + " killedUnitCount: " + Broodwar.self().killedUnitCount(UnitType.AllUnits)); + //currentY += 10; - /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 - public void drawBWTAResultOnMap() { - /*//we will iterate through all the base locations, and draw their outlines. - // C+ . for (std.set.const_iterator i = BWTA.getBaseLocations().begin(); i != BWTA.getBaseLocations().end(); i++) - for(BaseLocation baseLocation : BWTA.getBaseLocations()) - { - TilePosition p = baseLocation.getTilePosition(); - Position c = baseLocation.getPosition(); + //Broodwar.drawTextScreen(x, currentY, white + " UnitScore: " + Broodwar.self().getUnitScore()); + //currentY += 10; + //Broodwar.drawTextScreen(x, currentY, white + " RazingScore: " + Broodwar.self().getRazingScore()); + //currentY += 10; + //Broodwar.drawTextScreen(x, currentY, white + " BuildingScore: " + Broodwar.self().getBuildingScore()); + //currentY += 10; + //Broodwar.drawTextScreen(x, currentY, white + " KillScore: " + Broodwar.self().getKillScore()); + //currentY += 10; + } - //draw outline of Base location - Broodwar.drawBoxMap(p.getX() * 32, p.getY() * 32, p.getX() * 32 + 4 * 32, p.getY() * 32 + 3 * 32, Color.Blue); - - //draw a circle at each mineral patch - // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) - for(Unit unit : baseLocation.getStaticMinerals()) + + /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 + public void drawBWTAResultOnMap() { + /*//we will iterate through all the base locations, and draw their outlines. + // C+ . for (std.set.const_iterator i = BWTA.getBaseLocations().begin(); i != BWTA.getBaseLocations().end(); i++) + for(BaseLocation baseLocation : BWTA.getBaseLocations()) { - Position q = unit.getInitialPosition(); - Broodwar.drawCircleMap(q.getX(), q.getY(), 30, Color.Cyan); + TilePosition p = baseLocation.getTilePosition(); + Position c = baseLocation.getPosition(); + + //draw outline of Base location + Broodwar.drawBoxMap(p.getX() * 32, p.getY() * 32, p.getX() * 32 + 4 * 32, p.getY() * 32 + 3 * 32, Color.Blue); + + //draw a circle at each mineral patch + // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) + for(Unit unit : baseLocation.getStaticMinerals()) + { + Position q = unit.getInitialPosition(); + Broodwar.drawCircleMap(q.getX(), q.getY(), 30, Color.Cyan); + } + + //draw the outlines of vespene geysers + // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) + for(Unit unit :baseLocation.getGeysers() ) + { + TilePosition q = unit.getInitialTilePosition(); + Broodwar.drawBoxMap(q.getX() * 32, q.getY() * 32, q.getX() * 32 + 4 * 32, q.getY() * 32 + 2 * 32, Color.Orange); + } + + //if this is an island expansion, draw a yellow circle around the base location + if (baseLocation.isIsland()) + { + Broodwar.drawCircleMap(c, 80, Color.Yellow); + } } - //draw the outlines of vespene geysers - // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) - for(Unit unit :baseLocation.getGeysers() ) + //we will iterate through all the regions and draw the polygon outline of it in green. + // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for(Region region : BWTA.getRegions()) { - TilePosition q = unit.getInitialTilePosition(); - Broodwar.drawBoxMap(q.getX() * 32, q.getY() * 32, q.getX() * 32 + 4 * 32, q.getY() * 32 + 2 * 32, Color.Orange); + Polygon p = region.getPolygon(); + for (int j = 0; j.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for(Region region : BWTA.getRegions()) - { - Polygon p = region.getPolygon(); - for (int j = 0; j.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for(Region region : BWTA.getRegions()) { - Position point1 = p.getPoints().get(j); - Position point2 = p.getPoints().get((j + 1) % p.getPoints().size()); - Broodwar.drawLineMap(point1, point2, Color.Green); - } - } - - //we will visualize the chokepoints with red lines - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for(Region region : BWTA.getRegions()) - { - // C++ : for (std.set.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) - for(Chokepoint Chokepoint : region.getChokepoints()) - { - Position point1 = Chokepoint.getSides().first; - Position point2 = Chokepoint.getSides().second; - Broodwar.drawLineMap(point1, point2, Color.Red); - } - }*/ - int blueCount = 0; - int cyanCount = 0; - int orangeCount = 0; -// int purpleCount = 0; - - if (hasSavedBWTAInfo == false) { - for (BaseLocation baseLocation : BWTA.getBaseLocations()) { - blueCount++; -// purpleCount++; - for (Unit unit : baseLocation.getStaticMinerals()) { - cyanCount++; - } - for (Unit unit : baseLocation.getGeysers()) { - orangeCount++; - } - - } - - blue = new int[blueCount][4]; - int blueIndex = 0; - cyan = new int[cyanCount][2]; - int cyanIndex = 0; - orange = new int[orangeCount][4]; - int orangeIndex = 0; - -// purple = new int[purpleCount][4]; -// int purpleIndex = 0; - - for (BaseLocation baseLocation : BWTA.getBaseLocations()) { - TilePosition p = baseLocation.getTilePosition(); - Position c = baseLocation.getPosition(); - - blue[blueIndex][0] = p.getX() * 32; - blue[blueIndex][1] = p.getY() * 32; - blue[blueIndex][2] = p.getX() * 32 + 4 * 32; - blue[blueIndex][3] = p.getY() * 32 + 3 * 32; - blueIndex++; - -// purple[purpleIndex][0] = (p.getX()+4) * 32; -// purple[purpleIndex][1] = (p.getY()+1) * 32; -// purple[purpleIndex][2] = (p.getX()+4) * 32 + 2 * 32; -// purple[purpleIndex][3] = (p.getY()+1) * 32 + 2 * 32; -// purpleIndex++; - - //draw a circle at each mineral patch - // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) - for (Unit unit : baseLocation.getStaticMinerals()) { - Position q = unit.getInitialPosition(); - cyan[cyanIndex][0] = q.getX(); - cyan[cyanIndex][1] = q.getY(); - cyanIndex++; - } - - //draw the outlines of vespene geysers - // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) - for (Unit unit : baseLocation.getGeysers()) { - TilePosition q = unit.getInitialTilePosition(); - orange[orangeIndex][0] = q.getX() * 32; - orange[orangeIndex][1] = q.getY() * 32; - orange[orangeIndex][2] = q.getX() * 32 + 4 * 32; - orange[orangeIndex][3] = q.getY() * 32 + 2 * 32; - orangeIndex++; - } - - //if this is an island expansion, draw a yellow circle around the base location - if (baseLocation.isIsland()) { - yellow.add(c); - } - } - - //we will iterate through all the regions and draw the polygon outline of it in green. - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for (Region region : BWTA.getRegions()) { - Polygon p = region.getPolygon(); - for (int j = 0; j < p.getPoints().size(); j++) { - green1.add(p.getPoints().get(j)); - green2.add(p.getPoints().get((j + 1) % p.getPoints().size())); - } - } - - //we will visualize the chokepoints with red lines - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for (Region region : BWTA.getRegions()) { - // C++ : for (std.set.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) - for (Chokepoint Chokepoint : region.getChokepoints()) { - red1.add(Chokepoint.getSides().first); - red2.add(Chokepoint.getSides().second); - } - } - hasSavedBWTAInfo = true; - -// System.out.println(blueCount + " " + cyanCount + " " + orangeCount + " " + yellowCount + " " + greenCount + " " + redCount); - } - - if (hasSavedBWTAInfo) { - for (int i1 = 0; i1 < blue.length; i1++) { - Broodwar.drawBoxMap(blue[i1][0], blue[i1][1], blue[i1][2], blue[i1][3], Color.Blue); - } -// for(int i1=0 ; i1.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) + for(Chokepoint Chokepoint : region.getChokepoints()) + { + Position point1 = Chokepoint.getSides().first; + Position point2 = Chokepoint.getSides().second; + Broodwar.drawLineMap(point1, point2, Color.Red); + } + }*/ + int blueCount = 0; + int cyanCount = 0; + int orangeCount = 0; +// int purpleCount = 0; + + if (hasSavedBWTAInfo == false) { + for (BaseLocation baseLocation : BWTA.getBaseLocations()) { + blueCount++; +// purpleCount++; + for (Unit unit : baseLocation.getStaticMinerals()) { + cyanCount++; + } + for (Unit unit : baseLocation.getGeysers()) { + orangeCount++; + } + + } + + blue = new int[blueCount][4]; + int blueIndex = 0; + cyan = new int[cyanCount][2]; + int cyanIndex = 0; + orange = new int[orangeCount][4]; + int orangeIndex = 0; + +// purple = new int[purpleCount][4]; +// int purpleIndex = 0; + + for (BaseLocation baseLocation : BWTA.getBaseLocations()) { + TilePosition p = baseLocation.getTilePosition(); + Position c = baseLocation.getPosition(); + + blue[blueIndex][0] = p.getX() * 32; + blue[blueIndex][1] = p.getY() * 32; + blue[blueIndex][2] = p.getX() * 32 + 4 * 32; + blue[blueIndex][3] = p.getY() * 32 + 3 * 32; + blueIndex++; + +// purple[purpleIndex][0] = (p.getX()+4) * 32; +// purple[purpleIndex][1] = (p.getY()+1) * 32; +// purple[purpleIndex][2] = (p.getX()+4) * 32 + 2 * 32; +// purple[purpleIndex][3] = (p.getY()+1) * 32 + 2 * 32; +// purpleIndex++; + + //draw a circle at each mineral patch + // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) + for (Unit unit : baseLocation.getStaticMinerals()) { + Position q = unit.getInitialPosition(); + cyan[cyanIndex][0] = q.getX(); + cyan[cyanIndex][1] = q.getY(); + cyanIndex++; + } + + //draw the outlines of vespene geysers + // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) + for (Unit unit : baseLocation.getGeysers()) { + TilePosition q = unit.getInitialTilePosition(); + orange[orangeIndex][0] = q.getX() * 32; + orange[orangeIndex][1] = q.getY() * 32; + orange[orangeIndex][2] = q.getX() * 32 + 4 * 32; + orange[orangeIndex][3] = q.getY() * 32 + 2 * 32; + orangeIndex++; + } + + //if this is an island expansion, draw a yellow circle around the base location + if (baseLocation.isIsland()) { + yellow.add(c); + } + } + + //we will iterate through all the regions and draw the polygon outline of it in green. + // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for (Region region : BWTA.getRegions()) { + Polygon p = region.getPolygon(); + for (int j = 0; j < p.getPoints().size(); j++) { + green1.add(p.getPoints().get(j)); + green2.add(p.getPoints().get((j + 1) % p.getPoints().size())); + } + } + + //we will visualize the chokepoints with red lines + // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for (Region region : BWTA.getRegions()) { + // C++ : for (std.set.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) + for (Chokepoint Chokepoint : region.getChokepoints()) { + red1.add(Chokepoint.getSides().first); + red2.add(Chokepoint.getSides().second); + } + } + hasSavedBWTAInfo = true; + +// System.out.println(blueCount + " " + cyanCount + " " + orangeCount + " " + yellowCount + " " + greenCount + " " + redCount); + } + + if (hasSavedBWTAInfo) { + for (int i1 = 0; i1 < blue.length; i1++) { + Broodwar.drawBoxMap(blue[i1][0], blue[i1][1], blue[i1][2], blue[i1][3], Color.Blue); + } +// for(int i1=0 ; i1 buildQueue = BuildManager.Instance().buildQueue.getQueue(); + int itemCount = 0; + + Object[] tempQueue = buildQueue.toArray(); + + for (int i = 0; i < tempQueue.length; i++) { + BuildOrderItem currentItem = (BuildOrderItem) tempQueue[i]; + //Broodwar.drawTextScreen(x, y + 10 + (itemCount * 10), currentItem.blocking + " " + UxColor.CHAR_WHITE + currentItem.metaType.getName()); + UxDrawConfig uxDrawConfig; + uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",currentItem.blocking + " " + currentItem.metaType.getName(),UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + itemCount++; + if (itemCount >= 24) break; + } + } + + /// Build 진행 상태를 Screen 에 표시합니다 + public void drawBuildStatusOnScreen(int x, int y) { + // 건설 / 훈련 중인 유닛 진행상황 표시 + Vector unitsUnderConstruction = new Vector(); + for (Unit unit : Broodwar.self().getUnits()) { + if (unit != null && unit.isBeingConstructed()) { + unitsUnderConstruction.add(unit); + } + } + + // sort it based on the time it was started + Object[] tempArr = unitsUnderConstruction.toArray(); + //Arrays.sort(tempArr); + unitsUnderConstruction = new Vector(); + for (int i = 0; i < tempArr.length; i++) { + unitsUnderConstruction.add((Unit) tempArr[i]); + } + // C++ : std.sort(unitsUnderConstruction.begin(), unitsUnderConstruction.end(), CompareWhenStarted()); + + //Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + " "); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R",""," ",UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + + int reps = unitsUnderConstruction.size() < 10 ? unitsUnderConstruction.size() : 10; + + for (Unit unit : unitsUnderConstruction) { + y += 10; + UnitType t = unit.getType(); + if (t == UnitType.Zerg_Egg) { + t = unit.getBuildType(); + } + //Broodwar.drawTextScreen(x, y, "" + UxColor.CHAR_WHITE + t + " (" + unit.getRemainingBuildTime() + ")"); + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","" + t + " (" + unit.getRemainingBuildTime() + ")",UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + } + + // Tech Research 표시 + + // Upgrade 표시 + } + + /// Construction 을 하기 위해 예약해둔 Tile 들을 Map 에 표시합니다 + public void drawReservedBuildingTilesOnMap() { + boolean[][] reserveMap = ConstructionPlaceFinder.Instance().getReserveMap(); + if (reserveMap.length > 0 && reserveMap[0] != null && reserveMap[0].length > 0) { + int rwidth = reserveMap.length; + int rheight = reserveMap[0].length; + + for (int x = 0; x < rwidth; ++x) { + for (int y = 0; y < rheight; ++y) { + if (reserveMap[x][y]) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Yellow, false); + } + } + } + } + } + + /// Construction 을 하지 못하는 Tile 들을 Map 에 표시합니다 + public void drawTilesToAvoidOnMap() { + int y = 0; + int x = 0; + + for (y = 0; y < 128; y++) { + for (x = 0; x < 128; x++) { + if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); + } + if (ConstructionPlaceFinder.Instance().getTilesToAvoidAbsolute(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Purple, false); + } + if (ConstructionPlaceFinder.Instance().getTilesToAvoidSupply(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); + } + } + } + } + + /// ConstructionQueue 를 Screen 에 표시합니다 + public void drawConstructionQueueOnScreenAndMap() { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("M",""," ",UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + + int yspace = 0; + + Vector constructionQueue = ConstructionManager.Instance().getConstructionQueue(); + + for (final ConstructionTask b : constructionQueue) { + String constructionState = ""; + + if (b.getStatus() == ConstructionTask.ConstructionStatus.Unassigned.ordinal()) { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","","" + b.getType() + " - No Worker",UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } else if (b.getStatus() == ConstructionTask.ConstructionStatus.Assigned.ordinal()) { + if (b.getConstructionWorker() == null) { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",b.getType() + " - Assigned Worker Null",UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } else { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")",UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } + + int x1 = b.getFinalPosition().getX() * 32; + int y1 = b.getFinalPosition().getY() * 32; + int x2 = (b.getFinalPosition().getX() + b.getType().tileWidth()) * 32; + int y2 = (b.getFinalPosition().getY() + b.getType().tileHeight()) * 32; + + Broodwar.drawLineMap(b.getConstructionWorker().getPosition().getX(), b.getConstructionWorker().getPosition().getY(), (x1 + x2) / 2, (y1 + y2) / 2, Color.Orange); + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); + } else if (b.getStatus() == ConstructionTask.ConstructionStatus.UnderConstruction.ordinal()) { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","","" + b.getType() + " - Under Construction",UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } + yspace++; + } + } + + public void drawnextPoints() { + +// Position nextEX = InformationManager.Instance().getNextExpansionLocation().getPosition(); +// Position nextBuild = InformationManager.Instance().getLastBuildingLocation().toPosition(); +// Position lastBuild2 = InformationManager.Instance().getLastBuildingLocation2().toPosition(); + +// BaseLocation getExpansionLocation = InformationManager.Instance().getExpansionLocation; +// BaseLocation secondStartPosition = null;//InformationManager.Instance().getSecondStartPosition(); +// TilePosition getLastBuildingLocation = InformationManager.Instance().getLastBuildingLocation; +// TilePosition getLastBuildingFinalLocation = InformationManager.Instance().getLastBuildingFinalLocation; + // + // +// if (secondStartPosition != null) { +// Broodwar.drawTextScreen(10, 120, "secondStartPosition: " + secondStartPosition.getTilePosition()); +// Broodwar.drawTextMap(secondStartPosition.getPosition(), "secondStartPosition"); +// } else { +// Broodwar.drawTextScreen(10, 120, "secondStartPosition: null"); +// } +// if (getExpansionLocation != null) { +// Broodwar.drawTextScreen(10, 130, "getExpansionLocation: " + getExpansionLocation.getTilePosition()); +// Broodwar.drawTextMap(getExpansionLocation.getPosition(), "nextEX"); +// } else { +// Broodwar.drawTextScreen(10, 130, "getExpansionLocation: null"); +// } +// if (getLastBuildingLocation != null) { +// Broodwar.drawTextScreen(10, 140, "getLastBuildingLocation: " + getLastBuildingLocation); +// Broodwar.drawTextMap(getLastBuildingLocation.toPosition(), "nextBuild"); +// } else { +// Broodwar.drawTextScreen(10, 140, "getLastBuildingLocation: null"); +// } +// if (getLastBuildingFinalLocation != null) { +// Broodwar.drawTextScreen(10, 150, "getLastBuildingFinalLocation: " + getLastBuildingFinalLocation); +// Broodwar.drawTextMap(getLastBuildingFinalLocation.toPosition(), "LastBuild"); +// } else { +// Broodwar.drawTextScreen(10, 150, "getLastBuildingFinalLocation: null"); +// } + // + // +// Broodwar.drawTextScreen(10, 160, "mainBaseLocationFull: " + BuildManager.Instance().mainBaseLocationFull); +// Broodwar.drawTextScreen(10, 170, "secondChokePointFull: " + BuildManager.Instance().secondChokePointFull); +// Broodwar.drawTextScreen(10, 180, "secondStartLocationFull: " + BuildManager.Instance().secondStartLocationFull); +// Broodwar.drawTextScreen(10, 190, "fisrtSupplePointFull: " + BuildManager.Instance().fisrtSupplePointFull); + // +// Broodwar.drawTextScreen(10, 200, "myMainbaseLocation : " + BaseUtils.myMainBase().getTilePosition()); +// Broodwar.drawTextScreen(10, 210, "enemyMainbaseLocation : " + BaseUtils.enemyMainBase().getTilePosition()); + + } + + + public void drawMineralIdOnMap() { + for (Unit unit : Broodwar.getStaticMinerals()) { + + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); + } + } + + /// Unit 의 Id 를 Map 에 표시합니다 + public void drawUnitIdOnMap() { + for (Unit unit : Broodwar.self().getUnits()) { + if (unit.getType().isBuilding()) { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 25, "" + UxColor.CHAR_WHITE + unit.getTilePosition().getX() + " / " + unit.getTilePosition().getY()); + } else { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); + } + + } + for (Unit unit : Broodwar.enemy().getUnits()) { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); + } + } + + public void drawLeaderUnitOnMap() { + +// +// if(leader!=null){ +// for (Unit unit : Broodwar.self().getUnits()) +// { +// if(unit.getID() == leader.getID()) +// Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + blue + "LEADER"); +// } // } - for (int i2 = 0; i2 < cyan.length; i2++) { - Broodwar.drawCircleMap(cyan[i2][0], cyan[i2][1], 30, Color.Cyan); - } - for (int i3 = 0; i3 < orange.length; i3++) { - Broodwar.drawBoxMap(orange[i3][0], orange[i3][1], orange[i3][2], orange[i3][3], Color.Orange); - } - for (int i4 = 0; i4 < yellow.size(); i4++) { - Broodwar.drawCircleMap(yellow.get(i4), 80, Color.Yellow); - } - for (int i5 = 0; i5 < green1.size(); i5++) { - Broodwar.drawLineMap(green1.get(i5), green2.get(i5), Color.Green); - } - for (int i6 = 0; i6 < red1.size(); i6++) { - Broodwar.drawLineMap(red1.get(i6), red2.get(i6), Color.Red); - } - } - - // ChokePoint, BaseLocation 을 텍스트로 표시 - if (ChokeUtils.myFirstChoke() != null) { - Broodwar.drawTextMap(BaseUtils.myMainBase().getPosition(), "My MainBaseLocation"); - } - if (ChokeUtils.myFirstChoke() != null) { - Broodwar.drawTextMap(ChokeUtils.myFirstChoke().getCenter(), "My First ChokePoint"); - } - if (ChokeUtils.mySecondChoke() != null) { - Broodwar.drawTextMap(ChokeUtils.mySecondChoke().getCenter(), "My Second ChokePoint"); - } - if (BaseUtils.myFirstExpansion() != null) { - Broodwar.drawTextMap(BaseUtils.myFirstExpansion().getPosition(), "My First ExpansionLocation"); - } - -// if (UnitTypeUtils.enemyFirstChoke().getFirstChokePoint(PlayerUtils.enemyPlayer()) != null) { -// Broodwar.drawTextMap(BaseUtils.enemyMainBase().getPosition(), "Enemy MainBaseLocation"); -// } -// if (UnitTypeUtils.getFirstChokePoint(PlayerUtils.enemyPlayer()) != null) { -// Broodwar.drawTextMap(InformationManager.Instance().getFirstChokePoint(PlayerUtils.enemyPlayer()).getCenter(), "Enemy First ChokePoint"); -// } - if (ChokeUtils.enemySecondChoke() != null) { - Broodwar.drawTextMap(ChokeUtils.enemySecondChoke().getCenter(), "Enemy Second ChokePoint"); - } - if (BaseUtils.enemyFirstExpansion() != null) { - Broodwar.drawTextMap(BaseUtils.enemyFirstExpansion().getPosition(), "Enemy First ExpansionLocation"); - } - } - - /// Tile Position 그리드를 Map 에 표시합니다 - public void drawMapGrid() { - int cellSize = MapGrid.Instance().getCellSize(); - int mapWidth = MapGrid.Instance().getMapWidth(); - int mapHeight = MapGrid.Instance().getMapHeight(); - int rows = MapGrid.Instance().getRows(); - int cols = MapGrid.Instance().getCols(); - - for (int i = 0; i < cols; i++) { - Broodwar.drawLineMap(i * cellSize, 0, i * cellSize, mapHeight, Color.Blue); - } - - for (int j = 0; j < rows; j++) { - Broodwar.drawLineMap(0, j * cellSize, mapWidth, j * cellSize, Color.Blue); - } - - for (int r = 0; r < rows; r += 2) { - for (int c = 0; c < cols; c += 2) { - Broodwar.drawTextMap(c * 32, r * 32, c + "," + r); - } - } - } - - /// BuildOrderQueue 를 Screen 에 표시합니다 - public void drawBuildOrderQueueOnScreen(int x, int y) { - char initialFinishedColor; - - Deque buildQueue = BuildManager.Instance().buildQueue.getQueue(); - int itemCount = 0; - - Object[] tempQueue = buildQueue.toArray(); - - for (int i = 0; i < tempQueue.length; i++) { - BuildOrderItem currentItem = (BuildOrderItem) tempQueue[i]; - Broodwar.drawTextScreen(x, y + 10 + (itemCount * 10), currentItem.blocking + " " + UxColor.CHAR_WHITE + currentItem.metaType.getName()); - itemCount++; - if (itemCount >= 24) break; - } - } - - /// Build 진행 상태를 Screen 에 표시합니다 - public void drawBuildStatusOnScreen(int x, int y) { - // 건설 / 훈련 중인 유닛 진행상황 표시 - Vector unitsUnderConstruction = new Vector(); - for (Unit unit : Broodwar.self().getUnits()) { - if (unit != null && unit.isBeingConstructed()) { - unitsUnderConstruction.add(unit); - } - } - - // sort it based on the time it was started - Object[] tempArr = unitsUnderConstruction.toArray(); - //Arrays.sort(tempArr); - unitsUnderConstruction = new Vector(); - for (int i = 0; i < tempArr.length; i++) { - unitsUnderConstruction.add((Unit) tempArr[i]); - } - // C++ : std.sort(unitsUnderConstruction.begin(), unitsUnderConstruction.end(), CompareWhenStarted()); - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + " "); - - int reps = unitsUnderConstruction.size() < 10 ? unitsUnderConstruction.size() : 10; - - for (Unit unit : unitsUnderConstruction) { - y += 10; - UnitType t = unit.getType(); - if (t == UnitType.Zerg_Egg) { - t = unit.getBuildType(); - } - - Broodwar.drawTextScreen(x, y, "" + UxColor.CHAR_WHITE + t + " (" + unit.getRemainingBuildTime() + ")"); - } - - // Tech Research 표시 - - // Upgrade 표시 - } - - /// Construction 을 하기 위해 예약해둔 Tile 들을 Map 에 표시합니다 - public void drawReservedBuildingTilesOnMap() { - boolean[][] reserveMap = ConstructionPlaceFinder.Instance().getReserveMap(); - if (reserveMap.length > 0 && reserveMap[0] != null && reserveMap[0].length > 0) { - int rwidth = reserveMap.length; - int rheight = reserveMap[0].length; - - for (int x = 0; x < rwidth; ++x) { - for (int y = 0; y < rheight; ++y) { - if (reserveMap[x][y]) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Yellow, false); - } - } - } - } - } - - /// Construction 을 하지 못하는 Tile 들을 Map 에 표시합니다 - public void drawTilesToAvoidOnMap() { - int y = 0; - int x = 0; - - for (y = 0; y < 128; y++) { - for (x = 0; x < 128; x++) { - if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); - } - if (ConstructionPlaceFinder.Instance().getTilesToAvoidAbsolute(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Purple, false); - } - if (ConstructionPlaceFinder.Instance().getTilesToAvoidSupply(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); - } - } - } - } - - /// ConstructionQueue 를 Screen 에 표시합니다 - public void drawConstructionQueueOnScreenAndMap(int x, int y) { - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + " "); - - int yspace = 0; - - Vector constructionQueue = ConstructionManager.Instance().getConstructionQueue(); - - for (final ConstructionTask b : constructionQueue) { - String constructionState = ""; - - if (b.getStatus() == ConstructionTask.ConstructionStatus.Unassigned.ordinal()) { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), "" + UxColor.CHAR_WHITE + b.getType() + " - No Worker"); - } else if (b.getStatus() == ConstructionTask.ConstructionStatus.Assigned.ordinal()) { - if (b.getConstructionWorker() == null) { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), b.getType() + " - Assigned Worker Null"); - } else { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")"); - } - - int x1 = b.getFinalPosition().getX() * 32; - int y1 = b.getFinalPosition().getY() * 32; - int x2 = (b.getFinalPosition().getX() + b.getType().tileWidth()) * 32; - int y2 = (b.getFinalPosition().getY() + b.getType().tileHeight()) * 32; - - Broodwar.drawLineMap(b.getConstructionWorker().getPosition().getX(), b.getConstructionWorker().getPosition().getY(), (x1 + x2) / 2, (y1 + y2) / 2, Color.Orange); - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); - } else if (b.getStatus() == ConstructionTask.ConstructionStatus.UnderConstruction.ordinal()) { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), "" + UxColor.CHAR_WHITE + b.getType() + " - Under Construction"); - } - yspace++; - } - } - - public void drawnextPoints() { - -// Position nextEX = InformationManager.Instance().getNextExpansionLocation().getPosition(); -// Position nextBuild = InformationManager.Instance().getLastBuildingLocation().toPosition(); -// Position lastBuild2 = InformationManager.Instance().getLastBuildingLocation2().toPosition(); - -// BaseLocation getExpansionLocation = InformationManager.Instance().getExpansionLocation; -// BaseLocation secondStartPosition = null;//InformationManager.Instance().getSecondStartPosition(); -// TilePosition getLastBuildingLocation = InformationManager.Instance().getLastBuildingLocation; -// TilePosition getLastBuildingFinalLocation = InformationManager.Instance().getLastBuildingFinalLocation; -// -// -// if (secondStartPosition != null) { -// Broodwar.drawTextScreen(10, 120, "secondStartPosition: " + secondStartPosition.getTilePosition()); -// Broodwar.drawTextMap(secondStartPosition.getPosition(), "secondStartPosition"); -// } else { -// Broodwar.drawTextScreen(10, 120, "secondStartPosition: null"); -// } -// if (getExpansionLocation != null) { -// Broodwar.drawTextScreen(10, 130, "getExpansionLocation: " + getExpansionLocation.getTilePosition()); -// Broodwar.drawTextMap(getExpansionLocation.getPosition(), "nextEX"); -// } else { -// Broodwar.drawTextScreen(10, 130, "getExpansionLocation: null"); -// } -// if (getLastBuildingLocation != null) { -// Broodwar.drawTextScreen(10, 140, "getLastBuildingLocation: " + getLastBuildingLocation); -// Broodwar.drawTextMap(getLastBuildingLocation.toPosition(), "nextBuild"); -// } else { -// Broodwar.drawTextScreen(10, 140, "getLastBuildingLocation: null"); -// } -// if (getLastBuildingFinalLocation != null) { -// Broodwar.drawTextScreen(10, 150, "getLastBuildingFinalLocation: " + getLastBuildingFinalLocation); -// Broodwar.drawTextMap(getLastBuildingFinalLocation.toPosition(), "LastBuild"); -// } else { -// Broodwar.drawTextScreen(10, 150, "getLastBuildingFinalLocation: null"); -// } -// -// -// Broodwar.drawTextScreen(10, 160, "mainBaseLocationFull: " + BuildManager.Instance().mainBaseLocationFull); -// Broodwar.drawTextScreen(10, 170, "secondChokePointFull: " + BuildManager.Instance().secondChokePointFull); -// Broodwar.drawTextScreen(10, 180, "secondStartLocationFull: " + BuildManager.Instance().secondStartLocationFull); -// Broodwar.drawTextScreen(10, 190, "fisrtSupplePointFull: " + BuildManager.Instance().fisrtSupplePointFull); -// -// Broodwar.drawTextScreen(10, 200, "myMainbaseLocation : " + BaseUtils.myMainBase().getTilePosition()); -// Broodwar.drawTextScreen(10, 210, "enemyMainbaseLocation : " + BaseUtils.enemyMainBase().getTilePosition()); - - } - - - public void drawMineralIdOnMap() { - for (Unit unit : Broodwar.getStaticMinerals()) { - - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - } - } - - /// Unit 의 Id 를 Map 에 표시합니다 - public void drawUnitIdOnMap() { - for (Unit unit : Broodwar.self().getUnits()) { - if (unit.getType().isBuilding()) { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 25, "" + UxColor.CHAR_WHITE + unit.getTilePosition().getX() + " / " + unit.getTilePosition().getY()); - } else { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - } - - } - for (Unit unit : Broodwar.enemy().getUnits()) { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - } - } - - public void drawLeaderUnitOnMap() { - -// -// if(leader!=null){ -// for (Unit unit : Broodwar.self().getUnits()) -// { -// if(unit.getID() == leader.getID()) -// Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + blue + "LEADER"); + } + + /// Worker Unit 들의 상태를 Screen 에 표시합니다 + public void drawWorkerStateOnScreen(int x, int y) { + WorkerData workerData = WorkerManager.Instance().getWorkerData(); + + Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + ""); + + int yspace = 0; + + for (Unit unit : workerData.getWorkers()) { + if (unit == null) continue; + + // Mineral / Gas / Idle Worker 는 표시 안한다 + if (workerData.getJobCode(unit) == 'M' || workerData.getJobCode(unit) == 'I' || workerData.getJobCode(unit) == 'G') { + continue; + } + + Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), UxColor.CHAR_WHITE + " " + unit.getID()); + + if (workerData.getJobCode(unit) == 'B') { + Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), UxColor.CHAR_WHITE + " " + workerData.getJobCode(unit) + " " + unit.getBuildType() + " " + (unit.isConstructing() ? 'Y' : 'N') + " (" + unit.getTilePosition().getX() + ", " + unit.getTilePosition().getY() + ")"); + } else { + Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), UxColor.CHAR_WHITE + " " + workerData.getJobCode(unit)); + } + } + } + + /// ResourceDepot 별 Worker 숫자를 Map 에 표시합니다 + public void drawWorkerCountOnMap() { + for (Unit depot : WorkerManager.Instance().getWorkerData().getDepots()) { + if (depot == null) continue; + + int x = depot.getPosition().getX() - 64; + int y = depot.getPosition().getY() - 32; + + Broodwar.drawBoxMap(x - 2, y - 1, x + 75, y + 14, Color.Black, true); + Broodwar.drawTextMap(x, y, UxColor.CHAR_WHITE + " Workers: " + WorkerManager.Instance().getWorkerData().getNumAssignedWorkers(depot)); + } + } + + /// Worker Unit 의 자원채취 현황을 Map 에 표시합니다 + public void drawWorkerMiningStatusOnMap() { + WorkerData workerData = WorkerManager.Instance().getWorkerData(); + + for (Unit worker : workerData.getWorkers()) { + if (worker == null) continue; + + Position pos = worker.getTargetPosition(); + + Broodwar.drawTextMap(worker.getPosition().getX(), worker.getPosition().getY() - 5, "" + UxColor.CHAR_WHITE + workerData.getJobCode(worker)); + + Broodwar.drawLineMap(worker.getPosition().getX(), worker.getPosition().getY(), pos.getX(), pos.getY(), Color.Cyan); + + /* + // ResourceDepot ~ Worker 사이에 직선 표시 + BWAPI.Unit depot = workerData.getWorkerDepot(worker); + if (depot) { + Monster.game.drawLineMap(worker.getPosition().x, worker.getPosition().y, depot.getPosition().x, depot.getPosition().y, Color.Orange); + } + */ + } + } + + /// 정찰 상태를 Screen 에 표시합니다 + public void drawScoutInformation(int x, int y) { + + // get the enemy base location, if we have one + BaseLocation enemyBaseLocation = BaseUtils.enemyMainBase(); + + if (enemyBaseLocation != null) { + Broodwar.drawTextScreen(x, y, "Enemy MainBaseLocation : (" + enemyBaseLocation.getTilePosition().getX() + ", " + enemyBaseLocation.getTilePosition().getY() + ")"); + } else { + Broodwar.drawTextScreen(x, y, "Enemy MainBaseLocation : Unknown"); + } + } + + /// Unit 의 Target 으로 잇는 선을 Map 에 표시합니다 + public void drawUnitTargetOnMap() { + for (Unit unit : Broodwar.self().getUnits()) { + if (unit != null && unit.isCompleted() && !unit.getType().isBuilding() && !unit.getType().isWorker()) { + Unit targetUnit = unit.getTarget(); + if (targetUnit != null && targetUnit.getPlayer() != Broodwar.self()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Red, true); + Broodwar.drawCircleMap(targetUnit.getTargetPosition(), dotRadius, Color.Red, true); + Broodwar.drawLineMap(unit.getPosition(), targetUnit.getTargetPosition(), Color.Red); + } else if (unit.isMoving()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); + Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); + Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); + } + + } + } + } + + /// Bullet 을 Map 에 표시합니다
+ /// Cloaking Unit 의 Bullet 표시에 쓰입니다 + public void drawBulletsOnMap() { + for (Bullet b : Broodwar.getBullets()) { + Position p = b.getPosition(); + double velocityX = b.getVelocityX(); + double velocityY = b.getVelocityY(); + + if (b.getType() == BulletType.Acid_Spore) bulletTypeName = "Acid_Spore"; + else if (b.getType() == BulletType.Anti_Matter_Missile) bulletTypeName = "Anti_Matter_Missile"; + else if (b.getType() == BulletType.Arclite_Shock_Cannon_Hit) bulletTypeName = "Arclite_Shock_Cannon_Hit"; + else if (b.getType() == BulletType.ATS_ATA_Laser_Battery) bulletTypeName = "ATS_ATA_Laser_Battery"; + else if (b.getType() == BulletType.Burst_Lasers) bulletTypeName = "Burst_Lasers"; + else if (b.getType() == BulletType.C_10_Canister_Rifle_Hit) bulletTypeName = "C_10_Canister_Rifle_Hit"; + else if (b.getType() == BulletType.Consume) bulletTypeName = "Consume"; + else if (b.getType() == BulletType.Corrosive_Acid_Shot) bulletTypeName = "Corrosive_Acid_Shot"; + else if (b.getType() == BulletType.Dual_Photon_Blasters_Hit) bulletTypeName = "Dual_Photon_Blasters_Hit"; + else if (b.getType() == BulletType.EMP_Missile) bulletTypeName = "EMP_Missile"; + else if (b.getType() == BulletType.Ensnare) bulletTypeName = "Ensnare"; + else if (b.getType() == BulletType.Fragmentation_Grenade) bulletTypeName = "Fragmentation_Grenade"; + else if (b.getType() == BulletType.Fusion_Cutter_Hit) bulletTypeName = "Fusion_Cutter_Hit"; + else if (b.getType() == BulletType.Gauss_Rifle_Hit) bulletTypeName = "Gauss_Rifle_Hit"; + else if (b.getType() == BulletType.Gemini_Missiles) bulletTypeName = "Gemini_Missiles"; + else if (b.getType() == BulletType.Glave_Wurm) bulletTypeName = "Glave_Wurm"; + else if (b.getType() == BulletType.Halo_Rockets) bulletTypeName = "Halo_Rockets"; + else if (b.getType() == BulletType.Invisible) bulletTypeName = "Invisible"; + else if (b.getType() == BulletType.Longbolt_Missile) bulletTypeName = "Longbolt_Missile"; + else if (b.getType() == BulletType.Melee) bulletTypeName = "Melee"; + else if (b.getType() == BulletType.Needle_Spine_Hit) bulletTypeName = "Needle_Spine_Hit"; + else if (b.getType() == BulletType.Neutron_Flare) bulletTypeName = "Neutron_Flare"; + else if (b.getType() == BulletType.None) bulletTypeName = "None"; + else if (b.getType() == BulletType.Optical_Flare_Grenade) bulletTypeName = "Optical_Flare_Grenade"; + else if (b.getType() == BulletType.Particle_Beam_Hit) bulletTypeName = "Particle_Beam_Hit"; + else if (b.getType() == BulletType.Phase_Disruptor) bulletTypeName = "Phase_Disruptor"; + else if (b.getType() == BulletType.Plague_Cloud) bulletTypeName = "Plague_Cloud"; + else if (b.getType() == BulletType.Psionic_Shockwave_Hit) bulletTypeName = "Psionic_Shockwave_Hit"; + else if (b.getType() == BulletType.Psionic_Storm) bulletTypeName = "Psionic_Storm"; + else if (b.getType() == BulletType.Pulse_Cannon) bulletTypeName = "Pulse_Cannon"; + else if (b.getType() == BulletType.Queen_Spell_Carrier) bulletTypeName = "Queen_Spell_Carrier"; + else if (b.getType() == BulletType.Seeker_Spores) bulletTypeName = "Seeker_Spores"; + else if (b.getType() == BulletType.STA_STS_Cannon_Overlay) bulletTypeName = "STA_STS_Cannon_Overlay"; + else if (b.getType() == BulletType.Subterranean_Spines) bulletTypeName = "Subterranean_Spines"; + else if (b.getType() == BulletType.Sunken_Colony_Tentacle) bulletTypeName = "Sunken_Colony_Tentacle"; + else if (b.getType() == BulletType.Unknown) bulletTypeName = "Unknown"; + else if (b.getType() == BulletType.Yamato_Gun) bulletTypeName = "Yamato_Gun"; + + // 아군 것이면 녹색, 적군 것이면 빨간색 + Broodwar.drawLineMap(p, new Position(p.getX() + (int) velocityX, p.getY() + (int) velocityY), b.getPlayer() == Broodwar.self() ? Color.Green : Color.Red); + if (b.getType() != null) { + Broodwar.drawTextMap(p, (b.getPlayer() == Broodwar.self() ? "" + UxColor.CHAR_TEAL : "" + UxColor.CHAR_RED) + bulletTypeName); + } + } + } + + private void drawSquadUnitTagMap() { + // draw neutral units and our units + for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { + Color color = UxColor.SQUAD_COLOR.get(squad.getClass()); + if (color == null) { + continue; + } + String squadName = squad.getSquadName(); + + StrategyCode.SmallFightPredict smallFightPredict = null; + if (squad instanceof WatcherSquad) { + smallFightPredict = ((WatcherSquad) squad).getSmallFightPredict(); + } + + if (squadName.length() > 4) { + squadName = squadName.substring(0, 4); + } + + for (Unit unit : squad.unitList) { + Broodwar.drawCircleMap(unit.getPosition(), 10, color); + Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 30, squadName); + if (smallFightPredict != null && smallFightPredict == StrategyCode.SmallFightPredict.BACK) { + Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 15, UxColor.CHAR_RED + smallFightPredict.toString()); + } + } + +// Map checkerSiteMap = VultureTravelManager.Instance().getCheckerSiteMap2(); +// List baseList = VultureTravelManager.Instance().getBaseLocationsCheckerOrdered(); +// for (Integer checkerId : checkerSiteMap.keySet()) { +// Unit unit = Broodwar.getUnit(checkerId); +// if (UnitUtils.isValidUnit(unit)) { +// Integer index = checkerSiteMap.get(checkerId); +// if (index != null) { +// Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 5, UxColor.CHAR_ORANGE + baseList.get(index).getPosition().toString()); +// } + // +// } +// } + } + } + + private void drawSquadInfoOnMap() { + /// ConstructionQueue 를 Screen 에 표시합니다 + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L",""," ",UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","" + "*" + "SCV"," "+ UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_SCV),UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { + Color squadColor = UxColor.SQUAD_COLOR.get(squad.getClass()); + String squadName = ""; + if (squadColor != null) { + squadName = "" + UxColor.COLOR_TO_CHARACTER.get(squadColor) + squad.getSquadName(); + } else { + squadName = "*" + squad.getSquadName(); + } + String unitIds = " ... "; + for (Unit unit : squad.unitList) { + unitIds = unitIds + unit.getID() + "/"; + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L",squadName," "+ "" + squad.unitList.size() + unitIds,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } + } + + private void drawManagerTimeSpent() { + List gameManagers = Arrays.asList( + //InformationManager.Instance(), + StrategyManager.Instance(), + MapGrid.Instance(), + BuildManager.Instance(), + BuildQueueProvider.Instance(), + ConstructionManager.Instance(), + WorkerManager.Instance(), + CombatManager.Instance() +// AttackDecisionMaker.Instance() + ); + + + for (GameManager gameManager : gameManagers) { + char drawColor = UxColor.CHAR_WHITE; + if (gameManager.getRecorded() > 10L) { + drawColor = UxColor.CHAR_TEAL; + } else if (gameManager.getRecorded() > 30L) { + drawColor = UxColor.CHAR_RED; + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R",gameManager.getClass().getSimpleName()+drawColor,gameManager.getRecorded(),UxColor.CHAR_PURPLE); + drawStrategyRightList.add(uxDrawConfig); + } + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","* group size: " + LagObserver.groupsize(),UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","* manager rotation size: " + LagObserver.managerRotationSize(),UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + } + + private void drawBigWatch() { + Map resultTimeMap = BigWatch.getResultTimeMap(); + Map recordTimeMap = BigWatch.getRecordTimeMap(); + + List tags = new ArrayList<>(recordTimeMap.keySet()); + Collections.sort(tags); + + int currentY = 0; + for (String tag : tags) { + Long resultTime = resultTimeMap.get(tag); + resultTime = resultTime == null ? 0L : resultTime; + Long recordTime = recordTimeMap.get(tag); + + char drawColor = UxColor.CHAR_WHITE; + if (recordTime > 10L) { + drawColor = UxColor.CHAR_TEAL; + } else if (recordTime > 30L) { + drawColor = UxColor.CHAR_RED; + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","",tag + " : " + resultTime + " / " + drawColor + recordTime,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } + } + + private void drawPathData() { + for (Unit depot : UnitUtils.getUnitList(UnitType.Terran_Command_Center)) { + List mineralsList = WorkerData.depotMineral.get(depot); + if (mineralsList == null) { +// System.out.println("mineralsList is null."); +// if (depot != null) { +// System.out.println("depot=" + depot.getID() + "" + depot.getPosition()); +// } else { +// System.out.println("depot is null"); +// } + return; + } + + for (Minerals minr : mineralsList) { + if (minr.mineralTrick != null) { + Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), 4, Color.Blue, true); + Broodwar.drawCircleMap(minr.mineralTrick.getPosition().getX(), minr.mineralTrick.getPosition().getY(), 4, Color.Purple, true); + } + } + + + for (Minerals minr : WorkerData.depotMineral.get(depot)) { + if (minr.posTrick != bwapi.Position.None) { + Broodwar.drawCircleMap(minr.posTrick.getX(), minr.posTrick.getY(), 4, Color.Red, true); + Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), 4, Color.Yellow, true); + } + } + + //Broodwar->drawCircleMap(Minerals[0].posTrick.x(),Minerals[0].posTrick.y(),2,Colors::Purple,true); + + //Prebot.Broodwar.drawCircleMap(Mineral.Instance().CCtrick.getX(),Mineral.Instance().CCtrick.getY(),2,Color.Brown,true); + //for(int i=0; i< MineralManager.Instance().minerals.size(); i++){ + //Prebot.Broodwar.drawTextMap( minr.mineral.getPosition().getX(),minr.mineral.getPosition().getY(), "(" + (int)(MineralManager.Instance().minerals.get(i).MinToCC) + (int)(MineralManager.Instance().minerals.get(i).CCToMin) + ")"); + //} + } + + } + + private void drawStrategy(){ + String upgradeString = ""; + for (MetaType metaType : StrategyBoard.upgrade) { + upgradeString += metaType.getName() + " > "; + } + + int y = 10; + Race enemyRace = PlayerUtils.enemyRace(); + EnemyStrategy strategy = StrategyBoard.currentStrategy; + int phase = EnemyStrategyAnalyzer.Instance().getPhase(); + + //setting + UxDrawConfig uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","", "[" + strategy.name() + " ...(phase " + phase + ")]"); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","UPGRADE",upgradeString); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","EXPANSION",StrategyBoard.expansionOption); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","MISSION",strategy.missionTypeList); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","", ClueManager.Instance().getClueInfoList()); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","", strategy.buildTimeMap); + drawStrategyLeftList.add(uxDrawConfig); + + + + + y = 10; + for (EnemyStrategy enemyStrategy : EnemyStrategy.values()) { + if (enemyStrategy.name().startsWith(enemyRace.toString().toUpperCase())) { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","",""+enemyStrategy.name(),UxColor.CHAR_YELLOW); + drawStrategyRightList.add(uxDrawConfig); + } + } + } + + private void drawEnemyAirDefenseRange() { + List airDefenseEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, UnitTypeUtils.enemyAirDefenseUnitType()); + for (UnitInfo eui : airDefenseEuiList) { + if (eui.getType() == UnitType.Terran_Bunker) { + Broodwar.drawCircleMap(eui.getLastPosition(), Broodwar.enemy().weaponMaxRange(UnitType.Terran_Marine.groundWeapon()) + 96, Color.White); + } else { + Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.White); + } + } + List wraithKillerEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, UnitTypeUtils.wraithKillerUnitType()); + for (UnitInfo eui : wraithKillerEuiList) { + Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.Grey); + } + } + + private void drawAirForceInformation() { + // wraith moving + for (Unit unit : UnitUtils.getUnitList(UnitType.Zerg_Mutalisk)) { + if (unit.isMoving()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); + Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); + Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); + } + } + + // target position + List targetPositions = AirForceManager.Instance().getTargetPositions(); + for (int i = 0; i < targetPositions.size(); i++) { + Broodwar.drawTextMap(targetPositions.get(i), "position#" + i); + } + + // air force team + int y = 190; + Set airForceTeamSet = new HashSet<>(AirForceManager.Instance().getAirForceTeamMap().values()); + List airForceList = new ArrayList<>(airForceTeamSet); + airForceList.sort(new Comparator() { + @Override + public int compare(AirForceTeam a1, AirForceTeam a2) { + int memberGap = a1.memberList.size() - a2.memberList.size(); + int idGap = a1.leaderUnit.getID() - a2.leaderUnit.getID(); + return memberGap * 100 + idGap; + } + }); + for (AirForceTeam airForceTeam : airForceList) { + char color = UxColor.CHAR_WHITE; + if (airForceTeam.repairCenter != null) { + color = UxColor.CHAR_RED; + } + Position position = airForceTeam.leaderUnit.getPosition(); + Broodwar.drawTextMap(position.getX(), position.getY() - 10, color + "leader#" + airForceTeam.leaderUnit.getID()); + + Position targetPosition = new Position(airForceTeam.getTargetPosition().getX(), airForceTeam.getTargetPosition().getY() - 10); + Broodwar.drawTextMap(targetPosition, UxColor.CHAR_RED + "*" + airForceTeam.leaderUnit.getID()); + Broodwar.drawTextScreen(L, y += 15, "" + UxColor.CHAR_YELLOW + airForceTeam.toString()); + } + + /* Broodwar.drawTextScreen(L, y += 15, "Defense Mode? " + AirForceManager.Instance().isAirForceDefenseMode()); + Broodwar.drawTextScreen(L, y += 15, "strike level=" + AirForceManager.Instance().getStrikeLevel()); + Broodwar.drawTextScreen(L, y += 15, "total achievement=" + AirForceManager.Instance().getAchievementEffectiveFrame()); + Broodwar.drawTextScreen(L, y += 15, "accumulated achievement=" + AirForceManager.Instance().getAccumulatedAchievement()); + Broodwar.drawTextScreen(L, y += 15, "wraith count=" + StrategyBoard.wraithCount);*/ + } + + private void drawVulturePolicy() { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","[vulture policy]",UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","checkerMaxNumber=" + StrategyBoard.checkerMaxNumber,UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","spiderMineNumberPerPosition=" + StrategyBoard.spiderMineNumberPerPosition,UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","spiderMineNumberPerGoodPosition=" + StrategyBoard.spiderMineNumberPerGoodPosition,UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","watcherMinePositionLevel=" + StrategyBoard.watcherMinePositionLevel,UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + } + + private void drawEnemyBaseToBaseTime() { + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","campPosition : " + StrategyBoard.campPosition + " / " + StrategyBoard.campType,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","mainPosition : " + StrategyBoard.mainPosition,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","watcherPosition : " + StrategyBoard.watcherPosition,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","mainSquadCenter : " + StrategyBoard.mainSquadCenter,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyGroundSquadPosition : " + StrategyBoard.nearGroundEnemyPosition + " / " + StrategyBoard.enemyUnitStatus,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyAirSquadPosition : " + StrategyBoard.nearAirEnemyPosition,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyDropEnemyPosition : " + StrategyBoard.dropEnemyPosition,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + Position enemyBasePosition = null; + Position enemyExpansionPosition = null; + if (BaseUtils.enemyMainBase() != null) { + enemyBasePosition = BaseUtils.enemyMainBase().getPosition(); + enemyExpansionPosition = BaseUtils.enemyMainBase().getPosition(); + + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyMainBase : " + enemyBasePosition,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyFirstExpansion : " + enemyExpansionPosition,UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); +// if (StrategyBoard.enemyBaseExpected != null) { +// Broodwar.drawTextScreen(10, y += 15, "enemyMainBase (Expect) : " + StrategyBoard.enemyBaseExpected.getPosition()); +// } +// for (Entry unitType : InformationManager.Instance().baseToBaseUnit.entrySet()) { +// Prebot.Broodwar.drawTextScreen(20, y += 10, "" + UxColor.CHAR_YELLOW + unitType.getKey() + " : " + unitType.getValue()); // } -// } - } - - /// Worker Unit 들의 상태를 Screen 에 표시합니다 - public void drawWorkerStateOnScreen(int x, int y) { - WorkerData workerData = WorkerManager.Instance().getWorkerData(); - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + ""); - - int yspace = 0; - - for (Unit unit : workerData.getWorkers()) { - if (unit == null) continue; - - // Mineral / Gas / Idle Worker 는 표시 안한다 - if (workerData.getJobCode(unit) == 'M' || workerData.getJobCode(unit) == 'I' || workerData.getJobCode(unit) == 'G') { - continue; - } - - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), UxColor.CHAR_WHITE + " " + unit.getID()); - - if (workerData.getJobCode(unit) == 'B') { - Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), UxColor.CHAR_WHITE + " " + workerData.getJobCode(unit) + " " + unit.getBuildType() + " " + (unit.isConstructing() ? 'Y' : 'N') + " (" + unit.getTilePosition().getX() + ", " + unit.getTilePosition().getY() + ")"); - } else { - Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), UxColor.CHAR_WHITE + " " + workerData.getJobCode(unit)); - } - } - } - - /// ResourceDepot 별 Worker 숫자를 Map 에 표시합니다 - public void drawWorkerCountOnMap() { - for (Unit depot : WorkerManager.Instance().getWorkerData().getDepots()) { - if (depot == null) continue; - - int x = depot.getPosition().getX() - 64; - int y = depot.getPosition().getY() - 32; - - Broodwar.drawBoxMap(x - 2, y - 1, x + 75, y + 14, Color.Black, true); - Broodwar.drawTextMap(x, y, UxColor.CHAR_WHITE + " Workers: " + WorkerManager.Instance().getWorkerData().getNumAssignedWorkers(depot)); - } - } - - /// Worker Unit 의 자원채취 현황을 Map 에 표시합니다 - public void drawWorkerMiningStatusOnMap() { - WorkerData workerData = WorkerManager.Instance().getWorkerData(); - - for (Unit worker : workerData.getWorkers()) { - if (worker == null) continue; - - Position pos = worker.getTargetPosition(); - - Broodwar.drawTextMap(worker.getPosition().getX(), worker.getPosition().getY() - 5, "" + UxColor.CHAR_WHITE + workerData.getJobCode(worker)); - - Broodwar.drawLineMap(worker.getPosition().getX(), worker.getPosition().getY(), pos.getX(), pos.getY(), Color.Cyan); - - /* - // ResourceDepot ~ Worker 사이에 직선 표시 - BWAPI.Unit depot = workerData.getWorkerDepot(worker); - if (depot) { - Monster.game.drawLineMap(worker.getPosition().x, worker.getPosition().y, depot.getPosition().x, depot.getPosition().y, Color.Orange); - } - */ - } - } - - /// 정찰 상태를 Screen 에 표시합니다 - public void drawScoutInformation(int x, int y) { - - // get the enemy base location, if we have one - BaseLocation enemyBaseLocation = BaseUtils.enemyMainBase(); - - if (enemyBaseLocation != null) { - Broodwar.drawTextScreen(x, y, "Enemy MainBaseLocation : (" + enemyBaseLocation.getTilePosition().getX() + ", " + enemyBaseLocation.getTilePosition().getY() + ")"); - } else { - Broodwar.drawTextScreen(x, y, "Enemy MainBaseLocation : Unknown"); - } - } - - /// Unit 의 Target 으로 잇는 선을 Map 에 표시합니다 - public void drawUnitTargetOnMap() { - for (Unit unit : Broodwar.self().getUnits()) { - if (unit != null && unit.isCompleted() && !unit.getType().isBuilding() && !unit.getType().isWorker()) { - Unit targetUnit = unit.getTarget(); - if (targetUnit != null && targetUnit.getPlayer() != Broodwar.self()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Red, true); - Broodwar.drawCircleMap(targetUnit.getTargetPosition(), dotRadius, Color.Red, true); - Broodwar.drawLineMap(unit.getPosition(), targetUnit.getTargetPosition(), Color.Red); - } else if (unit.isMoving()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); - Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); - Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); - } - - } - } - } - - /// Bullet 을 Map 에 표시합니다
- /// Cloaking Unit 의 Bullet 표시에 쓰입니다 - public void drawBulletsOnMap() { - for (Bullet b : Broodwar.getBullets()) { - Position p = b.getPosition(); - double velocityX = b.getVelocityX(); - double velocityY = b.getVelocityY(); - - if (b.getType() == BulletType.Acid_Spore) bulletTypeName = "Acid_Spore"; - else if (b.getType() == BulletType.Anti_Matter_Missile) bulletTypeName = "Anti_Matter_Missile"; - else if (b.getType() == BulletType.Arclite_Shock_Cannon_Hit) bulletTypeName = "Arclite_Shock_Cannon_Hit"; - else if (b.getType() == BulletType.ATS_ATA_Laser_Battery) bulletTypeName = "ATS_ATA_Laser_Battery"; - else if (b.getType() == BulletType.Burst_Lasers) bulletTypeName = "Burst_Lasers"; - else if (b.getType() == BulletType.C_10_Canister_Rifle_Hit) bulletTypeName = "C_10_Canister_Rifle_Hit"; - else if (b.getType() == BulletType.Consume) bulletTypeName = "Consume"; - else if (b.getType() == BulletType.Corrosive_Acid_Shot) bulletTypeName = "Corrosive_Acid_Shot"; - else if (b.getType() == BulletType.Dual_Photon_Blasters_Hit) bulletTypeName = "Dual_Photon_Blasters_Hit"; - else if (b.getType() == BulletType.EMP_Missile) bulletTypeName = "EMP_Missile"; - else if (b.getType() == BulletType.Ensnare) bulletTypeName = "Ensnare"; - else if (b.getType() == BulletType.Fragmentation_Grenade) bulletTypeName = "Fragmentation_Grenade"; - else if (b.getType() == BulletType.Fusion_Cutter_Hit) bulletTypeName = "Fusion_Cutter_Hit"; - else if (b.getType() == BulletType.Gauss_Rifle_Hit) bulletTypeName = "Gauss_Rifle_Hit"; - else if (b.getType() == BulletType.Gemini_Missiles) bulletTypeName = "Gemini_Missiles"; - else if (b.getType() == BulletType.Glave_Wurm) bulletTypeName = "Glave_Wurm"; - else if (b.getType() == BulletType.Halo_Rockets) bulletTypeName = "Halo_Rockets"; - else if (b.getType() == BulletType.Invisible) bulletTypeName = "Invisible"; - else if (b.getType() == BulletType.Longbolt_Missile) bulletTypeName = "Longbolt_Missile"; - else if (b.getType() == BulletType.Melee) bulletTypeName = "Melee"; - else if (b.getType() == BulletType.Needle_Spine_Hit) bulletTypeName = "Needle_Spine_Hit"; - else if (b.getType() == BulletType.Neutron_Flare) bulletTypeName = "Neutron_Flare"; - else if (b.getType() == BulletType.None) bulletTypeName = "None"; - else if (b.getType() == BulletType.Optical_Flare_Grenade) bulletTypeName = "Optical_Flare_Grenade"; - else if (b.getType() == BulletType.Particle_Beam_Hit) bulletTypeName = "Particle_Beam_Hit"; - else if (b.getType() == BulletType.Phase_Disruptor) bulletTypeName = "Phase_Disruptor"; - else if (b.getType() == BulletType.Plague_Cloud) bulletTypeName = "Plague_Cloud"; - else if (b.getType() == BulletType.Psionic_Shockwave_Hit) bulletTypeName = "Psionic_Shockwave_Hit"; - else if (b.getType() == BulletType.Psionic_Storm) bulletTypeName = "Psionic_Storm"; - else if (b.getType() == BulletType.Pulse_Cannon) bulletTypeName = "Pulse_Cannon"; - else if (b.getType() == BulletType.Queen_Spell_Carrier) bulletTypeName = "Queen_Spell_Carrier"; - else if (b.getType() == BulletType.Seeker_Spores) bulletTypeName = "Seeker_Spores"; - else if (b.getType() == BulletType.STA_STS_Cannon_Overlay) bulletTypeName = "STA_STS_Cannon_Overlay"; - else if (b.getType() == BulletType.Subterranean_Spines) bulletTypeName = "Subterranean_Spines"; - else if (b.getType() == BulletType.Sunken_Colony_Tentacle) bulletTypeName = "Sunken_Colony_Tentacle"; - else if (b.getType() == BulletType.Unknown) bulletTypeName = "Unknown"; - else if (b.getType() == BulletType.Yamato_Gun) bulletTypeName = "Yamato_Gun"; - - // 아군 것이면 녹색, 적군 것이면 빨간색 - Broodwar.drawLineMap(p, new Position(p.getX() + (int) velocityX, p.getY() + (int) velocityY), b.getPlayer() == Broodwar.self() ? Color.Green : Color.Red); - if (b.getType() != null) { - Broodwar.drawTextMap(p, (b.getPlayer() == Broodwar.self() ? "" + UxColor.CHAR_TEAL : "" + UxColor.CHAR_RED) + bulletTypeName); - } - } - } - - private void drawSquadUnitTagMap() { - // draw neutral units and our units - for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { - Color color = UxColor.SQUAD_COLOR.get(squad.getClass()); - if (color == null) { - continue; - } - String squadName = squad.getSquadName(); - - StrategyCode.SmallFightPredict smallFightPredict = null; - if (squad instanceof WatcherSquad) { - smallFightPredict = ((WatcherSquad) squad).getSmallFightPredict(); - } - - if (squadName.length() > 4) { - squadName = squadName.substring(0, 4); - } - - for (Unit unit : squad.unitList) { - Broodwar.drawCircleMap(unit.getPosition(), 10, color); - Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 30, squadName); - if (smallFightPredict != null && smallFightPredict == StrategyCode.SmallFightPredict.BACK) { - Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 15, UxColor.CHAR_RED + smallFightPredict.toString()); - } - } - -// Map checkerSiteMap = VultureTravelManager.Instance().getCheckerSiteMap2(); -// List baseList = VultureTravelManager.Instance().getBaseLocationsCheckerOrdered(); -// for (Integer checkerId : checkerSiteMap.keySet()) { -// Unit unit = Broodwar.getUnit(checkerId); -// if (UnitUtils.isValidUnit(unit)) { -// Integer index = checkerSiteMap.get(checkerId); -// if (index != null) { -// Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 5, UxColor.CHAR_ORANGE + baseList.get(index).getPosition().toString()); -// } -// -// } -// } - } - } - - private void drawSquadInfoOnMap(int x, int y) { - /// ConstructionQueue 를 Screen 에 표시합니다 - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + ""); - Broodwar.drawTextScreen(x + 110, y, UxColor.CHAR_WHITE + " "); - - y += 15; - Broodwar.drawTextScreen(x, y, "" + "*" + "SCV"); - Broodwar.drawTextScreen(x + 120, y, "" + UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_SCV)); - y += 10; - for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { - Color squadColor = UxColor.SQUAD_COLOR.get(squad.getClass()); - if (squadColor != null) { - Broodwar.drawTextScreen(x, y, "" + UxColor.COLOR_TO_CHARACTER.get(squadColor) + squad.getSquadName()); - } else { - Broodwar.drawTextScreen(x, y, "" + "*" + squad.getSquadName()); - } - String unitIds = " ... "; - for (Unit unit : squad.unitList) { - unitIds = unitIds + unit.getID() + "/"; - } - Broodwar.drawTextScreen(x + 120, y, "" + squad.unitList.size() + unitIds); - y += 10; - } - } - - private void drawManagerTimeSpent(int x, int y) { - List gameManagers = Arrays.asList( - //InformationManager.Instance(), - StrategyManager.Instance(), - MapGrid.Instance(), - BuildManager.Instance(), - BuildQueueProvider.Instance(), - ConstructionManager.Instance(), - WorkerManager.Instance(), - CombatManager.Instance() -// AttackDecisionMaker.Instance() - ); - - - int currentY = y; - for (GameManager gameManager : gameManagers) { - currentY += 10; - Broodwar.drawTextScreen(x, currentY, UxColor.CHAR_PURPLE + gameManager.getClass().getSimpleName()); - - char drawColor = UxColor.CHAR_WHITE; - if (gameManager.getRecorded() > 10L) { - drawColor = UxColor.CHAR_TEAL; - } else if (gameManager.getRecorded() > 30L) { - drawColor = UxColor.CHAR_RED; - } - Broodwar.drawTextScreen(x + 103, currentY, ": " + drawColor + gameManager.getRecorded()); - } - - Broodwar.drawTextScreen(x, currentY += 15, "* group size: " + LagObserver.groupsize()); - Broodwar.drawTextScreen(x, currentY += 10, "* manager rotation size: " + LagObserver.managerRotationSize()); - } - - private void drawBigWatch() { - Map resultTimeMap = BigWatch.getResultTimeMap(); - Map recordTimeMap = BigWatch.getRecordTimeMap(); - - List tags = new ArrayList<>(recordTimeMap.keySet()); - Collections.sort(tags); - - int currentY = 0; - for (String tag : tags) { - Long resultTime = resultTimeMap.get(tag); - resultTime = resultTime == null ? 0L : resultTime; - Long recordTime = recordTimeMap.get(tag); - - char drawColor = UxColor.CHAR_WHITE; - if (recordTime > 10L) { - drawColor = UxColor.CHAR_TEAL; - } else if (recordTime > 30L) { - drawColor = UxColor.CHAR_RED; - } - Broodwar.drawTextScreen(10, currentY += 10, UxColor.CHAR_WHITE + tag + " : " + resultTime + " / " + drawColor + recordTime); - } - } - - private void drawPathData() { - for (Unit depot : UnitUtils.getUnitList(UnitType.Terran_Command_Center)) { - List mineralsList = WorkerData.depotMineral.get(depot); - if (mineralsList == null) { -// System.out.println("mineralsList is null."); -// if (depot != null) { -// System.out.println("depot=" + depot.getID() + "" + depot.getPosition()); -// } else { -// System.out.println("depot is null"); + } + + private void drawPositionInformation() { + + if (StrategyBoard.mainSquadLeaderPosition != null) { + Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainSquadLeaderPosition, 0, -20), UxColor.CHAR_WHITE + "V"); + } + if (StrategyBoard.campPosition.equals(StrategyBoard.mainPosition)) { + Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_ORANGE + "camp & main"); + } else { + if (StrategyBoard.campPosition != null) { + Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_YELLOW + "camp"); + } + if (StrategyBoard.mainPosition != null) { + Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainPosition, 0, -10), UxColor.CHAR_RED + "main"); + } + } + if (StrategyBoard.campPositionSiege != null) { + Broodwar.drawTextMap(StrategyBoard.campPositionSiege, UxColor.CHAR_YELLOW + "camp (siege)"); + } + if (StrategyBoard.watcherPosition != null) { + Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.watcherPosition, 0, -20), UxColor.CHAR_BLUE + "watcherPos"); + } + if (StrategyBoard.mainSquadCenter != null) { + Broodwar.drawTextMap(StrategyBoard.mainSquadCenter, "mainSqCntr"); + Broodwar.drawCircleMap(StrategyBoard.mainSquadCenter.getX(), StrategyBoard.mainSquadCenter.getY(), StrategyBoard.mainSquadCoverRadius, Color.Cyan); + } + if (StrategyBoard.nearGroundEnemyPosition != null) { + Broodwar.drawTextMap(StrategyBoard.nearGroundEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Ground)"); + Broodwar.drawCircleMap(StrategyBoard.nearGroundEnemyPosition, 150, Color.Red); + } + if (StrategyBoard.nearAirEnemyPosition != null) { + Broodwar.drawTextMap(StrategyBoard.nearAirEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Air)"); + Broodwar.drawCircleMap(StrategyBoard.nearAirEnemyPosition, 150, Color.Red); + } + if (StrategyBoard.dropEnemyPosition != null) { + Broodwar.drawTextMap(StrategyBoard.dropEnemyPosition, UxColor.CHAR_RED + "dropEnemySq"); + Broodwar.drawCircleMap(StrategyBoard.dropEnemyPosition, 150, Color.Red); + } + if (StrategyBoard.totalEnemyCneterPosition != null) { + Broodwar.drawTextMap(StrategyBoard.totalEnemyCneterPosition, "totalEnemySq"); + Broodwar.drawCircleMap(StrategyBoard.totalEnemyCneterPosition, 250, Color.Red); + } + if (PositionUtils.myReadyToPosition() != null) { + Broodwar.drawTextMap(PositionUtils.myReadyToPosition(), "myReadyTo"); + } + if (PositionUtils.enemyReadyToPosition() != null) { + Broodwar.drawTextMap(PositionUtils.enemyReadyToPosition(), "enemyReadyTo"); + } +// if (VultureTravelManager.Instance().getTravelSites() != null) { +// for (TravelSite site : VultureTravelManager.Instance().getTravelSites()) { +// Broodwar.drawTextMap(site.baseLocation.getPosition(), "travel site\n" + site); // } - return; - } - - for (Minerals minr : mineralsList) { - if (minr.mineralTrick != null) { - Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), 4, Color.Blue, true); - Broodwar.drawCircleMap(minr.mineralTrick.getPosition().getX(), minr.mineralTrick.getPosition().getY(), 4, Color.Purple, true); - } - } - - - for (Minerals minr : WorkerData.depotMineral.get(depot)) { - if (minr.posTrick != bwapi.Position.None) { - Broodwar.drawCircleMap(minr.posTrick.getX(), minr.posTrick.getY(), 4, Color.Red, true); - Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), 4, Color.Yellow, true); - } - } - - //Broodwar->drawCircleMap(Minerals[0].posTrick.x(),Minerals[0].posTrick.y(),2,Colors::Purple,true); - - //Prebot.Broodwar.drawCircleMap(Mineral.Instance().CCtrick.getX(),Mineral.Instance().CCtrick.getY(),2,Color.Brown,true); - //for(int i=0; i< MineralManager.Instance().minerals.size(); i++){ - //Prebot.Broodwar.drawTextMap( minr.mineral.getPosition().getX(),minr.mineral.getPosition().getY(), "(" + (int)(MineralManager.Instance().minerals.get(i).MinToCC) + (int)(MineralManager.Instance().minerals.get(i).CCToMin) + ")"); - //} - } - - } - - private void drawStrategy() { - String upgradeString = ""; - for (MetaType metaType : StrategyBoard.upgrade) { - upgradeString += metaType.getName() + " > "; - } - - int y = 10; - Race enemyRace = PlayerUtils.enemyRace(); - EnemyStrategy strategy = StrategyBoard.currentStrategy; - int phase = EnemyStrategyAnalyzer.Instance().getPhase(); - - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "[" + strategy.name() + " ...(phase " + phase + ")]"); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "FAC RATIO : " + StrategyBoard.factoryRatio + ".. (" + UnitUtils.myFactoryUnitSupplyCount() + ")"); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "UPGRADE : " + upgradeString); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "MARINE CNT : " + StrategyBoard.marineCount); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "ADDON : " + StrategyBoard.addOnOption); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "EXPANSION : " + StrategyBoard.expansionOption); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "WRAITH CNT : " + StrategyBoard.wraithCount); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "VALKYRIE CNT : " + StrategyBoard.valkyrieCount); - Broodwar.drawTextScreen(20, y += 12, UxColor.CHAR_YELLOW + "MISSION : " + strategy.missionTypeList); - Broodwar.drawTextScreen(20, y += 20, UxColor.CHAR_YELLOW + "" + strategy.buildTimeMap); - - Broodwar.drawTextScreen(20, 260, "" + UxColor.CHAR_YELLOW + ClueManager.Instance().getClueInfoList()); - - y = 10; - for (EnemyStrategy enemyStrategy : EnemyStrategy.values()) { - if (enemyStrategy.name().startsWith(enemyRace.toString().toUpperCase())) { - Broodwar.drawTextScreen(400, y += 10, "" + UxColor.CHAR_YELLOW + enemyStrategy.name()); - } - } - } - - private void drawEnemyAirDefenseRange() { - List airDefenseEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, UnitTypeUtils.enemyAirDefenseUnitType()); - for (UnitInfo eui : airDefenseEuiList) { - if (eui.getType() == UnitType.Terran_Bunker) { - Broodwar.drawCircleMap(eui.getLastPosition(), Broodwar.enemy().weaponMaxRange(UnitType.Terran_Marine.groundWeapon()) + 96, Color.White); - } else { - Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.White); - } - } - List wraithKillerEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, UnitTypeUtils.wraithKillerUnitType()); - for (UnitInfo eui : wraithKillerEuiList) { - Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.Grey); - } - } - - private void drawAirForceInformation() { - // wraith moving - for (Unit unit : UnitUtils.getUnitList(UnitType.Terran_Wraith)) { - if (unit.isMoving()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); - Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); - Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); - } - } - - // target position - List targetPositions = AirForceManager.Instance().getTargetPositions(); - for (int i = 0; i < targetPositions.size(); i++) { - Broodwar.drawTextMap(targetPositions.get(i), "position#" + i); - } - - // air force team - int y = 190; - Set airForceTeamSet = new HashSet<>(AirForceManager.Instance().getAirForceTeamMap().values()); - List airForceList = new ArrayList<>(airForceTeamSet); - airForceList.sort(new Comparator() { - @Override - public int compare(AirForceTeam a1, AirForceTeam a2) { - int memberGap = a1.memberList.size() - a2.memberList.size(); - int idGap = a1.leaderUnit.getID() - a2.leaderUnit.getID(); - return memberGap * 100 + idGap; - } - }); - for (AirForceTeam airForceTeam : airForceList) { - char color = UxColor.CHAR_WHITE; - if (airForceTeam.repairCenter != null) { - color = UxColor.CHAR_RED; - } - Position position = airForceTeam.leaderUnit.getPosition(); - Broodwar.drawTextMap(position.getX(), position.getY() - 10, color + "leader#" + airForceTeam.leaderUnit.getID()); - - Position targetPosition = new Position(airForceTeam.getTargetPosition().getX(), airForceTeam.getTargetPosition().getY() - 10); - Broodwar.drawTextMap(targetPosition, UxColor.CHAR_RED + "*" + airForceTeam.leaderUnit.getID()); - Broodwar.drawTextScreen(20, y += 15, "" + UxColor.CHAR_YELLOW + airForceTeam.toString()); - } - Broodwar.drawTextScreen(20, y += 15, "Defense Mode? " + AirForceManager.Instance().isAirForceDefenseMode()); - Broodwar.drawTextScreen(20, y += 15, "strike level=" + AirForceManager.Instance().getStrikeLevel()); - Broodwar.drawTextScreen(20, y += 15, "total achievement=" + AirForceManager.Instance().getAchievementEffectiveFrame()); - Broodwar.drawTextScreen(20, y += 15, "accumulated achievement=" + AirForceManager.Instance().getAccumulatedAchievement()); - Broodwar.drawTextScreen(20, y += 15, "wraith count=" + StrategyBoard.wraithCount); - } - - private void drawVulturePolicy() { - int y = 10; - Broodwar.drawTextScreen(400, y += 15, "[vulture policy]"); - Broodwar.drawTextScreen(400, y += 15, "checkerMaxNumber=" + StrategyBoard.checkerMaxNumber); - Broodwar.drawTextScreen(400, y += 15, "spiderMineNumberPerPosition=" + StrategyBoard.spiderMineNumberPerPosition); - Broodwar.drawTextScreen(400, y += 15, "spiderMineNumberPerGoodPosition=" + StrategyBoard.spiderMineNumberPerGoodPosition); - Broodwar.drawTextScreen(400, y += 15, "watcherMinePositionLevel=" + StrategyBoard.watcherMinePositionLevel); - } - - private void drawEnemyBaseToBaseTime() { - int y = 0; - Broodwar.drawTextScreen(10, y += 15, "campPosition : " + StrategyBoard.campPosition + " / " + StrategyBoard.campType); - Broodwar.drawTextScreen(10, y += 15, "mainPosition : " + StrategyBoard.mainPosition); - Broodwar.drawTextScreen(10, y += 15, "watcherPosition : " + StrategyBoard.watcherPosition); - Broodwar.drawTextScreen(10, y += 15, "mainSquadCenter : " + StrategyBoard.mainSquadCenter); - Broodwar.drawTextScreen(10, y += 15, "enemyGroundSquadPosition : " + StrategyBoard.nearGroundEnemyPosition + " / " + StrategyBoard.enemyUnitStatus); - Broodwar.drawTextScreen(10, y += 15, "enemyAirSquadPosition : " + StrategyBoard.nearAirEnemyPosition); - Broodwar.drawTextScreen(10, y += 15, "enemyDropEnemyPosition : " + StrategyBoard.dropEnemyPosition); - - y += 10; - Position enemyBasePosition = null; - Position enemyExpansionPosition = null; - if (BaseUtils.enemyMainBase() != null) { - enemyBasePosition = BaseUtils.enemyMainBase().getPosition(); - enemyExpansionPosition = BaseUtils.enemyMainBase().getPosition(); - - } - Broodwar.drawTextScreen(10, y += 15, "enemyMainBase : " + enemyBasePosition); - Broodwar.drawTextScreen(10, y += 15, "enemyFirstExpansion : " + enemyExpansionPosition); - -// if (StrategyBoard.enemyBaseExpected != null) { -// Broodwar.drawTextScreen(10, y += 15, "enemyMainBase (Expect) : " + StrategyBoard.enemyBaseExpected.getPosition()); -// } -// for (Entry unitType : InformationManager.Instance().baseToBaseUnit.entrySet()) { -// Prebot.Broodwar.drawTextScreen(20, y += 10, "" + UxColor.CHAR_YELLOW + unitType.getKey() + " : " + unitType.getValue()); -// } - } - - private void drawPositionInformation() { - - if (StrategyBoard.mainSquadLeaderPosition != null) { - Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainSquadLeaderPosition, 0, -20), UxColor.CHAR_WHITE + "V"); - } - if (StrategyBoard.campPosition.equals(StrategyBoard.mainPosition)) { - Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_ORANGE + "camp & main"); - } else { - if (StrategyBoard.campPosition != null) { - Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_YELLOW + "camp"); - } - if (StrategyBoard.mainPosition != null) { - Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainPosition, 0, -10), UxColor.CHAR_RED + "main"); - } - } - if (StrategyBoard.campPositionSiege != null) { - Broodwar.drawTextMap(StrategyBoard.campPositionSiege, UxColor.CHAR_YELLOW + "camp (siege)"); - } - if (StrategyBoard.watcherPosition != null) { - Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.watcherPosition, 0, -20), UxColor.CHAR_BLUE + "watcherPos"); - } - if (StrategyBoard.mainSquadCenter != null) { - Broodwar.drawTextMap(StrategyBoard.mainSquadCenter, "mainSqCntr"); - Broodwar.drawCircleMap(StrategyBoard.mainSquadCenter.getX(), StrategyBoard.mainSquadCenter.getY(), StrategyBoard.mainSquadCoverRadius, Color.Cyan); - } - if (StrategyBoard.nearGroundEnemyPosition != null) { - Broodwar.drawTextMap(StrategyBoard.nearGroundEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Ground)"); - Broodwar.drawCircleMap(StrategyBoard.nearGroundEnemyPosition, 150, Color.Red); - } - if (StrategyBoard.nearAirEnemyPosition != null) { - Broodwar.drawTextMap(StrategyBoard.nearAirEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Air)"); - Broodwar.drawCircleMap(StrategyBoard.nearAirEnemyPosition, 150, Color.Red); - } - if (StrategyBoard.dropEnemyPosition != null) { - Broodwar.drawTextMap(StrategyBoard.dropEnemyPosition, UxColor.CHAR_RED + "dropEnemySq"); - Broodwar.drawCircleMap(StrategyBoard.dropEnemyPosition, 150, Color.Red); - } - if (StrategyBoard.totalEnemyCneterPosition != null) { - Broodwar.drawTextMap(StrategyBoard.totalEnemyCneterPosition, "totalEnemySq"); - Broodwar.drawCircleMap(StrategyBoard.totalEnemyCneterPosition, 250, Color.Red); - } - if (PositionUtils.myReadyToPosition() != null) { - Broodwar.drawTextMap(PositionUtils.myReadyToPosition(), "myReadyTo"); - } - if (PositionUtils.enemyReadyToPosition() != null) { - Broodwar.drawTextMap(PositionUtils.enemyReadyToPosition(), "enemyReadyTo"); - } -// if (VultureTravelManager.Instance().getTravelSites() != null) { -// for (TravelSite site : VultureTravelManager.Instance().getTravelSites()) { -// Broodwar.drawTextMap(site.baseLocation.getPosition(), "travel site\n" + site); // } -// } - } - - private void drawCCtoScvCount() { + } + + private void drawCCtoScvCount() { + + int y = 100; + for (Unit depot : UnitUtils.getCompletedUnitList(UnitType.Terran_Command_Center)) { + // update workerData with the new job + Broodwar.drawTextScreen(R, y, "depot.getID() : " + depot.getID() + " cnt : " + WorkerData.depotWorkerCount.get(depot.getID())); + y += 10; + } + } + + /// turret 건설 지점의 반경 표시 + public void drawTurretMap() { + BaseLocation myBase = BaseUtils.myMainBase(); + BaseLocation myFirstExpansion = BaseUtils.myFirstExpansion(); + Chokepoint myFirstChoke = ChokeUtils.myFirstChoke(); + Chokepoint mySecondChoke = ChokeUtils.mySecondChoke(); + + int turretCount = UnitUtils.getCompletedUnitCount(UnitType.Terran_Missile_Turret); + + Position firstChokeMainHalf = new Position((myBase.getPosition().getX() + myFirstChoke.getX() * 2) / 3 - 60, + (myBase.getPosition().getY() + myFirstChoke.getY() * 2) / 3 - 60); + + Position firstChokeExpHalf = new Position((myFirstExpansion.getPosition().getX() * 2 + myFirstChoke.getX()) / 3, + (myFirstExpansion.getPosition().getY() * 2 + myFirstChoke.getY()) / 3); + +//// Position betweenChoke = new Position((myFirstChoke.getX() * 2 + myFirstChoke.getX()) / 3, +//// (mySecondChoke.getY() * 2 + mySecondChoke.getY()) / 3); +//// + +// Broodwar.drawTextMap(firstChokeExpHalf.getX() + 20, firstChokeExpHalf.getY() + 10, "(" + (int) (firstChokeExpHalf.getX()) + ", " + (int) (firstChokeExpHalf.getY()) + ")"); +// +// Broodwar.drawCircleMap(firstChokeExpHalf, 150, Color.Orange, false); +// +// Broodwar.drawCircleMap(firstChokeExpHalf, 150 + turretCount * 15, Color.Orange, false); +// +// Broodwar.drawTextMap(mySecondChoke.getCenter().getX() + 20, mySecondChoke.getCenter().getY() + 10, "(" + (int) (mySecondChoke.getCenter().getX()) + ", " + (int) (mySecondChoke.getCenter().getY()) + ")"); +// +// Broodwar.drawCircleMap(mySecondChoke.getCenter(), 150, Color.Cyan, false); +// +// Broodwar.drawCircleMap(mySecondChoke.getCenter(), 150 + turretCount * 15, Color.Cyan, false); +// +// Position betweenChoke2 = Position.None; +// +// if (MapUtils.getMapSpecificInformation().getMap() == GameMap.FIGHTING_SPIRITS) { +// betweenChoke2 = new Position((firstChokeMainHalf.getX() * 4 + mySecondChoke.getX() * 7) / 11, +// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); +// }else { +// betweenChoke2 = new Position((firstChokeMainHalf.getX() * 3 + mySecondChoke.getX() * 4) / 7, +// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); +// } +// +//// Position betweenChoke2 = new Position((firstChokeMainHalf.getX() * 4 + mySecondChoke.getX() * 7) / 11, +//// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); +// +// Broodwar.drawTextMap(betweenChoke2.getX() + 20, betweenChoke2.getY() + 10, "(" + (int) (betweenChoke2.getX()) + ", " + (int) (betweenChoke2.getY()) + ")"); +// +// Broodwar.drawCircleMap(betweenChoke2, 120, Color.White, false); +// +// Broodwar.drawCircleMap(betweenChoke2, 120 + turretCount * 15, Color.White, false); +// +//// radius1 + turretCount * 15 + + } + private void addDrawStrategyListOrigin() throws IllegalArgumentException, IllegalAccessException{ + // TODO Auto-generated method stub + if(!drawStrategyListOrigin[uxOption].isEmpty()){ + UxDrawConfig uxDrawConfig; + for (UxDrawConfig drwaConfig : drawStrategyListOrigin[uxOption]) { + drwaConfig.setClazz(drwaConfig.getKey()); + Class c = drwaConfig.getClazz(); + if(drwaConfig.getValue() != null){ + Field fld = null; + try{ + fld = c.getDeclaredField(drwaConfig.getValue()); + if (!fld.isAccessible()) fld.setAccessible(true); + fld.get(drwaConfig.getValue()); + + + } catch (Exception e) { + continue; + } + uxDrawConfig = UxDrawConfig.newInstanceObjectType(fld.getName(),fld.get(c).toString(),drwaConfig.getColor()); + uxDrawConfig.setPos(drwaConfig.getPos()); + if(drwaConfig.getPos() == UxDrawConfig.posMap.get("L")){ + drawStrategyLeftList.add(uxDrawConfig); + }else if(drwaConfig.getPos() == UxDrawConfig.posMap.get("M")){ + drawStrategyMidList.add(uxDrawConfig); + }else if(drwaConfig.getPos() == UxDrawConfig.posMap.get("R")){ + drawStrategyRightList.add(uxDrawConfig); + }else{ + drawStrategyLeftList.add(uxDrawConfig); + } + } + + } + } + } + // 600 * 300 + private void drawStrategyList() { + // TODO Auto-generated method stub + int nextLy = 20, nextMy = 20, nextRy = 20; +// nextLy = nextMy = nextRy = 20; + + for(UxDrawConfig uxDraw : drawStrategyLeftList){ + int lineCnt = 1; + int fromIndex = -1; + while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { + lineCnt++; + } + Broodwar.drawTextScreen(uxDraw.getPos(), nextLy, uxDraw.getColor() + uxDraw.getClassFieldName()); +// y += (lineCnt*12); + nextLy += (lineCnt*12); + } + + for(UxDrawConfig uxDraw : drawStrategyMidList){ + int lineCnt = 1; + int fromIndex = -1; + while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { + lineCnt++; + } + Broodwar.drawTextScreen(uxDraw.getPos(), nextMy, uxDraw.getColor() + uxDraw.getClassFieldName()); +// y += (lineCnt*12); + nextMy += (lineCnt*12); + } + + for(UxDrawConfig uxDraw : drawStrategyRightList){ + int lineCnt = 1; + int fromIndex = -1; + while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { + lineCnt++; + } + Broodwar.drawTextScreen(uxDraw.getPos(), nextRy, uxDraw.getColor() + uxDraw.getClassFieldName()); +// y += (lineCnt*12); + nextRy += (lineCnt*12); + } + + if(TimeUtils.getFrame() % 7 == 0){ + Broodwar.drawTextScreen(L, (nextLy + 24), " "); + Broodwar.drawTextScreen(M, (nextMy + 24), " "); + Broodwar.drawTextScreen(R, (nextRy + 24), " "); + }else{ + Broodwar.drawTextScreen(L, (nextLy + 24), " : "); + Broodwar.drawTextScreen(M, (nextMy + 24), " : "); + Broodwar.drawTextScreen(R, (nextRy + 24), " : "); +// Broodwar.drawTextScreen(20, nextY+12, ""); + } + } + + /* + * 사용자 별 화면 */ + + public void getSMDisplay(){ + if (uxOption == 0) { + clearList(); + drawDebugginUxMenu(); + drawUxInfo(); + } else if (uxOption == 1) { + UXManager.Instance().update(); + clearList(); + // 미네랄PATH + } else if (uxOption == 2) { + clearList(); + drawGameInformationOnScreen(5, 5); + drawBWTAResultOnMap(); + drawBuildOrderQueueOnScreen(500, 50); + drawBuildStatusOnScreen(370, 50); + drawReservedBuildingTilesOnMap(); + drawTilesToAvoidOnMap(); + drawWorkerMiningStatusOnMap(); + drawUnitTargetOnMap(); + drawnextPoints(); + //drawTurretMap(); + drawManagerTimeSpent(); + drawConstructionQueueOnScreenAndMap(); + + // draw tile position of mouse cursor + int mouseX = Broodwar.getMousePosition().getX() + Broodwar.getScreenPosition().getX(); + int mouseY = Broodwar.getMousePosition().getY() + Broodwar.getScreenPosition().getY(); + Broodwar.drawTextMap(mouseX + 20, mouseY, + "(" + (int) (mouseX / 32) + ", " + (int) (mouseY / 32) + ")"); + Broodwar.drawTextMap(mouseX + 20, mouseY + 10, "(" + (int) (mouseX) + ", " + (int) (mouseY) + ")"); - int y = 100; - for (Unit depot : UnitUtils.getCompletedUnitList(UnitType.Terran_Command_Center)) { - // update workerData with the new job - Broodwar.drawTextScreen(500, y, "depot.getID() : " + depot.getID() + " cnt : " + WorkerData.depotWorkerCount.get(depot.getID())); - y += 10; - } - } + } else if (uxOption == 3) { + clearList(); + drawStrategy(); + // drawCCtoScvCount(); + } else if (uxOption == 4) { + clearList(); + drawEnemyBuildTimer(); + } else if (uxOption == 5) { + clearList(); + drawSquadInfoOnMap(); + drawManagerTimeSpent(); + drawDecision(); + drawEnemyAirDefenseRange(); + drawAirForceInformation(); + drawVulturePolicy(); + } else if (uxOption == 6) { + clearList(); + drawEnemyBaseToBaseTime(); + } else if (uxOption == 7) { + clearList(); + drawBigWatch(); + drawManagerTimeSpent(); + } else if (uxOption == 8) { + clearList(); + drawTurretMap(); + drawTilesToAvoidOnMap(); + drawReservedBuildingTilesOnMap(); + } else if (uxOption == 9) { + //drawExpectedResource(); + //drawExpectedResource2(); + + } + + drawMineralIdOnMap(); + drawUnitIdOnMap(); + drawPositionInformation(); + drawTimer(); + drawPathData(); + drawSquadUnitTagMap(); + + addDrawStrategyListOrigin(); + drawStrategyList(); - /// turret 건설 지점의 반경 표시 - public void drawTurretMap() { - BaseLocation myBase = BaseUtils.myMainBase(); - BaseLocation myFirstExpansion = BaseUtils.myFirstExpansion(); - Chokepoint myFirstChoke = ChokeUtils.myFirstChoke(); - Chokepoint mySecondChoke = ChokeUtils.mySecondChoke(); - - int turretCount = UnitUtils.getCompletedUnitCount(UnitType.Terran_Missile_Turret); - - Position firstChokeMainHalf = new Position((myBase.getPosition().getX() + myFirstChoke.getX() * 2) / 3 - 60, - (myBase.getPosition().getY() + myFirstChoke.getY() * 2) / 3 - 60); - - Position firstChokeExpHalf = new Position((myFirstExpansion.getPosition().getX() * 2 + myFirstChoke.getX()) / 3, - (myFirstExpansion.getPosition().getY() * 2 + myFirstChoke.getY()) / 3); - -//// Position betweenChoke = new Position((myFirstChoke.getX() * 2 + myFirstChoke.getX()) / 3, -//// (mySecondChoke.getY() * 2 + mySecondChoke.getY()) / 3); -//// - -// Broodwar.drawTextMap(firstChokeExpHalf.getX() + 20, firstChokeExpHalf.getY() + 10, "(" + (int) (firstChokeExpHalf.getX()) + ", " + (int) (firstChokeExpHalf.getY()) + ")"); -// -// Broodwar.drawCircleMap(firstChokeExpHalf, 150, Color.Orange, false); -// -// Broodwar.drawCircleMap(firstChokeExpHalf, 150 + turretCount * 15, Color.Orange, false); -// -// Broodwar.drawTextMap(mySecondChoke.getCenter().getX() + 20, mySecondChoke.getCenter().getY() + 10, "(" + (int) (mySecondChoke.getCenter().getX()) + ", " + (int) (mySecondChoke.getCenter().getY()) + ")"); -// -// Broodwar.drawCircleMap(mySecondChoke.getCenter(), 150, Color.Cyan, false); -// -// Broodwar.drawCircleMap(mySecondChoke.getCenter(), 150 + turretCount * 15, Color.Cyan, false); -// -// Position betweenChoke2 = Position.None; -// -// if (MapUtils.getMapSpecificInformation().getMap() == GameMap.FIGHTING_SPIRITS) { -// betweenChoke2 = new Position((firstChokeMainHalf.getX() * 4 + mySecondChoke.getX() * 7) / 11, -// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); -// }else { -// betweenChoke2 = new Position((firstChokeMainHalf.getX() * 3 + mySecondChoke.getX() * 4) / 7, -// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); -// } -// -//// Position betweenChoke2 = new Position((firstChokeMainHalf.getX() * 4 + mySecondChoke.getX() * 7) / 11, -//// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); -// -// Broodwar.drawTextMap(betweenChoke2.getX() + 20, betweenChoke2.getY() + 10, "(" + (int) (betweenChoke2.getX()) + ", " + (int) (betweenChoke2.getY()) + ")"); -// -// Broodwar.drawCircleMap(betweenChoke2, 120, Color.White, false); -// -// Broodwar.drawCircleMap(betweenChoke2, 120 + turretCount * 15, Color.White, false); -// -//// radius1 + turretCount * 15 + clearDecisionListForUx(); + } + public void getJwDisplay() throws Exception { + } - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/src/main/java/org/monster/debugger/chat/ChatBot.java b/src/main/java/org/monster/debugger/chat/ChatBot.java index e3c20e9..d94e993 100644 --- a/src/main/java/org/monster/debugger/chat/ChatBot.java +++ b/src/main/java/org/monster/debugger/chat/ChatBot.java @@ -1,9 +1,11 @@ package org.monster.debugger.chat; import bwapi.Game; + import org.monster.debugger.chat.impl.GameSpeedAdjuster; import org.monster.debugger.chat.impl.StrategyChanger; import org.monster.debugger.chat.impl.StrikeLevelAdjuster; +import org.monster.debugger.chat.impl.UxListAddMinus; import org.monster.debugger.chat.impl.UxOptionChanger; import java.util.ArrayList; @@ -16,10 +18,13 @@ public class ChatBot { /***************************************************************************** * 설명 * - * 1) 게임스피드 조절 : s + 숫자 ex) s0=매우빠름, s24=bot경기스피드, s42=fastest - * 2) UX 타입 변경 : d + 숫자 ex) d1=?, d0=prebot1 display - * 3) 전략 변경 : $ + 전략명 ex) $TERRAN INIT - * 4) 레이쓰 공격레벨 변경 : w + 숫자 ex) w1 + * 1) 게임스피드 조절 : s + 숫자 ex) s0=매우빠름, s24=bot경기스피드, s42=fastest + * 2) UX 타입 변경 : d + 숫자 ex) d1=?, d0=prebot1 display + * 3) 전략 변경 : $ + 전략명 ex) $TERRAN INIT + * 4) 레이쓰 공격레벨 변경 : w + 숫자 ex) w1 + * 5) 디버깅 변수 추가 : a + class + 변수 ex) a strategyBoard startStrategy + * 5) 디버깅 변수 제거 : m + 변수이름 ex) m startStrategy + * 6) 디버깅 초기화 * *****************************************************************************/ static { @@ -27,6 +32,8 @@ public class ChatBot { chatExecuters.add(new UxOptionChanger('d')); chatExecuters.add(new StrategyChanger('$')); chatExecuters.add(new StrikeLevelAdjuster('w')); + chatExecuters.add(new UxListAddMinus('a')); + chatExecuters.add(new UxListAddMinus('m')); } public static void addChatExecuter(ChatExecuter chatExecuter) { @@ -45,10 +52,10 @@ public static void operateChatBot(String command) { char type = command.charAt(0); String option = command.substring(1); - + for (ChatExecuter executer : chatExecuters) { if (executer.isExecuteCharacter(type)) { - executer.execute(option); + executer.execute(option); break; } } diff --git a/src/main/java/org/monster/debugger/chat/ChatExecuter.java b/src/main/java/org/monster/debugger/chat/ChatExecuter.java index 51e2499..2018d3d 100644 --- a/src/main/java/org/monster/debugger/chat/ChatExecuter.java +++ b/src/main/java/org/monster/debugger/chat/ChatExecuter.java @@ -8,8 +8,12 @@ public abstract class ChatExecuter { public ChatExecuter(char ch) { this.type = Character.toLowerCase(ch); } + + public char getType() { + return type; + } - public boolean isExecuteCharacter(char ch) { + public boolean isExecuteCharacter(char ch) { return this.type == Character.toLowerCase(ch); } diff --git a/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java b/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java new file mode 100644 index 0000000..e165917 --- /dev/null +++ b/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java @@ -0,0 +1,136 @@ +package org.monster.debugger.chat.impl; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; + +import org.monster.board.StrategyBoard; +import org.monster.debugger.UxColor; +import org.monster.worker.WorkerManager; + +public class UxDrawConfig { + + static Map> classMap = new HashMap<>(); + static { + classMap.put("STRATEGYBOARD", StrategyBoard.class); + classMap.put("WORKERMANAGER", WorkerManager.class); + } + + public static Map posMap = new HashMap<>(); + static { + posMap.put("L", 20); + posMap.put("M", 250); + posMap.put("R", 500); + + } + + private char color; + private Class clazz; + private Field field; + + private int pos = posMap.get("L"); + + public void setPos(int pos) { + this.pos = pos; + } + + public int getPos() { + return pos; + } + + private String key; + private Object value; + + + public char getColor() { + return color; + } + + public void setColor(char color) { + this.color = color; + } + + private UxDrawConfig(Class clazz, Field field, char color) { + this.clazz = clazz; + this.field = field; + this.color = color; + + } + + private UxDrawConfig(String key, Object value, char color) { + this.key = key; + this.value = value; + this.color = color; + + } + + public UxDrawConfig(String pos, String key, Object value, char color) { + this.pos = posMap.get(pos.toUpperCase()); + this.key = key; + this.value = value; + this.color = color; + // TODO Auto-generated constructor stub + } + + public static UxDrawConfig newInstanceClassType(Class clazz, Field field, char color) { + return new UxDrawConfig(clazz, field, color); + } + + public static UxDrawConfig newInstanceClassType(String pos,String key, Object value, char color) { + return new UxDrawConfig(pos, key, value, color); + } + + public static UxDrawConfig newInstanceObjectType(String pos, String key, Object value) { + return newInstanceObjectType(pos, key, value, UxColor.CHAR_YELLOW); + } + + public static UxDrawConfig newInstanceObjectType(String key, Object value, char color) { + return new UxDrawConfig(key, value, color); + } + + public static UxDrawConfig newInstanceObjectType(String pos,String key, Object value, char color) { + return new UxDrawConfig(pos, key, value, color); + } + + public String getClassFieldName() { + if (clazz != null) { + return this.clazz.getSimpleName() + "." + this.field.getName(); + } else if(this.key.equals("")){ + return this.value.toString(); + }else{ + return this.key + " : " + this.value.toString(); + } + } + + public String getFieldName() { + if (this.field == null) { + return ""; + } else { + return field.toString(); + } + } + + public String getValue() { + if (this.value == null) { + return ""; + } else { + return value.toString(); + } + } + + + public Class getClazz() { + return this.clazz; + } + + public String getKey() { + return this.key; + } + + public void setClazz(String className) { + this.clazz = classMap.get(className.toUpperCase()); + } + + /// 일꾼 유닛에게 지정하는 임무의 종류 + +}; \ No newline at end of file diff --git a/src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java b/src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java new file mode 100644 index 0000000..924f6bc --- /dev/null +++ b/src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java @@ -0,0 +1,39 @@ +package org.monster.debugger.chat.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.monster.board.StrategyBoard; +import org.monster.debugger.PreBotUXManager; +import org.monster.debugger.UxColor; +import org.monster.debugger.chat.ChatExecuter; + +public class UxListAddMinus extends ChatExecuter { + public UxListAddMinus(char type) { + super(type); + // TODO Auto-generated constructor stub + } + + @Override + public void execute(String option) { + // TODO Auto-generated method stub + if('a' == getType()){ + String pos = option.split(" ")[1]; + String key = option.split(" ")[2]; + String value = option.split(" ")[3]; + + UxDrawConfig ux = UxDrawConfig.newInstanceClassType(pos,key,value,UxColor.CHAR_GREEN); + PreBotUXManager.Instance().drawStrategyListOrigin[PreBotUXManager.Instance().getUxOption()].add(ux); + }else if('m' == getType()){ + for (UxDrawConfig drawList : PreBotUXManager.Instance().drawStrategyListOrigin[PreBotUXManager.Instance().getUxOption()]) { + if(drawList.getFieldName().equals(option.split(" ")[1]) + || drawList.getValue().equals(option.split(" ")[1])){ + PreBotUXManager.Instance().drawStrategyListOrigin[PreBotUXManager.Instance().getUxOption()].remove(drawList); + } + } + } + + } + +} From b10d638e390a2be68ed15012c0a7d20a5e063959 Mon Sep 17 00:00:00 2001 From: staeminba Date: Wed, 20 Feb 2019 23:34:18 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[debugging]=20debuging=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/monster/debugger/PreBotUXManager.java | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/monster/debugger/PreBotUXManager.java b/src/main/java/org/monster/debugger/PreBotUXManager.java index c413e7c..8a2749b 100644 --- a/src/main/java/org/monster/debugger/PreBotUXManager.java +++ b/src/main/java/org/monster/debugger/PreBotUXManager.java @@ -116,7 +116,7 @@ public PreBotUXManager() { initDisplay1(); } - public void onStart(Game Broodwar) throws ClassNotFoundException, NoSuchFieldException, SecurityException, NoSuchMethodException { + public void onStart(Game Broodwar){ for (int i = 0; i(); } @@ -162,10 +162,10 @@ public static PreBotUXManager Instance() { public int option = 0; public void update() { - if(player.getName().equals("staeminba")){ getSMDisplay(); } + getSMDisplay(); } @@ -346,12 +346,10 @@ private void drawDebugginUxMenu() { } // 게임 개요 정보를 Screen 에 표시합니다 - public void drawGameInformationOnScreen(int x, int y) { + public void drawGameInformationOnScreen() { uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","Current Strategy",StrategyBoard.currentStrategy.name(),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - y = 10; - String history = ""; for (int i = StrategyBoard.strategyHistory.size() - 1; i >= 0; i--) { if (i == StrategyBoard.strategyHistory.size() - 3) { @@ -831,7 +829,7 @@ public void drawMapGrid() { } /// BuildOrderQueue 를 Screen 에 표시합니다 - public void drawBuildOrderQueueOnScreen(int x, int y) { + public void drawBuildOrderQueueOnScreen() { char initialFinishedColor; Deque buildQueue = BuildManager.Instance().buildQueue.getQueue(); @@ -851,7 +849,7 @@ public void drawBuildOrderQueueOnScreen(int x, int y) { } /// Build 진행 상태를 Screen 에 표시합니다 - public void drawBuildStatusOnScreen(int x, int y) { + public void drawBuildStatusOnScreen() { // 건설 / 훈련 중인 유닛 진행상황 표시 Vector unitsUnderConstruction = new Vector(); for (Unit unit : Broodwar.self().getUnits()) { @@ -877,7 +875,6 @@ public void drawBuildStatusOnScreen(int x, int y) { int reps = unitsUnderConstruction.size() < 10 ? unitsUnderConstruction.size() : 10; for (Unit unit : unitsUnderConstruction) { - y += 10; UnitType t = unit.getType(); if (t == UnitType.Zerg_Egg) { t = unit.getBuildType(); @@ -1660,7 +1657,7 @@ public void drawTurretMap() { //// radius1 + turretCount * 15 } - private void addDrawStrategyListOrigin() throws IllegalArgumentException, IllegalAccessException{ + private void addDrawStrategyListOrigin() throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException{ // TODO Auto-generated method stub if(!drawStrategyListOrigin[uxOption].isEmpty()){ UxDrawConfig uxDrawConfig; @@ -1671,14 +1668,14 @@ private void addDrawStrategyListOrigin() throws IllegalArgumentException, Illega Field fld = null; try{ fld = c.getDeclaredField(drwaConfig.getValue()); - if (!fld.isAccessible()) fld.setAccessible(true); - fld.get(drwaConfig.getValue()); - - + if (!fld.isAccessible()) { + fld.setAccessible(true); + } } catch (Exception e) { + System.out.println(e.getMessage()); continue; } - uxDrawConfig = UxDrawConfig.newInstanceObjectType(fld.getName(),fld.get(c).toString(),drwaConfig.getColor()); + uxDrawConfig = UxDrawConfig.newInstanceObjectType(fld.getName(),fld.get(drwaConfig.getValue()),drwaConfig.getColor()); uxDrawConfig.setPos(drwaConfig.getPos()); if(drwaConfig.getPos() == UxDrawConfig.posMap.get("L")){ drawStrategyLeftList.add(uxDrawConfig); @@ -1748,7 +1745,7 @@ private void drawStrategyList() { /* * 사용자 별 화면 */ - public void getSMDisplay(){ + public void getSMDisplay() { if (uxOption == 0) { clearList(); drawDebugginUxMenu(); @@ -1759,10 +1756,10 @@ public void getSMDisplay(){ // 미네랄PATH } else if (uxOption == 2) { clearList(); - drawGameInformationOnScreen(5, 5); + drawGameInformationOnScreen(); drawBWTAResultOnMap(); - drawBuildOrderQueueOnScreen(500, 50); - drawBuildStatusOnScreen(370, 50); + drawBuildOrderQueueOnScreen(); + drawBuildStatusOnScreen(); drawReservedBuildingTilesOnMap(); drawTilesToAvoidOnMap(); drawWorkerMiningStatusOnMap(); @@ -1819,13 +1816,20 @@ public void getSMDisplay(){ drawPathData(); drawSquadUnitTagMap(); - addDrawStrategyListOrigin(); + try { + addDrawStrategyListOrigin(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } drawStrategyList(); clearDecisionListForUx(); } - public void getJwDisplay() throws Exception { - } - - } \ No newline at end of file From 2e7eea532b86b1b4b377c3aa5eec09b13aac9ca9 Mon Sep 17 00:00:00 2001 From: staeminba Date: Sun, 3 Mar 2019 23:05:01 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[debugging]=20debuging=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/monster/debugger/PreBotUXManager.java | 694 +++--------------- .../java/org/monster/debugger/ScreenUx.java | 103 +++ .../java/org/monster/debugger/UXManager.java | 105 --- .../org/monster/debugger/chat/ChatBot.java | 2 +- .../debugger/chat/impl/UxDrawConfig.java | 98 ++- .../debugger/chat/impl/UxListAddMinus.java | 2 +- 6 files changed, 276 insertions(+), 728 deletions(-) create mode 100644 src/main/java/org/monster/debugger/ScreenUx.java diff --git a/src/main/java/org/monster/debugger/PreBotUXManager.java b/src/main/java/org/monster/debugger/PreBotUXManager.java index 8a2749b..0a3a632 100644 --- a/src/main/java/org/monster/debugger/PreBotUXManager.java +++ b/src/main/java/org/monster/debugger/PreBotUXManager.java @@ -1,6 +1,8 @@ package org.monster.debugger; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -36,6 +38,7 @@ import org.monster.common.util.TimeUtils; import org.monster.common.util.UnitTypeUtils; import org.monster.common.util.UnitUtils; +import org.monster.common.util.internal.GameMap; import org.monster.debugger.chat.impl.UxDrawConfig; import org.monster.micro.CombatManager; import org.monster.micro.MicroDecision; @@ -74,14 +77,11 @@ /// 여러 Manager 들로부터 정보를 조회하여 Screen 혹은 Map 에 정보를 표시합니다 public class PreBotUXManager { - private static final int JW = 2; - private static final int KK = 3; - private static PreBotUXManager instance = new PreBotUXManager(); private final int dotRadius = 2; public Unit leader = null; - private int uxOption = 0; + public int uxOption = 0; private boolean hasSavedBWTAInfo = false; private int[][] blue = null; private int[][] cyan = null; @@ -94,8 +94,7 @@ public class PreBotUXManager { private List red2 = new ArrayList(); private String bulletTypeName = ""; private String tempUnitName = ""; - private Game Broodwar; - private Player player; + protected Game Broodwar; private int L = UxDrawConfig.posMap.get("L"); private int M = UxDrawConfig.posMap.get("M"); private int R = UxDrawConfig.posMap.get("R"); @@ -112,63 +111,25 @@ public class PreBotUXManager { private Map decisionListForUx = new HashMap<>(); public PreBotUXManager() { - initDisplay0(); - initDisplay1(); } public void onStart(Game Broodwar){ for (int i = 0; i(); } - this.Broodwar = Broodwar; - player = Broodwar.self(); - System.out.println("player.getName() : " + player.getName()); - + this.Broodwar = Broodwar; } - - private void initDisplay0() { - Displayer displayer = new Displayer(); - displayers.add(displayer); - } - private void initDisplay1() { - Displayer displayer = new Displayer(); - displayers.add(displayer); - } - - // TestUxManager.getJwDisplayer(); - // TestUxManager.getDisplayer(1); - // TestUxManager.getDisplayer(2); // 0..1 : default // 2..3 : custom - private List displayers = new ArrayList<>(); - - public Displayer getJwDisplayer() { - return displayers.get(JW); - } - - public Displayer getkKDisplayer() { - return displayers.get(KK); - } - /// static singleton 객체를 리턴합니다 public static PreBotUXManager Instance() { return instance; } - public int option = 0; - - public void update() { - if(player.getName().equals("staeminba")){ - getSMDisplay(); - } - getSMDisplay(); - - } - public void setUxOption(int uxOption) { this.uxOption = uxOption; } @@ -176,48 +137,48 @@ public void setUxOption(int uxOption) { public int getUxOption() { return uxOption; } + + public void update() { + ScreenUx.showDisplay(); + } + + - private void drawUxInfo() { + protected void drawUxInfo() { // TODO Auto-generated method stub int y = 10; //setting - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","/*****************************************************************************",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","/*****************************************************************************",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","*",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","*",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 2) UX Type Change : d + num ex) d1=?, d0=prebot1 display",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 1) UX Type Change : d + num ex) d1=?, d0=prebot1 display",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 3) Change Strategy : $ + Strategy Name ex) $ INIT",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 2) Change Strategy : $ + Strategy Name ex) $ INIT",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - //uxDrawConfig= new UxDrawConfig("* 4) 레이쓰 공격레벨 변경 : w + 숫자 ex) w1"); - //drawStrategyList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 4) add Var : a + pos + class + var ex) a L(R/M) strategyBoard startStrategy",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 3) add Var : a + pos + class + var ex) a L(R/M) strategyBoard startStrategy",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","* 5) minus Var : m + var ex) m startStrategy",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 4) minus Var : m + var ex) m startStrategy",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - //uxDrawConfig= new UxDrawConfig("* 6) 디버깅 초기화"); - //drawStrategyList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","*",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","*",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","*****************************************************************************///",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","*****************************************************************************///",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); } - private void clearList() { + public void clearList() { // TODO Auto-generated method stub drawStrategyLeftList.clear(); drawStrategyMidList.clear(); @@ -243,12 +204,12 @@ public void clearDecisionListForUx() { decisionListForUx.clear(); } - private void drawTimer() { + protected void drawTimer() { char battleColor = UxColor.CHAR_WHITE; if (StrategyBoard.initiated) { battleColor = UxColor.CHAR_RED; } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",StrategyBoard.mainSquadMode.toString() + ": " + DrawingUtils.framesToTimeString(TimeUtils.getFrame()) + "(" + TimeUtils.getFrame() + ")",battleColor); + uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",StrategyBoard.mainSquadMode.toString() + ": " + DrawingUtils.framesToTimeString(TimeUtils.getFrame()) + "(" + TimeUtils.getFrame() + ")",battleColor); drawStrategyMidList.add(uxDrawConfig); char apmColor = UxColor.CHAR_WHITE; @@ -262,37 +223,36 @@ private void drawTimer() { } else { apmColor = UxColor.CHAR_WHITE; } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","APM : " + Broodwar.getAPM(),apmColor); + uxDrawConfig = UxDrawConfig.newInstanceStringType("R","APM : ",Broodwar.getAPM(),apmColor); drawStrategyRightList.add(uxDrawConfig); } - private void drawEnemyBuildTimer(){ + protected void drawEnemyBuildTimer(){ Map buildTimeExpectMap = EnemyBuildTimer.Instance().buildTimeExpectMap; Map buildTimeMinimumMap = EnemyBuildTimer.Instance().buildTimeMinimumMap; Set buildTimeCertain = EnemyBuildTimer.Instance().buildTimeCertain; - int y = 20; - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","engine Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.engineeringBayBuildStartFrame),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","engine Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.engineeringBayBuildStartFrame),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","turret Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretBuildStartFrame),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","turret Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretBuildStartFrame),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","turret Need Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretNeedFrame),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","turret Need Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretNeedFrame),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","darkTemplarInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().darkTemplarInMyBaseFrame),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","darkTemplarInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().darkTemplarInMyBaseFrame),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","reaverInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().reaverInMyBaseFrame),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","reaverInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().reaverInMyBaseFrame),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","mutaliskInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().mutaliskInMyBaseFrame),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","mutaliskInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().mutaliskInMyBaseFrame),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","lurkerInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().lurkerInMyBaseFrame),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","lurkerInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().lurkerInMyBaseFrame),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); for (UnitType unitType : buildTimeExpectMap.keySet()) { @@ -304,50 +264,39 @@ private void drawEnemyBuildTimer(){ if (buildMinimum != null && buildMinimum != CommonCode.UNKNOWN) { minimum = DrawingUtils.framesToTimeString(buildMinimum); } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","",unitType + " : " + expect + " - min: " + minimum + " (" + buildTimeCertain.contains(unitType) + ")",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","",unitType + " : " + expect + " - min: " + minimum + " (" + buildTimeCertain.contains(unitType) + ")",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); } } - /*for(UxDrawConfig uxDraw : drawStrategyLeftList){ - int lineCnt = 1; - int fromIndex = -1; - while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { - lineCnt++; - } - Broodwar.drawTextScreen(L, y, UxColor.CHAR_YELLOW + uxDraw.getClassFieldName()); - y += (lineCnt*12); - }*/ - - } - private void drawDebugginUxMenu() { - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","1. Default Information",UxColor.CHAR_WHITE); + protected void drawDebugginUxMenu() { + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","1. Default Information",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","2. Strategy Information",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","2. Strategy Information",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","3. Position Finder Test",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","3. Position Finder Test",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","4. Air Micro Test",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","4. Air Micro Test",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","5. Unit Bast To Base",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","5. Unit Bast To Base",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceObjectType("L","","",UxColor.CHAR_WHITE); + uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); } // 게임 개요 정보를 Screen 에 표시합니다 public void drawGameInformationOnScreen() { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","Current Strategy",StrategyBoard.currentStrategy.name(),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","Current Strategy",StrategyBoard.currentStrategy.name(),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); String history = ""; @@ -360,41 +309,19 @@ public void drawGameInformationOnScreen() { } } - /*int vultureCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Vulture); - int tankCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Siege_Tank_Tank_Mode, UnitType.Terran_Siege_Tank_Siege_Mode); - int goliathCount = UnitUtils.getUnitCount(UnitFindStatus.ALL, UnitType.Terran_Goliath);*/ - -// UnitType selected = BuildQueueProvider.Instance().getFactoryUnitSelector().getSelected(); -// if (selected != UnitType.None) { -// factorySelected = selected; -// } - - - /* Broodwar.drawTextScreen(x + 100, y + 5, UxColor.CHAR_TEAL + "" + vultureCount + " " + tankCount + " " + goliathCount); - Broodwar.drawTextScreen(x, y, "" + UxColor.CHAR_WHITE + StrategyBoard.factoryRatio + ", selected=" + factorySelected); - y += 11; - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Wraith Count : "); - Broodwar.drawTextScreen(x + 75, y, "" + UxColor.CHAR_WHITE + StrategyBoard.wraithCount + " / " + UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_Wraith)); - y += 11; - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + "Valkyrie Count : "); - Broodwar.drawTextScreen(x + 75, y, "" + UxColor.CHAR_WHITE + StrategyBoard.valkyrieCount + " / " + UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_Valkyrie)); - y += 11;*/ - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","MYKillScore",Broodwar.self().getKillScore(),UxColor.CHAR_RED); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","MYKillScore",Broodwar.self().getKillScore(),UxColor.CHAR_RED); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","MYRazingScore",Broodwar.self().getRazingScore(),UxColor.CHAR_RED); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","MYRazingScore",Broodwar.self().getRazingScore(),UxColor.CHAR_RED); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","EnemyKillScore",Broodwar.enemy().getKillScore(),UxColor.CHAR_PURPLE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","EnemyKillScore",Broodwar.enemy().getKillScore(),UxColor.CHAR_PURPLE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","EnemyRazingScore",Broodwar.enemy().getRazingScore(),UxColor.CHAR_PURPLE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","EnemyRazingScore",Broodwar.enemy().getRazingScore(),UxColor.CHAR_PURPLE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","Reserved Resource",ConstructionManager.Instance().getReservedMinerals()+ " / " + ConstructionManager.Instance().getReservedGas(),UxColor.CHAR_TEAL); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","Reserved Resource",ConstructionManager.Instance().getReservedMinerals()+ " / " + ConstructionManager.Instance().getReservedGas(),UxColor.CHAR_TEAL); drawStrategyLeftList.add(uxDrawConfig); } @@ -560,104 +487,8 @@ public void drawUnitExtendedInformationOnMap() { } } - /// UnitType 별 통계 정보를 Screen 에 표시합니다 - public void drawUnitStatisticsOnScreen1(int x, int y) { - int currentY = y; - - // 아군이 입은 피해 누적값 - currentY += 10; - - // 아군 모든 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " allUnitCount: " + UnitUtils.getUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 건설/훈련 완료한 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " completedUnitCount: " + UnitUtils.getCompletedUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 건설/훈련중인 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " incompleteUnitCount: " + Broodwar.self().incompleteUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 유닛 파괴/사망 숫자 누적값 - //Broodwar.drawTextScreen(x, currentY, white + " deadUnitCount: " + Broodwar.self().deadUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 상대방 유닛을 파괴/사망 시킨 숫자 누적값 - //Broodwar.drawTextScreen(x, currentY, white + " killedUnitCount: " + Broodwar.self().killedUnitCount(UnitType.AllUnits)); - //currentY += 10; - - //Broodwar.drawTextScreen(x, currentY, white + " UnitScore: " + Broodwar.self().getUnitScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " RazingScore: " + Broodwar.self().getRazingScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " BuildingScore: " + Broodwar.self().getBuildingScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " KillScore: " + Broodwar.self().getKillScore()); - //currentY += 10; - } - - /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 public void drawBWTAResultOnMap() { - /*//we will iterate through all the base locations, and draw their outlines. - // C+ . for (std.set.const_iterator i = BWTA.getBaseLocations().begin(); i != BWTA.getBaseLocations().end(); i++) - for(BaseLocation baseLocation : BWTA.getBaseLocations()) - { - TilePosition p = baseLocation.getTilePosition(); - Position c = baseLocation.getPosition(); - - //draw outline of Base location - Broodwar.drawBoxMap(p.getX() * 32, p.getY() * 32, p.getX() * 32 + 4 * 32, p.getY() * 32 + 3 * 32, Color.Blue); - - //draw a circle at each mineral patch - // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) - for(Unit unit : baseLocation.getStaticMinerals()) - { - Position q = unit.getInitialPosition(); - Broodwar.drawCircleMap(q.getX(), q.getY(), 30, Color.Cyan); - } - - //draw the outlines of vespene geysers - // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) - for(Unit unit :baseLocation.getGeysers() ) - { - TilePosition q = unit.getInitialTilePosition(); - Broodwar.drawBoxMap(q.getX() * 32, q.getY() * 32, q.getX() * 32 + 4 * 32, q.getY() * 32 + 2 * 32, Color.Orange); - } - - //if this is an island expansion, draw a yellow circle around the base location - if (baseLocation.isIsland()) - { - Broodwar.drawCircleMap(c, 80, Color.Yellow); - } - } - - //we will iterate through all the regions and draw the polygon outline of it in green. - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for(Region region : BWTA.getRegions()) - { - Polygon p = region.getPolygon(); - for (int j = 0; j.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for(Region region : BWTA.getRegions()) - { - // C++ : for (std.set.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) - for(Chokepoint Chokepoint : region.getChokepoints()) - { - Position point1 = Chokepoint.getSides().first; - Position point2 = Chokepoint.getSides().second; - Broodwar.drawLineMap(point1, point2, Color.Red); - } - }*/ int blueCount = 0; int cyanCount = 0; int orangeCount = 0; @@ -830,7 +661,6 @@ public void drawMapGrid() { /// BuildOrderQueue 를 Screen 에 표시합니다 public void drawBuildOrderQueueOnScreen() { - char initialFinishedColor; Deque buildQueue = BuildManager.Instance().buildQueue.getQueue(); int itemCount = 0; @@ -841,7 +671,7 @@ public void drawBuildOrderQueueOnScreen() { BuildOrderItem currentItem = (BuildOrderItem) tempQueue[i]; //Broodwar.drawTextScreen(x, y + 10 + (itemCount * 10), currentItem.blocking + " " + UxColor.CHAR_WHITE + currentItem.metaType.getName()); UxDrawConfig uxDrawConfig; - uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",currentItem.blocking + " " + currentItem.metaType.getName(),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",currentItem.blocking + " " + currentItem.metaType.getName(),UxColor.CHAR_WHITE); drawStrategyMidList.add(uxDrawConfig); itemCount++; if (itemCount >= 24) break; @@ -869,18 +699,16 @@ public void drawBuildStatusOnScreen() { //Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + " "); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R",""," ",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("R",""," ",UxColor.CHAR_WHITE); drawStrategyRightList.add(uxDrawConfig); - int reps = unitsUnderConstruction.size() < 10 ? unitsUnderConstruction.size() : 10; for (Unit unit : unitsUnderConstruction) { UnitType t = unit.getType(); if (t == UnitType.Zerg_Egg) { t = unit.getBuildType(); } - //Broodwar.drawTextScreen(x, y, "" + UxColor.CHAR_WHITE + t + " (" + unit.getRemainingBuildTime() + ")"); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","" + t + " (" + unit.getRemainingBuildTime() + ")",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("R","","" + t + " (" + unit.getRemainingBuildTime() + ")",UxColor.CHAR_WHITE); drawStrategyRightList.add(uxDrawConfig); } @@ -948,25 +776,22 @@ public void drawTilesToAvoidOnMap() { /// ConstructionQueue 를 Screen 에 표시합니다 public void drawConstructionQueueOnScreenAndMap() { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("M",""," ",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("M",""," ",UxColor.CHAR_WHITE); drawStrategyMidList.add(uxDrawConfig); - int yspace = 0; Vector constructionQueue = ConstructionManager.Instance().getConstructionQueue(); for (final ConstructionTask b : constructionQueue) { - String constructionState = ""; - if (b.getStatus() == ConstructionTask.ConstructionStatus.Unassigned.ordinal()) { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","","" + b.getType() + " - No Worker",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("M","","" + b.getType() + " - No Worker",UxColor.CHAR_WHITE); drawStrategyMidList.add(uxDrawConfig); } else if (b.getStatus() == ConstructionTask.ConstructionStatus.Assigned.ordinal()) { if (b.getConstructionWorker() == null) { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",b.getType() + " - Assigned Worker Null",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",b.getType() + " - Assigned Worker Null",UxColor.CHAR_WHITE); drawStrategyMidList.add(uxDrawConfig); } else { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","",b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")",UxColor.CHAR_WHITE); drawStrategyMidList.add(uxDrawConfig); } @@ -978,60 +803,12 @@ public void drawConstructionQueueOnScreenAndMap() { Broodwar.drawLineMap(b.getConstructionWorker().getPosition().getX(), b.getConstructionWorker().getPosition().getY(), (x1 + x2) / 2, (y1 + y2) / 2, Color.Orange); Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); } else if (b.getStatus() == ConstructionTask.ConstructionStatus.UnderConstruction.ordinal()) { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("M","","" + b.getType() + " - Under Construction",UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("M","","" + b.getType() + " - Under Construction",UxColor.CHAR_WHITE); drawStrategyMidList.add(uxDrawConfig); } - yspace++; } } - public void drawnextPoints() { - -// Position nextEX = InformationManager.Instance().getNextExpansionLocation().getPosition(); -// Position nextBuild = InformationManager.Instance().getLastBuildingLocation().toPosition(); -// Position lastBuild2 = InformationManager.Instance().getLastBuildingLocation2().toPosition(); - -// BaseLocation getExpansionLocation = InformationManager.Instance().getExpansionLocation; -// BaseLocation secondStartPosition = null;//InformationManager.Instance().getSecondStartPosition(); -// TilePosition getLastBuildingLocation = InformationManager.Instance().getLastBuildingLocation; -// TilePosition getLastBuildingFinalLocation = InformationManager.Instance().getLastBuildingFinalLocation; - // - // -// if (secondStartPosition != null) { -// Broodwar.drawTextScreen(10, 120, "secondStartPosition: " + secondStartPosition.getTilePosition()); -// Broodwar.drawTextMap(secondStartPosition.getPosition(), "secondStartPosition"); -// } else { -// Broodwar.drawTextScreen(10, 120, "secondStartPosition: null"); -// } -// if (getExpansionLocation != null) { -// Broodwar.drawTextScreen(10, 130, "getExpansionLocation: " + getExpansionLocation.getTilePosition()); -// Broodwar.drawTextMap(getExpansionLocation.getPosition(), "nextEX"); -// } else { -// Broodwar.drawTextScreen(10, 130, "getExpansionLocation: null"); -// } -// if (getLastBuildingLocation != null) { -// Broodwar.drawTextScreen(10, 140, "getLastBuildingLocation: " + getLastBuildingLocation); -// Broodwar.drawTextMap(getLastBuildingLocation.toPosition(), "nextBuild"); -// } else { -// Broodwar.drawTextScreen(10, 140, "getLastBuildingLocation: null"); -// } -// if (getLastBuildingFinalLocation != null) { -// Broodwar.drawTextScreen(10, 150, "getLastBuildingFinalLocation: " + getLastBuildingFinalLocation); -// Broodwar.drawTextMap(getLastBuildingFinalLocation.toPosition(), "LastBuild"); -// } else { -// Broodwar.drawTextScreen(10, 150, "getLastBuildingFinalLocation: null"); -// } - // - // -// Broodwar.drawTextScreen(10, 160, "mainBaseLocationFull: " + BuildManager.Instance().mainBaseLocationFull); -// Broodwar.drawTextScreen(10, 170, "secondChokePointFull: " + BuildManager.Instance().secondChokePointFull); -// Broodwar.drawTextScreen(10, 180, "secondStartLocationFull: " + BuildManager.Instance().secondStartLocationFull); -// Broodwar.drawTextScreen(10, 190, "fisrtSupplePointFull: " + BuildManager.Instance().fisrtSupplePointFull); - // -// Broodwar.drawTextScreen(10, 200, "myMainbaseLocation : " + BaseUtils.myMainBase().getTilePosition()); -// Broodwar.drawTextScreen(10, 210, "enemyMainbaseLocation : " + BaseUtils.enemyMainBase().getTilePosition()); - - } public void drawMineralIdOnMap() { @@ -1057,57 +834,6 @@ public void drawUnitIdOnMap() { } } - public void drawLeaderUnitOnMap() { - -// -// if(leader!=null){ -// for (Unit unit : Broodwar.self().getUnits()) -// { -// if(unit.getID() == leader.getID()) -// Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + blue + "LEADER"); -// } -// } - } - - /// Worker Unit 들의 상태를 Screen 에 표시합니다 - public void drawWorkerStateOnScreen(int x, int y) { - WorkerData workerData = WorkerManager.Instance().getWorkerData(); - - Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + ""); - - int yspace = 0; - - for (Unit unit : workerData.getWorkers()) { - if (unit == null) continue; - - // Mineral / Gas / Idle Worker 는 표시 안한다 - if (workerData.getJobCode(unit) == 'M' || workerData.getJobCode(unit) == 'I' || workerData.getJobCode(unit) == 'G') { - continue; - } - - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), UxColor.CHAR_WHITE + " " + unit.getID()); - - if (workerData.getJobCode(unit) == 'B') { - Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), UxColor.CHAR_WHITE + " " + workerData.getJobCode(unit) + " " + unit.getBuildType() + " " + (unit.isConstructing() ? 'Y' : 'N') + " (" + unit.getTilePosition().getX() + ", " + unit.getTilePosition().getY() + ")"); - } else { - Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), UxColor.CHAR_WHITE + " " + workerData.getJobCode(unit)); - } - } - } - - /// ResourceDepot 별 Worker 숫자를 Map 에 표시합니다 - public void drawWorkerCountOnMap() { - for (Unit depot : WorkerManager.Instance().getWorkerData().getDepots()) { - if (depot == null) continue; - - int x = depot.getPosition().getX() - 64; - int y = depot.getPosition().getY() - 32; - - Broodwar.drawBoxMap(x - 2, y - 1, x + 75, y + 14, Color.Black, true); - Broodwar.drawTextMap(x, y, UxColor.CHAR_WHITE + " Workers: " + WorkerManager.Instance().getWorkerData().getNumAssignedWorkers(depot)); - } - } - /// Worker Unit 의 자원채취 현황을 Map 에 표시합니다 public void drawWorkerMiningStatusOnMap() { WorkerData workerData = WorkerManager.Instance().getWorkerData(); @@ -1121,26 +847,6 @@ public void drawWorkerMiningStatusOnMap() { Broodwar.drawLineMap(worker.getPosition().getX(), worker.getPosition().getY(), pos.getX(), pos.getY(), Color.Cyan); - /* - // ResourceDepot ~ Worker 사이에 직선 표시 - BWAPI.Unit depot = workerData.getWorkerDepot(worker); - if (depot) { - Monster.game.drawLineMap(worker.getPosition().x, worker.getPosition().y, depot.getPosition().x, depot.getPosition().y, Color.Orange); - } - */ - } - } - - /// 정찰 상태를 Screen 에 표시합니다 - public void drawScoutInformation(int x, int y) { - - // get the enemy base location, if we have one - BaseLocation enemyBaseLocation = BaseUtils.enemyMainBase(); - - if (enemyBaseLocation != null) { - Broodwar.drawTextScreen(x, y, "Enemy MainBaseLocation : (" + enemyBaseLocation.getTilePosition().getX() + ", " + enemyBaseLocation.getTilePosition().getY() + ")"); - } else { - Broodwar.drawTextScreen(x, y, "Enemy MainBaseLocation : Unknown"); } } @@ -1217,7 +923,7 @@ public void drawBulletsOnMap() { } } - private void drawSquadUnitTagMap() { + protected void drawSquadUnitTagMap() { // draw neutral units and our units for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { Color color = UxColor.SQUAD_COLOR.get(squad.getClass()); @@ -1243,22 +949,10 @@ private void drawSquadUnitTagMap() { } } -// Map checkerSiteMap = VultureTravelManager.Instance().getCheckerSiteMap2(); -// List baseList = VultureTravelManager.Instance().getBaseLocationsCheckerOrdered(); -// for (Integer checkerId : checkerSiteMap.keySet()) { -// Unit unit = Broodwar.getUnit(checkerId); -// if (UnitUtils.isValidUnit(unit)) { -// Integer index = checkerSiteMap.get(checkerId); -// if (index != null) { -// Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 5, UxColor.CHAR_ORANGE + baseList.get(index).getPosition().toString()); -// } - // -// } -// } } } - private void drawSquadInfoOnMap() { + /* private void drawSquadInfoOnMap() { /// ConstructionQueue 를 Screen 에 표시합니다 uxDrawConfig = UxDrawConfig.newInstanceObjectType("L",""," ",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); @@ -1281,9 +975,9 @@ private void drawSquadInfoOnMap() { uxDrawConfig = UxDrawConfig.newInstanceObjectType("L",squadName," "+ "" + squad.unitList.size() + unitIds,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); } - } + }*/ - private void drawManagerTimeSpent() { + protected void drawManagerTimeSpent() { List gameManagers = Arrays.asList( //InformationManager.Instance(), StrategyManager.Instance(), @@ -1304,24 +998,23 @@ private void drawManagerTimeSpent() { } else if (gameManager.getRecorded() > 30L) { drawColor = UxColor.CHAR_RED; } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R",gameManager.getClass().getSimpleName()+drawColor,gameManager.getRecorded(),UxColor.CHAR_PURPLE); + uxDrawConfig = UxDrawConfig.newInstanceStringType("R",gameManager.getClass().getSimpleName(),gameManager.getRecorded(),UxColor.CHAR_PURPLE); drawStrategyRightList.add(uxDrawConfig); } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","* group size: " + LagObserver.groupsize(),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceMethodType("R","* group size",LagObserver.class, "groupsize",UxColor.CHAR_WHITE); drawStrategyRightList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","* manager rotation size: " + LagObserver.managerRotationSize(),UxColor.CHAR_WHITE); + uxDrawConfig = UxDrawConfig.newInstanceMethodType("R","* manager rotation size",LagObserver.class,"managerRotationSize",UxColor.CHAR_WHITE); drawStrategyRightList.add(uxDrawConfig); } - private void drawBigWatch() { + /*private void drawBigWatch() { Map resultTimeMap = BigWatch.getResultTimeMap(); Map recordTimeMap = BigWatch.getRecordTimeMap(); List tags = new ArrayList<>(recordTimeMap.keySet()); Collections.sort(tags); - int currentY = 0; for (String tag : tags) { Long resultTime = resultTimeMap.get(tag); resultTime = resultTime == null ? 0L : resultTime; @@ -1336,18 +1029,12 @@ private void drawBigWatch() { uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","",tag + " : " + resultTime + " / " + drawColor + recordTime,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); } - } + }*/ - private void drawPathData() { + protected void drawPathData() { for (Unit depot : UnitUtils.getUnitList(UnitType.Terran_Command_Center)) { List mineralsList = WorkerData.depotMineral.get(depot); if (mineralsList == null) { -// System.out.println("mineralsList is null."); -// if (depot != null) { -// System.out.println("depot=" + depot.getID() + "" + depot.getPosition()); -// } else { -// System.out.println("depot is null"); -// } return; } @@ -1366,53 +1053,43 @@ private void drawPathData() { } } - //Broodwar->drawCircleMap(Minerals[0].posTrick.x(),Minerals[0].posTrick.y(),2,Colors::Purple,true); - - //Prebot.Broodwar.drawCircleMap(Mineral.Instance().CCtrick.getX(),Mineral.Instance().CCtrick.getY(),2,Color.Brown,true); - //for(int i=0; i< MineralManager.Instance().minerals.size(); i++){ - //Prebot.Broodwar.drawTextMap( minr.mineral.getPosition().getX(),minr.mineral.getPosition().getY(), "(" + (int)(MineralManager.Instance().minerals.get(i).MinToCC) + (int)(MineralManager.Instance().minerals.get(i).CCToMin) + ")"); - //} } } - private void drawStrategy(){ + protected void drawStrategy(){ String upgradeString = ""; for (MetaType metaType : StrategyBoard.upgrade) { upgradeString += metaType.getName() + " > "; } - int y = 10; Race enemyRace = PlayerUtils.enemyRace(); EnemyStrategy strategy = StrategyBoard.currentStrategy; int phase = EnemyStrategyAnalyzer.Instance().getPhase(); //setting - UxDrawConfig uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","", "[" + strategy.name() + " ...(phase " + phase + ")]"); + UxDrawConfig uxDrawConfig = UxDrawConfig.newInstanceStringType("L","", "[" + strategy.name() + " ...(phase " + phase + ")]",UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","UPGRADE",upgradeString); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","UPGRADE",upgradeString,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","EXPANSION",StrategyBoard.expansionOption); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","EXPANSION",StrategyBoard.expansionOption,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","MISSION",strategy.missionTypeList); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","MISSION",strategy.missionTypeList,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","", ClueManager.Instance().getClueInfoList()); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","",ClueManager.Instance().getClueInfoList(),UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","", strategy.buildTimeMap); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L","",strategy.buildTimeMap,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); - - - y = 10; for (EnemyStrategy enemyStrategy : EnemyStrategy.values()) { if (enemyStrategy.name().startsWith(enemyRace.toString().toUpperCase())) { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","",""+enemyStrategy.name(),UxColor.CHAR_YELLOW); + uxDrawConfig = UxDrawConfig.newInstanceStringType("R","",enemyStrategy.name(),UxColor.CHAR_YELLOW); drawStrategyRightList.add(uxDrawConfig); } } @@ -1474,31 +1151,10 @@ public int compare(AirForceTeam a1, AirForceTeam a2) { Broodwar.drawTextScreen(L, y += 15, "" + UxColor.CHAR_YELLOW + airForceTeam.toString()); } - /* Broodwar.drawTextScreen(L, y += 15, "Defense Mode? " + AirForceManager.Instance().isAirForceDefenseMode()); - Broodwar.drawTextScreen(L, y += 15, "strike level=" + AirForceManager.Instance().getStrikeLevel()); - Broodwar.drawTextScreen(L, y += 15, "total achievement=" + AirForceManager.Instance().getAchievementEffectiveFrame()); - Broodwar.drawTextScreen(L, y += 15, "accumulated achievement=" + AirForceManager.Instance().getAccumulatedAchievement()); - Broodwar.drawTextScreen(L, y += 15, "wraith count=" + StrategyBoard.wraithCount);*/ } - private void drawVulturePolicy() { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","[vulture policy]",UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","checkerMaxNumber=" + StrategyBoard.checkerMaxNumber,UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","spiderMineNumberPerPosition=" + StrategyBoard.spiderMineNumberPerPosition,UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","spiderMineNumberPerGoodPosition=" + StrategyBoard.spiderMineNumberPerGoodPosition,UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("R","","watcherMinePositionLevel=" + StrategyBoard.watcherMinePositionLevel,UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - } - - private void drawEnemyBaseToBaseTime() { + /* private void drawEnemyBaseToBaseTime() { uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","campPosition : " + StrategyBoard.campPosition + " / " + StrategyBoard.campType,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); @@ -1532,15 +1188,9 @@ private void drawEnemyBaseToBaseTime() { uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyFirstExpansion : " + enemyExpansionPosition,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); -// if (StrategyBoard.enemyBaseExpected != null) { -// Broodwar.drawTextScreen(10, y += 15, "enemyMainBase (Expect) : " + StrategyBoard.enemyBaseExpected.getPosition()); -// } -// for (Entry unitType : InformationManager.Instance().baseToBaseUnit.entrySet()) { -// Prebot.Broodwar.drawTextScreen(20, y += 10, "" + UxColor.CHAR_YELLOW + unitType.getKey() + " : " + unitType.getValue()); -// } - } + }*/ - private void drawPositionInformation() { + protected void drawPositionInformation() { if (StrategyBoard.mainSquadLeaderPosition != null) { Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainSquadLeaderPosition, 0, -20), UxColor.CHAR_WHITE + "V"); @@ -1581,83 +1231,9 @@ private void drawPositionInformation() { Broodwar.drawTextMap(StrategyBoard.totalEnemyCneterPosition, "totalEnemySq"); Broodwar.drawCircleMap(StrategyBoard.totalEnemyCneterPosition, 250, Color.Red); } - if (PositionUtils.myReadyToPosition() != null) { - Broodwar.drawTextMap(PositionUtils.myReadyToPosition(), "myReadyTo"); - } - if (PositionUtils.enemyReadyToPosition() != null) { - Broodwar.drawTextMap(PositionUtils.enemyReadyToPosition(), "enemyReadyTo"); - } -// if (VultureTravelManager.Instance().getTravelSites() != null) { -// for (TravelSite site : VultureTravelManager.Instance().getTravelSites()) { -// Broodwar.drawTextMap(site.baseLocation.getPosition(), "travel site\n" + site); -// } -// } } - private void drawCCtoScvCount() { - - int y = 100; - for (Unit depot : UnitUtils.getCompletedUnitList(UnitType.Terran_Command_Center)) { - // update workerData with the new job - Broodwar.drawTextScreen(R, y, "depot.getID() : " + depot.getID() + " cnt : " + WorkerData.depotWorkerCount.get(depot.getID())); - y += 10; - } - } - - /// turret 건설 지점의 반경 표시 - public void drawTurretMap() { - BaseLocation myBase = BaseUtils.myMainBase(); - BaseLocation myFirstExpansion = BaseUtils.myFirstExpansion(); - Chokepoint myFirstChoke = ChokeUtils.myFirstChoke(); - Chokepoint mySecondChoke = ChokeUtils.mySecondChoke(); - - int turretCount = UnitUtils.getCompletedUnitCount(UnitType.Terran_Missile_Turret); - - Position firstChokeMainHalf = new Position((myBase.getPosition().getX() + myFirstChoke.getX() * 2) / 3 - 60, - (myBase.getPosition().getY() + myFirstChoke.getY() * 2) / 3 - 60); - - Position firstChokeExpHalf = new Position((myFirstExpansion.getPosition().getX() * 2 + myFirstChoke.getX()) / 3, - (myFirstExpansion.getPosition().getY() * 2 + myFirstChoke.getY()) / 3); - -//// Position betweenChoke = new Position((myFirstChoke.getX() * 2 + myFirstChoke.getX()) / 3, -//// (mySecondChoke.getY() * 2 + mySecondChoke.getY()) / 3); -//// - -// Broodwar.drawTextMap(firstChokeExpHalf.getX() + 20, firstChokeExpHalf.getY() + 10, "(" + (int) (firstChokeExpHalf.getX()) + ", " + (int) (firstChokeExpHalf.getY()) + ")"); -// -// Broodwar.drawCircleMap(firstChokeExpHalf, 150, Color.Orange, false); -// -// Broodwar.drawCircleMap(firstChokeExpHalf, 150 + turretCount * 15, Color.Orange, false); -// -// Broodwar.drawTextMap(mySecondChoke.getCenter().getX() + 20, mySecondChoke.getCenter().getY() + 10, "(" + (int) (mySecondChoke.getCenter().getX()) + ", " + (int) (mySecondChoke.getCenter().getY()) + ")"); -// -// Broodwar.drawCircleMap(mySecondChoke.getCenter(), 150, Color.Cyan, false); -// -// Broodwar.drawCircleMap(mySecondChoke.getCenter(), 150 + turretCount * 15, Color.Cyan, false); -// -// Position betweenChoke2 = Position.None; -// -// if (MapUtils.getMapSpecificInformation().getMap() == GameMap.FIGHTING_SPIRITS) { -// betweenChoke2 = new Position((firstChokeMainHalf.getX() * 4 + mySecondChoke.getX() * 7) / 11, -// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); -// }else { -// betweenChoke2 = new Position((firstChokeMainHalf.getX() * 3 + mySecondChoke.getX() * 4) / 7, -// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); -// } -// -//// Position betweenChoke2 = new Position((firstChokeMainHalf.getX() * 4 + mySecondChoke.getX() * 7) / 11, -//// (firstChokeMainHalf.getY() * 4 + mySecondChoke.getY() * 7) / 11); -// -// Broodwar.drawTextMap(betweenChoke2.getX() + 20, betweenChoke2.getY() + 10, "(" + (int) (betweenChoke2.getX()) + ", " + (int) (betweenChoke2.getY()) + ")"); -// -// Broodwar.drawCircleMap(betweenChoke2, 120, Color.White, false); -// -// Broodwar.drawCircleMap(betweenChoke2, 120 + turretCount * 15, Color.White, false); -// -//// radius1 + turretCount * 15 - - } - private void addDrawStrategyListOrigin() throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException{ + /*private void addDrawStrategyListOrigin() throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException{ // TODO Auto-generated method stub if(!drawStrategyListOrigin[uxOption].isEmpty()){ UxDrawConfig uxDrawConfig; @@ -1667,7 +1243,12 @@ private void addDrawStrategyListOrigin() throws IllegalArgumentException, Illega if(drwaConfig.getValue() != null){ Field fld = null; try{ + Method method = c.getMethod("Instance"); + Object obj = method.invoke(arg0, arg1); + obj.getClass().getDeclaredField(name) fld = c.getDeclaredField(drwaConfig.getValue()); + + if (!fld.isAccessible()) { fld.setAccessible(true); } @@ -1675,7 +1256,7 @@ private void addDrawStrategyListOrigin() throws IllegalArgumentException, Illega System.out.println(e.getMessage()); continue; } - uxDrawConfig = UxDrawConfig.newInstanceObjectType(fld.getName(),fld.get(drwaConfig.getValue()),drwaConfig.getColor()); + uxDrawConfig = UxDrawConfig.newInstanceFieldType(fld.getName(),fld.get(drwaConfig.getValue()),drwaConfig.getColor()); uxDrawConfig.setPos(drwaConfig.getPos()); if(drwaConfig.getPos() == UxDrawConfig.posMap.get("L")){ drawStrategyLeftList.add(uxDrawConfig); @@ -1690,43 +1271,40 @@ private void addDrawStrategyListOrigin() throws IllegalArgumentException, Illega } } - } + }*/ + // 600 * 300 - private void drawStrategyList() { + protected void drawStrategyList() { // TODO Auto-generated method stub int nextLy = 20, nextMy = 20, nextRy = 20; -// nextLy = nextMy = nextRy = 20; for(UxDrawConfig uxDraw : drawStrategyLeftList){ int lineCnt = 1; int fromIndex = -1; + Broodwar.drawTextScreen(uxDraw.getPos(), nextLy, uxDraw.getColor() + uxDraw.getClassFieldName()); while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { lineCnt++; } - Broodwar.drawTextScreen(uxDraw.getPos(), nextLy, uxDraw.getColor() + uxDraw.getClassFieldName()); -// y += (lineCnt*12); nextLy += (lineCnt*12); } for(UxDrawConfig uxDraw : drawStrategyMidList){ int lineCnt = 1; int fromIndex = -1; + Broodwar.drawTextScreen(uxDraw.getPos(), nextMy, uxDraw.getColor() + uxDraw.getClassFieldName()); while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { lineCnt++; } - Broodwar.drawTextScreen(uxDraw.getPos(), nextMy, uxDraw.getColor() + uxDraw.getClassFieldName()); -// y += (lineCnt*12); nextMy += (lineCnt*12); } for(UxDrawConfig uxDraw : drawStrategyRightList){ int lineCnt = 1; int fromIndex = -1; + Broodwar.drawTextScreen(uxDraw.getPos(), nextRy,uxDraw.getClassFieldName()); while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { lineCnt++; } - Broodwar.drawTextScreen(uxDraw.getPos(), nextRy, uxDraw.getColor() + uxDraw.getClassFieldName()); -// y += (lineCnt*12); nextRy += (lineCnt*12); } @@ -1738,98 +1316,6 @@ private void drawStrategyList() { Broodwar.drawTextScreen(L, (nextLy + 24), " : "); Broodwar.drawTextScreen(M, (nextMy + 24), " : "); Broodwar.drawTextScreen(R, (nextRy + 24), " : "); -// Broodwar.drawTextScreen(20, nextY+12, ""); } } - - /* - * 사용자 별 화면 */ - - public void getSMDisplay() { - if (uxOption == 0) { - clearList(); - drawDebugginUxMenu(); - drawUxInfo(); - } else if (uxOption == 1) { - UXManager.Instance().update(); - clearList(); - // 미네랄PATH - } else if (uxOption == 2) { - clearList(); - drawGameInformationOnScreen(); - drawBWTAResultOnMap(); - drawBuildOrderQueueOnScreen(); - drawBuildStatusOnScreen(); - drawReservedBuildingTilesOnMap(); - drawTilesToAvoidOnMap(); - drawWorkerMiningStatusOnMap(); - drawUnitTargetOnMap(); - drawnextPoints(); - //drawTurretMap(); - drawManagerTimeSpent(); - drawConstructionQueueOnScreenAndMap(); - - // draw tile position of mouse cursor - int mouseX = Broodwar.getMousePosition().getX() + Broodwar.getScreenPosition().getX(); - int mouseY = Broodwar.getMousePosition().getY() + Broodwar.getScreenPosition().getY(); - Broodwar.drawTextMap(mouseX + 20, mouseY, - "(" + (int) (mouseX / 32) + ", " + (int) (mouseY / 32) + ")"); - Broodwar.drawTextMap(mouseX + 20, mouseY + 10, "(" + (int) (mouseX) + ", " + (int) (mouseY) + ")"); - - } else if (uxOption == 3) { - clearList(); - drawStrategy(); - // drawCCtoScvCount(); - } else if (uxOption == 4) { - clearList(); - drawEnemyBuildTimer(); - } else if (uxOption == 5) { - clearList(); - drawSquadInfoOnMap(); - drawManagerTimeSpent(); - drawDecision(); - drawEnemyAirDefenseRange(); - drawAirForceInformation(); - drawVulturePolicy(); - } else if (uxOption == 6) { - clearList(); - drawEnemyBaseToBaseTime(); - } else if (uxOption == 7) { - clearList(); - drawBigWatch(); - drawManagerTimeSpent(); - } else if (uxOption == 8) { - clearList(); - drawTurretMap(); - drawTilesToAvoidOnMap(); - drawReservedBuildingTilesOnMap(); - } else if (uxOption == 9) { - //drawExpectedResource(); - //drawExpectedResource2(); - - } - - drawMineralIdOnMap(); - drawUnitIdOnMap(); - drawPositionInformation(); - drawTimer(); - drawPathData(); - drawSquadUnitTagMap(); - - try { - addDrawStrategyListOrigin(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - drawStrategyList(); - - clearDecisionListForUx(); - } } \ No newline at end of file diff --git a/src/main/java/org/monster/debugger/ScreenUx.java b/src/main/java/org/monster/debugger/ScreenUx.java new file mode 100644 index 0000000..39a0605 --- /dev/null +++ b/src/main/java/org/monster/debugger/ScreenUx.java @@ -0,0 +1,103 @@ +package org.monster.debugger; + +import org.monster.build.base.BuildManager; +import org.monster.build.base.ConstructionManager; +import org.monster.build.provider.BuildQueueProvider; +import org.monster.common.MapGrid; +import org.monster.common.util.TimeUtils; +import org.monster.strategy.StrategyManager; +import org.monster.bootstrap.GameManager; +import org.monster.micro.CombatManager; +import org.monster.worker.WorkerManager; + +import bwapi.Game; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ScreenUx{ + + private static ScreenUx instance = new ScreenUx(); + private static int uxOption; + public static void showDisplay() { + uxOption = PreBotUXManager.Instance().uxOption; + PreBotUXManager.Instance().clearList(); + if (uxOption == 0) { + PreBotUXManager.Instance().drawDebugginUxMenu(); //drawing ux 메뉴 설명 + PreBotUXManager.Instance().drawUxInfo(); //debuging 메뉴 설명 (화면 , 속도 등) + } else if (uxOption == 1) { + UXManager.Instance().update(); //프리봇 전 기본 디버깅 메뉴 + // 미네랄PATH + } else if (uxOption == 2) { + PreBotUXManager.Instance().drawGameInformationOnScreen(); + PreBotUXManager.Instance().drawBWTAResultOnMap(); + PreBotUXManager.Instance().drawBuildOrderQueueOnScreen(); + PreBotUXManager.Instance().drawBuildStatusOnScreen(); + PreBotUXManager.Instance().drawReservedBuildingTilesOnMap(); + PreBotUXManager.Instance().drawTilesToAvoidOnMap(); + PreBotUXManager.Instance().drawWorkerMiningStatusOnMap(); + PreBotUXManager.Instance().drawUnitTargetOnMap(); + //drawTurretMap(); + PreBotUXManager.Instance().drawManagerTimeSpent(); + PreBotUXManager.Instance().drawConstructionQueueOnScreenAndMap(); //ConstructionQueue + + // draw tile position of mouse cursor + int mouseX = PreBotUXManager.Instance().Broodwar.getMousePosition().getX() + PreBotUXManager.Instance().Broodwar.getScreenPosition().getX(); + int mouseY = PreBotUXManager.Instance().Broodwar.getMousePosition().getY() + PreBotUXManager.Instance().Broodwar.getScreenPosition().getY(); + PreBotUXManager.Instance().Broodwar.drawTextMap(mouseX + 20, mouseY, + "(" + (int) (mouseX / 32) + ", " + (int) (mouseY / 32) + ")"); + PreBotUXManager.Instance().Broodwar.drawTextMap(mouseX + 20, mouseY + 10, "(" + (int) (mouseX) + ", " + (int) (mouseY) + ")"); + + } else if (uxOption == 3) { + PreBotUXManager.Instance().drawStrategy(); + } else if (uxOption == 4) { + PreBotUXManager.Instance().drawEnemyBuildTimer(); + }/* else if (uxOption == 5) { + clearList(); + drawSquadInfoOnMap(); + drawManagerTimeSpent(); + drawDecision(); + drawEnemyAirDefenseRange(); + drawAirForceInformation(); + } else if (uxOption == 6) { + clearList(); + drawEnemyBaseToBaseTime(); + } else if (uxOption == 7) { + clearList(); + drawBigWatch(); + drawManagerTimeSpent(); + } else if (uxOption == 8) { + clearList(); + drawTilesToAvoidOnMap(); + drawReservedBuildingTilesOnMap(); + } else if (uxOption == 9) { + //drawExpectedResource(); + //drawExpectedResource2(); + + }*/ + + PreBotUXManager.Instance().drawMineralIdOnMap(); + PreBotUXManager.Instance().drawUnitIdOnMap(); + PreBotUXManager.Instance().drawPositionInformation(); + PreBotUXManager.Instance().drawTimer(); + PreBotUXManager.Instance().drawPathData(); + PreBotUXManager.Instance().drawSquadUnitTagMap(); + + /*try { + PreBotUXManager.Instance().addDrawStrategyListOrigin(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + PreBotUXManager.Instance().drawStrategyList(); + PreBotUXManager.Instance().clearDecisionListForUx(); + } +} diff --git a/src/main/java/org/monster/debugger/UXManager.java b/src/main/java/org/monster/debugger/UXManager.java index d485cdf..ebb1cf7 100644 --- a/src/main/java/org/monster/debugger/UXManager.java +++ b/src/main/java/org/monster/debugger/UXManager.java @@ -342,35 +342,6 @@ public void drawUnitStatisticsOnScreen(int x, int y) { // 아군이 입은 피해 누적값 currentY += 10; - // 아군 모든 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " allUnitCount: " + UnitUtils.getUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 건설/훈련 완료한 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " completedUnitCount: " + UnitUtils.getCompletedUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 건설/훈련중인 유닛 숫자 합계 - //Broodwar.drawTextScreen(x, currentY, white + " incompleteUnitCount: " + Broodwar.self().incompleteUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 아군 유닛 파괴/사망 숫자 누적값 - //Broodwar.drawTextScreen(x, currentY, white + " deadUnitCount: " + Broodwar.self().deadUnitCount(UnitType.AllUnits)); - //currentY += 10; - - // 상대방 유닛을 파괴/사망 시킨 숫자 누적값 - //Broodwar.drawTextScreen(x, currentY, white + " killedUnitCount: " + Broodwar.self().killedUnitCount(UnitType.AllUnits)); - //currentY += 10; - - //Broodwar.drawTextScreen(x, currentY, white + " UnitScore: " + Broodwar.self().getUnitScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " RazingScore: " + Broodwar.self().getRazingScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " BuildingScore: " + Broodwar.self().getBuildingScore()); - //currentY += 10; - //Broodwar.drawTextScreen(x, currentY, white + " KillScore: " + Broodwar.self().getKillScore()); - //currentY += 10; - // 적군의 UnitType 별 파악된 Unit 숫자를 표시 Broodwar.drawTextScreen(x, currentY + 20, white + " UNIT NAME"); Broodwar.drawTextScreen(x + 110, currentY + 20, white + " Created"); @@ -383,64 +354,6 @@ public void drawUnitStatisticsOnScreen(int x, int y) { /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 public void drawBWTAResultOnMap() { - /*//we will iterate through all the base locations, and draw their outlines. - // C+ . for (std.set.const_iterator i = BWTA.getBaseLocations().begin(); i != BWTA.getBaseLocations().end(); i++) - for(BaseLocation baseLocation : BWTA.getBaseLocations()) - { - TilePosition p = baseLocation.getTilePosition(); - Position c = baseLocation.getPosition(); - - //draw outline of Base location - Broodwar.drawBoxMap(p.getX() * 32, p.getY() * 32, p.getX() * 32 + 4 * 32, p.getY() * 32 + 3 * 32, Color.Blue); - - //draw a circle at each mineral patch - // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) - for(Unit unit : baseLocation.getStaticMinerals()) - { - Position q = unit.getInitialPosition(); - Broodwar.drawCircleMap(q.getX(), q.getY(), 30, Color.Cyan); - } - - //draw the outlines of vespene geysers - // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) - for(Unit unit :baseLocation.getGeysers() ) - { - TilePosition q = unit.getInitialTilePosition(); - Broodwar.drawBoxMap(q.getX() * 32, q.getY() * 32, q.getX() * 32 + 4 * 32, q.getY() * 32 + 2 * 32, Color.Orange); - } - - //if this is an island expansion, draw a yellow circle around the base location - if (baseLocation.isIsland()) - { - Broodwar.drawCircleMap(c, 80, Color.Yellow); - } - } - - //we will iterate through all the regions and draw the polygon outline of it in green. - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for(Region region : BWTA.getRegions()) - { - Polygon p = region.getPolygon(); - for (int j = 0; j.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for(Region region : BWTA.getRegions()) - { - // C++ : for (std.set.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) - for(Chokepoint Chokepoint : region.getChokepoints()) - { - Position point1 = Chokepoint.getSides().first; - Position point2 = Chokepoint.getSides().second; - Broodwar.drawLineMap(point1, point2, Color.Red); - } - }*/ int blueCount = 0; int cyanCount = 0; int orangeCount = 0; @@ -608,14 +521,6 @@ public void drawMapGrid() { public void drawBuildOrderQueueOnScreen(int x, int y) { Broodwar.drawTextScreen(x, y, white + " "); - /* - std.deque< BuildOrderItem >* queue = BuildManager.Instance().buildQueue.getQueue(); - size_t reps = queue.size() < 24 ? queue.size() : 24; - for (size_t i(0); i buildQueue = BuildManager.Instance().buildQueue.getQueue(); int itemCount = 0; @@ -699,16 +604,6 @@ public void drawReservedBuildingTilesOnMap() { /// Construction 을 하지 못하는 Tile 들을 Map 에 표시합니다 public void drawTilesToAvoidOnMap() { -// Set tilesToAvoid = ConstructionPlaceFinder.Instance().getTilesToAvoid(); -// for (TilePosition t : tilesToAvoid) -// { -// int x1 = t.getX() * 32 + 8; -// int y1 = t.getY() * 32 + 8; -// int x2 = (t.getX() + 1) * 32 - 8; -// int y2 = (t.getY() + 1) * 32 - 8; - // -// Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); -// } int y = 0; int x = 0; diff --git a/src/main/java/org/monster/debugger/chat/ChatBot.java b/src/main/java/org/monster/debugger/chat/ChatBot.java index d94e993..299df27 100644 --- a/src/main/java/org/monster/debugger/chat/ChatBot.java +++ b/src/main/java/org/monster/debugger/chat/ChatBot.java @@ -22,7 +22,7 @@ public class ChatBot { * 2) UX 타입 변경 : d + 숫자 ex) d1=?, d0=prebot1 display * 3) 전략 변경 : $ + 전략명 ex) $TERRAN INIT * 4) 레이쓰 공격레벨 변경 : w + 숫자 ex) w1 - * 5) 디버깅 변수 추가 : a + class + 변수 ex) a strategyBoard startStrategy + * 5) 디버깅 변수 추가 : a + class + 변수 ex) a L strategyBoard startStrategy * 5) 디버깅 변수 제거 : m + 변수이름 ex) m startStrategy * 6) 디버깅 초기화 * diff --git a/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java b/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java index e165917..44107a7 100644 --- a/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java +++ b/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java @@ -1,6 +1,8 @@ package org.monster.debugger.chat.impl; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -26,8 +28,20 @@ public class UxDrawConfig { private char color; private Class clazz; + private Method method; + public Method getMethod() { + return method; + } + + private Field field; + //private Field field; + public Field getField() { + return field; + } + + private int pos = posMap.get("L"); public void setPos(int pos) { @@ -50,21 +64,33 @@ public void setColor(char color) { this.color = color; } - private UxDrawConfig(Class clazz, Field field, char color) { + public UxDrawConfig(String pos, String key, Class clazz, Method method, char color) { + this.pos = posMap.get(pos.toUpperCase()); + this.key = key; + this.clazz = clazz; + this.method = method; + this.color = color; + // TODO Auto-generated constructor stub + } + + public UxDrawConfig(String pos, String key, Class clazz, Field field, char color) { + this.pos = posMap.get(pos.toUpperCase()); + this.key = key; this.clazz = clazz; this.field = field; this.color = color; - + // TODO Auto-generated constructor stub } - private UxDrawConfig(String key, Object value, char color) { + public UxDrawConfig(String pos, String key, Object value, char color) { + this.pos = posMap.get(pos.toUpperCase()); this.key = key; this.value = value; this.color = color; - + // TODO Auto-generated constructor stub } - - public UxDrawConfig(String pos, String key, Object value, char color) { + + public UxDrawConfig(String pos, String key, int value, char color) { this.pos = posMap.get(pos.toUpperCase()); this.key = key; this.value = value; @@ -72,35 +98,74 @@ public UxDrawConfig(String pos, String key, Object value, char color) { // TODO Auto-generated constructor stub } - public static UxDrawConfig newInstanceClassType(Class clazz, Field field, char color) { - return new UxDrawConfig(clazz, field, color); + public static UxDrawConfig newInstanceFiledType(String pos, String key, Class clazz, String field, char color) { + Class c = clazz.getClass(); + Field fld = null; + try{ + fld = c.getDeclaredField(field); + if (!fld.isAccessible()) { + fld.setAccessible(true); + } + } catch (Exception e) { +// System.out.println(e.getMessage()); + } + System.out.println(fld.getName().toString()); + return new UxDrawConfig(pos, key, c, fld, color); } - public static UxDrawConfig newInstanceClassType(String pos,String key, Object value, char color) { - return new UxDrawConfig(pos, key, value, color); + public static UxDrawConfig newInstanceMethodType(String pos, String key, Class clazz, String method, char color) { + Method invokeMethod = null; + try { + invokeMethod = clazz.getDeclaredMethod(method); + if (!invokeMethod.isAccessible()) { + invokeMethod.setAccessible(true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return new UxDrawConfig(pos, key, clazz, invokeMethod, color); } - public static UxDrawConfig newInstanceObjectType(String pos, String key, Object value) { - return newInstanceObjectType(pos, key, value, UxColor.CHAR_YELLOW); + /*public static UxDrawConfig newInstanceStringType(String pos, String key, String value, char color) { + + return new UxDrawConfig(pos, key, value, color); + }*/ + + public static UxDrawConfig newInstanceStringType(String pos, String key, Object value, char color) { + + return new UxDrawConfig(pos, key, value, color); } - public static UxDrawConfig newInstanceObjectType(String key, Object value, char color) { +/* public static UxDrawConfig newInstanceObjectType(String key, Object value, char color) { return new UxDrawConfig(key, value, color); } public static UxDrawConfig newInstanceObjectType(String pos,String key, Object value, char color) { return new UxDrawConfig(pos, key, value, color); - } + }*/ + public String getClassFieldName() { if (clazz != null) { - return this.clazz.getSimpleName() + "." + this.field.getName(); - } else if(this.key.equals("")){ + if(method != null){ + try { + return this.key + " : " + this.method.invoke(clazz).toString(); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(field != null){ + return this.key + " : " +this.field.getName().toString(); + } + }else if(this.key.equals("")){ return this.value.toString(); }else{ return this.key + " : " + this.value.toString(); } + return key; } + public String getFieldName() { if (this.field == null) { @@ -131,6 +196,5 @@ public void setClazz(String className) { this.clazz = classMap.get(className.toUpperCase()); } - /// 일꾼 유닛에게 지정하는 임무의 종류 }; \ No newline at end of file diff --git a/src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java b/src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java index 924f6bc..8cb736c 100644 --- a/src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java +++ b/src/main/java/org/monster/debugger/chat/impl/UxListAddMinus.java @@ -23,7 +23,7 @@ public void execute(String option) { String key = option.split(" ")[2]; String value = option.split(" ")[3]; - UxDrawConfig ux = UxDrawConfig.newInstanceClassType(pos,key,value,UxColor.CHAR_GREEN); + UxDrawConfig ux = UxDrawConfig.newInstanceFiledType(pos,key,UxDrawConfig.classMap.get(key.toUpperCase()),value,UxColor.CHAR_GREEN); PreBotUXManager.Instance().drawStrategyListOrigin[PreBotUXManager.Instance().getUxOption()].add(ux); }else if('m' == getType()){ for (UxDrawConfig drawList : PreBotUXManager.Instance().drawStrategyListOrigin[PreBotUXManager.Instance().getUxOption()]) { From 9394933da2398c512b66715f068bfa7abd6d20f0 Mon Sep 17 00:00:00 2001 From: staeminba Date: Sun, 17 Mar 2019 22:28:12 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[debugging]=20debuging=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/monster/debugger/PreBotUXManager.java | 2535 +++++++++-------- .../java/org/monster/debugger/ScreenUx.java | 158 +- .../java/org/monster/debugger/UXManager.java | 1726 +++++------ .../debugger/chat/impl/UxDrawConfig.java | 61 +- src/main/java/org/monster/debugger/readme.md | 22 + 5 files changed, 2336 insertions(+), 2166 deletions(-) create mode 100644 src/main/java/org/monster/debugger/readme.md diff --git a/src/main/java/org/monster/debugger/PreBotUXManager.java b/src/main/java/org/monster/debugger/PreBotUXManager.java index 0a3a632..fecb1d3 100644 --- a/src/main/java/org/monster/debugger/PreBotUXManager.java +++ b/src/main/java/org/monster/debugger/PreBotUXManager.java @@ -1,11 +1,7 @@ package org.monster.debugger; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; @@ -29,16 +25,13 @@ import org.monster.common.UnitInfo; import org.monster.common.constant.CommonCode; import org.monster.common.constant.EnemyUnitVisibleStatus; -import org.monster.common.constant.UnitFindStatus; import org.monster.common.util.BaseUtils; import org.monster.common.util.ChokeUtils; import org.monster.common.util.DrawingUtils; import org.monster.common.util.PlayerUtils; -import org.monster.common.util.PositionUtils; import org.monster.common.util.TimeUtils; import org.monster.common.util.UnitTypeUtils; import org.monster.common.util.UnitUtils; -import org.monster.common.util.internal.GameMap; import org.monster.debugger.chat.impl.UxDrawConfig; import org.monster.micro.CombatManager; import org.monster.micro.MicroDecision; @@ -78,1244 +71,1352 @@ public class PreBotUXManager { private static PreBotUXManager instance = new PreBotUXManager(); - + private final int dotRadius = 2; - public Unit leader = null; + public Unit leader = null; public int uxOption = 0; private boolean hasSavedBWTAInfo = false; private int[][] blue = null; - private int[][] cyan = null; - private int[][] orange = null; - private int[][] purple = null; - private List yellow = new ArrayList(); - private List green1 = new ArrayList(); - private List green2 = new ArrayList(); - private List red1 = new ArrayList(); - private List red2 = new ArrayList(); - private String bulletTypeName = ""; - private String tempUnitName = ""; + private int[][] cyan = null; + private int[][] orange = null; + private int[][] purple = null; + private List yellow = new ArrayList(); + private List green1 = new ArrayList(); + private List green2 = new ArrayList(); + private List red1 = new ArrayList(); + private List red2 = new ArrayList(); + private String bulletTypeName = ""; + private String tempUnitName = ""; protected Game Broodwar; - private int L = UxDrawConfig.posMap.get("L"); - private int M = UxDrawConfig.posMap.get("M"); - private int R = UxDrawConfig.posMap.get("R"); + private int L = UxDrawConfig.posMap.get("L"); + private int M = UxDrawConfig.posMap.get("M"); + private int R = UxDrawConfig.posMap.get("R"); private UxDrawConfig uxDrawConfig; public ArrayList[] drawStrategyListOrigin = new ArrayList[9]; - public HashMap> drawStrategyListMap = new HashMap>(); - public ArrayList drawStrategyLeftList = new ArrayList(); - public ArrayList drawStrategyMidList = new ArrayList(); - public ArrayList drawStrategyRightList = new ArrayList(); - - private UnitType factorySelected = UnitType.None; - - private Map decisionListForUx = new HashMap<>(); - + public HashMap> drawStrategyListMap = new HashMap>(); + public ArrayList drawStrategyLeftList = new ArrayList(); + public ArrayList drawStrategyMidList = new ArrayList(); + public ArrayList drawStrategyRightList = new ArrayList(); + + private UnitType factorySelected = UnitType.None; + + private Map decisionListForUx = new HashMap<>(); + public PreBotUXManager() { } - public void onStart(Game Broodwar){ - for (int i = 0; i(); + public void onStart(Game Broodwar) { + for (int i = 0; i < drawStrategyListOrigin.length; i++) { + drawStrategyListOrigin[i] = new ArrayList(); } - this.Broodwar = Broodwar; - } - - + this.Broodwar = Broodwar; + } + // 0..1 : default // 2..3 : custom - /// static singleton 객체를 리턴합니다 public static PreBotUXManager Instance() { return instance; } - + public void setUxOption(int uxOption) { - this.uxOption = uxOption; - } - + this.uxOption = uxOption; + } + public int getUxOption() { - return uxOption; - } + return uxOption; + } public void update() { ScreenUx.showDisplay(); } - - - - - - - protected void drawUxInfo() { - // TODO Auto-generated method stub - int y = 10; - //setting - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","/*****************************************************************************",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","*",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 1) UX Type Change : d + num ex) d1=?, d0=prebot1 display",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 2) Change Strategy : $ + Strategy Name ex) $ INIT",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 3) add Var : a + pos + class + var ex) a L(R/M) strategyBoard startStrategy",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","* 4) minus Var : m + var ex) m startStrategy",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","*",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","*****************************************************************************///",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); + + protected void drawUxInfo() { + // TODO Auto-generated method stub + int y = 10; + // setting + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", + "/*****************************************************************************", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "*", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", + "* 1) UX Type Change : d + num ex) d1=?, d0=prebot1 display", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", + "* 2) Change Strategy : $ + Strategy Name ex) $ INIT", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", + "* 3) add Var : a + pos + class + var ex) a L(R/M) strategyBoard startStrategy", + UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", + "* 4) minus Var : m + var ex) m startStrategy", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "*", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", + "*****************************************************************************///", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } + + public void clearList() { + // TODO Auto-generated method stub + drawStrategyLeftList.clear(); + drawStrategyMidList.clear(); + drawStrategyRightList.clear(); + } + + private void drawDecision() { + for (Integer unitId : decisionListForUx.keySet()) { + Unit unit = Broodwar.getUnit(unitId); + MicroDecision decision = decisionListForUx.get(unitId); + Broodwar.drawTextMap(unit.getPosition(), UxColor.CHAR_YELLOW + decision.toString()); + if (decision.eui != null) { + Broodwar.drawLineMap(unit.getPosition(), decision.eui.getLastPosition(), Color.Yellow); + } + } + } + + public void addDecisionListForUx(Unit unit, MicroDecision decision) { + decisionListForUx.put(unit.getID(), decision); + } + + public void clearDecisionListForUx() { + decisionListForUx.clear(); + } + + protected void drawTimer() { + char battleColor = UxColor.CHAR_WHITE; + if (StrategyBoard.initiated) { + battleColor = UxColor.CHAR_RED; + } + uxDrawConfig = UxDrawConfig.newInstanceStringType("M", + "", StrategyBoard.mainSquadMode.toString() + ": " + + DrawingUtils.framesToTimeString(TimeUtils.getFrame()) + "(" + TimeUtils.getFrame() + ")", + battleColor); + drawStrategyMidList.add(uxDrawConfig); + + char apmColor = UxColor.CHAR_WHITE; + int apm = Broodwar.getAPM(); + if (apm > 3000) { + apmColor = UxColor.CHAR_RED; + } else if (apm > 2000) { + apmColor = UxColor.CHAR_YELLOW; + } else if (apm > 1000) { + apmColor = UxColor.CHAR_GREEN; + } else { + apmColor = UxColor.CHAR_WHITE; + } + uxDrawConfig = UxDrawConfig.newInstanceStringType("R", "APM : ", Broodwar.getAPM(), apmColor); + drawStrategyRightList.add(uxDrawConfig); + } + + protected void drawEnemyBuildTimer() { + + Map buildTimeExpectMap = EnemyBuildTimer.Instance().buildTimeExpectMap; + Map buildTimeMinimumMap = EnemyBuildTimer.Instance().buildTimeMinimumMap; + Set buildTimeCertain = EnemyBuildTimer.Instance().buildTimeCertain; + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "engine Build Frame", + DrawingUtils.framesToTimeString(StrategyBoard.engineeringBayBuildStartFrame), UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "turret Build Frame", + DrawingUtils.framesToTimeString(StrategyBoard.turretBuildStartFrame), UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "turret Need Frame", + DrawingUtils.framesToTimeString(StrategyBoard.turretNeedFrame), UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "darkTemplarInMyBaseFrame", + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().darkTemplarInMyBaseFrame), + UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "reaverInMyBaseFrame", + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().reaverInMyBaseFrame), UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "mutaliskInMyBaseFrame", + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().mutaliskInMyBaseFrame), UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "lurkerInMyBaseFrame", + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().lurkerInMyBaseFrame), UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + for (UnitType unitType : buildTimeExpectMap.keySet()) { + Integer buildTimeExpect = buildTimeExpectMap.get(unitType); + if (buildTimeExpect != null && buildTimeExpect != CommonCode.UNKNOWN) { + String expect = DrawingUtils.framesToTimeString(buildTimeExpect); + String minimum = ""; + Integer buildMinimum = buildTimeMinimumMap.get(unitType); + if (buildMinimum != null && buildMinimum != CommonCode.UNKNOWN) { + minimum = DrawingUtils.framesToTimeString(buildMinimum); + } + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", unitType + " : " + expect + " - min: " + + minimum + " (" + buildTimeCertain.contains(unitType) + ")", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } + } + + } + + protected void drawDebugginUxMenu() { + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "1. Default Information", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "2. Strategy Information", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "3. Position Finder Test", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "4. Air Micro Test", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "5. Unit Bast To Base", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", "", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + } + + // 게임 개요 정보를 Screen 에 표시합니다 + public void drawGameInformationOnScreen() { + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "Current Strategy", StrategyBoard.currentStrategy.name(), + UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + String history = ""; + for (int i = StrategyBoard.strategyHistory.size() - 1; i >= 0; i--) { + if (i == StrategyBoard.strategyHistory.size() - 3) { + history = "... " + history; + break; + } else { + history = StrategyBoard.strategyHistory.get(i).name() + " -> " + history; + } + } + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "MYKillScore", Broodwar.self().getKillScore(), + UxColor.CHAR_RED); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "MYRazingScore", Broodwar.self().getRazingScore(), + UxColor.CHAR_RED); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "EnemyKillScore", Broodwar.enemy().getKillScore(), + UxColor.CHAR_PURPLE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "EnemyRazingScore", Broodwar.enemy().getRazingScore(), + UxColor.CHAR_PURPLE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "Reserved Resource", + ConstructionManager.Instance().getReservedMinerals() + " / " + + ConstructionManager.Instance().getReservedGas(), + UxColor.CHAR_TEAL); + drawStrategyLeftList.add(uxDrawConfig); + + } + + /// Players 정보를 Screen 에 표시합니다 + public void drawPlayers() { + for (Player p : Broodwar.getPlayers()) { + Broodwar.sendText("Player [" + p.getID() + "]: " + p.getName() + " is in force: " + p.getForce().getName()); + } + } + + /// Player 들의 팀 (Force) 들의 정보를 Screen 에 표시합니다 + public void drawForces() { + for (Force f : Broodwar.getForces()) { + Broodwar.sendText("Force " + f.getName() + " has the following players:"); + for (Player p : f.getPlayers()) { + Broodwar.sendText(" - Player [" + p.getID() + "]: " + p.getName()); + } + } + } + + /// Unit 의 HitPoint 등 추가 정보를 Map 에 표시합니다 + public void drawUnitExtendedInformationOnMap() { + int verticalOffset = -10; + + for (UnitInfo ui : UnitUtils.getEnemyUnitInfoList()) { + + UnitType type = ui.getType(); + int hitPoints = ui.getLastHealth(); + int shields = ui.getLastShields(); + + Position pos = ui.getLastPosition(); + + int left = pos.getX() - type.dimensionLeft(); + int right = pos.getX() + type.dimensionRight(); + int top = pos.getY() - type.dimensionUp(); + int bottom = pos.getY() + type.dimensionDown(); + + // 적 유닛이면 주위에 박스 표시 + if (!Broodwar.isVisible(ui.getLastPosition().toTilePosition())) { + Broodwar.drawBoxMap(new Position(left, top), new Position(right, bottom), Color.Grey, false); + Broodwar.drawTextMap(new Position(left + 3, top + 4), ui.getType().toString()); + } + + // 유닛의 HitPoint 남아있는 비율 표시 + if (!type.isResourceContainer() && type.maxHitPoints() > 0) { + double hpRatio = (double) hitPoints / (double) type.maxHitPoints(); + + Color hpColor = Color.Green; + if (hpRatio < 0.66) + hpColor = Color.Orange; + if (hpRatio < 0.33) + hpColor = Color.Red; + + int ratioRight = left + (int) ((right - left) * hpRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + + // 유닛의 Shield 남아있는 비율 표시 + if (!type.isResourceContainer() && type.maxShields() > 0) { + double shieldRatio = (double) shields / (double) type.maxShields(); + + int ratioRight = left + (int) ((right - left) * shieldRatio); + int hpTop = top - 3 + verticalOffset; + int hpBottom = top + 1 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + } + + // draw neutral units and our units + for (Unit unit : Broodwar.getAllUnits()) { + if (unit.getPlayer() == PlayerUtils.enemyPlayer()) { + continue; + } + + final Position pos = unit.getPosition(); + + int left = pos.getX() - unit.getType().dimensionLeft(); + int right = pos.getX() + unit.getType().dimensionRight(); + int top = pos.getY() - unit.getType().dimensionUp(); + int bottom = pos.getY() + unit.getType().dimensionDown(); + + // Monster.game.drawBoxMap(BWAPI.Position(left, top), + // BWAPI.Position(right, bottom), Color.Grey, false); + + // 유닛의 HitPoint 남아있는 비율 표시 + if (!unit.getType().isResourceContainer() && unit.getType().maxHitPoints() > 0) { + double hpRatio = (double) unit.getHitPoints() / (double) unit.getType().maxHitPoints(); + + Color hpColor = Color.Green; + if (hpRatio < 0.66) + hpColor = Color.Orange; + if (hpRatio < 0.33) + hpColor = Color.Red; + + int ratioRight = left + (int) ((right - left) * hpRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), hpColor.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + + // 유닛의 Shield 남아있는 비율 표시 + if (!unit.getType().isResourceContainer() && unit.getType().maxShields() > 0) { + double shieldRatio = (double) unit.getShields() / (double) unit.getType().maxShields(); + + int ratioRight = left + (int) ((right - left) * shieldRatio); + int hpTop = top - 3 + verticalOffset; + int hpBottom = top + 1 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + + // Mineral / Gas 가 얼마나 남아있는가 + if (unit.getType().isResourceContainer() && unit.getInitialResources() > 0) { + double mineralRatio = (double) unit.getResources() / (double) unit.getInitialResources(); + + int ratioRight = left + (int) ((right - left) * mineralRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Cyan, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + } + } + + /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 + public void drawBWTAResultOnMap() { + int blueCount = 0; + int cyanCount = 0; + int orangeCount = 0; + // int purpleCount = 0; + + if (hasSavedBWTAInfo == false) { + for (BaseLocation baseLocation : BWTA.getBaseLocations()) { + blueCount++; + // purpleCount++; + for (Unit unit : baseLocation.getStaticMinerals()) { + cyanCount++; + } + for (Unit unit : baseLocation.getGeysers()) { + orangeCount++; + } + + } + + blue = new int[blueCount][4]; + int blueIndex = 0; + cyan = new int[cyanCount][2]; + int cyanIndex = 0; + orange = new int[orangeCount][4]; + int orangeIndex = 0; + + // purple = new int[purpleCount][4]; + // int purpleIndex = 0; + + for (BaseLocation baseLocation : BWTA.getBaseLocations()) { + TilePosition p = baseLocation.getTilePosition(); + Position c = baseLocation.getPosition(); + + blue[blueIndex][0] = p.getX() * 32; + blue[blueIndex][1] = p.getY() * 32; + blue[blueIndex][2] = p.getX() * 32 + 4 * 32; + blue[blueIndex][3] = p.getY() * 32 + 3 * 32; + blueIndex++; + + // purple[purpleIndex][0] = (p.getX()+4) * 32; + // purple[purpleIndex][1] = (p.getY()+1) * 32; + // purple[purpleIndex][2] = (p.getX()+4) * 32 + 2 * 32; + // purple[purpleIndex][3] = (p.getY()+1) * 32 + 2 * 32; + // purpleIndex++; + + // draw a circle at each mineral patch + // C++ : for (BWAPI.Unitset.iterator j = + // (*i).getStaticMinerals().begin(); j != + // (*i).getStaticMinerals().end(); j++) + for (Unit unit : baseLocation.getStaticMinerals()) { + Position q = unit.getInitialPosition(); + cyan[cyanIndex][0] = q.getX(); + cyan[cyanIndex][1] = q.getY(); + cyanIndex++; + } + + // draw the outlines of vespene geysers + // C++ : for (BWAPI.Unitset.iterator j = + // (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) + for (Unit unit : baseLocation.getGeysers()) { + TilePosition q = unit.getInitialTilePosition(); + orange[orangeIndex][0] = q.getX() * 32; + orange[orangeIndex][1] = q.getY() * 32; + orange[orangeIndex][2] = q.getX() * 32 + 4 * 32; + orange[orangeIndex][3] = q.getY() * 32 + 2 * 32; + orangeIndex++; + } + + // if this is an island expansion, draw a yellow circle around + // the base location + if (baseLocation.isIsland()) { + yellow.add(c); + } + } + + // we will iterate through all the regions and draw the polygon + // outline of it in green. + // C++ : for (std.set.const_iterator r = + // BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for (Region region : BWTA.getRegions()) { + Polygon p = region.getPolygon(); + for (int j = 0; j < p.getPoints().size(); j++) { + green1.add(p.getPoints().get(j)); + green2.add(p.getPoints().get((j + 1) % p.getPoints().size())); + } + } + + // we will visualize the chokepoints with red lines + // C++ : for (std.set.const_iterator r = + // BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for (Region region : BWTA.getRegions()) { + // C++ : for (std.set.const_iterator c = + // (*r).getChokepoints().begin(); c != + // (*r).getChokepoints().end(); c++) + for (Chokepoint Chokepoint : region.getChokepoints()) { + red1.add(Chokepoint.getSides().first); + red2.add(Chokepoint.getSides().second); + } + } + hasSavedBWTAInfo = true; + + // System.out.println(blueCount + " " + cyanCount + " " + + // orangeCount + " " + yellowCount + " " + greenCount + " " + + // redCount); + } + + if (hasSavedBWTAInfo) { + for (int i1 = 0; i1 < blue.length; i1++) { + Broodwar.drawBoxMap(blue[i1][0], blue[i1][1], blue[i1][2], blue[i1][3], Color.Blue); + } + // for(int i1=0 ; i1 buildQueue = BuildManager.Instance().buildQueue.getQueue(); + int itemCount = 0; + + Object[] tempQueue = buildQueue.toArray(); + + for (int i = 0; i < tempQueue.length; i++) { + BuildOrderItem currentItem = (BuildOrderItem) tempQueue[i]; + // Broodwar.drawTextScreen(x, y + 10 + (itemCount * 10), + // currentItem.blocking + " " + UxColor.CHAR_WHITE + + // currentItem.metaType.getName()); + UxDrawConfig uxDrawConfig; + uxDrawConfig = UxDrawConfig.newInstanceStringType("M", "", + currentItem.blocking + " " + currentItem.metaType.getName(), UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + itemCount++; + if (itemCount >= 24) + break; + } + } + + /// Build 진행 상태를 Screen 에 표시합니다 + public void drawBuildStatusOnScreen() { + // 건설 / 훈련 중인 유닛 진행상황 표시 + Vector unitsUnderConstruction = new Vector(); + for (Unit unit : Broodwar.self().getUnits()) { + if (unit != null && unit.isBeingConstructed()) { + unitsUnderConstruction.add(unit); + } + } + + // sort it based on the time it was started + Object[] tempArr = unitsUnderConstruction.toArray(); + // Arrays.sort(tempArr); + unitsUnderConstruction = new Vector(); + for (int i = 0; i < tempArr.length; i++) { + unitsUnderConstruction.add((Unit) tempArr[i]); + } + // C++ : std.sort(unitsUnderConstruction.begin(), + // unitsUnderConstruction.end(), CompareWhenStarted()); + + // Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + " "); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("R", "", " ", UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + + for (Unit unit : unitsUnderConstruction) { + UnitType t = unit.getType(); + if (t == UnitType.Zerg_Egg) { + t = unit.getBuildType(); + } + uxDrawConfig = UxDrawConfig.newInstanceStringType("R", "", + "" + t + " (" + unit.getRemainingBuildTime() + ")", UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + } + + // Tech Research 표시 + + // Upgrade 표시 + } + + /// Construction 을 하기 위해 예약해둔 Tile 들을 Map 에 표시합니다 + public void drawReservedBuildingTilesOnMap() { + boolean[][] reserveMap = ConstructionPlaceFinder.Instance().getReserveMap(); + if (reserveMap.length > 0 && reserveMap[0] != null && reserveMap[0].length > 0) { + int rwidth = reserveMap.length; + int rheight = reserveMap[0].length; + + for (int x = 0; x < rwidth; ++x) { + for (int y = 0; y < rheight; ++y) { + if (reserveMap[x][y]) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Yellow, false); + } + } + } + } + } + + /// Construction 을 하지 못하는 Tile 들을 Map 에 표시합니다 + public void drawTilesToAvoidOnMap() { + int y = 0; + int x = 0; + + for (y = 0; y < 128; y++) { + for (x = 0; x < 128; x++) { + if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); + } + if (ConstructionPlaceFinder.Instance().getTilesToAvoidAbsolute(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Purple, false); + } + if (ConstructionPlaceFinder.Instance().getTilesToAvoidSupply(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); + } + } + } + } + + /// ConstructionQueue 를 Screen 에 표시합니다 + public void drawConstructionQueueOnScreenAndMap() { + uxDrawConfig = UxDrawConfig.newInstanceStringType("M", "", " ", UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + + Vector constructionQueue = ConstructionManager.Instance().getConstructionQueue(); + + for (final ConstructionTask b : constructionQueue) { + if (b.getStatus() == ConstructionTask.ConstructionStatus.Unassigned.ordinal()) { + uxDrawConfig = UxDrawConfig.newInstanceStringType("M", "", "" + b.getType() + " - No Worker", + UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } else if (b.getStatus() == ConstructionTask.ConstructionStatus.Assigned.ordinal()) { + if (b.getConstructionWorker() == null) { + uxDrawConfig = UxDrawConfig.newInstanceStringType("M", "", b.getType() + " - Assigned Worker Null", + UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } else { + uxDrawConfig = UxDrawConfig.newInstanceStringType("M", "", + b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")", + UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } + + int x1 = b.getFinalPosition().getX() * 32; + int y1 = b.getFinalPosition().getY() * 32; + int x2 = (b.getFinalPosition().getX() + b.getType().tileWidth()) * 32; + int y2 = (b.getFinalPosition().getY() + b.getType().tileHeight()) * 32; + + Broodwar.drawLineMap(b.getConstructionWorker().getPosition().getX(), + b.getConstructionWorker().getPosition().getY(), (x1 + x2) / 2, (y1 + y2) / 2, Color.Orange); + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); + } else if (b.getStatus() == ConstructionTask.ConstructionStatus.UnderConstruction.ordinal()) { + uxDrawConfig = UxDrawConfig.newInstanceStringType("M", "", "" + b.getType() + " - Under Construction", + UxColor.CHAR_WHITE); + drawStrategyMidList.add(uxDrawConfig); + } + } + } + + public void drawMineralIdOnMap() { + for (Unit unit : Broodwar.getStaticMinerals()) { + + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, + "" + UxColor.CHAR_WHITE + unit.getID()); + } + } + + /// Unit 의 Id 를 Map 에 표시합니다 + public void drawUnitIdOnMap() { + for (Unit unit : Broodwar.self().getUnits()) { + if (unit.getType().isBuilding()) { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, + "" + UxColor.CHAR_WHITE + unit.getID()); + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 25, "" + UxColor.CHAR_WHITE + + unit.getTilePosition().getX() + " / " + unit.getTilePosition().getY()); + } else { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, + "" + UxColor.CHAR_WHITE + unit.getID()); + } + + } + for (Unit unit : Broodwar.enemy().getUnits()) { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, + "" + UxColor.CHAR_WHITE + unit.getID()); + } + } + + /// Worker Unit 의 자원채취 현황을 Map 에 표시합니다 + public void drawWorkerMiningStatusOnMap() { + WorkerData workerData = WorkerManager.Instance().getWorkerData(); + + for (Unit worker : workerData.getWorkers()) { + if (worker == null) + continue; + + Position pos = worker.getTargetPosition(); + + Broodwar.drawTextMap(worker.getPosition().getX(), worker.getPosition().getY() - 5, + "" + UxColor.CHAR_WHITE + workerData.getJobCode(worker)); + + Broodwar.drawLineMap(worker.getPosition().getX(), worker.getPosition().getY(), pos.getX(), pos.getY(), + Color.Cyan); + + } + } + + /// Unit 의 Target 으로 잇는 선을 Map 에 표시합니다 + public void drawUnitTargetOnMap() { + for (Unit unit : Broodwar.self().getUnits()) { + if (unit != null && unit.isCompleted() && !unit.getType().isBuilding() && !unit.getType().isWorker()) { + Unit targetUnit = unit.getTarget(); + if (targetUnit != null && targetUnit.getPlayer() != Broodwar.self()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Red, true); + Broodwar.drawCircleMap(targetUnit.getTargetPosition(), dotRadius, Color.Red, true); + Broodwar.drawLineMap(unit.getPosition(), targetUnit.getTargetPosition(), Color.Red); + } else if (unit.isMoving()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); + Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); + Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); + } + + } + } + } + + /// Bullet 을 Map 에 표시합니다
+ /// Cloaking Unit 의 Bullet 표시에 쓰입니다 + public void drawBulletsOnMap() { + for (Bullet b : Broodwar.getBullets()) { + Position p = b.getPosition(); + double velocityX = b.getVelocityX(); + double velocityY = b.getVelocityY(); + + if (b.getType() == BulletType.Acid_Spore) + bulletTypeName = "Acid_Spore"; + else if (b.getType() == BulletType.Anti_Matter_Missile) + bulletTypeName = "Anti_Matter_Missile"; + else if (b.getType() == BulletType.Arclite_Shock_Cannon_Hit) + bulletTypeName = "Arclite_Shock_Cannon_Hit"; + else if (b.getType() == BulletType.ATS_ATA_Laser_Battery) + bulletTypeName = "ATS_ATA_Laser_Battery"; + else if (b.getType() == BulletType.Burst_Lasers) + bulletTypeName = "Burst_Lasers"; + else if (b.getType() == BulletType.C_10_Canister_Rifle_Hit) + bulletTypeName = "C_10_Canister_Rifle_Hit"; + else if (b.getType() == BulletType.Consume) + bulletTypeName = "Consume"; + else if (b.getType() == BulletType.Corrosive_Acid_Shot) + bulletTypeName = "Corrosive_Acid_Shot"; + else if (b.getType() == BulletType.Dual_Photon_Blasters_Hit) + bulletTypeName = "Dual_Photon_Blasters_Hit"; + else if (b.getType() == BulletType.EMP_Missile) + bulletTypeName = "EMP_Missile"; + else if (b.getType() == BulletType.Ensnare) + bulletTypeName = "Ensnare"; + else if (b.getType() == BulletType.Fragmentation_Grenade) + bulletTypeName = "Fragmentation_Grenade"; + else if (b.getType() == BulletType.Fusion_Cutter_Hit) + bulletTypeName = "Fusion_Cutter_Hit"; + else if (b.getType() == BulletType.Gauss_Rifle_Hit) + bulletTypeName = "Gauss_Rifle_Hit"; + else if (b.getType() == BulletType.Gemini_Missiles) + bulletTypeName = "Gemini_Missiles"; + else if (b.getType() == BulletType.Glave_Wurm) + bulletTypeName = "Glave_Wurm"; + else if (b.getType() == BulletType.Halo_Rockets) + bulletTypeName = "Halo_Rockets"; + else if (b.getType() == BulletType.Invisible) + bulletTypeName = "Invisible"; + else if (b.getType() == BulletType.Longbolt_Missile) + bulletTypeName = "Longbolt_Missile"; + else if (b.getType() == BulletType.Melee) + bulletTypeName = "Melee"; + else if (b.getType() == BulletType.Needle_Spine_Hit) + bulletTypeName = "Needle_Spine_Hit"; + else if (b.getType() == BulletType.Neutron_Flare) + bulletTypeName = "Neutron_Flare"; + else if (b.getType() == BulletType.None) + bulletTypeName = "None"; + else if (b.getType() == BulletType.Optical_Flare_Grenade) + bulletTypeName = "Optical_Flare_Grenade"; + else if (b.getType() == BulletType.Particle_Beam_Hit) + bulletTypeName = "Particle_Beam_Hit"; + else if (b.getType() == BulletType.Phase_Disruptor) + bulletTypeName = "Phase_Disruptor"; + else if (b.getType() == BulletType.Plague_Cloud) + bulletTypeName = "Plague_Cloud"; + else if (b.getType() == BulletType.Psionic_Shockwave_Hit) + bulletTypeName = "Psionic_Shockwave_Hit"; + else if (b.getType() == BulletType.Psionic_Storm) + bulletTypeName = "Psionic_Storm"; + else if (b.getType() == BulletType.Pulse_Cannon) + bulletTypeName = "Pulse_Cannon"; + else if (b.getType() == BulletType.Queen_Spell_Carrier) + bulletTypeName = "Queen_Spell_Carrier"; + else if (b.getType() == BulletType.Seeker_Spores) + bulletTypeName = "Seeker_Spores"; + else if (b.getType() == BulletType.STA_STS_Cannon_Overlay) + bulletTypeName = "STA_STS_Cannon_Overlay"; + else if (b.getType() == BulletType.Subterranean_Spines) + bulletTypeName = "Subterranean_Spines"; + else if (b.getType() == BulletType.Sunken_Colony_Tentacle) + bulletTypeName = "Sunken_Colony_Tentacle"; + else if (b.getType() == BulletType.Unknown) + bulletTypeName = "Unknown"; + else if (b.getType() == BulletType.Yamato_Gun) + bulletTypeName = "Yamato_Gun"; + + // 아군 것이면 녹색, 적군 것이면 빨간색 + Broodwar.drawLineMap(p, new Position(p.getX() + (int) velocityX, p.getY() + (int) velocityY), + b.getPlayer() == Broodwar.self() ? Color.Green : Color.Red); + if (b.getType() != null) { + Broodwar.drawTextMap(p, + (b.getPlayer() == Broodwar.self() ? "" + UxColor.CHAR_TEAL : "" + UxColor.CHAR_RED) + + bulletTypeName); + } + } + } + + protected void drawSquadUnitTagMap() { + // draw neutral units and our units + for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { + Color color = UxColor.SQUAD_COLOR.get(squad.getClass()); + if (color == null) { + continue; + } + String squadName = squad.getSquadName(); + + StrategyCode.SmallFightPredict smallFightPredict = null; + if (squad instanceof WatcherSquad) { + smallFightPredict = ((WatcherSquad) squad).getSmallFightPredict(); + } + + if (squadName.length() > 4) { + squadName = squadName.substring(0, 4); + } + + for (Unit unit : squad.unitList) { + Broodwar.drawCircleMap(unit.getPosition(), 10, color); + Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 30, squadName); + if (smallFightPredict != null && smallFightPredict == StrategyCode.SmallFightPredict.BACK) { + Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 15, + UxColor.CHAR_RED + smallFightPredict.toString()); + } + } + } + } - public void clearList() { - // TODO Auto-generated method stub - drawStrategyLeftList.clear(); - drawStrategyMidList.clear(); - drawStrategyRightList.clear(); + /* + * private void drawSquadInfoOnMap() { /// ConstructionQueue 를 Screen 에 + * 표시합니다 uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L",""," " + * ,UxColor.CHAR_WHITE); drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","" + "*" + + * "SCV"," "+ UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, + * UnitType.Terran_SCV),UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * for (Squad squad : + * CombatManager.Instance().squadData.getSquadMap().values()) { Color + * squadColor = UxColor.SQUAD_COLOR.get(squad.getClass()); String squadName + * = ""; if (squadColor != null) { squadName = "" + + * UxColor.COLOR_TO_CHARACTER.get(squadColor) + squad.getSquadName(); } else + * { squadName = "*" + squad.getSquadName(); } String unitIds = " ... "; for + * (Unit unit : squad.unitList) { unitIds = unitIds + unit.getID() + "/"; } + * uxDrawConfig = UxDrawConfig.newInstanceObjectType("L",squadName," "+ "" + * + squad.unitList.size() + unitIds,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); } } + */ + + protected void drawManagerTimeSpent() { + List gameManagers = Arrays.asList( + // InformationManager.Instance(), + StrategyManager.Instance(), MapGrid.Instance(), BuildManager.Instance(), BuildQueueProvider.Instance(), + ConstructionManager.Instance(), WorkerManager.Instance(), CombatManager.Instance() + // AttackDecisionMaker.Instance() + ); + + for (GameManager gameManager : gameManagers) { + char drawColor = UxColor.CHAR_WHITE; + if (gameManager.getRecorded() > 10L) { + drawColor = UxColor.CHAR_TEAL; + } else if (gameManager.getRecorded() > 30L) { + drawColor = UxColor.CHAR_RED; + } + uxDrawConfig = UxDrawConfig.newInstanceStringType("R", gameManager.getClass().getSimpleName(), + gameManager.getRecorded(), UxColor.CHAR_PURPLE); + drawStrategyRightList.add(uxDrawConfig); } - private void drawDecision() { - for (Integer unitId : decisionListForUx.keySet()) { - Unit unit = Broodwar.getUnit(unitId); - MicroDecision decision = decisionListForUx.get(unitId); - Broodwar.drawTextMap(unit.getPosition(), UxColor.CHAR_YELLOW + decision.toString()); - if (decision.eui != null) { - Broodwar.drawLineMap(unit.getPosition(), decision.eui.getLastPosition(), Color.Yellow); - } - } - } - - public void addDecisionListForUx(Unit unit, MicroDecision decision) { - decisionListForUx.put(unit.getID(), decision); - } - - public void clearDecisionListForUx() { - decisionListForUx.clear(); - } - - protected void drawTimer() { - char battleColor = UxColor.CHAR_WHITE; - if (StrategyBoard.initiated) { - battleColor = UxColor.CHAR_RED; - } - uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",StrategyBoard.mainSquadMode.toString() + ": " + DrawingUtils.framesToTimeString(TimeUtils.getFrame()) + "(" + TimeUtils.getFrame() + ")",battleColor); - drawStrategyMidList.add(uxDrawConfig); - - char apmColor = UxColor.CHAR_WHITE; - int apm = Broodwar.getAPM(); - if (apm > 3000) { - apmColor = UxColor.CHAR_RED; - } else if (apm > 2000) { - apmColor = UxColor.CHAR_YELLOW; - } else if (apm > 1000) { - apmColor = UxColor.CHAR_GREEN; - } else { - apmColor = UxColor.CHAR_WHITE; - } - uxDrawConfig = UxDrawConfig.newInstanceStringType("R","APM : ",Broodwar.getAPM(),apmColor); - drawStrategyRightList.add(uxDrawConfig); - } - - protected void drawEnemyBuildTimer(){ - - Map buildTimeExpectMap = EnemyBuildTimer.Instance().buildTimeExpectMap; - Map buildTimeMinimumMap = EnemyBuildTimer.Instance().buildTimeMinimumMap; - Set buildTimeCertain = EnemyBuildTimer.Instance().buildTimeCertain; - - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","engine Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.engineeringBayBuildStartFrame),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","turret Build Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretBuildStartFrame),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","turret Need Frame",DrawingUtils.framesToTimeString(StrategyBoard.turretNeedFrame),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","darkTemplarInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().darkTemplarInMyBaseFrame),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","reaverInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().reaverInMyBaseFrame),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","mutaliskInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().mutaliskInMyBaseFrame),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","lurkerInMyBaseFrame",DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().lurkerInMyBaseFrame),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - for (UnitType unitType : buildTimeExpectMap.keySet()) { - Integer buildTimeExpect = buildTimeExpectMap.get(unitType); - if (buildTimeExpect != null && buildTimeExpect != CommonCode.UNKNOWN) { - String expect = DrawingUtils.framesToTimeString(buildTimeExpect); - String minimum = ""; - Integer buildMinimum = buildTimeMinimumMap.get(unitType); - if (buildMinimum != null && buildMinimum != CommonCode.UNKNOWN) { - minimum = DrawingUtils.framesToTimeString(buildMinimum); - } - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","",unitType + " : " + expect + " - min: " + minimum + " (" + buildTimeCertain.contains(unitType) + ")",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - } - } - - } - - protected void drawDebugginUxMenu() { - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","1. Default Information",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","2. Strategy Information",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","3. Position Finder Test",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","4. Air Micro Test",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","5. Unit Bast To Base",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - uxDrawConfig= UxDrawConfig.newInstanceStringType("L","","",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - } - - // 게임 개요 정보를 Screen 에 표시합니다 - public void drawGameInformationOnScreen() { - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","Current Strategy",StrategyBoard.currentStrategy.name(),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - String history = ""; - for (int i = StrategyBoard.strategyHistory.size() - 1; i >= 0; i--) { - if (i == StrategyBoard.strategyHistory.size() - 3) { - history = "... " + history; - break; - } else { - history = StrategyBoard.strategyHistory.get(i).name() + " -> " + history; - } - } - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","MYKillScore",Broodwar.self().getKillScore(),UxColor.CHAR_RED); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","MYRazingScore",Broodwar.self().getRazingScore(),UxColor.CHAR_RED); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","EnemyKillScore",Broodwar.enemy().getKillScore(),UxColor.CHAR_PURPLE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","EnemyRazingScore",Broodwar.enemy().getRazingScore(),UxColor.CHAR_PURPLE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","Reserved Resource",ConstructionManager.Instance().getReservedMinerals()+ " / " + ConstructionManager.Instance().getReservedGas(),UxColor.CHAR_TEAL); - drawStrategyLeftList.add(uxDrawConfig); - - } - - /// Players 정보를 Screen 에 표시합니다 - public void drawPlayers() { - for (Player p : Broodwar.getPlayers()) { - Broodwar.sendText("Player [" + p.getID() + "]: " + p.getName() + " is in force: " + p.getForce().getName()); - } - } - - /// Player 들의 팀 (Force) 들의 정보를 Screen 에 표시합니다 - public void drawForces() { - for (Force f : Broodwar.getForces()) { - Broodwar.sendText("Force " + f.getName() + " has the following players:"); - for (Player p : f.getPlayers()) { - Broodwar.sendText(" - Player [" + p.getID() + "]: " + p.getName()); - } - } - } - - /// Unit 의 HitPoint 등 추가 정보를 Map 에 표시합니다 - public void drawUnitExtendedInformationOnMap() { - int verticalOffset = -10; - - for (UnitInfo ui : UnitUtils.getEnemyUnitInfoList()) { - - UnitType type = ui.getType(); - int hitPoints = ui.getLastHealth(); - int shields = ui.getLastShields(); - - Position pos = ui.getLastPosition(); - - int left = pos.getX() - type.dimensionLeft(); - int right = pos.getX() + type.dimensionRight(); - int top = pos.getY() - type.dimensionUp(); - int bottom = pos.getY() + type.dimensionDown(); - - // 적 유닛이면 주위에 박스 표시 - if (!Broodwar.isVisible(ui.getLastPosition().toTilePosition())) { - Broodwar.drawBoxMap(new Position(left, top), new Position(right, bottom), Color.Grey, false); - Broodwar.drawTextMap(new Position(left + 3, top + 4), ui.getType().toString()); - } - - // 유닛의 HitPoint 남아있는 비율 표시 - if (!type.isResourceContainer() && type.maxHitPoints() > 0) { - double hpRatio = (double) hitPoints / (double) type.maxHitPoints(); - - Color hpColor = Color.Green; - if (hpRatio < 0.66) hpColor = Color.Orange; - if (hpRatio < 0.33) hpColor = Color.Red; - - int ratioRight = left + (int) ((right - left) * hpRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // 유닛의 Shield 남아있는 비율 표시 - if (!type.isResourceContainer() && type.maxShields() > 0) { - double shieldRatio = (double) shields / (double) type.maxShields(); - - int ratioRight = left + (int) ((right - left) * shieldRatio); - int hpTop = top - 3 + verticalOffset; - int hpBottom = top + 1 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - } - - // draw neutral units and our units - for (Unit unit : Broodwar.getAllUnits()) { - if (unit.getPlayer() == PlayerUtils.enemyPlayer()) { - continue; - } - - final Position pos = unit.getPosition(); - - int left = pos.getX() - unit.getType().dimensionLeft(); - int right = pos.getX() + unit.getType().dimensionRight(); - int top = pos.getY() - unit.getType().dimensionUp(); - int bottom = pos.getY() + unit.getType().dimensionDown(); - - //Monster.game.drawBoxMap(BWAPI.Position(left, top), BWAPI.Position(right, bottom), Color.Grey, false); - - // 유닛의 HitPoint 남아있는 비율 표시 - if (!unit.getType().isResourceContainer() && unit.getType().maxHitPoints() > 0) { - double hpRatio = (double) unit.getHitPoints() / (double) unit.getType().maxHitPoints(); - - Color hpColor = Color.Green; - if (hpRatio < 0.66) hpColor = Color.Orange; - if (hpRatio < 0.33) hpColor = Color.Red; - - int ratioRight = left + (int) ((right - left) * hpRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), hpColor.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // 유닛의 Shield 남아있는 비율 표시 - if (!unit.getType().isResourceContainer() && unit.getType().maxShields() > 0) { - double shieldRatio = (double) unit.getShields() / (double) unit.getType().maxShields(); - - int ratioRight = left + (int) ((right - left) * shieldRatio); - int hpTop = top - 3 + verticalOffset; - int hpBottom = top + 1 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // Mineral / Gas 가 얼마나 남아있는가 - if (unit.getType().isResourceContainer() && unit.getInitialResources() > 0) { - double mineralRatio = (double) unit.getResources() / (double) unit.getInitialResources(); - - int ratioRight = left + (int) ((right - left) * mineralRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Cyan, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - } - } - - /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 - public void drawBWTAResultOnMap() { - int blueCount = 0; - int cyanCount = 0; - int orangeCount = 0; -// int purpleCount = 0; - - if (hasSavedBWTAInfo == false) { - for (BaseLocation baseLocation : BWTA.getBaseLocations()) { - blueCount++; -// purpleCount++; - for (Unit unit : baseLocation.getStaticMinerals()) { - cyanCount++; - } - for (Unit unit : baseLocation.getGeysers()) { - orangeCount++; - } - - } - - blue = new int[blueCount][4]; - int blueIndex = 0; - cyan = new int[cyanCount][2]; - int cyanIndex = 0; - orange = new int[orangeCount][4]; - int orangeIndex = 0; - -// purple = new int[purpleCount][4]; -// int purpleIndex = 0; - - for (BaseLocation baseLocation : BWTA.getBaseLocations()) { - TilePosition p = baseLocation.getTilePosition(); - Position c = baseLocation.getPosition(); - - blue[blueIndex][0] = p.getX() * 32; - blue[blueIndex][1] = p.getY() * 32; - blue[blueIndex][2] = p.getX() * 32 + 4 * 32; - blue[blueIndex][3] = p.getY() * 32 + 3 * 32; - blueIndex++; - -// purple[purpleIndex][0] = (p.getX()+4) * 32; -// purple[purpleIndex][1] = (p.getY()+1) * 32; -// purple[purpleIndex][2] = (p.getX()+4) * 32 + 2 * 32; -// purple[purpleIndex][3] = (p.getY()+1) * 32 + 2 * 32; -// purpleIndex++; - - //draw a circle at each mineral patch - // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) - for (Unit unit : baseLocation.getStaticMinerals()) { - Position q = unit.getInitialPosition(); - cyan[cyanIndex][0] = q.getX(); - cyan[cyanIndex][1] = q.getY(); - cyanIndex++; - } - - //draw the outlines of vespene geysers - // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) - for (Unit unit : baseLocation.getGeysers()) { - TilePosition q = unit.getInitialTilePosition(); - orange[orangeIndex][0] = q.getX() * 32; - orange[orangeIndex][1] = q.getY() * 32; - orange[orangeIndex][2] = q.getX() * 32 + 4 * 32; - orange[orangeIndex][3] = q.getY() * 32 + 2 * 32; - orangeIndex++; - } - - //if this is an island expansion, draw a yellow circle around the base location - if (baseLocation.isIsland()) { - yellow.add(c); - } - } - - //we will iterate through all the regions and draw the polygon outline of it in green. - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for (Region region : BWTA.getRegions()) { - Polygon p = region.getPolygon(); - for (int j = 0; j < p.getPoints().size(); j++) { - green1.add(p.getPoints().get(j)); - green2.add(p.getPoints().get((j + 1) % p.getPoints().size())); - } - } - - //we will visualize the chokepoints with red lines - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for (Region region : BWTA.getRegions()) { - // C++ : for (std.set.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) - for (Chokepoint Chokepoint : region.getChokepoints()) { - red1.add(Chokepoint.getSides().first); - red2.add(Chokepoint.getSides().second); - } - } - hasSavedBWTAInfo = true; - -// System.out.println(blueCount + " " + cyanCount + " " + orangeCount + " " + yellowCount + " " + greenCount + " " + redCount); - } - - if (hasSavedBWTAInfo) { - for (int i1 = 0; i1 < blue.length; i1++) { - Broodwar.drawBoxMap(blue[i1][0], blue[i1][1], blue[i1][2], blue[i1][3], Color.Blue); - } -// for(int i1=0 ; i1 buildQueue = BuildManager.Instance().buildQueue.getQueue(); - int itemCount = 0; - - Object[] tempQueue = buildQueue.toArray(); - - for (int i = 0; i < tempQueue.length; i++) { - BuildOrderItem currentItem = (BuildOrderItem) tempQueue[i]; - //Broodwar.drawTextScreen(x, y + 10 + (itemCount * 10), currentItem.blocking + " " + UxColor.CHAR_WHITE + currentItem.metaType.getName()); - UxDrawConfig uxDrawConfig; - uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",currentItem.blocking + " " + currentItem.metaType.getName(),UxColor.CHAR_WHITE); - drawStrategyMidList.add(uxDrawConfig); - itemCount++; - if (itemCount >= 24) break; - } - } - - /// Build 진행 상태를 Screen 에 표시합니다 - public void drawBuildStatusOnScreen() { - // 건설 / 훈련 중인 유닛 진행상황 표시 - Vector unitsUnderConstruction = new Vector(); - for (Unit unit : Broodwar.self().getUnits()) { - if (unit != null && unit.isBeingConstructed()) { - unitsUnderConstruction.add(unit); - } - } - - // sort it based on the time it was started - Object[] tempArr = unitsUnderConstruction.toArray(); - //Arrays.sort(tempArr); - unitsUnderConstruction = new Vector(); - for (int i = 0; i < tempArr.length; i++) { - unitsUnderConstruction.add((Unit) tempArr[i]); - } - // C++ : std.sort(unitsUnderConstruction.begin(), unitsUnderConstruction.end(), CompareWhenStarted()); - - //Broodwar.drawTextScreen(x, y, UxColor.CHAR_WHITE + " "); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("R",""," ",UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - - - for (Unit unit : unitsUnderConstruction) { - UnitType t = unit.getType(); - if (t == UnitType.Zerg_Egg) { - t = unit.getBuildType(); - } - uxDrawConfig = UxDrawConfig.newInstanceStringType("R","","" + t + " (" + unit.getRemainingBuildTime() + ")",UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - } - - // Tech Research 표시 - - // Upgrade 표시 - } - - /// Construction 을 하기 위해 예약해둔 Tile 들을 Map 에 표시합니다 - public void drawReservedBuildingTilesOnMap() { - boolean[][] reserveMap = ConstructionPlaceFinder.Instance().getReserveMap(); - if (reserveMap.length > 0 && reserveMap[0] != null && reserveMap[0].length > 0) { - int rwidth = reserveMap.length; - int rheight = reserveMap[0].length; - - for (int x = 0; x < rwidth; ++x) { - for (int y = 0; y < rheight; ++y) { - if (reserveMap[x][y]) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Yellow, false); - } - } - } - } - } - - /// Construction 을 하지 못하는 Tile 들을 Map 에 표시합니다 - public void drawTilesToAvoidOnMap() { - int y = 0; - int x = 0; - - for (y = 0; y < 128; y++) { - for (x = 0; x < 128; x++) { - if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); - } - if (ConstructionPlaceFinder.Instance().getTilesToAvoidAbsolute(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Purple, false); - } - if (ConstructionPlaceFinder.Instance().getTilesToAvoidSupply(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); - } - } - } - } - - /// ConstructionQueue 를 Screen 에 표시합니다 - public void drawConstructionQueueOnScreenAndMap() { - uxDrawConfig = UxDrawConfig.newInstanceStringType("M",""," ",UxColor.CHAR_WHITE); - drawStrategyMidList.add(uxDrawConfig); - - - Vector constructionQueue = ConstructionManager.Instance().getConstructionQueue(); - - for (final ConstructionTask b : constructionQueue) { - if (b.getStatus() == ConstructionTask.ConstructionStatus.Unassigned.ordinal()) { - uxDrawConfig = UxDrawConfig.newInstanceStringType("M","","" + b.getType() + " - No Worker",UxColor.CHAR_WHITE); - drawStrategyMidList.add(uxDrawConfig); - } else if (b.getStatus() == ConstructionTask.ConstructionStatus.Assigned.ordinal()) { - if (b.getConstructionWorker() == null) { - uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",b.getType() + " - Assigned Worker Null",UxColor.CHAR_WHITE); - drawStrategyMidList.add(uxDrawConfig); - } else { - uxDrawConfig = UxDrawConfig.newInstanceStringType("M","",b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")",UxColor.CHAR_WHITE); - drawStrategyMidList.add(uxDrawConfig); - } - - int x1 = b.getFinalPosition().getX() * 32; - int y1 = b.getFinalPosition().getY() * 32; - int x2 = (b.getFinalPosition().getX() + b.getType().tileWidth()) * 32; - int y2 = (b.getFinalPosition().getY() + b.getType().tileHeight()) * 32; - - Broodwar.drawLineMap(b.getConstructionWorker().getPosition().getX(), b.getConstructionWorker().getPosition().getY(), (x1 + x2) / 2, (y1 + y2) / 2, Color.Orange); - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); - } else if (b.getStatus() == ConstructionTask.ConstructionStatus.UnderConstruction.ordinal()) { - uxDrawConfig = UxDrawConfig.newInstanceStringType("M","","" + b.getType() + " - Under Construction",UxColor.CHAR_WHITE); - drawStrategyMidList.add(uxDrawConfig); - } - } - } - - - - public void drawMineralIdOnMap() { - for (Unit unit : Broodwar.getStaticMinerals()) { - - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - } - } - - /// Unit 의 Id 를 Map 에 표시합니다 - public void drawUnitIdOnMap() { - for (Unit unit : Broodwar.self().getUnits()) { - if (unit.getType().isBuilding()) { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 25, "" + UxColor.CHAR_WHITE + unit.getTilePosition().getX() + " / " + unit.getTilePosition().getY()); - } else { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - } - - } - for (Unit unit : Broodwar.enemy().getUnits()) { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + UxColor.CHAR_WHITE + unit.getID()); - } - } - - /// Worker Unit 의 자원채취 현황을 Map 에 표시합니다 - public void drawWorkerMiningStatusOnMap() { - WorkerData workerData = WorkerManager.Instance().getWorkerData(); - - for (Unit worker : workerData.getWorkers()) { - if (worker == null) continue; - - Position pos = worker.getTargetPosition(); - - Broodwar.drawTextMap(worker.getPosition().getX(), worker.getPosition().getY() - 5, "" + UxColor.CHAR_WHITE + workerData.getJobCode(worker)); - - Broodwar.drawLineMap(worker.getPosition().getX(), worker.getPosition().getY(), pos.getX(), pos.getY(), Color.Cyan); - - } - } - - /// Unit 의 Target 으로 잇는 선을 Map 에 표시합니다 - public void drawUnitTargetOnMap() { - for (Unit unit : Broodwar.self().getUnits()) { - if (unit != null && unit.isCompleted() && !unit.getType().isBuilding() && !unit.getType().isWorker()) { - Unit targetUnit = unit.getTarget(); - if (targetUnit != null && targetUnit.getPlayer() != Broodwar.self()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Red, true); - Broodwar.drawCircleMap(targetUnit.getTargetPosition(), dotRadius, Color.Red, true); - Broodwar.drawLineMap(unit.getPosition(), targetUnit.getTargetPosition(), Color.Red); - } else if (unit.isMoving()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); - Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); - Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); - } - - } - } - } - - /// Bullet 을 Map 에 표시합니다
- /// Cloaking Unit 의 Bullet 표시에 쓰입니다 - public void drawBulletsOnMap() { - for (Bullet b : Broodwar.getBullets()) { - Position p = b.getPosition(); - double velocityX = b.getVelocityX(); - double velocityY = b.getVelocityY(); - - if (b.getType() == BulletType.Acid_Spore) bulletTypeName = "Acid_Spore"; - else if (b.getType() == BulletType.Anti_Matter_Missile) bulletTypeName = "Anti_Matter_Missile"; - else if (b.getType() == BulletType.Arclite_Shock_Cannon_Hit) bulletTypeName = "Arclite_Shock_Cannon_Hit"; - else if (b.getType() == BulletType.ATS_ATA_Laser_Battery) bulletTypeName = "ATS_ATA_Laser_Battery"; - else if (b.getType() == BulletType.Burst_Lasers) bulletTypeName = "Burst_Lasers"; - else if (b.getType() == BulletType.C_10_Canister_Rifle_Hit) bulletTypeName = "C_10_Canister_Rifle_Hit"; - else if (b.getType() == BulletType.Consume) bulletTypeName = "Consume"; - else if (b.getType() == BulletType.Corrosive_Acid_Shot) bulletTypeName = "Corrosive_Acid_Shot"; - else if (b.getType() == BulletType.Dual_Photon_Blasters_Hit) bulletTypeName = "Dual_Photon_Blasters_Hit"; - else if (b.getType() == BulletType.EMP_Missile) bulletTypeName = "EMP_Missile"; - else if (b.getType() == BulletType.Ensnare) bulletTypeName = "Ensnare"; - else if (b.getType() == BulletType.Fragmentation_Grenade) bulletTypeName = "Fragmentation_Grenade"; - else if (b.getType() == BulletType.Fusion_Cutter_Hit) bulletTypeName = "Fusion_Cutter_Hit"; - else if (b.getType() == BulletType.Gauss_Rifle_Hit) bulletTypeName = "Gauss_Rifle_Hit"; - else if (b.getType() == BulletType.Gemini_Missiles) bulletTypeName = "Gemini_Missiles"; - else if (b.getType() == BulletType.Glave_Wurm) bulletTypeName = "Glave_Wurm"; - else if (b.getType() == BulletType.Halo_Rockets) bulletTypeName = "Halo_Rockets"; - else if (b.getType() == BulletType.Invisible) bulletTypeName = "Invisible"; - else if (b.getType() == BulletType.Longbolt_Missile) bulletTypeName = "Longbolt_Missile"; - else if (b.getType() == BulletType.Melee) bulletTypeName = "Melee"; - else if (b.getType() == BulletType.Needle_Spine_Hit) bulletTypeName = "Needle_Spine_Hit"; - else if (b.getType() == BulletType.Neutron_Flare) bulletTypeName = "Neutron_Flare"; - else if (b.getType() == BulletType.None) bulletTypeName = "None"; - else if (b.getType() == BulletType.Optical_Flare_Grenade) bulletTypeName = "Optical_Flare_Grenade"; - else if (b.getType() == BulletType.Particle_Beam_Hit) bulletTypeName = "Particle_Beam_Hit"; - else if (b.getType() == BulletType.Phase_Disruptor) bulletTypeName = "Phase_Disruptor"; - else if (b.getType() == BulletType.Plague_Cloud) bulletTypeName = "Plague_Cloud"; - else if (b.getType() == BulletType.Psionic_Shockwave_Hit) bulletTypeName = "Psionic_Shockwave_Hit"; - else if (b.getType() == BulletType.Psionic_Storm) bulletTypeName = "Psionic_Storm"; - else if (b.getType() == BulletType.Pulse_Cannon) bulletTypeName = "Pulse_Cannon"; - else if (b.getType() == BulletType.Queen_Spell_Carrier) bulletTypeName = "Queen_Spell_Carrier"; - else if (b.getType() == BulletType.Seeker_Spores) bulletTypeName = "Seeker_Spores"; - else if (b.getType() == BulletType.STA_STS_Cannon_Overlay) bulletTypeName = "STA_STS_Cannon_Overlay"; - else if (b.getType() == BulletType.Subterranean_Spines) bulletTypeName = "Subterranean_Spines"; - else if (b.getType() == BulletType.Sunken_Colony_Tentacle) bulletTypeName = "Sunken_Colony_Tentacle"; - else if (b.getType() == BulletType.Unknown) bulletTypeName = "Unknown"; - else if (b.getType() == BulletType.Yamato_Gun) bulletTypeName = "Yamato_Gun"; - - // 아군 것이면 녹색, 적군 것이면 빨간색 - Broodwar.drawLineMap(p, new Position(p.getX() + (int) velocityX, p.getY() + (int) velocityY), b.getPlayer() == Broodwar.self() ? Color.Green : Color.Red); - if (b.getType() != null) { - Broodwar.drawTextMap(p, (b.getPlayer() == Broodwar.self() ? "" + UxColor.CHAR_TEAL : "" + UxColor.CHAR_RED) + bulletTypeName); - } - } - } - - protected void drawSquadUnitTagMap() { - // draw neutral units and our units - for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { - Color color = UxColor.SQUAD_COLOR.get(squad.getClass()); - if (color == null) { - continue; - } - String squadName = squad.getSquadName(); - - StrategyCode.SmallFightPredict smallFightPredict = null; - if (squad instanceof WatcherSquad) { - smallFightPredict = ((WatcherSquad) squad).getSmallFightPredict(); - } - - if (squadName.length() > 4) { - squadName = squadName.substring(0, 4); - } - - for (Unit unit : squad.unitList) { - Broodwar.drawCircleMap(unit.getPosition(), 10, color); - Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 30, squadName); - if (smallFightPredict != null && smallFightPredict == StrategyCode.SmallFightPredict.BACK) { - Broodwar.drawTextMap(unit.getPosition().getX() - 20, unit.getPosition().getY() - 15, UxColor.CHAR_RED + smallFightPredict.toString()); - } - } - - } - } - - /* private void drawSquadInfoOnMap() { - /// ConstructionQueue 를 Screen 에 표시합니다 - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L",""," ",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","" + "*" + "SCV"," "+ UnitUtils.getUnitCount(UnitFindStatus.COMPLETE, UnitType.Terran_SCV),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - for (Squad squad : CombatManager.Instance().squadData.getSquadMap().values()) { - Color squadColor = UxColor.SQUAD_COLOR.get(squad.getClass()); - String squadName = ""; - if (squadColor != null) { - squadName = "" + UxColor.COLOR_TO_CHARACTER.get(squadColor) + squad.getSquadName(); - } else { - squadName = "*" + squad.getSquadName(); - } - String unitIds = " ... "; - for (Unit unit : squad.unitList) { - unitIds = unitIds + unit.getID() + "/"; - } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L",squadName," "+ "" + squad.unitList.size() + unitIds,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - } - }*/ - - protected void drawManagerTimeSpent() { - List gameManagers = Arrays.asList( - //InformationManager.Instance(), - StrategyManager.Instance(), - MapGrid.Instance(), - BuildManager.Instance(), - BuildQueueProvider.Instance(), - ConstructionManager.Instance(), - WorkerManager.Instance(), - CombatManager.Instance() -// AttackDecisionMaker.Instance() - ); - - - for (GameManager gameManager : gameManagers) { - char drawColor = UxColor.CHAR_WHITE; - if (gameManager.getRecorded() > 10L) { - drawColor = UxColor.CHAR_TEAL; - } else if (gameManager.getRecorded() > 30L) { - drawColor = UxColor.CHAR_RED; - } - uxDrawConfig = UxDrawConfig.newInstanceStringType("R",gameManager.getClass().getSimpleName(),gameManager.getRecorded(),UxColor.CHAR_PURPLE); - drawStrategyRightList.add(uxDrawConfig); - } - - uxDrawConfig = UxDrawConfig.newInstanceMethodType("R","* group size",LagObserver.class, "groupsize",UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - uxDrawConfig = UxDrawConfig.newInstanceMethodType("R","* manager rotation size",LagObserver.class,"managerRotationSize",UxColor.CHAR_WHITE); - drawStrategyRightList.add(uxDrawConfig); - } - - /*private void drawBigWatch() { - Map resultTimeMap = BigWatch.getResultTimeMap(); - Map recordTimeMap = BigWatch.getRecordTimeMap(); - - List tags = new ArrayList<>(recordTimeMap.keySet()); - Collections.sort(tags); - - for (String tag : tags) { - Long resultTime = resultTimeMap.get(tag); - resultTime = resultTime == null ? 0L : resultTime; - Long recordTime = recordTimeMap.get(tag); - - char drawColor = UxColor.CHAR_WHITE; - if (recordTime > 10L) { - drawColor = UxColor.CHAR_TEAL; - } else if (recordTime > 30L) { - drawColor = UxColor.CHAR_RED; - } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","",tag + " : " + resultTime + " / " + drawColor + recordTime,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - } - }*/ - - protected void drawPathData() { - for (Unit depot : UnitUtils.getUnitList(UnitType.Terran_Command_Center)) { - List mineralsList = WorkerData.depotMineral.get(depot); - if (mineralsList == null) { - return; - } - - for (Minerals minr : mineralsList) { - if (minr.mineralTrick != null) { - Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), 4, Color.Blue, true); - Broodwar.drawCircleMap(minr.mineralTrick.getPosition().getX(), minr.mineralTrick.getPosition().getY(), 4, Color.Purple, true); - } - } - - - for (Minerals minr : WorkerData.depotMineral.get(depot)) { - if (minr.posTrick != bwapi.Position.None) { - Broodwar.drawCircleMap(minr.posTrick.getX(), minr.posTrick.getY(), 4, Color.Red, true); - Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), 4, Color.Yellow, true); - } - } - - } - - } - - protected void drawStrategy(){ - String upgradeString = ""; - for (MetaType metaType : StrategyBoard.upgrade) { - upgradeString += metaType.getName() + " > "; - } - - Race enemyRace = PlayerUtils.enemyRace(); - EnemyStrategy strategy = StrategyBoard.currentStrategy; - int phase = EnemyStrategyAnalyzer.Instance().getPhase(); - - //setting - UxDrawConfig uxDrawConfig = UxDrawConfig.newInstanceStringType("L","", "[" + strategy.name() + " ...(phase " + phase + ")]",UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","UPGRADE",upgradeString,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","EXPANSION",StrategyBoard.expansionOption,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","MISSION",strategy.missionTypeList,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","",ClueManager.Instance().getClueInfoList(),UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceStringType("L","",strategy.buildTimeMap,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - - for (EnemyStrategy enemyStrategy : EnemyStrategy.values()) { - if (enemyStrategy.name().startsWith(enemyRace.toString().toUpperCase())) { - uxDrawConfig = UxDrawConfig.newInstanceStringType("R","",enemyStrategy.name(),UxColor.CHAR_YELLOW); - drawStrategyRightList.add(uxDrawConfig); - } - } - } - - private void drawEnemyAirDefenseRange() { - List airDefenseEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, UnitTypeUtils.enemyAirDefenseUnitType()); - for (UnitInfo eui : airDefenseEuiList) { - if (eui.getType() == UnitType.Terran_Bunker) { - Broodwar.drawCircleMap(eui.getLastPosition(), Broodwar.enemy().weaponMaxRange(UnitType.Terran_Marine.groundWeapon()) + 96, Color.White); - } else { - Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.White); - } - } - List wraithKillerEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, UnitTypeUtils.wraithKillerUnitType()); - for (UnitInfo eui : wraithKillerEuiList) { - Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.Grey); - } - } - - private void drawAirForceInformation() { - // wraith moving - for (Unit unit : UnitUtils.getUnitList(UnitType.Zerg_Mutalisk)) { - if (unit.isMoving()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); - Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); - Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); - } - } - - // target position - List targetPositions = AirForceManager.Instance().getTargetPositions(); - for (int i = 0; i < targetPositions.size(); i++) { - Broodwar.drawTextMap(targetPositions.get(i), "position#" + i); - } - - // air force team - int y = 190; - Set airForceTeamSet = new HashSet<>(AirForceManager.Instance().getAirForceTeamMap().values()); - List airForceList = new ArrayList<>(airForceTeamSet); - airForceList.sort(new Comparator() { - @Override - public int compare(AirForceTeam a1, AirForceTeam a2) { - int memberGap = a1.memberList.size() - a2.memberList.size(); - int idGap = a1.leaderUnit.getID() - a2.leaderUnit.getID(); - return memberGap * 100 + idGap; - } - }); - for (AirForceTeam airForceTeam : airForceList) { - char color = UxColor.CHAR_WHITE; - if (airForceTeam.repairCenter != null) { - color = UxColor.CHAR_RED; - } - Position position = airForceTeam.leaderUnit.getPosition(); - Broodwar.drawTextMap(position.getX(), position.getY() - 10, color + "leader#" + airForceTeam.leaderUnit.getID()); - - Position targetPosition = new Position(airForceTeam.getTargetPosition().getX(), airForceTeam.getTargetPosition().getY() - 10); - Broodwar.drawTextMap(targetPosition, UxColor.CHAR_RED + "*" + airForceTeam.leaderUnit.getID()); - Broodwar.drawTextScreen(L, y += 15, "" + UxColor.CHAR_YELLOW + airForceTeam.toString()); - } - - } - - - /* private void drawEnemyBaseToBaseTime() { - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","campPosition : " + StrategyBoard.campPosition + " / " + StrategyBoard.campType,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","mainPosition : " + StrategyBoard.mainPosition,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","watcherPosition : " + StrategyBoard.watcherPosition,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","mainSquadCenter : " + StrategyBoard.mainSquadCenter,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyGroundSquadPosition : " + StrategyBoard.nearGroundEnemyPosition + " / " + StrategyBoard.enemyUnitStatus,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyAirSquadPosition : " + StrategyBoard.nearAirEnemyPosition,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyDropEnemyPosition : " + StrategyBoard.dropEnemyPosition,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - Position enemyBasePosition = null; - Position enemyExpansionPosition = null; - if (BaseUtils.enemyMainBase() != null) { - enemyBasePosition = BaseUtils.enemyMainBase().getPosition(); - enemyExpansionPosition = BaseUtils.enemyMainBase().getPosition(); - - } - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyMainBase : " + enemyBasePosition,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - - uxDrawConfig = UxDrawConfig.newInstanceObjectType("L","","enemyFirstExpansion : " + enemyExpansionPosition,UxColor.CHAR_WHITE); - drawStrategyLeftList.add(uxDrawConfig); - }*/ - - protected void drawPositionInformation() { - - if (StrategyBoard.mainSquadLeaderPosition != null) { - Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainSquadLeaderPosition, 0, -20), UxColor.CHAR_WHITE + "V"); - } - if (StrategyBoard.campPosition.equals(StrategyBoard.mainPosition)) { - Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_ORANGE + "camp & main"); - } else { - if (StrategyBoard.campPosition != null) { - Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_YELLOW + "camp"); - } - if (StrategyBoard.mainPosition != null) { - Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainPosition, 0, -10), UxColor.CHAR_RED + "main"); - } - } - if (StrategyBoard.campPositionSiege != null) { - Broodwar.drawTextMap(StrategyBoard.campPositionSiege, UxColor.CHAR_YELLOW + "camp (siege)"); - } - if (StrategyBoard.watcherPosition != null) { - Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.watcherPosition, 0, -20), UxColor.CHAR_BLUE + "watcherPos"); - } - if (StrategyBoard.mainSquadCenter != null) { - Broodwar.drawTextMap(StrategyBoard.mainSquadCenter, "mainSqCntr"); - Broodwar.drawCircleMap(StrategyBoard.mainSquadCenter.getX(), StrategyBoard.mainSquadCenter.getY(), StrategyBoard.mainSquadCoverRadius, Color.Cyan); - } - if (StrategyBoard.nearGroundEnemyPosition != null) { - Broodwar.drawTextMap(StrategyBoard.nearGroundEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Ground)"); - Broodwar.drawCircleMap(StrategyBoard.nearGroundEnemyPosition, 150, Color.Red); - } - if (StrategyBoard.nearAirEnemyPosition != null) { - Broodwar.drawTextMap(StrategyBoard.nearAirEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Air)"); - Broodwar.drawCircleMap(StrategyBoard.nearAirEnemyPosition, 150, Color.Red); - } - if (StrategyBoard.dropEnemyPosition != null) { - Broodwar.drawTextMap(StrategyBoard.dropEnemyPosition, UxColor.CHAR_RED + "dropEnemySq"); - Broodwar.drawCircleMap(StrategyBoard.dropEnemyPosition, 150, Color.Red); - } - if (StrategyBoard.totalEnemyCneterPosition != null) { - Broodwar.drawTextMap(StrategyBoard.totalEnemyCneterPosition, "totalEnemySq"); - Broodwar.drawCircleMap(StrategyBoard.totalEnemyCneterPosition, 250, Color.Red); - } - } - - /*private void addDrawStrategyListOrigin() throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException{ - // TODO Auto-generated method stub - if(!drawStrategyListOrigin[uxOption].isEmpty()){ - UxDrawConfig uxDrawConfig; - for (UxDrawConfig drwaConfig : drawStrategyListOrigin[uxOption]) { - drwaConfig.setClazz(drwaConfig.getKey()); - Class c = drwaConfig.getClazz(); - if(drwaConfig.getValue() != null){ - Field fld = null; - try{ - Method method = c.getMethod("Instance"); - Object obj = method.invoke(arg0, arg1); - obj.getClass().getDeclaredField(name) - fld = c.getDeclaredField(drwaConfig.getValue()); - - - if (!fld.isAccessible()) { - fld.setAccessible(true); - } - } catch (Exception e) { - System.out.println(e.getMessage()); - continue; - } - uxDrawConfig = UxDrawConfig.newInstanceFieldType(fld.getName(),fld.get(drwaConfig.getValue()),drwaConfig.getColor()); - uxDrawConfig.setPos(drwaConfig.getPos()); - if(drwaConfig.getPos() == UxDrawConfig.posMap.get("L")){ - drawStrategyLeftList.add(uxDrawConfig); - }else if(drwaConfig.getPos() == UxDrawConfig.posMap.get("M")){ - drawStrategyMidList.add(uxDrawConfig); - }else if(drwaConfig.getPos() == UxDrawConfig.posMap.get("R")){ - drawStrategyRightList.add(uxDrawConfig); - }else{ - drawStrategyLeftList.add(uxDrawConfig); - } - } - + uxDrawConfig = UxDrawConfig.newInstanceMethodType("R", "* group size", LagObserver.class, "groupsize", + UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + uxDrawConfig = UxDrawConfig.newInstanceMethodType("R", "* manager rotation size", LagObserver.class, + "managerRotationSize", UxColor.CHAR_WHITE); + drawStrategyRightList.add(uxDrawConfig); + } + + /* + * private void drawBigWatch() { Map resultTimeMap = + * BigWatch.getResultTimeMap(); Map recordTimeMap = + * BigWatch.getRecordTimeMap(); + * + * List tags = new ArrayList<>(recordTimeMap.keySet()); + * Collections.sort(tags); + * + * for (String tag : tags) { Long resultTime = resultTimeMap.get(tag); + * resultTime = resultTime == null ? 0L : resultTime; Long recordTime = + * recordTimeMap.get(tag); + * + * char drawColor = UxColor.CHAR_WHITE; if (recordTime > 10L) { drawColor = + * UxColor.CHAR_TEAL; } else if (recordTime > 30L) { drawColor = + * UxColor.CHAR_RED; } uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","",tag + " : " + resultTime + + * " / " + drawColor + recordTime,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); } } + */ + + protected void drawPathData() { + for (Unit depot : UnitUtils.getUnitList(UnitType.Terran_Command_Center)) { + List mineralsList = WorkerData.depotMineral.get(depot); + if (mineralsList == null) { + return; + } + + for (Minerals minr : mineralsList) { + if (minr.mineralTrick != null) { + Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), + 4, Color.Blue, true); + Broodwar.drawCircleMap(minr.mineralTrick.getPosition().getX(), + minr.mineralTrick.getPosition().getY(), 4, Color.Purple, true); + } + } + + for (Minerals minr : WorkerData.depotMineral.get(depot)) { + if (minr.posTrick != bwapi.Position.None) { + Broodwar.drawCircleMap(minr.posTrick.getX(), minr.posTrick.getY(), 4, Color.Red, true); + Broodwar.drawCircleMap(minr.mineralUnit.getPosition().getX(), minr.mineralUnit.getPosition().getY(), + 4, Color.Yellow, true); } - } - }*/ - - // 600 * 300 - protected void drawStrategyList() { - // TODO Auto-generated method stub - int nextLy = 20, nextMy = 20, nextRy = 20; - - for(UxDrawConfig uxDraw : drawStrategyLeftList){ - int lineCnt = 1; - int fromIndex = -1; - Broodwar.drawTextScreen(uxDraw.getPos(), nextLy, uxDraw.getColor() + uxDraw.getClassFieldName()); - while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { - lineCnt++; - } - nextLy += (lineCnt*12); - } - - for(UxDrawConfig uxDraw : drawStrategyMidList){ - int lineCnt = 1; - int fromIndex = -1; - Broodwar.drawTextScreen(uxDraw.getPos(), nextMy, uxDraw.getColor() + uxDraw.getClassFieldName()); - while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { - lineCnt++; - } - nextMy += (lineCnt*12); - } - - for(UxDrawConfig uxDraw : drawStrategyRightList){ - int lineCnt = 1; - int fromIndex = -1; - Broodwar.drawTextScreen(uxDraw.getPos(), nextRy,uxDraw.getClassFieldName()); - while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { - lineCnt++; - } - nextRy += (lineCnt*12); - } - - if(TimeUtils.getFrame() % 7 == 0){ - Broodwar.drawTextScreen(L, (nextLy + 24), " "); - Broodwar.drawTextScreen(M, (nextMy + 24), " "); - Broodwar.drawTextScreen(R, (nextRy + 24), " "); - }else{ - Broodwar.drawTextScreen(L, (nextLy + 24), " : "); - Broodwar.drawTextScreen(M, (nextMy + 24), " : "); - Broodwar.drawTextScreen(R, (nextRy + 24), " : "); - } + } + + } + + } + + protected void drawStrategy() { + String upgradeString = ""; + for (MetaType metaType : StrategyBoard.upgrade) { + upgradeString += metaType.getName() + " > "; + } + + Race enemyRace = PlayerUtils.enemyRace(); + EnemyStrategy strategy = StrategyBoard.currentStrategy; + int phase = EnemyStrategyAnalyzer.Instance().getPhase(); + + // setting + UxDrawConfig uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", + "[" + strategy.name() + " ...(phase " + phase + ")]", UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "UPGRADE", upgradeString, UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "EXPANSION", StrategyBoard.expansionOption, + UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "MISSION", strategy.missionTypeList, UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", ClueManager.Instance().getClueInfoList(), + UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "", strategy.buildTimeMap, UxColor.CHAR_WHITE); + drawStrategyLeftList.add(uxDrawConfig); + + for (EnemyStrategy enemyStrategy : EnemyStrategy.values()) { + if (enemyStrategy.name().startsWith(enemyRace.toString().toUpperCase())) { + uxDrawConfig = UxDrawConfig.newInstanceStringType("R", "", enemyStrategy.name(), UxColor.CHAR_YELLOW); + drawStrategyRightList.add(uxDrawConfig); + } + } + } + + private void drawEnemyAirDefenseRange() { + List airDefenseEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, + UnitTypeUtils.enemyAirDefenseUnitType()); + for (UnitInfo eui : airDefenseEuiList) { + if (eui.getType() == UnitType.Terran_Bunker) { + Broodwar.drawCircleMap(eui.getLastPosition(), + Broodwar.enemy().weaponMaxRange(UnitType.Terran_Marine.groundWeapon()) + 96, Color.White); + } else { + Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.White); + } + } + List wraithKillerEuiList = UnitUtils.getEnemyUnitInfoList(EnemyUnitVisibleStatus.ALL, + UnitTypeUtils.wraithKillerUnitType()); + for (UnitInfo eui : wraithKillerEuiList) { + Broodwar.drawCircleMap(eui.getLastPosition(), eui.getType().airWeapon().maxRange(), Color.Grey); + } + } + + private void drawAirForceInformation() { + // wraith moving + for (Unit unit : UnitUtils.getUnitList(UnitType.Zerg_Mutalisk)) { + if (unit.isMoving()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); + Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); + Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); + } + } + + // target position + List targetPositions = AirForceManager.Instance().getTargetPositions(); + for (int i = 0; i < targetPositions.size(); i++) { + Broodwar.drawTextMap(targetPositions.get(i), "position#" + i); + } + + // air force team + int y = 190; + Set airForceTeamSet = new HashSet<>(AirForceManager.Instance().getAirForceTeamMap().values()); + List airForceList = new ArrayList<>(airForceTeamSet); + airForceList.sort(new Comparator() { + @Override + public int compare(AirForceTeam a1, AirForceTeam a2) { + int memberGap = a1.memberList.size() - a2.memberList.size(); + int idGap = a1.leaderUnit.getID() - a2.leaderUnit.getID(); + return memberGap * 100 + idGap; + } + }); + for (AirForceTeam airForceTeam : airForceList) { + char color = UxColor.CHAR_WHITE; + if (airForceTeam.repairCenter != null) { + color = UxColor.CHAR_RED; + } + Position position = airForceTeam.leaderUnit.getPosition(); + Broodwar.drawTextMap(position.getX(), position.getY() - 10, + color + "leader#" + airForceTeam.leaderUnit.getID()); + + Position targetPosition = new Position(airForceTeam.getTargetPosition().getX(), + airForceTeam.getTargetPosition().getY() - 10); + Broodwar.drawTextMap(targetPosition, UxColor.CHAR_RED + "*" + airForceTeam.leaderUnit.getID()); + Broodwar.drawTextScreen(L, y += 15, "" + UxColor.CHAR_YELLOW + airForceTeam.toString()); + } + + } + + /* + * private void drawEnemyBaseToBaseTime() { uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","campPosition : " + + * StrategyBoard.campPosition + " / " + + * StrategyBoard.campType,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","mainPosition : " + + * StrategyBoard.mainPosition,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","watcherPosition : " + + * StrategyBoard.watcherPosition,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","mainSquadCenter : " + + * StrategyBoard.mainSquadCenter,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","enemyGroundSquadPosition : " + + * StrategyBoard.nearGroundEnemyPosition + " / " + + * StrategyBoard.enemyUnitStatus,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","enemyAirSquadPosition : " + + * StrategyBoard.nearAirEnemyPosition,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","enemyDropEnemyPosition : " + + * StrategyBoard.dropEnemyPosition,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * Position enemyBasePosition = null; Position enemyExpansionPosition = + * null; if (BaseUtils.enemyMainBase() != null) { enemyBasePosition = + * BaseUtils.enemyMainBase().getPosition(); enemyExpansionPosition = + * BaseUtils.enemyMainBase().getPosition(); + * + * } uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","enemyMainBase : " + + * enemyBasePosition,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); + * + * uxDrawConfig = + * UxDrawConfig.newInstanceObjectType("L","","enemyFirstExpansion : " + + * enemyExpansionPosition,UxColor.CHAR_WHITE); + * drawStrategyLeftList.add(uxDrawConfig); } + */ + + protected void drawPositionInformation() { + + if (StrategyBoard.mainSquadLeaderPosition != null) { + Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainSquadLeaderPosition, 0, -20), + UxColor.CHAR_WHITE + "V"); + } + if (StrategyBoard.campPosition.equals(StrategyBoard.mainPosition)) { + Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_ORANGE + "camp & main"); + } else { + if (StrategyBoard.campPosition != null) { + Broodwar.drawTextMap(StrategyBoard.campPosition, UxColor.CHAR_YELLOW + "camp"); + } + if (StrategyBoard.mainPosition != null) { + Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.mainPosition, 0, -10), + UxColor.CHAR_RED + "main"); + } + } + if (StrategyBoard.campPositionSiege != null) { + Broodwar.drawTextMap(StrategyBoard.campPositionSiege, UxColor.CHAR_YELLOW + "camp (siege)"); + } + if (StrategyBoard.watcherPosition != null) { + Broodwar.drawTextMap(DrawingUtils.positionAdjusted(StrategyBoard.watcherPosition, 0, -20), + UxColor.CHAR_BLUE + "watcherPos"); } - } \ No newline at end of file + if (StrategyBoard.mainSquadCenter != null) { + Broodwar.drawTextMap(StrategyBoard.mainSquadCenter, "mainSqCntr"); + Broodwar.drawCircleMap(StrategyBoard.mainSquadCenter.getX(), StrategyBoard.mainSquadCenter.getY(), + StrategyBoard.mainSquadCoverRadius, Color.Cyan); + } + if (StrategyBoard.nearGroundEnemyPosition != null) { + Broodwar.drawTextMap(StrategyBoard.nearGroundEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Ground)"); + Broodwar.drawCircleMap(StrategyBoard.nearGroundEnemyPosition, 150, Color.Red); + } + if (StrategyBoard.nearAirEnemyPosition != null) { + Broodwar.drawTextMap(StrategyBoard.nearAirEnemyPosition, UxColor.CHAR_RED + "nearEnemySq(Air)"); + Broodwar.drawCircleMap(StrategyBoard.nearAirEnemyPosition, 150, Color.Red); + } + if (StrategyBoard.dropEnemyPosition != null) { + Broodwar.drawTextMap(StrategyBoard.dropEnemyPosition, UxColor.CHAR_RED + "dropEnemySq"); + Broodwar.drawCircleMap(StrategyBoard.dropEnemyPosition, 150, Color.Red); + } + if (StrategyBoard.totalEnemyCneterPosition != null) { + Broodwar.drawTextMap(StrategyBoard.totalEnemyCneterPosition, "totalEnemySq"); + Broodwar.drawCircleMap(StrategyBoard.totalEnemyCneterPosition, 250, Color.Red); + } + } + + /* + * private void addDrawStrategyListOrigin() throws IllegalArgumentException, + * IllegalAccessException, ClassNotFoundException{ // TODO Auto-generated + * method stub if(!drawStrategyListOrigin[uxOption].isEmpty()){ UxDrawConfig + * uxDrawConfig; for (UxDrawConfig drwaConfig : + * drawStrategyListOrigin[uxOption]) { + * drwaConfig.setClazz(drwaConfig.getKey()); Class c = + * drwaConfig.getClazz(); if(drwaConfig.getValue() != null){ Field fld = + * null; try{ Method method = c.getMethod("Instance"); Object obj = + * method.invoke(arg0, arg1); obj.getClass().getDeclaredField(name) fld = + * c.getDeclaredField(drwaConfig.getValue()); + * + * + * if (!fld.isAccessible()) { fld.setAccessible(true); } } catch (Exception + * e) { System.out.println(e.getMessage()); continue; } uxDrawConfig = + * UxDrawConfig.newInstanceFieldType(fld.getName(),fld.get(drwaConfig. + * getValue()),drwaConfig.getColor()); + * uxDrawConfig.setPos(drwaConfig.getPos()); if(drwaConfig.getPos() == + * UxDrawConfig.posMap.get("L")){ drawStrategyLeftList.add(uxDrawConfig); + * }else if(drwaConfig.getPos() == UxDrawConfig.posMap.get("M")){ + * drawStrategyMidList.add(uxDrawConfig); }else if(drwaConfig.getPos() == + * UxDrawConfig.posMap.get("R")){ drawStrategyRightList.add(uxDrawConfig); + * }else{ drawStrategyLeftList.add(uxDrawConfig); } } + * + * } } } + */ + + // 600 * 300 + protected void drawStrategyList() { + // TODO Auto-generated method stub + int nextLy = 20, nextMy = 20, nextRy = 20; + + for (UxDrawConfig uxDraw : drawStrategyLeftList) { + int lineCnt = 1; + int fromIndex = -1; + Broodwar.drawTextScreen(uxDraw.getPos(), nextLy, uxDraw.getColor() + uxDraw.getClassFieldName()); + while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { + lineCnt++; + } + nextLy += (lineCnt * 12); + } + + for (UxDrawConfig uxDraw : drawStrategyMidList) { + int lineCnt = 1; + int fromIndex = -1; + Broodwar.drawTextScreen(uxDraw.getPos(), nextMy, uxDraw.getColor() + uxDraw.getClassFieldName()); + while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { + lineCnt++; + } + nextMy += (lineCnt * 12); + } + + for (UxDrawConfig uxDraw : drawStrategyRightList) { + int lineCnt = 1; + int fromIndex = -1; + Broodwar.drawTextScreen(uxDraw.getPos(), nextRy, uxDraw.getClassFieldName()); + while ((fromIndex = uxDraw.getClassFieldName().indexOf("\n", fromIndex + 1)) >= 0) { + lineCnt++; + } + nextRy += (lineCnt * 12); + } + + if (TimeUtils.getFrame() % 7 == 0) { + Broodwar.drawTextScreen(L, (nextLy + 24), " "); + Broodwar.drawTextScreen(M, (nextMy + 24), " "); + Broodwar.drawTextScreen(R, (nextRy + 24), " "); + } else { + Broodwar.drawTextScreen(L, (nextLy + 24), " : "); + Broodwar.drawTextScreen(M, (nextMy + 24), " : "); + Broodwar.drawTextScreen(R, (nextRy + 24), " : "); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/monster/debugger/ScreenUx.java b/src/main/java/org/monster/debugger/ScreenUx.java index 39a0605..c6b594b 100644 --- a/src/main/java/org/monster/debugger/ScreenUx.java +++ b/src/main/java/org/monster/debugger/ScreenUx.java @@ -1,102 +1,76 @@ package org.monster.debugger; -import org.monster.build.base.BuildManager; -import org.monster.build.base.ConstructionManager; -import org.monster.build.provider.BuildQueueProvider; -import org.monster.common.MapGrid; -import org.monster.common.util.TimeUtils; -import org.monster.strategy.StrategyManager; -import org.monster.bootstrap.GameManager; -import org.monster.micro.CombatManager; -import org.monster.worker.WorkerManager; +public class ScreenUx { -import bwapi.Game; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ScreenUx{ - private static ScreenUx instance = new ScreenUx(); - private static int uxOption; + private static int uxOption; + public static void showDisplay() { - uxOption = PreBotUXManager.Instance().uxOption; + uxOption = PreBotUXManager.Instance().uxOption; PreBotUXManager.Instance().clearList(); if (uxOption == 0) { - PreBotUXManager.Instance().drawDebugginUxMenu(); //drawing ux 메뉴 설명 - PreBotUXManager.Instance().drawUxInfo(); //debuging 메뉴 설명 (화면 , 속도 등) - } else if (uxOption == 1) { - UXManager.Instance().update(); //프리봇 전 기본 디버깅 메뉴 - // 미네랄PATH - } else if (uxOption == 2) { - PreBotUXManager.Instance().drawGameInformationOnScreen(); - PreBotUXManager.Instance().drawBWTAResultOnMap(); - PreBotUXManager.Instance().drawBuildOrderQueueOnScreen(); - PreBotUXManager.Instance().drawBuildStatusOnScreen(); - PreBotUXManager.Instance().drawReservedBuildingTilesOnMap(); - PreBotUXManager.Instance().drawTilesToAvoidOnMap(); - PreBotUXManager.Instance().drawWorkerMiningStatusOnMap(); - PreBotUXManager.Instance().drawUnitTargetOnMap(); - //drawTurretMap(); - PreBotUXManager.Instance().drawManagerTimeSpent(); - PreBotUXManager.Instance().drawConstructionQueueOnScreenAndMap(); //ConstructionQueue - - // draw tile position of mouse cursor - int mouseX = PreBotUXManager.Instance().Broodwar.getMousePosition().getX() + PreBotUXManager.Instance().Broodwar.getScreenPosition().getX(); - int mouseY = PreBotUXManager.Instance().Broodwar.getMousePosition().getY() + PreBotUXManager.Instance().Broodwar.getScreenPosition().getY(); - PreBotUXManager.Instance().Broodwar.drawTextMap(mouseX + 20, mouseY, - "(" + (int) (mouseX / 32) + ", " + (int) (mouseY / 32) + ")"); - PreBotUXManager.Instance().Broodwar.drawTextMap(mouseX + 20, mouseY + 10, "(" + (int) (mouseX) + ", " + (int) (mouseY) + ")"); - - } else if (uxOption == 3) { - PreBotUXManager.Instance().drawStrategy(); - } else if (uxOption == 4) { - PreBotUXManager.Instance().drawEnemyBuildTimer(); - }/* else if (uxOption == 5) { - clearList(); - drawSquadInfoOnMap(); - drawManagerTimeSpent(); - drawDecision(); - drawEnemyAirDefenseRange(); - drawAirForceInformation(); - } else if (uxOption == 6) { - clearList(); - drawEnemyBaseToBaseTime(); - } else if (uxOption == 7) { - clearList(); - drawBigWatch(); - drawManagerTimeSpent(); - } else if (uxOption == 8) { - clearList(); - drawTilesToAvoidOnMap(); - drawReservedBuildingTilesOnMap(); - } else if (uxOption == 9) { - //drawExpectedResource(); - //drawExpectedResource2(); - - }*/ - - PreBotUXManager.Instance().drawMineralIdOnMap(); - PreBotUXManager.Instance().drawUnitIdOnMap(); - PreBotUXManager.Instance().drawPositionInformation(); - PreBotUXManager.Instance().drawTimer(); - PreBotUXManager.Instance().drawPathData(); - PreBotUXManager.Instance().drawSquadUnitTagMap(); - - /*try { - PreBotUXManager.Instance().addDrawStrategyListOrigin(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ + PreBotUXManager.Instance().drawDebugginUxMenu(); // drawing ux 메뉴 설명 + PreBotUXManager.Instance().drawUxInfo(); // debuging 메뉴 설명 (화면 , 속도 + // 등) + } else if (uxOption == 1) { + UXManager.Instance().update(); // 프리봇 전 기본 디버깅 메뉴 + // 미네랄PATH + } else if (uxOption == 2) { + PreBotUXManager.Instance().drawGameInformationOnScreen(); + PreBotUXManager.Instance().drawBWTAResultOnMap(); + PreBotUXManager.Instance().drawBuildOrderQueueOnScreen(); + PreBotUXManager.Instance().drawBuildStatusOnScreen(); + PreBotUXManager.Instance().drawReservedBuildingTilesOnMap(); + PreBotUXManager.Instance().drawTilesToAvoidOnMap(); + PreBotUXManager.Instance().drawWorkerMiningStatusOnMap(); + PreBotUXManager.Instance().drawUnitTargetOnMap(); + // drawTurretMap(); + PreBotUXManager.Instance().drawManagerTimeSpent(); + PreBotUXManager.Instance().drawConstructionQueueOnScreenAndMap(); // ConstructionQueue + + // draw tile position of mouse cursor + int mouseX = PreBotUXManager.Instance().Broodwar.getMousePosition().getX() + + PreBotUXManager.Instance().Broodwar.getScreenPosition().getX(); + int mouseY = PreBotUXManager.Instance().Broodwar.getMousePosition().getY() + + PreBotUXManager.Instance().Broodwar.getScreenPosition().getY(); + PreBotUXManager.Instance().Broodwar.drawTextMap(mouseX + 20, mouseY, + "(" + (int) (mouseX / 32) + ", " + (int) (mouseY / 32) + ")"); + PreBotUXManager.Instance().Broodwar.drawTextMap(mouseX + 20, mouseY + 10, + "(" + (int) (mouseX) + ", " + (int) (mouseY) + ")"); + + } else if (uxOption == 3) { + PreBotUXManager.Instance().drawStrategy(); + } else if (uxOption == 4) { + PreBotUXManager.Instance().drawEnemyBuildTimer(); + } /* + * else if (uxOption == 5) { clearList(); drawSquadInfoOnMap(); + * drawManagerTimeSpent(); drawDecision(); + * drawEnemyAirDefenseRange(); drawAirForceInformation(); } else if + * (uxOption == 6) { clearList(); drawEnemyBaseToBaseTime(); } else + * if (uxOption == 7) { clearList(); drawBigWatch(); + * drawManagerTimeSpent(); } else if (uxOption == 8) { clearList(); + * drawTilesToAvoidOnMap(); drawReservedBuildingTilesOnMap(); } else + * if (uxOption == 9) { //drawExpectedResource(); + * //drawExpectedResource2(); + * + * } + */ + + PreBotUXManager.Instance().drawMineralIdOnMap(); + PreBotUXManager.Instance().drawUnitIdOnMap(); + PreBotUXManager.Instance().drawPositionInformation(); + PreBotUXManager.Instance().drawTimer(); + PreBotUXManager.Instance().drawPathData(); + PreBotUXManager.Instance().drawSquadUnitTagMap(); + + /* + * try { PreBotUXManager.Instance().addDrawStrategyListOrigin(); } catch + * (IllegalArgumentException e) { // TODO Auto-generated catch block + * e.printStackTrace(); } catch (IllegalAccessException e) { // TODO + * Auto-generated catch block e.printStackTrace(); } catch + * (ClassNotFoundException e) { // TODO Auto-generated catch block + * e.printStackTrace(); } + */ PreBotUXManager.Instance().drawStrategyList(); PreBotUXManager.Instance().clearDecisionListForUx(); } diff --git a/src/main/java/org/monster/debugger/UXManager.java b/src/main/java/org/monster/debugger/UXManager.java index ebb1cf7..8fc715d 100644 --- a/src/main/java/org/monster/debugger/UXManager.java +++ b/src/main/java/org/monster/debugger/UXManager.java @@ -1,20 +1,10 @@ package org.monster.debugger; -import bwapi.Bullet; -import bwapi.BulletType; -import bwapi.Color; -import bwapi.Force; -import bwapi.Game; -import bwapi.Player; -import bwapi.Position; -import bwapi.TilePosition; -import bwapi.Unit; -import bwapi.UnitType; -import bwta.BWTA; -import bwta.BaseLocation; -import bwta.Chokepoint; -import bwta.Polygon; -import bwta.Region; +import java.util.ArrayList; +import java.util.Deque; +import java.util.List; +import java.util.Vector; + import org.monster.bootstrap.Config; import org.monster.build.base.BuildManager; import org.monster.build.base.BuildOrderItem; @@ -31,814 +21,914 @@ import org.monster.worker.WorkerData; import org.monster.worker.WorkerManager; -import java.util.ArrayList; -import java.util.Deque; -import java.util.List; -import java.util.Vector; +import bwapi.Bullet; +import bwapi.BulletType; +import bwapi.Color; +import bwapi.Force; +import bwapi.Game; +import bwapi.Player; +import bwapi.Position; +import bwapi.TilePosition; +import bwapi.Unit; +import bwapi.UnitType; +import bwta.BWTA; +import bwta.BaseLocation; +import bwta.Chokepoint; +import bwta.Polygon; +import bwta.Region; /// 봇 프로그램 개발의 편의성 향상을 위해 게임 화면에 추가 정보들을 표시하는 class
/// 여러 Manager 들로부터 정보를 조회하여 Screen 혹은 Map 에 정보를 표시합니다 public class UXManager { - private static UXManager instance = new UXManager(); - private final Character brown = ''; - private final char red = ''; - private final char teal = ''; - // private final char blue = ''; - private final char purple = ''; - private final char white = ''; - private final int dotRadius = 2; - private boolean hasSavedBWTAInfo = false; - private int[][] blue = null; - private int[][] cyan = null; - private int[][] orange = null; - private List yellow = new ArrayList(); - private List green1 = new ArrayList(); - private List green2 = new ArrayList(); - private List red1 = new ArrayList(); - private List red2 = new ArrayList(); - private String bulletTypeName = ""; - private String tempUnitName = ""; - - private Game Broodwar; - - /// static singleton 객체를 리턴합니다 - public static UXManager Instance() { - return instance; - } - - /// 경기가 시작될 때 일회적으로 추가 정보를 출력합니다 - public void onStart(Game Broodwar) { - this.Broodwar = Broodwar; - } - - /// 경기 진행 중 매 프레임마다 추가 정보를 출력하고 사용자 입력을 처리합니다 - public void update() { - drawGameInformationOnScreen(5, 5); - - if (Config.DrawEnemyUnitInfo) { - drawUnitStatisticsOnScreen(400, 20); - } - - if (Config.DrawBWTAInfo) { - drawBWTAResultOnMap(); - } - - if (Config.DrawMapGrid) { - drawMapGrid(); - } - - // 빌드오더큐 : 빌드 실행 전 - if (Config.DrawProductionInfo) { - drawBuildOrderQueueOnScreen(80, 60); - } - - // 빌드 실행 상황 : 건물 건설, 유닛 생산, 업그레이드, 리서치 - if (Config.DrawProductionInfo) { - drawBuildStatusOnScreen(200, 60); - } - - // 건물 건설 큐. 건물 건설 상황 - if (Config.DrawBuildingInfo) { - drawConstructionQueueOnScreenAndMap(200, 150); - } - - // 건물이 건설될 위치 - if (Config.DrawReservedBuildingTiles) { - // 건물 건설 장소 예약 지점 - drawReservedBuildingTilesOnMap(); - // 건물 건설 불가 구역 (미네랄/가스/베이스 사이) - drawTilesToAvoidOnMap(); - } - - if (Config.DrawUnitHealthBars) { - drawUnitExtendedInformationOnMap(); - drawUnitIdOnMap(); - } - - if (Config.DrawWorkerInfo) { - // 각 일꾼들의 임무 상황 - drawWorkerStateOnScreen(5, 60); - - // 베이스캠프당 일꾼 수 - drawWorkerCountOnMap(); - } - - // 일꾼 자원채취 임무 상황 - if (Config.DrawResourceInfo) { - drawWorkerMiningStatusOnMap(); - } - - // 정찰 -// if (Config.DrawScoutInfo) { -// drawScoutInformation(220,330); -// } - - // 공격 - if (Config.DrawUnitTargetInfo) { - drawUnitTargetOnMap(); - - // 미사일, 럴커의 보이지않는 공격등을 표시 - drawBulletsOnMap(); - } - - // draw tile position of mouse cursor - if (Config.DrawMouseCursorInfo) { - int mouseX = Broodwar.getMousePosition().getX() + Broodwar.getScreenPosition().getX(); - int mouseY = Broodwar.getMousePosition().getY() + Broodwar.getScreenPosition().getY(); - Broodwar.drawTextMap(mouseX + 20, mouseY, "(" + (int) (mouseX / Config.TILE_SIZE) + ", " + (int) (mouseY / Config.TILE_SIZE) + ")"); - } - - } - - // 게임 개요 정보를 Screen 에 표시합니다 - public void drawGameInformationOnScreen(int x, int y) { - Broodwar.drawTextScreen(x, y, white + "Players : "); - //Broodwar.drawTextScreen(x + 50, y, Broodwar.self().getTextColor() + Broodwar.self().getName() + "(" + InformationManager.Instance().selfRace + ") " + white + " vs. " + - // PlayerUtils.enemyPlayer().getTextColor() + PlayerUtils.enemyPlayer().getName() + "(" + PlayerUtils.enemyRace() + ")"); - y += 12; - - Broodwar.drawTextScreen(x, y, white + "Map : "); - Broodwar.drawTextScreen(x + 50, y, white + Broodwar.mapFileName() + " (" + Broodwar.mapWidth() + " x " + Broodwar.mapHeight() + " size)"); - Broodwar.setTextSize(); - y += 12; - - Broodwar.drawTextScreen(x, y, white + "Time : "); - Broodwar.drawTextScreen(x + 50, y, "" + white + TimeUtils.getFrame()); - Broodwar.drawTextScreen(x + 90, y, "" + white + (int) (TimeUtils.getFrame() / (23.8 * 60)) + ":" + (int) ((int) (TimeUtils.getFrame() / 23.8) % 60)); - } - - /// APM (Action Per Minute) 숫자를 Screen 에 표시합니다 - public void drawAPM(int x, int y) { - int bwapiAPM = Broodwar.getAPM(); - Broodwar.drawTextScreen(x, y, "APM : " + bwapiAPM); - } - - /// Players 정보를 Screen 에 표시합니다 - public void drawPlayers() { - for (Player p : Broodwar.getPlayers()) { - Broodwar.sendText("Player [" + p.getID() + "]: " + p.getName() + " is in force: " + p.getForce().getName()); - } - } - - /// Player 들의 팀 (Force) 들의 정보를 Screen 에 표시합니다 - public void drawForces() { - for (Force f : Broodwar.getForces()) { - Broodwar.sendText("Force " + f.getName() + " has the following players:"); - for (Player p : f.getPlayers()) { - Broodwar.sendText(" - Player [" + p.getID() + "]: " + p.getName()); - } - } - } - - /// Unit 의 HitPoint 등 추가 정보를 Map 에 표시합니다 - public void drawUnitExtendedInformationOnMap() { - int verticalOffset = -10; - - for (UnitInfo ui : UnitUtils.getEnemyUnitInfoList()) { - - UnitType type = ui.getType(); - int hitPoints = ui.getLastHealth(); - int shields = ui.getLastShields(); - - Position pos = ui.getLastPosition(); - - int left = pos.getX() - type.dimensionLeft(); - int right = pos.getX() + type.dimensionRight(); - int top = pos.getY() - type.dimensionUp(); - int bottom = pos.getY() + type.dimensionDown(); - - // 적 유닛이면 주위에 박스 표시 - if (!Broodwar.isVisible(ui.getLastPosition().toTilePosition())) { - Broodwar.drawBoxMap(new Position(left, top), new Position(right, bottom), Color.Grey, false); - Broodwar.drawTextMap(new Position(left + 3, top + 4), ui.getType().toString()); - } - - // 유닛의 HitPoint 남아있는 비율 표시 - if (!type.isResourceContainer() && type.maxHitPoints() > 0) { - double hpRatio = (double) hitPoints / (double) type.maxHitPoints(); - - Color hpColor = Color.Green; - if (hpRatio < 0.66) hpColor = Color.Orange; - if (hpRatio < 0.33) hpColor = Color.Red; - - int ratioRight = left + (int) ((right - left) * hpRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // 유닛의 Shield 남아있는 비율 표시 - if (!type.isResourceContainer() && type.maxShields() > 0) { - double shieldRatio = (double) shields / (double) type.maxShields(); - - int ratioRight = left + (int) ((right - left) * shieldRatio); - int hpTop = top - 3 + verticalOffset; - int hpBottom = top + 1 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - } - - // draw neutral units and our units - for (Unit unit : Broodwar.getAllUnits()) { - if (unit.getPlayer() == PlayerUtils.enemyPlayer()) { - continue; - } - - final Position pos = unit.getPosition(); - - int left = pos.getX() - unit.getType().dimensionLeft(); - int right = pos.getX() + unit.getType().dimensionRight(); - int top = pos.getY() - unit.getType().dimensionUp(); - int bottom = pos.getY() + unit.getType().dimensionDown(); - - //Monster.game.drawBoxMap(BWAPI.Position(left, top), BWAPI.Position(right, bottom), Color.Grey, false); - - // 유닛의 HitPoint 남아있는 비율 표시 - if (!unit.getType().isResourceContainer() && unit.getType().maxHitPoints() > 0) { - double hpRatio = (double) unit.getHitPoints() / (double) unit.getType().maxHitPoints(); - - Color hpColor = Color.Green; - if (hpRatio < 0.66) hpColor = Color.Orange; - if (hpRatio < 0.33) hpColor = Color.Red; - - int ratioRight = left + (int) ((right - left) * hpRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), hpColor.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // 유닛의 Shield 남아있는 비율 표시 - if (!unit.getType().isResourceContainer() && unit.getType().maxShields() > 0) { - double shieldRatio = (double) unit.getShields() / (double) unit.getType().maxShields(); - - int ratioRight = left + (int) ((right - left) * shieldRatio); - int hpTop = top - 3 + verticalOffset; - int hpBottom = top + 1 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - - // Mineral / Gas 가 얼마나 남아있는가 - if (unit.getType().isResourceContainer() && unit.getInitialResources() > 0) { - double mineralRatio = (double) unit.getResources() / (double) unit.getInitialResources(); - - int ratioRight = left + (int) ((right - left) * mineralRatio); - int hpTop = top + verticalOffset; - int hpBottom = top + 4 + verticalOffset; - - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Cyan, true); - Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); - - int ticWidth = 3; - - for (int i = left; i < right - 1; i += ticWidth) { - Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); - } - } - } - } - - /// UnitType 별 통계 정보를 Screen 에 표시합니다 - public void drawUnitStatisticsOnScreen(int x, int y) { - int currentY = y; - - // 아군이 입은 피해 누적값 - currentY += 10; - - // 적군의 UnitType 별 파악된 Unit 숫자를 표시 - Broodwar.drawTextScreen(x, currentY + 20, white + " UNIT NAME"); - Broodwar.drawTextScreen(x + 110, currentY + 20, white + " Created"); - Broodwar.drawTextScreen(x + 150, currentY + 20, white + " Dead"); - Broodwar.drawTextScreen(x + 190, currentY + 20, white + " Alive"); - - int yspace = 0; - - } - - /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 - public void drawBWTAResultOnMap() { - int blueCount = 0; - int cyanCount = 0; - int orangeCount = 0; - - if (hasSavedBWTAInfo == false) { - for (BaseLocation baseLocation : BWTA.getBaseLocations()) { - blueCount++; - for (Unit unit : baseLocation.getStaticMinerals()) { - cyanCount++; - } - for (Unit unit : baseLocation.getGeysers()) { - orangeCount++; - } - } - - blue = new int[blueCount][4]; - int blueIndex = 0; - cyan = new int[cyanCount][2]; - int cyanIndex = 0; - orange = new int[orangeCount][4]; - int orangeIndex = 0; - - for (BaseLocation baseLocation : BWTA.getBaseLocations()) { - TilePosition p = baseLocation.getTilePosition(); - Position c = baseLocation.getPosition(); - - blue[blueIndex][0] = p.getX() * 32; - blue[blueIndex][1] = p.getY() * 32; - blue[blueIndex][2] = p.getX() * 32 + 4 * 32; - blue[blueIndex][3] = p.getY() * 32 + 3 * 32; - blueIndex++; - - //draw a circle at each mineral patch - // C++ : for (BWAPI.Unitset.iterator j = (*i).getStaticMinerals().begin(); j != (*i).getStaticMinerals().end(); j++) - for (Unit unit : baseLocation.getStaticMinerals()) { - Position q = unit.getInitialPosition(); - cyan[cyanIndex][0] = q.getX(); - cyan[cyanIndex][1] = q.getY(); - cyanIndex++; - } - - //draw the outlines of vespene geysers - // C++ : for (BWAPI.Unitset.iterator j = (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) - for (Unit unit : baseLocation.getGeysers()) { - TilePosition q = unit.getInitialTilePosition(); - orange[orangeIndex][0] = q.getX() * 32; - orange[orangeIndex][1] = q.getY() * 32; - orange[orangeIndex][2] = q.getX() * 32 + 4 * 32; - orange[orangeIndex][3] = q.getY() * 32 + 2 * 32; - orangeIndex++; - } - - //if this is an island expansion, draw a yellow circle around the base location - if (baseLocation.isIsland()) { - yellow.add(c); - } - } - - //we will iterate through all the regions and draw the polygon outline of it in green. - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for (Region region : BWTA.getRegions()) { - Polygon p = region.getPolygon(); - for (int j = 0; j < p.getPoints().size(); j++) { - green1.add(p.getPoints().get(j)); - green2.add(p.getPoints().get((j + 1) % p.getPoints().size())); - } - } - - //we will visualize the chokepoints with red lines - // C++ : for (std.set.const_iterator r = BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) - for (Region region : BWTA.getRegions()) { - // C++ : for (std.set.const_iterator c = (*r).getChokepoints().begin(); c != (*r).getChokepoints().end(); c++) - for (Chokepoint Chokepoint : region.getChokepoints()) { - red1.add(Chokepoint.getSides().first); - red2.add(Chokepoint.getSides().second); - } - } - hasSavedBWTAInfo = true; - -// System.out.println(blueCount + " " + cyanCount + " " + orangeCount + " " + yellowCount + " " + greenCount + " " + redCount); - } - - if (hasSavedBWTAInfo) { - for (int i1 = 0; i1 < blue.length; i1++) { - Broodwar.drawBoxMap(blue[i1][0], blue[i1][1], blue[i1][2], blue[i1][3], Color.Blue); - } - for (int i2 = 0; i2 < cyan.length; i2++) { - Broodwar.drawCircleMap(cyan[i2][0], cyan[i2][1], 30, Color.Cyan); - } - for (int i3 = 0; i3 < orange.length; i3++) { - Broodwar.drawBoxMap(orange[i3][0], orange[i3][1], orange[i3][2], orange[i3][3], Color.Orange); - } - for (int i4 = 0; i4 < yellow.size(); i4++) { - Broodwar.drawCircleMap(yellow.get(i4), 80, Color.Yellow); - } - for (int i5 = 0; i5 < green1.size(); i5++) { - Broodwar.drawLineMap(green1.get(i5), green2.get(i5), Color.Green); - } - for (int i6 = 0; i6 < red1.size(); i6++) { - Broodwar.drawLineMap(red1.get(i6), red2.get(i6), Color.Red); - } - - // OccupiedBaseLocation 을 원으로 표시 -// for (BaseLocation baseLocation : InformationManager.Instance().getOccupiedBaseLocations(PlayerUtils.myPlayer())) { -// Broodwar.drawCircleMap(baseLocation.getPosition(), 10 * Config.TILE_SIZE, Color.Blue); -// } -// for (BaseLocation baseLocation : UnitTypeUtils.getOccupiedBaseLocations(PlayerUtils.enemyPlayer())) { -// Broodwar.drawCircleMap(baseLocation.getPosition(), 10 * Config.TILE_SIZE, Color.Red); -// } - - // ChokePoint, BaseLocation 을 텍스트로 표시 - if (ChokeUtils.myFirstChoke() != null) { - Broodwar.drawTextMap(BaseUtils.myMainBase().getPosition(), "My MainBaseLocation"); - } - if (ChokeUtils.myFirstChoke() != null) { - Broodwar.drawTextMap(ChokeUtils.myFirstChoke().getCenter(), "My First ChokePoint"); - } - if (ChokeUtils.mySecondChoke() != null) { - Broodwar.drawTextMap(ChokeUtils.mySecondChoke().getCenter(), "My Second ChokePoint"); - } - if (BaseUtils.myFirstExpansion() != null) { - Broodwar.drawTextMap(BaseUtils.myFirstExpansion().getPosition(), "My First ExpansionLocation"); - } - -// if (InformationManager.Instance().getFirstChokePoint(PlayerUtils.enemyPlayer()) != null) { -// Broodwar.drawTextMap(BaseUtils.enemyMainBase().getPosition(), "Enemy MainBaseLocation"); -// } -// if (InformationManager.Instance().getFirstChokePoint(PlayerUtils.enemyPlayer()) != null) { -// Broodwar.drawTextMap(InformationManager.Instance().getFirstChokePoint(PlayerUtils.enemyPlayer()).getCenter(), "Enemy First ChokePoint"); -// } - if (ChokeUtils.enemySecondChoke() != null) { - Broodwar.drawTextMap(ChokeUtils.enemySecondChoke().getCenter(), "Enemy Second ChokePoint"); - } - if (BaseUtils.enemyFirstExpansion() != null) { - Broodwar.drawTextMap(BaseUtils.enemyFirstExpansion().getPosition(), "Enemy First ExpansionLocation"); - } - - } - } - - /// Tile Position 그리드를 Map 에 표시합니다 - public void drawMapGrid() { - int cellSize = MapGrid.Instance().getCellSize(); - int mapWidth = MapGrid.Instance().getMapWidth(); - int mapHeight = MapGrid.Instance().getMapHeight(); - int rows = MapGrid.Instance().getRows(); - int cols = MapGrid.Instance().getCols(); - - for (int i = 0; i < cols; i++) { - Broodwar.drawLineMap(i * cellSize, 0, i * cellSize, mapHeight, Color.Blue); - } - - for (int j = 0; j < rows; j++) { - Broodwar.drawLineMap(0, j * cellSize, mapWidth, j * cellSize, Color.Blue); - } - - for (int r = 0; r < rows; r += 2) { - for (int c = 0; c < cols; c += 2) { - Broodwar.drawTextMap(c * 32, r * 32, c + "," + r); - } - } - } - - /// BuildOrderQueue 를 Screen 에 표시합니다 - public void drawBuildOrderQueueOnScreen(int x, int y) { - Broodwar.drawTextScreen(x, y, white + " "); - - - Deque buildQueue = BuildManager.Instance().buildQueue.getQueue(); - int itemCount = 0; - - // C++ : for (std.deque.reverse_iterator itr = buildQueue.rbegin(); itr != buildQueue.rend(); itr++) { - // C++ : BuildOrderItem & currentItem = *itr; - // C++ : Monster.game.drawTextScreen(x, y + 10 + (itemCount * 10), " %s", currentItem.metaType.getName().c_str()); - // C++ : itemCount++; - // C++ : if (itemCount >= 24) break; - // C++ : } - - Object[] tempQueue = buildQueue.toArray(); - - for (int i = 0; i < tempQueue.length; i++) { - BuildOrderItem currentItem = (BuildOrderItem) tempQueue[i]; - Broodwar.drawTextScreen(x, y + 10 + (itemCount * 10), white + currentItem.metaType.getName() + " " + currentItem.blocking); - itemCount++; - if (itemCount >= 24) break; - } - } - - /// Build 진행 상태를 Screen 에 표시합니다 - public void drawBuildStatusOnScreen(int x, int y) { - // 건설 / 훈련 중인 유닛 진행상황 표시 - Vector unitsUnderConstruction = new Vector(); - for (Unit unit : Broodwar.self().getUnits()) { - if (unit != null && unit.isBeingConstructed()) { - unitsUnderConstruction.add(unit); - } - } - - // sort it based on the time it was started - Object[] tempArr = unitsUnderConstruction.toArray(); - //Arrays.sort(tempArr); - unitsUnderConstruction = new Vector(); - for (int i = 0; i < tempArr.length; i++) { - unitsUnderConstruction.add((Unit) tempArr[i]); - } - // C++ : std.sort(unitsUnderConstruction.begin(), unitsUnderConstruction.end(), CompareWhenStarted()); - - Broodwar.drawTextScreen(x, y, white + " "); - - int reps = unitsUnderConstruction.size() < 10 ? unitsUnderConstruction.size() : 10; - - for (Unit unit : unitsUnderConstruction) { - y += 10; - UnitType t = unit.getType(); - if (t == UnitType.Zerg_Egg) { - t = unit.getBuildType(); - } - - Broodwar.drawTextScreen(x, y, "" + white + t + " (" + unit.getRemainingBuildTime() + ")"); - } - - // Tech Research 표시 - - // Upgrade 표시 - } - - /// Construction 을 하기 위해 예약해둔 Tile 들을 Map 에 표시합니다 - public void drawReservedBuildingTilesOnMap() { - boolean[][] reserveMap = ConstructionPlaceFinder.Instance().getReserveMap(); - if (reserveMap.length > 0 && reserveMap[0] != null && reserveMap[0].length > 0) { - int rwidth = reserveMap.length; - int rheight = reserveMap[0].length; - - for (int x = 0; x < rwidth; ++x) { - for (int y = 0; y < rheight; ++y) { - if (reserveMap[x][y]) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Yellow, false); - } - } - } - } - } - - /// Construction 을 하지 못하는 Tile 들을 Map 에 표시합니다 - public void drawTilesToAvoidOnMap() { - int y = 0; - int x = 0; - - - for (y = 0; y < 128; y++) { - for (x = 0; x < 128; x++) { - if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); - } -// - } - } - - - for (y = 0; y < 128; y++) { - for (x = 0; x < 128; x++) { - if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); - } - if (ConstructionPlaceFinder.Instance().getTilesToAvoidAbsolute(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Purple, false); - } - if (ConstructionPlaceFinder.Instance().getTilesToAvoidSupply(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); - } - - if (ConstructionPlaceFinder.Instance().getTilesToAvoidAddonBuilding(x, y)) { - int x1 = x * 32 + 8; - int y1 = y * 32 + 8; - int x2 = (x + 1) * 32 - 8; - int y2 = (y + 1) * 32 - 8; - - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Black, false); - } -// - } - } - } - - /// ConstructionQueue 를 Screen 에 표시합니다 - public void drawConstructionQueueOnScreenAndMap(int x, int y) { - Broodwar.drawTextScreen(x, y, white + " "); - - int yspace = 0; - - Vector constructionQueue = ConstructionManager.Instance().getConstructionQueue(); - - for (final ConstructionTask b : constructionQueue) { - String constructionState = ""; - - if (b.getStatus() == ConstructionTask.ConstructionStatus.Unassigned.ordinal()) { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), "" + white + b.getType() + " - No Worker"); - } else if (b.getStatus() == ConstructionTask.ConstructionStatus.Assigned.ordinal()) { - if (b.getConstructionWorker() == null) { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), b.getType() + " - Assigned Worker Null"); - } else { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")"); - } - - int x1 = b.getFinalPosition().getX() * 32; - int y1 = b.getFinalPosition().getY() * 32; - int x2 = (b.getFinalPosition().getX() + b.getType().tileWidth()) * 32; - int y2 = (b.getFinalPosition().getY() + b.getType().tileHeight()) * 32; - - Broodwar.drawLineMap(b.getConstructionWorker().getPosition().getX(), b.getConstructionWorker().getPosition().getY(), (x1 + x2) / 2, (y1 + y2) / 2, Color.Orange); - Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); - } else if (b.getStatus() == ConstructionTask.ConstructionStatus.UnderConstruction.ordinal()) { - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), "" + white + b.getType() + " - Under Construction"); - } - yspace++; - } - } - - /// Unit 의 Id 를 Map 에 표시합니다 - public void drawUnitIdOnMap() { - for (Unit unit : Broodwar.self().getUnits()) { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + white + unit.getID()); - } - for (Unit unit : Broodwar.enemy().getUnits()) { - Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + white + unit.getID()); - } - } - - /// Worker Unit 들의 상태를 Screen 에 표시합니다 - public void drawWorkerStateOnScreen(int x, int y) { - WorkerData workerData = WorkerManager.Instance().getWorkerData(); - - Broodwar.drawTextScreen(x, y, white + ""); - - int yspace = 0; - - for (Unit unit : workerData.getWorkers()) { - if (unit == null) continue; - - // Mineral / Gas / Idle Worker 는 표시 안한다 - if (workerData.getJobCode(unit) == 'M' || workerData.getJobCode(unit) == 'I' || workerData.getJobCode(unit) == 'G') { - continue; - } - - Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), white + " " + unit.getID()); - - if (workerData.getJobCode(unit) == 'B') { - Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), white + " " + workerData.getJobCode(unit) + " " + unit.getBuildType() + " " + (unit.isConstructing() ? 'Y' : 'N') + " (" + unit.getTilePosition().getX() + ", " + unit.getTilePosition().getY() + ")"); - } else { - Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), white + " " + workerData.getJobCode(unit)); - } - } - } - - /// ResourceDepot 별 Worker 숫자를 Map 에 표시합니다 - public void drawWorkerCountOnMap() { - for (Unit depot : WorkerManager.Instance().getWorkerData().getDepots()) { - if (depot == null) continue; - - int x = depot.getPosition().getX() - 64; - int y = depot.getPosition().getY() - 32; - - Broodwar.drawBoxMap(x - 2, y - 1, x + 75, y + 14, Color.Black, true); - Broodwar.drawTextMap(x, y, white + " Workers: " + WorkerManager.Instance().getWorkerData().getNumAssignedWorkers(depot)); - } - } - - /// Worker Unit 의 자원채취 현황을 Map 에 표시합니다 - public void drawWorkerMiningStatusOnMap() { - WorkerData workerData = WorkerManager.Instance().getWorkerData(); - - for (Unit worker : workerData.getWorkers()) { - if (worker == null) continue; - - Position pos = worker.getTargetPosition(); - - Broodwar.drawTextMap(worker.getPosition().getX(), worker.getPosition().getY() - 5, "" + white + workerData.getJobCode(worker)); - - Broodwar.drawLineMap(worker.getPosition().getX(), worker.getPosition().getY(), pos.getX(), pos.getY(), Color.Cyan); + private static UXManager instance = new UXManager(); + private final Character brown = ''; + private final char red = ''; + private final char teal = ''; + // private final char blue = ''; + private final char purple = ''; + private final char white = ''; + private final int dotRadius = 2; + private boolean hasSavedBWTAInfo = false; + private int[][] blue = null; + private int[][] cyan = null; + private int[][] orange = null; + private List yellow = new ArrayList(); + private List green1 = new ArrayList(); + private List green2 = new ArrayList(); + private List red1 = new ArrayList(); + private List red2 = new ArrayList(); + private String bulletTypeName = ""; + private String tempUnitName = ""; + + private Game Broodwar; + + /// static singleton 객체를 리턴합니다 + public static UXManager Instance() { + return instance; + } + + /// 경기가 시작될 때 일회적으로 추가 정보를 출력합니다 + public void onStart(Game Broodwar) { + this.Broodwar = Broodwar; + } + + /// 경기 진행 중 매 프레임마다 추가 정보를 출력하고 사용자 입력을 처리합니다 + public void update() { + drawGameInformationOnScreen(5, 5); + + if (Config.DrawEnemyUnitInfo) { + drawUnitStatisticsOnScreen(400, 20); + } + + if (Config.DrawBWTAInfo) { + drawBWTAResultOnMap(); + } + + if (Config.DrawMapGrid) { + drawMapGrid(); + } + + // 빌드오더큐 : 빌드 실행 전 + if (Config.DrawProductionInfo) { + drawBuildOrderQueueOnScreen(80, 60); + } + + // 빌드 실행 상황 : 건물 건설, 유닛 생산, 업그레이드, 리서치 + if (Config.DrawProductionInfo) { + drawBuildStatusOnScreen(200, 60); + } + + // 건물 건설 큐. 건물 건설 상황 + if (Config.DrawBuildingInfo) { + drawConstructionQueueOnScreenAndMap(200, 150); + } + + // 건물이 건설될 위치 + if (Config.DrawReservedBuildingTiles) { + // 건물 건설 장소 예약 지점 + drawReservedBuildingTilesOnMap(); + // 건물 건설 불가 구역 (미네랄/가스/베이스 사이) + drawTilesToAvoidOnMap(); + } + + if (Config.DrawUnitHealthBars) { + drawUnitExtendedInformationOnMap(); + drawUnitIdOnMap(); + } + + if (Config.DrawWorkerInfo) { + // 각 일꾼들의 임무 상황 + drawWorkerStateOnScreen(5, 60); + + // 베이스캠프당 일꾼 수 + drawWorkerCountOnMap(); + } + + // 일꾼 자원채취 임무 상황 + if (Config.DrawResourceInfo) { + drawWorkerMiningStatusOnMap(); + } + + // 정찰 + // if (Config.DrawScoutInfo) { + // drawScoutInformation(220,330); + // } + + // 공격 + if (Config.DrawUnitTargetInfo) { + drawUnitTargetOnMap(); + + // 미사일, 럴커의 보이지않는 공격등을 표시 + drawBulletsOnMap(); + } + + // draw tile position of mouse cursor + if (Config.DrawMouseCursorInfo) { + int mouseX = Broodwar.getMousePosition().getX() + Broodwar.getScreenPosition().getX(); + int mouseY = Broodwar.getMousePosition().getY() + Broodwar.getScreenPosition().getY(); + Broodwar.drawTextMap(mouseX + 20, mouseY, + "(" + (int) (mouseX / Config.TILE_SIZE) + ", " + (int) (mouseY / Config.TILE_SIZE) + ")"); + } + + } + + // 게임 개요 정보를 Screen 에 표시합니다 + public void drawGameInformationOnScreen(int x, int y) { + Broodwar.drawTextScreen(x, y, white + "Players : "); + // Broodwar.drawTextScreen(x + 50, y, Broodwar.self().getTextColor() + + // Broodwar.self().getName() + "(" + + // InformationManager.Instance().selfRace + ") " + white + " vs. " + + // PlayerUtils.enemyPlayer().getTextColor() + + // PlayerUtils.enemyPlayer().getName() + "(" + PlayerUtils.enemyRace() + + // ")"); + y += 12; + + Broodwar.drawTextScreen(x, y, white + "Map : "); + Broodwar.drawTextScreen(x + 50, y, + white + Broodwar.mapFileName() + " (" + Broodwar.mapWidth() + " x " + Broodwar.mapHeight() + " size)"); + Broodwar.setTextSize(); + y += 12; + + Broodwar.drawTextScreen(x, y, white + "Time : "); + Broodwar.drawTextScreen(x + 50, y, "" + white + TimeUtils.getFrame()); + Broodwar.drawTextScreen(x + 90, y, "" + white + (int) (TimeUtils.getFrame() / (23.8 * 60)) + ":" + + (int) ((int) (TimeUtils.getFrame() / 23.8) % 60)); + } + + /// APM (Action Per Minute) 숫자를 Screen 에 표시합니다 + public void drawAPM(int x, int y) { + int bwapiAPM = Broodwar.getAPM(); + Broodwar.drawTextScreen(x, y, "APM : " + bwapiAPM); + } + + /// Players 정보를 Screen 에 표시합니다 + public void drawPlayers() { + for (Player p : Broodwar.getPlayers()) { + Broodwar.sendText("Player [" + p.getID() + "]: " + p.getName() + " is in force: " + p.getForce().getName()); + } + } + + /// Player 들의 팀 (Force) 들의 정보를 Screen 에 표시합니다 + public void drawForces() { + for (Force f : Broodwar.getForces()) { + Broodwar.sendText("Force " + f.getName() + " has the following players:"); + for (Player p : f.getPlayers()) { + Broodwar.sendText(" - Player [" + p.getID() + "]: " + p.getName()); + } + } + } + + /// Unit 의 HitPoint 등 추가 정보를 Map 에 표시합니다 + public void drawUnitExtendedInformationOnMap() { + int verticalOffset = -10; + + for (UnitInfo ui : UnitUtils.getEnemyUnitInfoList()) { + + UnitType type = ui.getType(); + int hitPoints = ui.getLastHealth(); + int shields = ui.getLastShields(); + + Position pos = ui.getLastPosition(); + + int left = pos.getX() - type.dimensionLeft(); + int right = pos.getX() + type.dimensionRight(); + int top = pos.getY() - type.dimensionUp(); + int bottom = pos.getY() + type.dimensionDown(); + + // 적 유닛이면 주위에 박스 표시 + if (!Broodwar.isVisible(ui.getLastPosition().toTilePosition())) { + Broodwar.drawBoxMap(new Position(left, top), new Position(right, bottom), Color.Grey, false); + Broodwar.drawTextMap(new Position(left + 3, top + 4), ui.getType().toString()); + } + + // 유닛의 HitPoint 남아있는 비율 표시 + if (!type.isResourceContainer() && type.maxHitPoints() > 0) { + double hpRatio = (double) hitPoints / (double) type.maxHitPoints(); + + Color hpColor = Color.Green; + if (hpRatio < 0.66) + hpColor = Color.Orange; + if (hpRatio < 0.33) + hpColor = Color.Red; + + int ratioRight = left + (int) ((right - left) * hpRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + + // 유닛의 Shield 남아있는 비율 표시 + if (!type.isResourceContainer() && type.maxShields() > 0) { + double shieldRatio = (double) shields / (double) type.maxShields(); + + int ratioRight = left + (int) ((right - left) * shieldRatio); + int hpTop = top - 3 + verticalOffset; + int hpBottom = top + 1 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + } + + // draw neutral units and our units + for (Unit unit : Broodwar.getAllUnits()) { + if (unit.getPlayer() == PlayerUtils.enemyPlayer()) { + continue; + } + + final Position pos = unit.getPosition(); + + int left = pos.getX() - unit.getType().dimensionLeft(); + int right = pos.getX() + unit.getType().dimensionRight(); + int top = pos.getY() - unit.getType().dimensionUp(); + int bottom = pos.getY() + unit.getType().dimensionDown(); + + // Monster.game.drawBoxMap(BWAPI.Position(left, top), + // BWAPI.Position(right, bottom), Color.Grey, false); + + // 유닛의 HitPoint 남아있는 비율 표시 + if (!unit.getType().isResourceContainer() && unit.getType().maxHitPoints() > 0) { + double hpRatio = (double) unit.getHitPoints() / (double) unit.getType().maxHitPoints(); + + Color hpColor = Color.Green; + if (hpRatio < 0.66) + hpColor = Color.Orange; + if (hpRatio < 0.33) + hpColor = Color.Red; + + int ratioRight = left + (int) ((right - left) * hpRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), hpColor, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), hpColor.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + + // 유닛의 Shield 남아있는 비율 표시 + if (!unit.getType().isResourceContainer() && unit.getType().maxShields() > 0) { + double shieldRatio = (double) unit.getShields() / (double) unit.getType().maxShields(); + + int ratioRight = left + (int) ((right - left) * shieldRatio); + int hpTop = top - 3 + verticalOffset; + int hpBottom = top + 1 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Blue, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + + // Mineral / Gas 가 얼마나 남아있는가 + if (unit.getType().isResourceContainer() && unit.getInitialResources() > 0) { + double mineralRatio = (double) unit.getResources() / (double) unit.getInitialResources(); + + int ratioRight = left + (int) ((right - left) * mineralRatio); + int hpTop = top + verticalOffset; + int hpBottom = top + 4 + verticalOffset; + + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Grey, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(ratioRight, hpBottom), Color.Cyan, true); + Broodwar.drawBoxMap(new Position(left, hpTop), new Position(right, hpBottom), Color.Black, false); + + int ticWidth = 3; + + for (int i = left; i < right - 1; i += ticWidth) { + Broodwar.drawLineMap(new Position(i, hpTop), new Position(i, hpBottom), Color.Black); + } + } + } + } + + /// UnitType 별 통계 정보를 Screen 에 표시합니다 + public void drawUnitStatisticsOnScreen(int x, int y) { + int currentY = y; + + // 아군이 입은 피해 누적값 + currentY += 10; + + // 적군의 UnitType 별 파악된 Unit 숫자를 표시 + Broodwar.drawTextScreen(x, currentY + 20, white + " UNIT NAME"); + Broodwar.drawTextScreen(x + 110, currentY + 20, white + " Created"); + Broodwar.drawTextScreen(x + 150, currentY + 20, white + " Dead"); + Broodwar.drawTextScreen(x + 190, currentY + 20, white + " Alive"); + + int yspace = 0; + + } + + /// BWTA 라이브러리에 의한 Map 분석 결과 정보를 Map 에 표시합니다 + public void drawBWTAResultOnMap() { + int blueCount = 0; + int cyanCount = 0; + int orangeCount = 0; + + if (hasSavedBWTAInfo == false) { + for (BaseLocation baseLocation : BWTA.getBaseLocations()) { + blueCount++; + for (Unit unit : baseLocation.getStaticMinerals()) { + cyanCount++; + } + for (Unit unit : baseLocation.getGeysers()) { + orangeCount++; + } + } + + blue = new int[blueCount][4]; + int blueIndex = 0; + cyan = new int[cyanCount][2]; + int cyanIndex = 0; + orange = new int[orangeCount][4]; + int orangeIndex = 0; + + for (BaseLocation baseLocation : BWTA.getBaseLocations()) { + TilePosition p = baseLocation.getTilePosition(); + Position c = baseLocation.getPosition(); + + blue[blueIndex][0] = p.getX() * 32; + blue[blueIndex][1] = p.getY() * 32; + blue[blueIndex][2] = p.getX() * 32 + 4 * 32; + blue[blueIndex][3] = p.getY() * 32 + 3 * 32; + blueIndex++; + + // draw a circle at each mineral patch + // C++ : for (BWAPI.Unitset.iterator j = + // (*i).getStaticMinerals().begin(); j != + // (*i).getStaticMinerals().end(); j++) + for (Unit unit : baseLocation.getStaticMinerals()) { + Position q = unit.getInitialPosition(); + cyan[cyanIndex][0] = q.getX(); + cyan[cyanIndex][1] = q.getY(); + cyanIndex++; + } + + // draw the outlines of vespene geysers + // C++ : for (BWAPI.Unitset.iterator j = + // (*i).getGeysers().begin(); j != (*i).getGeysers().end(); j++) + for (Unit unit : baseLocation.getGeysers()) { + TilePosition q = unit.getInitialTilePosition(); + orange[orangeIndex][0] = q.getX() * 32; + orange[orangeIndex][1] = q.getY() * 32; + orange[orangeIndex][2] = q.getX() * 32 + 4 * 32; + orange[orangeIndex][3] = q.getY() * 32 + 2 * 32; + orangeIndex++; + } + + // if this is an island expansion, draw a yellow circle around + // the base location + if (baseLocation.isIsland()) { + yellow.add(c); + } + } + + // we will iterate through all the regions and draw the polygon + // outline of it in green. + // C++ : for (std.set.const_iterator r = + // BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for (Region region : BWTA.getRegions()) { + Polygon p = region.getPolygon(); + for (int j = 0; j < p.getPoints().size(); j++) { + green1.add(p.getPoints().get(j)); + green2.add(p.getPoints().get((j + 1) % p.getPoints().size())); + } + } + + // we will visualize the chokepoints with red lines + // C++ : for (std.set.const_iterator r = + // BWTA.getRegions().begin(); r != BWTA.getRegions().end(); r++) + for (Region region : BWTA.getRegions()) { + // C++ : for (std.set.const_iterator c = + // (*r).getChokepoints().begin(); c != + // (*r).getChokepoints().end(); c++) + for (Chokepoint Chokepoint : region.getChokepoints()) { + red1.add(Chokepoint.getSides().first); + red2.add(Chokepoint.getSides().second); + } + } + hasSavedBWTAInfo = true; + + // System.out.println(blueCount + " " + cyanCount + " " + + // orangeCount + " " + yellowCount + " " + greenCount + " " + + // redCount); + } + + if (hasSavedBWTAInfo) { + for (int i1 = 0; i1 < blue.length; i1++) { + Broodwar.drawBoxMap(blue[i1][0], blue[i1][1], blue[i1][2], blue[i1][3], Color.Blue); + } + for (int i2 = 0; i2 < cyan.length; i2++) { + Broodwar.drawCircleMap(cyan[i2][0], cyan[i2][1], 30, Color.Cyan); + } + for (int i3 = 0; i3 < orange.length; i3++) { + Broodwar.drawBoxMap(orange[i3][0], orange[i3][1], orange[i3][2], orange[i3][3], Color.Orange); + } + for (int i4 = 0; i4 < yellow.size(); i4++) { + Broodwar.drawCircleMap(yellow.get(i4), 80, Color.Yellow); + } + for (int i5 = 0; i5 < green1.size(); i5++) { + Broodwar.drawLineMap(green1.get(i5), green2.get(i5), Color.Green); + } + for (int i6 = 0; i6 < red1.size(); i6++) { + Broodwar.drawLineMap(red1.get(i6), red2.get(i6), Color.Red); + } + + // OccupiedBaseLocation 을 원으로 표시 + // for (BaseLocation baseLocation : + // InformationManager.Instance().getOccupiedBaseLocations(PlayerUtils.myPlayer())) + // { + // Broodwar.drawCircleMap(baseLocation.getPosition(), 10 * + // Config.TILE_SIZE, Color.Blue); + // } + // for (BaseLocation baseLocation : + // UnitTypeUtils.getOccupiedBaseLocations(PlayerUtils.enemyPlayer())) + // { + // Broodwar.drawCircleMap(baseLocation.getPosition(), 10 * + // Config.TILE_SIZE, Color.Red); + // } + + // ChokePoint, BaseLocation 을 텍스트로 표시 + if (ChokeUtils.myFirstChoke() != null) { + Broodwar.drawTextMap(BaseUtils.myMainBase().getPosition(), "My MainBaseLocation"); + } + if (ChokeUtils.myFirstChoke() != null) { + Broodwar.drawTextMap(ChokeUtils.myFirstChoke().getCenter(), "My First ChokePoint"); + } + if (ChokeUtils.mySecondChoke() != null) { + Broodwar.drawTextMap(ChokeUtils.mySecondChoke().getCenter(), "My Second ChokePoint"); + } + if (BaseUtils.myFirstExpansion() != null) { + Broodwar.drawTextMap(BaseUtils.myFirstExpansion().getPosition(), "My First ExpansionLocation"); + } + + // if + // (InformationManager.Instance().getFirstChokePoint(PlayerUtils.enemyPlayer()) + // != null) { + // Broodwar.drawTextMap(BaseUtils.enemyMainBase().getPosition(), + // "Enemy MainBaseLocation"); + // } + // if + // (InformationManager.Instance().getFirstChokePoint(PlayerUtils.enemyPlayer()) + // != null) { + // Broodwar.drawTextMap(InformationManager.Instance().getFirstChokePoint(PlayerUtils.enemyPlayer()).getCenter(), + // "Enemy First ChokePoint"); + // } + if (ChokeUtils.enemySecondChoke() != null) { + Broodwar.drawTextMap(ChokeUtils.enemySecondChoke().getCenter(), "Enemy Second ChokePoint"); + } + if (BaseUtils.enemyFirstExpansion() != null) { + Broodwar.drawTextMap(BaseUtils.enemyFirstExpansion().getPosition(), "Enemy First ExpansionLocation"); + } + + } + } + + /// Tile Position 그리드를 Map 에 표시합니다 + public void drawMapGrid() { + int cellSize = MapGrid.Instance().getCellSize(); + int mapWidth = MapGrid.Instance().getMapWidth(); + int mapHeight = MapGrid.Instance().getMapHeight(); + int rows = MapGrid.Instance().getRows(); + int cols = MapGrid.Instance().getCols(); + + for (int i = 0; i < cols; i++) { + Broodwar.drawLineMap(i * cellSize, 0, i * cellSize, mapHeight, Color.Blue); + } + + for (int j = 0; j < rows; j++) { + Broodwar.drawLineMap(0, j * cellSize, mapWidth, j * cellSize, Color.Blue); + } + + for (int r = 0; r < rows; r += 2) { + for (int c = 0; c < cols; c += 2) { + Broodwar.drawTextMap(c * 32, r * 32, c + "," + r); + } + } + } + + /// BuildOrderQueue 를 Screen 에 표시합니다 + public void drawBuildOrderQueueOnScreen(int x, int y) { + Broodwar.drawTextScreen(x, y, white + " "); + + Deque buildQueue = BuildManager.Instance().buildQueue.getQueue(); + int itemCount = 0; + + // C++ : for (std.deque.reverse_iterator itr = + // buildQueue.rbegin(); itr != buildQueue.rend(); itr++) { + // C++ : BuildOrderItem & currentItem = *itr; + // C++ : Monster.game.drawTextScreen(x, y + 10 + (itemCount * 10), " + // %s", currentItem.metaType.getName().c_str()); + // C++ : itemCount++; + // C++ : if (itemCount >= 24) break; + // C++ : } + + Object[] tempQueue = buildQueue.toArray(); + + for (int i = 0; i < tempQueue.length; i++) { + BuildOrderItem currentItem = (BuildOrderItem) tempQueue[i]; + Broodwar.drawTextScreen(x, y + 10 + (itemCount * 10), + white + currentItem.metaType.getName() + " " + currentItem.blocking); + itemCount++; + if (itemCount >= 24) + break; + } + } + + /// Build 진행 상태를 Screen 에 표시합니다 + public void drawBuildStatusOnScreen(int x, int y) { + // 건설 / 훈련 중인 유닛 진행상황 표시 + Vector unitsUnderConstruction = new Vector(); + for (Unit unit : Broodwar.self().getUnits()) { + if (unit != null && unit.isBeingConstructed()) { + unitsUnderConstruction.add(unit); + } + } + + // sort it based on the time it was started + Object[] tempArr = unitsUnderConstruction.toArray(); + // Arrays.sort(tempArr); + unitsUnderConstruction = new Vector(); + for (int i = 0; i < tempArr.length; i++) { + unitsUnderConstruction.add((Unit) tempArr[i]); + } + // C++ : std.sort(unitsUnderConstruction.begin(), + // unitsUnderConstruction.end(), CompareWhenStarted()); + + Broodwar.drawTextScreen(x, y, white + " "); + + int reps = unitsUnderConstruction.size() < 10 ? unitsUnderConstruction.size() : 10; + + for (Unit unit : unitsUnderConstruction) { + y += 10; + UnitType t = unit.getType(); + if (t == UnitType.Zerg_Egg) { + t = unit.getBuildType(); + } + + Broodwar.drawTextScreen(x, y, "" + white + t + " (" + unit.getRemainingBuildTime() + ")"); + } + + // Tech Research 표시 + + // Upgrade 표시 + } + + /// Construction 을 하기 위해 예약해둔 Tile 들을 Map 에 표시합니다 + public void drawReservedBuildingTilesOnMap() { + boolean[][] reserveMap = ConstructionPlaceFinder.Instance().getReserveMap(); + if (reserveMap.length > 0 && reserveMap[0] != null && reserveMap[0].length > 0) { + int rwidth = reserveMap.length; + int rheight = reserveMap[0].length; + + for (int x = 0; x < rwidth; ++x) { + for (int y = 0; y < rheight; ++y) { + if (reserveMap[x][y]) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Yellow, false); + } + } + } + } + } + + /// Construction 을 하지 못하는 Tile 들을 Map 에 표시합니다 + public void drawTilesToAvoidOnMap() { + int y = 0; + int x = 0; + + for (y = 0; y < 128; y++) { + for (x = 0; x < 128; x++) { + if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); + } + // + } + } + + for (y = 0; y < 128; y++) { + for (x = 0; x < 128; x++) { + if (ConstructionPlaceFinder.Instance().getTilesToAvoid(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Orange, false); + } + if (ConstructionPlaceFinder.Instance().getTilesToAvoidAbsolute(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Purple, false); + } + if (ConstructionPlaceFinder.Instance().getTilesToAvoidSupply(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); + } + + if (ConstructionPlaceFinder.Instance().getTilesToAvoidAddonBuilding(x, y)) { + int x1 = x * 32 + 8; + int y1 = y * 32 + 8; + int x2 = (x + 1) * 32 - 8; + int y2 = (y + 1) * 32 - 8; + + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Black, false); + } + // + } + } + } + + /// ConstructionQueue 를 Screen 에 표시합니다 + public void drawConstructionQueueOnScreenAndMap(int x, int y) { + Broodwar.drawTextScreen(x, y, white + " "); + + int yspace = 0; + + Vector constructionQueue = ConstructionManager.Instance().getConstructionQueue(); + + for (final ConstructionTask b : constructionQueue) { + String constructionState = ""; + + if (b.getStatus() == ConstructionTask.ConstructionStatus.Unassigned.ordinal()) { + Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), "" + white + b.getType() + " - No Worker"); + } else if (b.getStatus() == ConstructionTask.ConstructionStatus.Assigned.ordinal()) { + if (b.getConstructionWorker() == null) { + Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), b.getType() + " - Assigned Worker Null"); + } else { + Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), + b.getType() + " - Assigned Worker " + b.getConstructionWorker().getID() + ", Position (" + + b.getFinalPosition().getX() + "," + b.getFinalPosition().getY() + ")"); + } + + int x1 = b.getFinalPosition().getX() * 32; + int y1 = b.getFinalPosition().getY() * 32; + int x2 = (b.getFinalPosition().getX() + b.getType().tileWidth()) * 32; + int y2 = (b.getFinalPosition().getY() + b.getType().tileHeight()) * 32; + + Broodwar.drawLineMap(b.getConstructionWorker().getPosition().getX(), + b.getConstructionWorker().getPosition().getY(), (x1 + x2) / 2, (y1 + y2) / 2, Color.Orange); + Broodwar.drawBoxMap(x1, y1, x2, y2, Color.Red, false); + } else if (b.getStatus() == ConstructionTask.ConstructionStatus.UnderConstruction.ordinal()) { + Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), + "" + white + b.getType() + " - Under Construction"); + } + yspace++; + } + } + + /// Unit 의 Id 를 Map 에 표시합니다 + public void drawUnitIdOnMap() { + for (Unit unit : Broodwar.self().getUnits()) { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + white + unit.getID()); + } + for (Unit unit : Broodwar.enemy().getUnits()) { + Broodwar.drawTextMap(unit.getPosition().getX(), unit.getPosition().getY() + 5, "" + white + unit.getID()); + } + } + + /// Worker Unit 들의 상태를 Screen 에 표시합니다 + public void drawWorkerStateOnScreen(int x, int y) { + WorkerData workerData = WorkerManager.Instance().getWorkerData(); + + Broodwar.drawTextScreen(x, y, white + ""); + + int yspace = 0; + + for (Unit unit : workerData.getWorkers()) { + if (unit == null) + continue; + + // Mineral / Gas / Idle Worker 는 표시 안한다 + if (workerData.getJobCode(unit) == 'M' || workerData.getJobCode(unit) == 'I' + || workerData.getJobCode(unit) == 'G') { + continue; + } + + Broodwar.drawTextScreen(x, y + 10 + ((yspace) * 10), white + " " + unit.getID()); + + if (workerData.getJobCode(unit) == 'B') { + Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), + white + " " + workerData.getJobCode(unit) + " " + unit.getBuildType() + " " + + (unit.isConstructing() ? 'Y' : 'N') + " (" + unit.getTilePosition().getX() + ", " + + unit.getTilePosition().getY() + ")"); + } else { + Broodwar.drawTextScreen(x + 30, y + 10 + ((yspace++) * 10), white + " " + workerData.getJobCode(unit)); + } + } + } + + /// ResourceDepot 별 Worker 숫자를 Map 에 표시합니다 + public void drawWorkerCountOnMap() { + for (Unit depot : WorkerManager.Instance().getWorkerData().getDepots()) { + if (depot == null) + continue; + + int x = depot.getPosition().getX() - 64; + int y = depot.getPosition().getY() - 32; + + Broodwar.drawBoxMap(x - 2, y - 1, x + 75, y + 14, Color.Black, true); + Broodwar.drawTextMap(x, y, + white + " Workers: " + WorkerManager.Instance().getWorkerData().getNumAssignedWorkers(depot)); + } + } + + /// Worker Unit 의 자원채취 현황을 Map 에 표시합니다 + public void drawWorkerMiningStatusOnMap() { + WorkerData workerData = WorkerManager.Instance().getWorkerData(); + + for (Unit worker : workerData.getWorkers()) { + if (worker == null) + continue; + + Position pos = worker.getTargetPosition(); + + Broodwar.drawTextMap(worker.getPosition().getX(), worker.getPosition().getY() - 5, + "" + white + workerData.getJobCode(worker)); + + Broodwar.drawLineMap(worker.getPosition().getX(), worker.getPosition().getY(), pos.getX(), pos.getY(), + Color.Cyan); /* - // ResourceDepot ~ Worker 사이에 직선 표시 - BWAPI.Unit depot = workerData.getWorkerDepot(worker); - if (depot) { - Monster.game.drawLineMap(worker.getPosition().x, worker.getPosition().y, depot.getPosition().x, depot.getPosition().y, Color.Orange); - } - */ - } - } - - /// Unit 의 Target 으로 잇는 선을 Map 에 표시합니다 - public void drawUnitTargetOnMap() { - for (Unit unit : Broodwar.self().getUnits()) { - if (unit != null && unit.isCompleted() && !unit.getType().isBuilding() && !unit.getType().isWorker()) { - Unit targetUnit = unit.getTarget(); - if (targetUnit != null && targetUnit.getPlayer() != Broodwar.self()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Red, true); - Broodwar.drawCircleMap(targetUnit.getTargetPosition(), dotRadius, Color.Red, true); - Broodwar.drawLineMap(unit.getPosition(), targetUnit.getTargetPosition(), Color.Red); - } else if (unit.isMoving()) { - Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); - Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); - Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); - } - - } - } - } - - /// Bullet 을 Map 에 표시합니다
- /// Cloaking Unit 의 Bullet 표시에 쓰입니다 - public void drawBulletsOnMap() { - for (Bullet b : Broodwar.getBullets()) { - Position p = b.getPosition(); - double velocityX = b.getVelocityX(); - double velocityY = b.getVelocityY(); - - if (b.getType() == BulletType.Acid_Spore) bulletTypeName = "Acid_Spore"; - else if (b.getType() == BulletType.Anti_Matter_Missile) bulletTypeName = "Anti_Matter_Missile"; - else if (b.getType() == BulletType.Arclite_Shock_Cannon_Hit) bulletTypeName = "Arclite_Shock_Cannon_Hit"; - else if (b.getType() == BulletType.ATS_ATA_Laser_Battery) bulletTypeName = "ATS_ATA_Laser_Battery"; - else if (b.getType() == BulletType.Burst_Lasers) bulletTypeName = "Burst_Lasers"; - else if (b.getType() == BulletType.C_10_Canister_Rifle_Hit) bulletTypeName = "C_10_Canister_Rifle_Hit"; - else if (b.getType() == BulletType.Consume) bulletTypeName = "Consume"; - else if (b.getType() == BulletType.Corrosive_Acid_Shot) bulletTypeName = "Corrosive_Acid_Shot"; - else if (b.getType() == BulletType.Dual_Photon_Blasters_Hit) bulletTypeName = "Dual_Photon_Blasters_Hit"; - else if (b.getType() == BulletType.EMP_Missile) bulletTypeName = "EMP_Missile"; - else if (b.getType() == BulletType.Ensnare) bulletTypeName = "Ensnare"; - else if (b.getType() == BulletType.Fragmentation_Grenade) bulletTypeName = "Fragmentation_Grenade"; - else if (b.getType() == BulletType.Fusion_Cutter_Hit) bulletTypeName = "Fusion_Cutter_Hit"; - else if (b.getType() == BulletType.Gauss_Rifle_Hit) bulletTypeName = "Gauss_Rifle_Hit"; - else if (b.getType() == BulletType.Gemini_Missiles) bulletTypeName = "Gemini_Missiles"; - else if (b.getType() == BulletType.Glave_Wurm) bulletTypeName = "Glave_Wurm"; - else if (b.getType() == BulletType.Halo_Rockets) bulletTypeName = "Halo_Rockets"; - else if (b.getType() == BulletType.Invisible) bulletTypeName = "Invisible"; - else if (b.getType() == BulletType.Longbolt_Missile) bulletTypeName = "Longbolt_Missile"; - else if (b.getType() == BulletType.Melee) bulletTypeName = "Melee"; - else if (b.getType() == BulletType.Needle_Spine_Hit) bulletTypeName = "Needle_Spine_Hit"; - else if (b.getType() == BulletType.Neutron_Flare) bulletTypeName = "Neutron_Flare"; - else if (b.getType() == BulletType.None) bulletTypeName = "None"; - else if (b.getType() == BulletType.Optical_Flare_Grenade) bulletTypeName = "Optical_Flare_Grenade"; - else if (b.getType() == BulletType.Particle_Beam_Hit) bulletTypeName = "Particle_Beam_Hit"; - else if (b.getType() == BulletType.Phase_Disruptor) bulletTypeName = "Phase_Disruptor"; - else if (b.getType() == BulletType.Plague_Cloud) bulletTypeName = "Plague_Cloud"; - else if (b.getType() == BulletType.Psionic_Shockwave_Hit) bulletTypeName = "Psionic_Shockwave_Hit"; - else if (b.getType() == BulletType.Psionic_Storm) bulletTypeName = "Psionic_Storm"; - else if (b.getType() == BulletType.Pulse_Cannon) bulletTypeName = "Pulse_Cannon"; - else if (b.getType() == BulletType.Queen_Spell_Carrier) bulletTypeName = "Queen_Spell_Carrier"; - else if (b.getType() == BulletType.Seeker_Spores) bulletTypeName = "Seeker_Spores"; - else if (b.getType() == BulletType.STA_STS_Cannon_Overlay) bulletTypeName = "STA_STS_Cannon_Overlay"; - else if (b.getType() == BulletType.Subterranean_Spines) bulletTypeName = "Subterranean_Spines"; - else if (b.getType() == BulletType.Sunken_Colony_Tentacle) bulletTypeName = "Sunken_Colony_Tentacle"; - else if (b.getType() == BulletType.Unknown) bulletTypeName = "Unknown"; - else if (b.getType() == BulletType.Yamato_Gun) bulletTypeName = "Yamato_Gun"; - - // 아군 것이면 녹색, 적군 것이면 빨간색 - Broodwar.drawLineMap(p, new Position(p.getX() + (int) velocityX, p.getY() + (int) velocityY), b.getPlayer() == Broodwar.self() ? Color.Green : Color.Red); - if (b.getType() != null) { - Broodwar.drawTextMap(p, (b.getPlayer() == Broodwar.self() ? "" + teal : "" + red) + bulletTypeName); - } - } - } + * // ResourceDepot ~ Worker 사이에 직선 표시 BWAPI.Unit depot = + * workerData.getWorkerDepot(worker); if (depot) { + * Monster.game.drawLineMap(worker.getPosition().x, + * worker.getPosition().y, depot.getPosition().x, + * depot.getPosition().y, Color.Orange); } + */ + } + } + + /// Unit 의 Target 으로 잇는 선을 Map 에 표시합니다 + public void drawUnitTargetOnMap() { + for (Unit unit : Broodwar.self().getUnits()) { + if (unit != null && unit.isCompleted() && !unit.getType().isBuilding() && !unit.getType().isWorker()) { + Unit targetUnit = unit.getTarget(); + if (targetUnit != null && targetUnit.getPlayer() != Broodwar.self()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Red, true); + Broodwar.drawCircleMap(targetUnit.getTargetPosition(), dotRadius, Color.Red, true); + Broodwar.drawLineMap(unit.getPosition(), targetUnit.getTargetPosition(), Color.Red); + } else if (unit.isMoving()) { + Broodwar.drawCircleMap(unit.getPosition(), dotRadius, Color.Orange, true); + Broodwar.drawCircleMap(unit.getTargetPosition(), dotRadius, Color.Orange, true); + Broodwar.drawLineMap(unit.getPosition(), unit.getTargetPosition(), Color.Orange); + } + + } + } + } + + /// Bullet 을 Map 에 표시합니다
+ /// Cloaking Unit 의 Bullet 표시에 쓰입니다 + public void drawBulletsOnMap() { + for (Bullet b : Broodwar.getBullets()) { + Position p = b.getPosition(); + double velocityX = b.getVelocityX(); + double velocityY = b.getVelocityY(); + + if (b.getType() == BulletType.Acid_Spore) + bulletTypeName = "Acid_Spore"; + else if (b.getType() == BulletType.Anti_Matter_Missile) + bulletTypeName = "Anti_Matter_Missile"; + else if (b.getType() == BulletType.Arclite_Shock_Cannon_Hit) + bulletTypeName = "Arclite_Shock_Cannon_Hit"; + else if (b.getType() == BulletType.ATS_ATA_Laser_Battery) + bulletTypeName = "ATS_ATA_Laser_Battery"; + else if (b.getType() == BulletType.Burst_Lasers) + bulletTypeName = "Burst_Lasers"; + else if (b.getType() == BulletType.C_10_Canister_Rifle_Hit) + bulletTypeName = "C_10_Canister_Rifle_Hit"; + else if (b.getType() == BulletType.Consume) + bulletTypeName = "Consume"; + else if (b.getType() == BulletType.Corrosive_Acid_Shot) + bulletTypeName = "Corrosive_Acid_Shot"; + else if (b.getType() == BulletType.Dual_Photon_Blasters_Hit) + bulletTypeName = "Dual_Photon_Blasters_Hit"; + else if (b.getType() == BulletType.EMP_Missile) + bulletTypeName = "EMP_Missile"; + else if (b.getType() == BulletType.Ensnare) + bulletTypeName = "Ensnare"; + else if (b.getType() == BulletType.Fragmentation_Grenade) + bulletTypeName = "Fragmentation_Grenade"; + else if (b.getType() == BulletType.Fusion_Cutter_Hit) + bulletTypeName = "Fusion_Cutter_Hit"; + else if (b.getType() == BulletType.Gauss_Rifle_Hit) + bulletTypeName = "Gauss_Rifle_Hit"; + else if (b.getType() == BulletType.Gemini_Missiles) + bulletTypeName = "Gemini_Missiles"; + else if (b.getType() == BulletType.Glave_Wurm) + bulletTypeName = "Glave_Wurm"; + else if (b.getType() == BulletType.Halo_Rockets) + bulletTypeName = "Halo_Rockets"; + else if (b.getType() == BulletType.Invisible) + bulletTypeName = "Invisible"; + else if (b.getType() == BulletType.Longbolt_Missile) + bulletTypeName = "Longbolt_Missile"; + else if (b.getType() == BulletType.Melee) + bulletTypeName = "Melee"; + else if (b.getType() == BulletType.Needle_Spine_Hit) + bulletTypeName = "Needle_Spine_Hit"; + else if (b.getType() == BulletType.Neutron_Flare) + bulletTypeName = "Neutron_Flare"; + else if (b.getType() == BulletType.None) + bulletTypeName = "None"; + else if (b.getType() == BulletType.Optical_Flare_Grenade) + bulletTypeName = "Optical_Flare_Grenade"; + else if (b.getType() == BulletType.Particle_Beam_Hit) + bulletTypeName = "Particle_Beam_Hit"; + else if (b.getType() == BulletType.Phase_Disruptor) + bulletTypeName = "Phase_Disruptor"; + else if (b.getType() == BulletType.Plague_Cloud) + bulletTypeName = "Plague_Cloud"; + else if (b.getType() == BulletType.Psionic_Shockwave_Hit) + bulletTypeName = "Psionic_Shockwave_Hit"; + else if (b.getType() == BulletType.Psionic_Storm) + bulletTypeName = "Psionic_Storm"; + else if (b.getType() == BulletType.Pulse_Cannon) + bulletTypeName = "Pulse_Cannon"; + else if (b.getType() == BulletType.Queen_Spell_Carrier) + bulletTypeName = "Queen_Spell_Carrier"; + else if (b.getType() == BulletType.Seeker_Spores) + bulletTypeName = "Seeker_Spores"; + else if (b.getType() == BulletType.STA_STS_Cannon_Overlay) + bulletTypeName = "STA_STS_Cannon_Overlay"; + else if (b.getType() == BulletType.Subterranean_Spines) + bulletTypeName = "Subterranean_Spines"; + else if (b.getType() == BulletType.Sunken_Colony_Tentacle) + bulletTypeName = "Sunken_Colony_Tentacle"; + else if (b.getType() == BulletType.Unknown) + bulletTypeName = "Unknown"; + else if (b.getType() == BulletType.Yamato_Gun) + bulletTypeName = "Yamato_Gun"; + + // 아군 것이면 녹색, 적군 것이면 빨간색 + Broodwar.drawLineMap(p, new Position(p.getX() + (int) velocityX, p.getY() + (int) velocityY), + b.getPlayer() == Broodwar.self() ? Color.Green : Color.Red); + if (b.getType() != null) { + Broodwar.drawTextMap(p, (b.getPlayer() == Broodwar.self() ? "" + teal : "" + red) + bulletTypeName); + } + } + } } \ No newline at end of file diff --git a/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java b/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java index 44107a7..0a2408f 100644 --- a/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java +++ b/src/main/java/org/monster/debugger/chat/impl/UxDrawConfig.java @@ -7,7 +7,6 @@ import java.util.Map; import org.monster.board.StrategyBoard; -import org.monster.debugger.UxColor; import org.monster.worker.WorkerManager; public class UxDrawConfig { @@ -17,7 +16,7 @@ public class UxDrawConfig { classMap.put("STRATEGYBOARD", StrategyBoard.class); classMap.put("WORKERMANAGER", WorkerManager.class); } - + public static Map posMap = new HashMap<>(); static { posMap.put("L", 20); @@ -29,21 +28,20 @@ public class UxDrawConfig { private char color; private Class clazz; private Method method; + public Method getMethod() { return method; } - private Field field; - //private Field field; - + // private Field field; + public Field getField() { return field; } - private int pos = posMap.get("L"); - + public void setPos(int pos) { this.pos = pos; } @@ -55,7 +53,6 @@ public int getPos() { private String key; private Object value; - public char getColor() { return color; } @@ -72,8 +69,8 @@ public UxDrawConfig(String pos, String key, Class clazz, Method method, char this.color = color; // TODO Auto-generated constructor stub } - - public UxDrawConfig(String pos, String key, Class clazz, Field field, char color) { + + public UxDrawConfig(String pos, String key, Class clazz, Field field, char color) { this.pos = posMap.get(pos.toUpperCase()); this.key = key; this.clazz = clazz; @@ -89,7 +86,7 @@ public UxDrawConfig(String pos, String key, Object value, char color) { this.color = color; // TODO Auto-generated constructor stub } - + public UxDrawConfig(String pos, String key, int value, char color) { this.pos = posMap.get(pos.toUpperCase()); this.key = key; @@ -101,19 +98,20 @@ public UxDrawConfig(String pos, String key, int value, char color) { public static UxDrawConfig newInstanceFiledType(String pos, String key, Class clazz, String field, char color) { Class c = clazz.getClass(); Field fld = null; - try{ + try { fld = c.getDeclaredField(field); if (!fld.isAccessible()) { fld.setAccessible(true); } } catch (Exception e) { -// System.out.println(e.getMessage()); + // System.out.println(e.getMessage()); } System.out.println(fld.getName().toString()); return new UxDrawConfig(pos, key, c, fld, color); } - - public static UxDrawConfig newInstanceMethodType(String pos, String key, Class clazz, String method, char color) { + + public static UxDrawConfig newInstanceMethodType(String pos, String key, Class clazz, String method, + char color) { Method invokeMethod = null; try { invokeMethod = clazz.getDeclaredMethod(method); @@ -127,45 +125,32 @@ public static UxDrawConfig newInstanceMethodType(String pos, String key, Class getClazz() { return this.clazz; } - + public String getKey() { return this.key; } @@ -196,5 +180,4 @@ public void setClazz(String className) { this.clazz = classMap.get(className.toUpperCase()); } - }; \ No newline at end of file diff --git a/src/main/java/org/monster/debugger/readme.md b/src/main/java/org/monster/debugger/readme.md new file mode 100644 index 0000000..c92c498 --- /dev/null +++ b/src/main/java/org/monster/debugger/readme.md @@ -0,0 +1,22 @@ +#debugging 사용법 + +1.구조 +*PreBouUxmanager.java 에 필요한 정보 추가 후 ScreenUx.java 에서 메소드 호출. +*화면 상에서 Left, Mid, Right 에 정보 표시 가능. +*UxDrawConfig 객체 생성 후 정적 팩토리 메서드 호출. +*String, Field, Method 로 호출 가능 + + +2.사용 +*출력하고자 하는 값일 String 일 경우 newInstanceStringType(위치,타이틀,값,칼라)-> +uxDrawConfig = UxDrawConfig.newInstanceStringType("L", "reaverInMyBaseFrame", + DrawingUtils.framesToTimeString(EnemyBuildTimer.Instance().reaverInMyBaseFrame), UxColor.CHAR_WHITE); + +*출력하고자 하는 값일 Field 일 경우 newInstanceFiledType(위치,타이틀,클래스,field,칼라)-> +newInstanceFiledType("M",key,UxDrawConfig.classMap.get(key.toUpperCase()),value,UxColor.CHAR_GREEN) + +*출력하고자 하는 값일 Method 일 경우 newInstanceFiledType(위치,타이틀,클래스,method명,칼라)-> +newInstanceMethodType("R", "* group size", LagObserver.class, "groupsize",UxColor.CHAR_WHITE); + + + \ No newline at end of file