Package org.freerealm.history

Examples of org.freerealm.history.PlayerHistory


        StringBuffer xml = new StringBuffer();
        xml.append("<history>\n");
        Iterator<Player> iterator = history.getPlayersIterator();
        while (iterator.hasNext()) {
            Player player = iterator.next();
            PlayerHistory playerHistory = history.getPlayerHistory(player);
            xml.append(new FreeRealmPlayerHistoryXMLConverter().toXML(playerHistory));
        }
        xml.append("</history>\n");
        return xml.toString();
    }
View Full Code Here


    public History initializeFromNode(Realm realm, Node node) {
        FreeRealmHistory freeRealmHistory = new FreeRealmHistory();
        for (Node playerHistoryNode = node.getFirstChild(); playerHistoryNode != null; playerHistoryNode = playerHistoryNode.getNextSibling()) {
            if (playerHistoryNode.getNodeType() == Node.ELEMENT_NODE) {
                PlayerHistory playerHistory = new FreeRealmPlayerHistoryXMLConverter().initializeFromNode(realm, playerHistoryNode);
                freeRealmHistory.addPlayerHistory(playerHistory.getPlayer(), playerHistory);
            }
        }
        return freeRealmHistory;
    }
View Full Code Here

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

    public PlayerHistory initializeFromNode(Realm realm, Node node) {
        PlayerHistory playerHistory = new FreeRealmPlayerHistory();
        Node playerIdNode = XMLConverterUtility.findNode(node, "playerId");
        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

        return new CommandResult(CommandResult.RESULT_OK, "", CommandResult.TURN_ENDED_UPDATE);
    }

    private void managePlayerHistory(Player player) {
        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());
View Full Code Here

TOP

Related Classes of org.freerealm.history.PlayerHistory

Copyright © 2018 www.massapicom. 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.