Package org.freerealm.player

Examples of org.freerealm.player.DefaultMessage


        xml.append("</missions>\n");
        xml.append("<messages>\n");
        Iterator<Message> messagesIterator = player.getMessagesIterator();
        while (messagesIterator.hasNext()) {
            Message message = messagesIterator.next();
            DefaultMessage defaultMessage = (DefaultMessage) message;
            xml.append(new MessageXMLConverter().toXML(defaultMessage));
        }
        xml.append("</messages>\n");
        return xml.toString();
    }
View Full Code Here


                    }
                } else if (subNode.getNodeName().equals("messages")) {
                    player.clearMessages();
                    for (Node messageNode = subNode.getFirstChild(); messageNode != null; messageNode = messageNode.getNextSibling()) {
                        if (messageNode.getNodeType() == Node.ELEMENT_NODE) {
                            DefaultMessage message = (new MessageXMLConverter()).initializeFromNode(realm, messageNode);
                            player.addMessage(message);
                        }
                    }
                }
            }
View Full Code Here

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

    public DefaultMessage initializeFromNode(Realm realm, Node node) {
        DefaultMessage message = new DefaultMessage();
        for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("text")) {
                    StringBuffer textValue = new StringBuffer(subNode.getFirstChild().getNodeValue());
                    message.setText(textValue);
                } else if (subNode.getNodeName().equals("read")) {
                    Boolean isReadValue = new Boolean(subNode.getFirstChild().getNodeValue());
                    message.setRead(isReadValue);
                } else if (subNode.getNodeName().equals("turnSent")) {
                    int turnSentValue = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    message.setTurnSent(turnSentValue);
                }
            }
        }
        return message;
    }
View Full Code Here

                } else if (currentProduction instanceof UnitType) {
                    if (((UnitType) currentProduction).getAbility("BuildCity") != null) {
                        int cityFoundingPopulation = Integer.parseInt(realm.getProperty("city_founding_population"));
                        if (settlement.getPopulation() < cityFoundingPopulation) {
                            StringBuffer messageText = new StringBuffer("Not enough population for unit");
                            DefaultMessage message = new DefaultMessage();
                            message.setText(messageText);
                            message.setTurnSent(realm.getNumberOfTurns());
                            settlement.getPlayer().addMessage(message);
                            return;
                        }
                        settlement.setPopulation(settlement.getPopulation() - cityFoundingPopulation);
                    }
View Full Code Here

TOP

Related Classes of org.freerealm.player.DefaultMessage

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.