Ejemplo n.º 1
0
 /**
  * Initialize the alarm at this settlement with respect to a player with the current national
  * tension.
  *
  * @param player The <code>Player</code> to set the alarm level for.
  */
 protected void initializeAlarm(Player player) {
   Tension tension = owner.getTension(player);
   setAlarm(player, new Tension(tension.getValue()));
 }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  protected void writeChildren(FreeColXMLWriter xw) throws XMLStreamException {
    super.writeChildren(xw);

    if (missionary != null) {
      xw.writeStartElement(MISSIONARY_TAG);

      missionary.toXML(xw);

      xw.writeEndElement();
    }

    if (xw.validFor(getOwner())) {

      for (Player p : getSortedCopy(contactLevels.keySet())) {
        xw.writeStartElement(CONTACT_LEVEL_TAG);

        xw.writeAttribute(LEVEL_TAG, contactLevels.get(p));

        xw.writeAttribute(PLAYER_TAG, p);

        xw.writeEndElement();
      }

      for (Player p : getSortedCopy(alarm.keySet())) {
        xw.writeStartElement(ALARM_TAG);

        xw.writeAttribute(PLAYER_TAG, p);

        xw.writeAttribute(VALUE_TAG, alarm.get(p).getValue());

        xw.writeEndElement();
      }

      for (Unit unit : getSortedCopy(ownedUnits)) {
        xw.writeStartElement(OWNED_UNITS_TAG);

        xw.writeAttribute(ID_ATTRIBUTE_TAG, unit);

        xw.writeEndElement();
      }

    } else {
      Player client = xw.getClientPlayer();

      ContactLevel cl = contactLevels.get(client);
      if (cl != null) {
        xw.writeStartElement(CONTACT_LEVEL_TAG);

        xw.writeAttribute(LEVEL_TAG, cl);

        xw.writeAttribute(PLAYER_TAG, client);

        xw.writeEndElement();
      }

      Tension alarm = getAlarm(client);
      if (alarm != null) {
        xw.writeStartElement(ALARM_TAG);

        xw.writeAttribute(PLAYER_TAG, client);

        xw.writeAttribute(VALUE_TAG, alarm.getValue());

        xw.writeEndElement();
      }
    }
  }