public void botBuild(int maxNum) { PlayerBot bot = (PlayerBot) GameRunner.getPlayerisTurn(); boolean done = false; while (!done && maxNum > 0) { bot.setUnitNums(); if (((float) bot.getUnitNums()[2]) < level) { if (level >= 2 && bot.gold >= costs.get(4)) { build(4); } } if (((float) bot.getUnitNums()[1]) / ((float) bot.getUnits().size()) < (1.0f - bot.getAggressiveness())) { if (bot.gold >= costs.get(0)) { build(0); } else { done = true; } } else if (((float) bot.getUnitNums()[0]) / ((float) bot.getUnits().size()) < bot.getAggressiveness()) { if (level >= 2 && bot.gold >= costs.get(4) && Math.random() <= .1f) { build(4); } if (level >= 3 && bot.gold >= costs.get(5) && Math.random() <= .7f) { build(5); } else if (bot.gold >= costs.get(1)) { build(1); } else { done = true; } } maxNum--; } }
@Override public void select() { super.select(); // get autoMine amount int mineGold = 0; for (Unit u : GameRunner.getPlayerisTurn().getUnits()) { if (u.type.equals("Support Unit")) { mineGold += ((SupportUnit) u).getAutoMineGold(); } } costs.set(3, -1 * mineGold); }
public void build(int build) { try { if (GameRunner.getPlayerisTurn().getGold() - costs.get(build) >= 0) { if (costs.get(build) > 0) GameRunner.getPlayerisTurn().addGold((-1) * costs.get(build)); if (build == 0) { MagicSpirit s = new MagicSpirit(addLoc(location, false, true), GameRunner.getMagicSpirit()); for (int i = 0; i < level - 1; i++) { s.levelUp(); } GameRunner.getPlayerisTurn().addUnit(s); } else if (build == 1) { Mage s = new Mage(addLoc(location, false, true), GameRunner.getMage()); for (int i = 0; i < level - 1; i++) { s.levelUp(); } GameRunner.getPlayerisTurn().addUnit(s); } else if (build == 2) { GameRunner.getPlayerisTurn().levelUp(); levelUp(); } else if (build == 3) { for (Unit u : GameRunner.getPlayerisTurn().getUnits()) { if (u.type.equals("Support Unit")) { ((SupportUnit) u).autoMine(); } } } else if (build == 4) { Summoner s = new Summoner(addLoc(location, false, true), GameRunner.getSummoner()); GameRunner.getPlayerisTurn().addUnit(s); } else if (build == 5) { ArchMage n = new ArchMage(addLoc(location, false, true), GameRunner.getArchMage()); for (int i = 0; i < level - 3; i++) { n.levelUp(); } GameRunner.getPlayerisTurn().addUnit(n); } } } catch (Exception e) { LogHandling.logError("Can't add unit " + e); } }