Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package vn.vule.travian.selenium;
- import com.google.common.base.Function;
- import java.io.File;
- import java.io.IOException;
- import java.io.Serializable;
- import java.net.URISyntaxException;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.apache.log4j.Logger;
- import org.openqa.selenium.By;
- import org.openqa.selenium.Cookie;
- import org.openqa.selenium.JavascriptExecutor;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.support.ui.ExpectedCondition;
- import org.openqa.selenium.support.ui.WebDriverWait;
- /**
- * @author vule
- */
- public class MainZravianAffGauls {
- private final static Logger log = Logger.getLogger(MainZravianAffGauls.class.getName());
- // private final static String USERNAME = "viki";
- // private final static String PASSWORD = "888888";
- private final static String USERNAME = "aff";
- private final static String PASSWORD = "rabbit123";
- private final static String VILLAGE_NAME_BUILD = "aff";
- private final static int NUMBER_BUILDING = 3;
- private static WebDriver webDriver;
- private static WebDriverWait wait;
- private static long timerCulturePoints = 0;
- private static List<String> villagesBuildResource = new ArrayList<String>();
- private static List<String> villagesTownHall = new ArrayList<String>();
- public static void main(String[] args) throws InterruptedException, IOException, URISyntaxException {
- initialize();
- processLogin("https://ss4.zravian.com", USERNAME, PASSWORD);
- // show level is ON
- Cookie cookie = new Cookie("lvl", "1", "/", new Date(2017, 12, 31));
- webDriver.manage().addCookie(cookie);
- log.debug("villagesBuildResource length: " + villagesBuildResource.size());
- if (villagesBuildResource.size() > 0) {
- boolean relogin = false;
- while (true) {
- try {
- if (relogin) {
- processLogin("https://ss4.zravian.com", USERNAME, PASSWORD);
- }
- for (String hrefVillage : villagesBuildResource) {
- webDriver.navigate().to(hrefVillage);
- if (checkBuilding()) continue;
- processClickOne();
- webDriver.navigate().to("https://ss4.zravian.com/village1.php");
- processUpgradeResource();
- Thread.sleep(500);
- processUpgradeResource();
- if (checkBuilding()) continue;
- webDriver.navigate().to("https://ss4.zravian.com/village2.php");
- log.debug("Processing construction to map for vilage - " + hrefVillage);
- Map<Integer, VillageBuild> map = processConstruction2Map();
- processUpgradeConstructionFull(map);
- log.debug("Sleeping 0.5s ..... for the next village");
- Thread.sleep(500);
- }
- if ((villagesTownHall != null) && (!villagesTownHall.isEmpty())) {
- for (String hrefVillage : villagesTownHall) {
- webDriver.navigate().to(hrefVillage);
- try {
- WebElement lswitch = webDriver.findElement(By.id("lswitch"));
- if (!lswitch.getAttribute("class").equals("on")) {
- lswitch.click();
- }
- } catch (Exception e) {
- log.error("ERROR: " + e.getMessage());
- e.printStackTrace();
- }
- processCulturePoints();
- // processUpgradeResidenceIfNotExist();
- }
- // }
- }
- log.debug("Sleeping 1s ..... for the next cycle");
- Thread.sleep(1000);
- } catch (Exception e) {
- log.debug("ERROR: " + e.getMessage());
- e.printStackTrace();
- String currentUrl = "";
- try {
- webDriver.getCurrentUrl();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- log.debug("CurrentUrl: " + currentUrl);
- if (currentUrl.isEmpty() || currentUrl.contains("https://zravian.com/?nosess")) {
- log.debug("Sleeping 6s ..... for relogin");
- Thread.sleep(6000);
- relogin = true;
- } else {
- log.debug("Sleeping 10m ..... for [ERROR]");
- Thread.sleep(600000);
- }
- }
- }
- }
- else {
- while (true) {
- webDriver.navigate().to("https://ss4.zravian.com/village2.php");
- try {
- WebElement lswitch = webDriver.findElement(By.id("lswitch"));
- if (!lswitch.getAttribute("class").equals("on")) {
- lswitch.click();
- }
- } catch (Exception e) {
- log.error("ERROR: " + e.getMessage());
- e.printStackTrace();
- }
- processCulturePoints();
- log.debug("Sleeping 72s ..... for the next cycle");
- Thread.sleep(72000);
- }
- }
- }
- private static void waitForPageLoadIsReadyState(final String expectedTitle) {
- wait.until(new Function<WebDriver, Boolean>() {
- public Boolean apply(WebDriver driver) {
- String actualTitle = webDriver.getTitle();
- boolean readyState = String.valueOf(((JavascriptExecutor) driver).executeScript("return document.readyState")).equals("complete");
- boolean loginPageReady = actualTitle.contains(expectedTitle);
- return loginPageReady && readyState;
- }
- });
- }
- private static void processClickOne() {
- processClickOne(true);
- }
- private static void processClickOne(final boolean clickOne) {
- // alt="Click here to disable Upgrade Mode"
- // title="Click here to disable Upgrade Mode"
- final WebElement cone = webDriver.findElement(By.id("cone"));
- String titleCone = cone.getAttribute("title");
- // log.debug("title cone: " + titleCone);
- if (clickOne) {
- if (titleCone.contains("enable")) {
- // log.debug("cone is disable - click to enable");
- cone.click();
- }
- } else {
- if (titleCone.contains("disable")) {
- // log.debug("cone is enable - click to disable");
- cone.click();
- }
- }
- }
- private static void processUpgradeResource() {
- if (webDriver.findElements(By.id("content")).size() > 0) {
- log.debug("Village Name: " + webDriver.findElement(By.id("content")).findElement(By.tagName("h1")).getText());
- }
- if (webDriver.findElements(By.id("rx")).isEmpty()) {
- log.error("Don't processUpgradeResource");
- return;
- }
- final WebElement maprx = webDriver.findElement(By.id("rx"));
- final List<WebElement> rxlist = maprx.findElements(By.tagName("area"));
- if ((rxlist != null) && (rxlist.size() > 0)) {
- String href = null;
- int minLevel = 10;
- for (WebElement element : rxlist) {
- String title = element.getAttribute("title");
- // log.debug("Map Resource: " + title + " - " + element.getAttribute("href"));
- int index = title.indexOf("level");
- if (index > 0) {
- // String res = title.substring(0, index -1);
- int level = -1;
- try {
- level = Integer.valueOf(title.substring(index + 6, title.length()));
- } catch (java.lang.NumberFormatException nfe) {
- }
- if ((level >= 0) && (level < minLevel)) {
- minLevel = level;
- href = element.getAttribute("href");
- }
- }
- }
- if ((minLevel < 10) && (href != null)) {
- webDriver.navigate().to(href);
- }
- }
- }
- private static void initialize() throws URISyntaxException {
- String path = MainZravianAffGauls.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
- File jarFile = new File(path);
- String jarDir = jarFile.getParentFile().getPath();
- log.debug("DIR PATH: " + jarDir);
- System.setProperty("webdriver.gecko.driver", jarDir + java.io.File.separator + "geckodriver");
- System.setProperty("webdriver.chrome.driver", jarDir + java.io.File.separator + "chromedriver");
- webDriver = new FirefoxDriver();
- wait = new WebDriverWait(webDriver, 120);
- }
- private static void processLogin(final String url, final String login, final String pwd) {
- log.debug("processLogin: login:" + login + " - pwd: " + pwd);
- webDriver.navigate().to("https://ss4.zravian.com/logout.php");
- webDriver.get(url);
- try {
- waitForPageLoadIsReadyState("Zravian");
- } catch (Exception e) {
- log.debug("[ERROR]", e);
- }
- WebElement username = webDriver.findElement(By.id("name"));
- WebElement password = webDriver.findElement(By.id("pass"));
- username.sendKeys(login);
- password.sendKeys(pwd);
- password.submit();
- try {
- waitForPageLoadIsReadyState("Zravian ss4");
- } catch (Exception e) {
- log.error("[ERROR]", e);
- throw e;
- }
- processBuildAllVillage();
- }
- private static void processBuildAllVillage() {
- villagesBuildResource = new ArrayList<String>();
- villagesTownHall = new ArrayList<String>();
- WebElement vlist = null;
- try {
- vlist = webDriver.findElement(By.id("vlist"));
- } catch (Exception e) {
- }
- if (vlist != null) {
- List<WebElement> links = vlist.findElements(By.tagName("a"));
- if ((links != null) && (links.size() > 0)) {
- for (WebElement element : links) {
- String href = element.getAttribute("href");
- String name = element.getText();
- if (name == null) continue;
- log.debug("Name: " + name + " - link: " + href);
- if (name.contains(VILLAGE_NAME_BUILD)) {
- //villagesBuildResource.add(href.replaceAll("village1.php", "village2.php"));
- villagesBuildResource.add(href);
- villagesTownHall.add(href.replaceAll("village1.php", "village2.php"));
- }
- }
- }
- }
- }
- private static boolean checkBuilding() {
- boolean isBuilding = false;
- if (webDriver.findElements(By.id("building_contract")).size() > 0) {
- final WebElement buildingContract = webDriver.findElement(By.id("building_contract"));
- if (buildingContract != null) {
- final List<WebElement> buildlinks = webDriver.findElements(By.className("buildlink"));
- if (buildlinks.size() > 0) {
- log.debug("Building ... " + buildlinks.size());
- if (buildlinks.size() >= NUMBER_BUILDING) {
- isBuilding = true;
- }
- }
- }
- } else {
- log.debug("NONE Building ...");
- }
- return isBuilding;
- }
- private static boolean checkConstructionBuilding(final String name) {
- boolean isBuilding = false;
- if (webDriver.findElements(By.id("building_contract")).size() > 0) {
- final WebElement buildingContract = webDriver.findElement(By.id("building_contract"));
- if (buildingContract != null) {
- final List<WebElement> buildlinks = webDriver.findElements(By.className("buildlink"));
- if (buildlinks.size() > 0) {
- WebElement buildlink = buildlinks.get(0);
- if (buildlink.getText().contains(name)) {
- log.debug("Building construction... " + name);
- isBuilding = true;
- }
- }
- }
- } else {
- log.debug("NONE Building ...");
- }
- return isBuilding;
- }
- private static void processUpgradeConstruction(final Map<Integer, VillageBuild> map) {
- if ((map == null) || map.isEmpty()) {
- log.error("Don't processUpgradeConstruction");
- return;
- }
- if (processUpgradeConstruction(map, "Main Building", 10)) {
- return;
- }
- if (processUpgradeConstruction(map, "Warehouse", 7)) {
- return;
- }
- if (processUpgradeConstruction(map, "Great Warehouse", 7)) {
- return;
- }
- if (processUpgradeConstruction(map, "Granary", 5)) {
- return;
- }
- if (processUpgradeConstruction(map, "Great Granary", 5)) {
- return;
- }
- if (processUpgradeConstruction(map, "Rally Point", 1)) {
- return;
- }
- if (processUpgradeConstruction(map, "Flour Mill", 5)) {
- return;
- }
- if (processUpgradeConstruction(map, "Brickworks", 5)) {
- return;
- }
- if (processUpgradeConstruction(map, "Bakery", 5)) {
- return;
- }
- if (processUpgradeConstruction(map, "Sawmill", 5)) {
- return;
- }
- if (processUpgradeConstruction(map, "Iron Foundry", 5)) {
- return;
- }
- }
- private static void processUpgradeConstructionFull(final Map<Integer, VillageBuild> map) {
- if ((map == null) || map.isEmpty()) {
- log.error("Don't processUpgradeConstruction");
- return;
- }
- if (processUpgradeConstruction(map, "Main Building")) return;
- if (processUpgradeConstruction(map, "Warehouse")) return;
- if (processUpgradeConstruction(map, "Great Warehouse")) return;
- if (processUpgradeConstruction(map, "Granary")) return;
- if (processUpgradeConstruction(map, "Great Granary")) return;
- if (processUpgradeConstruction(map, "Rally Point", 1)) return;
- if (processUpgradeConstruction(map, "Residence", 10)) return;
- if (processUpgradeConstruction(map, "Barracks")) return;
- if (processUpgradeConstruction(map, "Academy", 10)) return;
- if (processUpgradeConstruction(map, "Blacksmith", 10)) return;
- if (processUpgradeConstruction(map, "Stable")) return;
- if (processUpgradeConstruction(map, "Town Hall", 10)) return;
- if (processUpgradeConstruction(map, "Residence")) return;
- if (processUpgradeConstruction(map, "Marketplace")) return;
- if (processUpgradeConstruction(map, "Academy")) return;
- if (processUpgradeConstruction(map, "Town Hall")) return;
- if (processUpgradeConstruction(map, "Trade Office")) return;
- }
- private static void processUpgradeConstruction() {
- if (webDriver.findElements(By.id("map2")).isEmpty()) {
- log.error("Don't processUpgradeConstruction");
- return;
- }
- if (processUpgradeConstruction("Main Building")) return;
- if (processUpgradeConstruction("Warehouse")) return;
- if (processUpgradeConstruction("Granary")) return;
- if (processUpgradeConstruction("Residence")) return;
- if (processUpgradeConstruction("Marketplace")) return;
- if (processUpgradeConstruction("Academy")) return;
- if (processUpgradeConstruction("Rally Point", 10)) return;
- if (processUpgradeConstruction("Barracks")) return;
- if (processUpgradeConstruction("Stable")) return;
- if (processUpgradeConstruction("Town Hall")) return;
- if (processUpgradeConstruction("Flour Mill", 5)) return;
- if (processUpgradeConstruction("Brickworks", 5)) return;
- if (processUpgradeConstruction("Bakery", 5)) return;
- if (processUpgradeConstruction("Sawmill", 5)) return;
- if (processUpgradeConstruction("Iron Foundry", 5)) return;
- }
- private static boolean processUpgradeConstruction(final Map<Integer, VillageBuild> map, final String name) {
- boolean ret = false;
- if ((map == null) || map.isEmpty()) {
- log.error("Don't processUpgradeConstruction");
- return false;
- }
- for (Map.Entry m : map.entrySet()) {
- VillageBuild v = (VillageBuild) m.getValue();
- if (v.constName.contains(name) && v.level < 20) {
- webDriver.navigate().to(v.getHref());
- if (checkConstructionBuilding(name)) {
- ret = true;
- break;
- }
- }
- }
- return ret;
- }
- private static boolean processUpgradeConstruction(final String name) {
- boolean ret = false;
- if (webDriver.findElements(By.id("map2")).isEmpty()) {
- log.error("Don't processUpgradeMainBuilding");
- return false;
- }
- final WebElement map2 = webDriver.findElement(By.id("map2"));
- final List<WebElement> map2AreaList = map2.findElements(By.tagName("area"));
- if ((map2AreaList != null) && (map2AreaList.size() > 0)) {
- for (WebElement element : map2AreaList) {
- String title = null;
- try {
- title = element.getAttribute("title");
- } catch (Exception e) {
- log.debug("[ERROR] processUpgradeConstruction - CurrentUrl:" + webDriver.getCurrentUrl());
- log.debug("Element: " + element.toString());
- log.debug("Construction: " + name);
- e.printStackTrace();
- return false;
- }
- String href = element.getAttribute("href");
- // System.out.println("Map Constructions: " + title + " - " + href);
- int index = title.indexOf("level");
- if (index > 0) {
- String n = title.substring(0, index - 1);
- int level = -1;
- try {
- level = Integer.valueOf(title.substring(index + 6, title.length()));
- } catch (Exception e) {
- System.out.println("ERROR:" + e.getMessage());
- e.printStackTrace();
- return false;
- }
- if ((level < 20) && n.equals(name)) {
- webDriver.navigate().to(href);
- if (checkConstructionBuilding(name)) {
- ret = true;
- break;
- } else {
- ret = false;
- break;
- }
- }
- }
- }
- }
- return ret;
- }
- private static boolean processUpgradeConstruction(final Map<Integer, VillageBuild> map, final String name, final int levelExpectation) {
- boolean ret = false;
- if ((map == null) || map.isEmpty()) {
- log.error("Don't processUpgradeConstruction");
- return false;
- }
- for (Map.Entry m : map.entrySet()) {
- VillageBuild v = (VillageBuild) m.getValue();
- if (v.constName.contains(name) && v.level < levelExpectation) {
- webDriver.navigate().to(v.getHref());
- if (checkConstructionBuilding(name)) {
- ret = true;
- break;
- }
- }
- }
- return ret;
- }
- private static boolean processUpgradeConstruction(final String name, final int levelExpectation) {
- boolean ret = false;
- if (webDriver.findElements(By.id("map2")).isEmpty()) {
- log.error("Don't processUpgradeMainBuilding");
- return false;
- }
- final WebElement map2 = webDriver.findElement(By.id("map2"));
- final List<WebElement> map2AreaList = map2.findElements(By.tagName("area"));
- if ((map2AreaList != null) && (map2AreaList.size() > 0)) {
- for (WebElement element : map2AreaList) {
- String title = null;
- try {
- title = element.getAttribute("title");
- } catch (Exception e) {
- log.debug("[ERROR] processUpgradeConstruction - CurrentUrl:" + webDriver.getCurrentUrl());
- log.debug(element.toString());
- e.printStackTrace();
- return false;
- }
- String href = element.getAttribute("href");
- // System.out.println("Map Constructions: " + title + " - " + href);
- int index = title.indexOf("level");
- if (index > 0) {
- String n = title.substring(0, index - 1);
- int level = -1;
- try {
- level = Integer.valueOf(title.substring(index + 6, title.length()));
- } catch (Exception e) {
- System.out.println("ERROR:" + e.getMessage());
- e.printStackTrace();
- return false;
- }
- if ((level < levelExpectation) && n.equals(name)) {
- webDriver.navigate().to(href);
- if (checkConstructionBuilding(name)) {
- ret = true;
- break;
- }
- }
- }
- }
- }
- return ret;
- }
- private static boolean processUpgradeResidenceIfNotExist() {
- boolean ret = false;
- if (webDriver.findElements(By.id("map2")).isEmpty()) {
- log.error("Don't processUpgradeMainBuilding");
- return false;
- }
- final WebElement map2 = webDriver.findElement(By.id("map2"));
- final List<WebElement> map2AreaList = map2.findElements(By.tagName("area"));
- if ((map2AreaList != null) && (map2AreaList.size() > 0)) {
- boolean residenceExist = false;
- String href2Build = "";
- for (WebElement element : map2AreaList) {
- String title = null;
- try {
- title = element.getAttribute("title");
- } catch (Exception e) {
- log.debug("[ERROR] processUpgradeConstruction - CurrentUrl:" + webDriver.getCurrentUrl());
- log.debug(element.toString());
- e.printStackTrace();
- return false;
- }
- String href = element.getAttribute("href");
- // System.out.println("Map Constructions: " + title + " - " + href);
- if (title.equals("Empty place")) {
- href2Build = href;
- }
- int index = title.indexOf("level");
- if (index > 0) {
- String n = title.substring(0, index - 1);
- if (n.equals("Residence")) {
- residenceExist = true;
- href2Build = href;
- break;
- }
- }
- }
- if (!residenceExist && !href2Build.isEmpty()) { // not exist
- webDriver.navigate().to(href2Build);
- if (!webDriver.findElements(By.id("build")).isEmpty()) {
- WebElement divBuild = webDriver.findElement(By.id("build"));
- List<WebElement> h2WebElement = divBuild.findElements(By.tagName("h2"));
- List<WebElement> newBuildingWebElement = divBuild.findElements(By.className("new_building"));
- System.out.println("h2WebElement size: " + h2WebElement.size());
- System.out.println("newBuildingWebElement size: " + newBuildingWebElement.size());
- for (int i = 0; i < h2WebElement.size(); i++) {
- if (h2WebElement.get(i).getText().equals("Residence")) {
- if (!newBuildingWebElement.get(i).findElements(By.className("build")).isEmpty()) {
- newBuildingWebElement.get(i).findElement(By.className("build")).click();
- ret = true;
- break;
- }
- }
- }
- }
- }
- }
- return ret;
- }
- private static boolean processUpgradeConstruction(final String name, final int levelExpectation, final boolean recursive) {
- boolean ret = false;
- if (webDriver.findElements(By.id("map2")).isEmpty()) {
- log.error("Don't processUpgradeMainBuilding");
- return false;
- }
- final WebElement map2 = webDriver.findElement(By.id("map2"));
- final List<WebElement> map2AreaList = map2.findElements(By.tagName("area"));
- if ((map2AreaList != null) && (map2AreaList.size() > 0)) {
- for (WebElement element : map2AreaList) {
- String title = null;
- try {
- title = element.getAttribute("title");
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- String href = element.getAttribute("href");
- // System.out.println("Map Constructions: " + title + " - " + href);
- int index = title.indexOf("level");
- if (index > 0) {
- String n = title.substring(0, index - 1);
- int level = -1;
- try {
- level = Integer.valueOf(title.substring(index + 6, title.length()));
- } catch (Exception e) {
- System.out.println("ERROR:" + e.getMessage());
- e.printStackTrace();
- return false;
- }
- if ((level < levelExpectation) && n.equals(name)) {
- webDriver.navigate().to(href);
- if (checkConstructionBuilding(name)) {
- ret = true;
- break;
- }
- }
- }
- }
- }
- return ret;
- }
- private static void processCulturePoints() {
- processClickOne(false);
- final WebElement map2 = webDriver.findElement(By.id("map2"));
- final List<WebElement> map2AreaList = map2.findElements(By.tagName("area"));
- if ((map2AreaList != null) && (map2AreaList.size() > 0)) {
- for (WebElement element : map2AreaList) {
- String title = element.getAttribute("title");
- String href = element.getAttribute("href");
- // System.out.println("Map Constructions: " + title + " - " + href);
- int index = title.indexOf("level");
- if (index > 0) {
- String n = title.substring(0, index - 1);
- int level = -1;
- try {
- level = Integer.valueOf(title.substring(index + 6, title.length()));
- } catch (Exception e) {
- System.out.println("ERROR:" + e.getMessage());
- if (!n.equals("Town Hall")) {
- continue;
- }
- e.printStackTrace();
- break;
- }
- // Main Building
- if ((level == 20) && n.equals("Town Hall")) {
- webDriver.navigate().to(href);
- if (!webDriver.findElements(By.id("build")).isEmpty()) {
- WebElement divBuild = webDriver.findElement(By.id("build"));
- if (!divBuild.findElements(By.className("build")).isEmpty()) {
- List<WebElement> listLinkBuild = divBuild.findElements(By.className("build"));
- if ((listLinkBuild != null) && !listLinkBuild.isEmpty() && listLinkBuild.size() == 2) {
- WebElement linkBuild = listLinkBuild.get(1);
- // log.debug("href: " + linkBuild.getAttribute("href"));
- linkBuild.click();
- return;
- }
- }
- }
- return;
- }
- }
- }
- }
- }
- private static void waitForLoad(WebDriver driver) {
- ExpectedCondition<Boolean> pageLoadCondition = new ExpectedCondition<Boolean>() {
- public Boolean apply(WebDriver driver) {
- return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete");
- }
- };
- WebDriverWait wait = new WebDriverWait(driver, 30);
- wait.until(pageLoadCondition);
- }
- private static Map<Integer, VillageBuild> processConstruction2Map() {
- Map<Integer, VillageBuild> map = new HashMap<Integer, VillageBuild>();
- if (webDriver.findElements(By.id("map2")).isEmpty()) {
- log.error("Don't processUpgradeMainBuilding");
- return null;
- }
- final WebElement map2 = webDriver.findElement(By.id("map2"));
- final List<WebElement> map2AreaList = map2.findElements(By.tagName("area"));
- if ((map2AreaList != null) && (map2AreaList.size() > 0)) {
- int slot = 19;
- for (WebElement element : map2AreaList) {
- String title = null;
- try {
- title = element.getAttribute("title");
- } catch (Exception e) {
- e.printStackTrace();
- continue;
- }
- String href = element.getAttribute("href");
- // log.debug("Map Constructions: " + title + " - " + href);
- if ((title != null) && !title.equals("Empty place")) {
- int indexOfLevel = title.indexOf("level");
- if (indexOfLevel > 0) {
- String n = title.substring(0, indexOfLevel - 1);
- int level = -1;
- try {
- level = Integer.valueOf(title.substring(indexOfLevel + 6, title.length()));
- } catch (Exception e) {
- // System.out.println("ERROR:" + e.getMessage());
- // e.printStackTrace();
- }
- VillageBuild village = new VillageBuild();
- village.setSlot(slot);
- village.setLevel(level);
- village.setConstName(title);
- village.setHref(href);
- map.put(slot, village);
- }
- } else {
- VillageBuild village = new VillageBuild();
- village.setSlot(slot);
- village.setLevel(-1);
- village.setConstName(title);
- village.setHref(href);
- map.put(slot, village);
- }
- slot++;
- }
- }
- return map;
- }
- static class VillageBuild implements Serializable {
- /**
- * @return the href
- */
- public String getHref() {
- return href;
- }
- /**
- * @param href the href to set
- */
- public void setHref(String href) {
- this.href = href;
- }
- /**
- * @return the slot
- */
- public int getSlot() {
- return slot;
- }
- /**
- * @param slot the slot to set
- */
- public void setSlot(int slot) {
- this.slot = slot;
- }
- /**
- * @return the constName
- */
- public String getConstName() {
- return constName;
- }
- /**
- * @param constName the constName to set
- */
- public void setConstName(String constName) {
- this.constName = constName;
- }
- /**
- * @return the level
- */
- public int getLevel() {
- return level;
- }
- /**
- * @param level the level to set
- */
- public void setLevel(int level) {
- this.level = level;
- }
- private int slot;
- private String constName;
- private int level;
- private String href;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement