Examples of PlayerTurnHistory


Examples of org.freerealm.history.PlayerTurnHistory

        xml.append("</playerTurnHistory>\n");
        return xml.toString();
    }

    public PlayerTurnHistory initializeFromNode(Realm realm, Node node) {
        PlayerTurnHistory playerTurnHistory = new FreeRealmPlayerTurnHistory();

        Node turnNode = XMLConverterUtility.findNode(node, "turn");
        int turn = Integer.parseInt(turnNode.getFirstChild().getNodeValue());
        playerTurnHistory.setTurn(turn);

        Node populationNode = XMLConverterUtility.findNode(node, "population");
        int population = Integer.parseInt(populationNode.getFirstChild().getNodeValue());
        playerTurnHistory.setPopulation(population);

        Node wealthNode = XMLConverterUtility.findNode(node, "wealth");
        int wealth = Integer.parseInt(wealthNode.getFirstChild().getNodeValue());
        playerTurnHistory.setWealth(wealth);

        Node settlementCountNode = XMLConverterUtility.findNode(node, "settlementCount");
        int settlementCount = Integer.parseInt(settlementCountNode.getFirstChild().getNodeValue());
        playerTurnHistory.setSettlementCount(settlementCount);

        Node unitCountNode = XMLConverterUtility.findNode(node, "unitCount");
        int unitCount = Integer.parseInt(unitCountNode.getFirstChild().getNodeValue());
        playerTurnHistory.setUnitCount(unitCount);

        Node mapExplorationPercentNode = XMLConverterUtility.findNode(node, "mapExplorationPercent");
        int mapExplorationPercent = Integer.parseInt(mapExplorationPercentNode.getFirstChild().getNodeValue());
        playerTurnHistory.setMapExplorationPercent(mapExplorationPercent);

        return playerTurnHistory;

    }
View Full Code Here

Examples of org.freerealm.history.PlayerTurnHistory

        xml.append("<playerHistory>\n");
        xml.append("<playerId>" + playerHistory.getPlayer().getId() + "</playerId>\n");
        xml.append("<playerHistoryTurns>\n");
        Iterator<PlayerTurnHistory> playerTurnHistoryIterator = playerHistory.getPlayerTurnHistoryIterator();
        while (playerTurnHistoryIterator.hasNext()) {
            PlayerTurnHistory playerTurnHistory = playerTurnHistoryIterator.next();
            xml.append(new FreeRealmPlayerTurnHistoryXMLConverter().toXML(playerTurnHistory));
        }
        xml.append("</playerHistoryTurns>\n");
        xml.append("</playerHistory>\n");
        return xml.toString();
View Full Code Here

Examples of org.freerealm.history.PlayerTurnHistory

        int playerId = Integer.parseInt(playerIdNode.getFirstChild().getNodeValue());
        playerHistory.setPlayer(realm.getPlayerManager().getPlayer(playerId));
        Node playerHistoryTurnsNode = XMLConverterUtility.findNode(node, "playerHistoryTurns");
        for (Node playerTurnHistoryNode = playerHistoryTurnsNode.getFirstChild(); playerTurnHistoryNode != null; playerTurnHistoryNode = playerTurnHistoryNode.getNextSibling()) {
            if (playerTurnHistoryNode.getNodeType() == Node.ELEMENT_NODE) {
                PlayerTurnHistory playerTurnHistory = new FreeRealmPlayerTurnHistoryXMLConverter().initializeFromNode(realm, playerTurnHistoryNode);
                playerHistory.addTurnHistory(playerTurnHistory);
            }
        }
        return playerHistory;
    }
View Full Code Here

Examples of org.freerealm.history.PlayerTurnHistory

        if (realm.getHistory().getPlayerHistory(player) == null) {
            PlayerHistory playerHistory = new FreeRealmPlayerHistory();
            playerHistory.setPlayer(player);
            realm.getHistory().addPlayerHistory(player, playerHistory);
        }
        PlayerTurnHistory playerTurnHistory = new FreeRealmPlayerTurnHistory();
        playerTurnHistory.setTurn(realm.getNumberOfTurns());
        playerTurnHistory.setPopulation(player.getPopulation());
        playerTurnHistory.setWealth(player.getWealth());
        playerTurnHistory.setSettlementCount(player.getSettlementCount());
        playerTurnHistory.setUnitCount(player.getUnitCount());
        playerTurnHistory.setMapExplorationPercent(player.getMapExplorationPercent());
        realm.getHistory().addPlayerTurnHistory(player, playerTurnHistory);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.