/** * Display defence minus attack potential on a square. * * @param x the x * @param y the y */ public void displayDefenceMinusAttackPotential(int x, int y) { if (matrix[x][y] != null && !(matrix[x][y] instanceof Mountain)) { MovableEntity unit = board.getUnit(x, y); if (unit == null) squares[x][y].setBackground(COLOR_EMPTY); else { Font fnt = new Font("Serif", Font.PLAIN, windowHeight / 50); int diff = (unit.getAllyDefence() - unit.getEnemyAttack()); JLabel tmp = new JLabel(Integer.toString(diff), SwingConstants.RIGHT); tmp.setFont(fnt); squares[x][y].add(tmp); if (board.getUnit(x, y).getOwner() == 0) squares[x][y].setBackground( new Color( Math.min(240, Math.max(0, 75 + 4 * diff)), Math.min(240, Math.max(0, 75 + 4 * diff)), 255)); else squares[x][y].setBackground( new Color( 255, Math.min(240, Math.max(0, 75 + 4 * diff)), Math.min(240, Math.max(0, 75 + 4 * diff)))); } } }
/** * Displays the defence potential on a square. * * @param x the x * @param y the y */ public void displayDefencePotential(int x, int y) { if (matrix[x][y] != null && !(matrix[x][y] instanceof Mountain)) { MovableEntity unit = board.getUnit(x, y); if (unit != null) { Font fnt = new Font("Serif", Font.PLAIN, windowHeight / 50); JLabel tmp = new JLabel(Integer.toString(unit.getAllyDefence()), SwingConstants.RIGHT); tmp.setFont(fnt); squares[x][y].add(tmp); } } }