public void run() { targetName = (Settings.getFindTargetName() == null) ? "gfx/kritter/dragonfly/dragonfly" : Settings.getFindTargetName(); BotUtils.sysMsg("Target " + targetName, Color.WHITE); window = BotUtils.gui().add(new StatusWindow(), 300, 200); ui.root.findchild(FlowerMenu.class); while (BotUtils.getItemAtHand() == null) { GameUI gui = HavenPanel.lui.root.findchild(GameUI.class); IMeter.Meter stam = gui.getmeter("stam", 0); // Check energy stop if it is lower than 1500 IMeter.Meter nrj = gui.getmeter("nrj", 0); if (nrj.a <= 30) { t.stop(); return; } else if (stam.a <= 30 && nrj.a >= 95) { BotUtils.drink(); } // if (!BotUtils.isMoving()) { Gob gob = BotUtils.findObjectByNames(BotUtils.player().rc, 1000, targetName); if (gob != null) { BotUtils.goToCoord(gob.rc, 200, true); BotUtils.doClick(gob, 3, 0); } // } if (gob.getres().name.contains("terobjs")) { sleep(800); } sleep(800); } window.destroy(); t.stop(); }
public static void stopGame() { System.out.println("Black's score is: "); System.out.println(GameUI.getBlackScore()); System.out.println("White's score is: "); System.out.println(GameUI.getWhiteScore()); int bScore = Integer.parseInt(GameUI.getBlackScore()); int wScore = Integer.parseInt(GameUI.getWhiteScore()); System.out.println(""); if (bScore == wScore) { System.out.println("The game is a tie!"); } else if (bScore > wScore) { System.out.println("The Black player won"); } else { System.out.println("The White player won"); } System.out.println(""); System.out.println("You may now quit and play another game. Or get some snacks."); }
public static void flipPiecesUp(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Up for (int row = i - 1; row > -1; row--) { if (Game.board[row][j] == colorNum) break; else { GameUI.setColor(row, j, color); Game.setPieceFlip(row, j, colorNum); } } }
public static void flipPiecesLeft(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Left for (int column = j - 1; column > -1; column--) { if (Game.board[i][column] == colorNum) break; else { GameUI.setColor(i, column, color); Game.setPieceFlip(i, column, colorNum); } } }
public static void flipPiecesDown(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Down for (int row = i + 1; row < 8; row++) { if (Game.board[row][j] == colorNum) break; else { GameUI.setColor(row, j, color); Game.setPieceFlip(row, j, colorNum); } } }
public static void possibleShowLeft(int i, int j, int colorNum) { // Left for (int column = j - 1; column > -1; column--) { if (Game.board[i][column] == colorNum) { break; } else if (Game.board[i][column] == 0) { GameUI.setColor(i, column, Color.GRAY); break; } } }
public static void possibleShowDown(int i, int j, int colorNum) { // Down for (int row = i + 1; row < 8; row++) { if (Game.board[row][j] == colorNum) { break; } else if (Game.board[row][j] == 0) { GameUI.setColor(row, j, Color.GRAY); break; } } }
public static void possibleShowUp(int i, int j, int colorNum) { // Up for (int row = i - 1; row > -1; row--) { if (Game.board[row][j] == colorNum) { break; } else if (Game.board[row][j] == 0) { GameUI.setColor(row, j, Color.GRAY); break; } } }
public static void flipPiecesUpRight(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // up/right for (int row = i, column = j; row > -1 && column < 8; row--, column++) { if (Game.board[row][column] == colorNum) { break; } else { GameUI.setColor(row, column, color); Game.setPieceFlip(row, column, colorNum); } } }
public static void flipPiecesDownLeft(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // down/left for (int row = i, column = j; row < 8 && column > -1; row++, column--) { if (Game.board[row][column] == colorNum) { break; } else { GameUI.setColor(row, column, color); Game.setPieceFlip(row, column, colorNum); } } }
public static void possibleShowUpRight(int i, int j, int colorNum) { // up/right if (i - 1 != -1 && j + 1 != 8) { for (int row = i - 1, column = j + 1; row > -1 && column < 8; row--, column++) { if (Game.board[row][column] == colorNum) { break; } else if (Game.board[row][column] == 0) { GameUI.setColor(row, column, Color.GRAY); break; } } } }
public static void possibleShowDownLeft(int i, int j, int colorNum) { // down/left if (i + 1 != 8 && j - 11 != -1) { for (int row = i + 1, column = j - 1; row < 8 && column > -1; row++, column--) { if (Game.board[row][column] == colorNum) { break; } else if (Game.board[row][column] == 0) { GameUI.setColor(row, column, Color.GRAY); break; } } } }
public static void possibleShowDownRight(int i, int j, int colorNum) { // down/right if (i + 1 != 8 && j + 1 != 8) { for (int row = i + 1, column = j + 1; row < 8 && column < 8; row++, column++) { if (Game.board[row][column] == colorNum) { break; } else if (Game.board[row][column] == 0) { GameUI.setColor(row, column, Color.GRAY); break; } } } }
// DIAGONALS public static void possibleShowUpLeft(int i, int j, int colorNum) { // up/left if (i - 1 != -1 && j - 1 != -1) { for (int row = i - 1, column = j - 1; row > -1 && column > -1; row--, column--) { if (Game.board[row][column] == colorNum) { break; } else if (Game.board[row][column] == 0) { GameUI.setColor(row, column, Color.GRAY); break; } } } }
// Possible moves updates public static void possibleShowRight(int i, int j, int colorNum) { // Right for (int column = j + 1; column < 8; column++) { if (Game.board[i][column] == colorNum) { break; } else if (Game.board[i][column] == 0) { // this scans until it hits an empty space, placing a grey marker there, and // breaking. GameUI.setColor(i, column, Color.GRAY); break; } } }
// Method to flip pieces, depending on what direction sent by canMove // Jean-Philippe Lebel public static void flipPiecesRight(int i, int j, Color colorPass, int colorNum) { Color color = colorPass; // Right for (int column = j + 1; column < 8; column++) { // scans in the direction called, until it hits a piece of the same color, // breaking once it does. if (Game.board[i][column] == colorNum) break; // this is the same for all 8 directional methods. else { GameUI.setColor(i, column, color); Game.setPieceFlip(i, column, colorNum); } } }
public void startGame() { /*This is the method which is called by goButtonActionPerformed. It calls for the consturction of the Deal and Mail decks, along with the Board and StatWindow. It also contructs the Players, one after another, using a for loop to determine how many are to be created. Finally, it runs the game, calling takeYourTurn in player.*/ devMode = false; toDeal = new Deal(this); toMail = new Mail(this); toBoard = new Board(); // toStatWindow = new StatWindow(noOfPlayers, noOfMonths); System.out.println("Setting up the game..."); toPlayer = new Player[noOfPlayers]; for (int index = 0; index < noOfPlayers; index++) { toPlayer[index] = new Player(this, toBoard, index, toMail, toDeal); } toGameUI = new GameUI(noOfPlayers, this, toDeal, toMail, toBoard); for (int index = 0; index < noOfPlayers; index++) { toPlayer[index].setGameUI(toGameUI); } toDeal.updateCards(this); toMail.updateCards(this); toUIThread.setToGameUI(toGameUI); finished = false; toUIThreadsThread.start(); toGameUI.distributeStartingMoney(); this.passString("Setting up the game"); index++; jackpot = 0; ready = true; while (!finished) { for (int index = 0; index < noOfPlayers; index++) { if (!toPlayer[index].finished) { toPlayer[index].takeYourTurn(); } } } }
public void passString(String s) { toGameUI.setCurrentOutput(s); }
@Override public void run() { synchronized (gui.map.glob.oc) { for (Gob gob : gui.map.glob.oc) { Resource res = gob.getres(); if (res != null && (res.name.equals("gfx/terobjs/oven") || res.name.equals("gfx/terobjs/smelter") || res.name.equals("gfx/terobjs/steelcrucible") || res.name.equals("gfx/terobjs/kiln"))) { if (this.gob == null) this.gob = gob; else if (gob.rc.dist(gui.map.player().rc) < this.gob.rc.dist(gui.map.player().rc)) this.gob = gob; } } } try { if (gob == null) { gui.error("No ovens/smelters/steelboxes/kilns found."); return; } Equipory e = gui.getequipory(); WItem l = e.quickslots[6]; WItem r = e.quickslots[7]; boolean noltorch = true; boolean nortorch = true; if (l != null) { String lname = l.item.getname(); if (lname.contains("Lit Torch")) noltorch = false; } if (r != null) { String rname = r.item.getname(); if (rname.contains("Lit Torch")) nortorch = false; } if (noltorch && nortorch) { gui.error("No lit torch is equipped."); return; } WItem w = e.quickslots[noltorch ? 7 : 6]; w.mousedown(new Coord(w.sz.x / 2, w.sz.y / 2), 1); try { Thread.sleep(100); } catch (InterruptedException ie) { e.wdgmsg("drop", noltorch ? 7 : 6); return; } gui.map.wdgmsg("itemact", Coord.z, gob.rc, 0, 0, (int) gob.id, gob.rc, 0, -1); if (!Utils.waitForProgressFinish( gui, TIMEOUT_ACT, "Oops something went wrong. Timeout when trying to light with torch.")) { e.wdgmsg("drop", noltorch ? 7 : 6); return; } e.wdgmsg("drop", noltorch ? 7 : 6); } catch (InterruptedException ie) { } }