예제 #1
0
파일: Pixie.java 프로젝트: sillysoft/LuxSDK
  // a test of whether or not we should send some armies this cont's way
  protected boolean continentNeedsHelp(int cont) {
    // if we don't own it then it deffinately needs some help
    if (!BoardHelper.playerOwnsContinent(ID, cont, countries)) return true;

    // otherwise we own it.
    // check each border
    int[] borders = BoardHelper.getContinentBorders(cont, countries);
    for (int i = 0; i < borders.length; i++) {
      if (borderCountryNeedsHelp(countries[borders[i]])) return true;
    }

    return false;
  }
예제 #2
0
파일: Pixie.java 프로젝트: sillysoft/LuxSDK
  protected void fortifyContinent(int cont) {
    // We work from the borders back, fortifying closer.
    // Start out by getting a List of the cont's borders:
    int[] borders = BoardHelper.getContinentBorders(cont, countries);
    List cluster = new ArrayList();
    for (int i = 0; i < borders.length; i++) {
      cluster.add(countries[borders[i]]);
    }

    // So now the cluster borders are in <cluster>. fill it up while fortifying towards the borders.
    for (int i = 0; i < cluster.size(); i++) {
      CountryIterator neighbors = new NeighborIterator((Country) cluster.get(i));
      while (neighbors.hasNext()) {
        Country neighbor = neighbors.next();
        if (neighbor.getOwner() == ID
            && !cluster.contains(neighbor)
            && neighbor.getContinent() == cont) {
          // Then <neighbor> is part of the cluster. fortify any armies back and add to the List
          board.fortifyArmies(neighbor.getMoveableArmies(), neighbor, (Country) cluster.get(i));
          cluster.add(neighbor);
        }
      }
    }
  }