public class ChangeSet
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
ChangeSet.AttackChange
Encapsulate an attack.
|
private static class |
ChangeSet.AttributeChange
Encapsulate an attribute change.
|
private static class |
ChangeSet.Change
Abstract template for all types of Change.
|
static class |
ChangeSet.ChangePriority |
private static class |
ChangeSet.FeatureChange
Encapsulate a feature change.
|
private static class |
ChangeSet.MessageChange
Encapsulate a Message.
|
private static class |
ChangeSet.MoveChange
Encapsulate a move.
|
private static class |
ChangeSet.ObjectChange
Encapsulate a FreeColGameObject update.
|
private static class |
ChangeSet.OwnedChange
Encapsulate an owned object change.
|
private static class |
ChangeSet.PartialObjectChange
Encapsulate a partial update of a FreeColGameObject.
|
private static class |
ChangeSet.PlayerChange
Encapsulate a new player change.
|
private static class |
ChangeSet.RemoveChange
Encapsulates removing some objects.
|
static class |
ChangeSet.See
Class to control the visibility of a change.
|
private static class |
ChangeSet.SpyChange
Encapsulates a spying action.
|
private static class |
ChangeSet.StanceChange
Encapsulate a stance change.
|
private static class |
ChangeSet.TrivialChange
Encapsulate trivial element, which will only have attributes apart
from its name.
|
| Modifier and Type | Field and Description |
|---|---|
private static java.util.Comparator<ChangeSet.Change> |
changeComparator
Compare changes by ascending priority.
|
private java.util.ArrayList<ChangeSet.Change> |
changes |
| Constructor and Description |
|---|
ChangeSet()
Simple constructor.
|
ChangeSet(ChangeSet other)
Copying constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ChangeSet |
add(ChangeSet.See see,
ChangeSet.ChangePriority cp,
DOMMessage message)
Helper function to add a Message to a ChangeSet.
|
ChangeSet |
add(ChangeSet.See see,
java.util.Collection<? extends FreeColGameObject> objects)
Helper function to add updates for multiple objects to a ChangeSet.
|
ChangeSet |
add(ChangeSet.See see,
FreeColGameObject... objects)
Helper function to add updates for multiple objects to a ChangeSet.
|
ChangeSet |
addAttack(ChangeSet.See see,
Unit attacker,
Unit defender,
boolean success)
Helper function to add an attack to a ChangeSet.
|
ChangeSet |
addAttribute(ChangeSet.See see,
java.lang.String key,
java.lang.String value)
Helper function to add an attribute setting to a ChangeSet.
|
ChangeSet |
addDead(ServerPlayer serverPlayer)
Helper function to add a dead player event to a ChangeSet.
|
ChangeSet |
addDisappear(ServerPlayer owner,
Tile tile,
FreeColGameObject fcgo)
Helper function to add a removal for an object that disappears
(that is, moves where it can not be seen) to a ChangeSet.
|
ChangeSet |
addFather(ServerPlayer serverPlayer,
FoundingFather father)
Helper function to add a founding father addition event to a ChangeSet.
|
ChangeSet |
addFeatureChange(ServerPlayer serverPlayer,
FreeColGameObject object,
Ability ability,
boolean add)
Helper function to add an Ability to a FreeColGameObject, or remove it.
|
ChangeSet |
addFeatureChange(ServerPlayer serverPlayer,
FreeColGameObject object,
Modifier modifier,
boolean add)
Helper function to add a Modifier to a FreeColGameObject, or remove it.
|
ChangeSet |
addGlobalHistory(Game game,
HistoryEvent history)
Helper function to add a global history event to a ChangeSet.
|
ChangeSet |
addHistory(ServerPlayer serverPlayer,
HistoryEvent history)
Helper function to add a history event to a ChangeSet.
|
ChangeSet |
addMessage(ChangeSet.See see,
ModelMessage message)
Helper function to add a message to a ChangeSet.
|
ChangeSet |
addMove(ChangeSet.See see,
Unit unit,
Location loc,
Tile tile)
Helper function to add a move to a ChangeSet.
|
ChangeSet |
addPartial(ChangeSet.See see,
FreeColGameObject fcgo,
java.lang.String... fields)
Helper function to add a partial update change for an object to
a ChangeSet.
|
ChangeSet |
addPlayer(ServerPlayer serverPlayer)
Helper function to add a new player to a ChangeSet.
|
ChangeSet |
addRemove(ChangeSet.See see,
Location loc,
FreeColGameObject obj)
Helper function to add a removal to a ChangeSet.
|
ChangeSet |
addRemoves(ChangeSet.See see,
Location loc,
java.util.List<? extends FreeColGameObject> objects)
Helper function to add removals for several objects to a ChangeSet.
|
ChangeSet |
addSale(ServerPlayer serverPlayer,
Settlement settlement,
GoodsType type,
int price)
Helper function to add a sale change to a ChangeSet.
|
ChangeSet |
addSpy(ChangeSet.See see,
Settlement settlement)
Helper function to add a spying change to a ChangeSet.
|
ChangeSet |
addStance(ChangeSet.See see,
Player first,
Stance stance,
Player second)
Helper function to add a stance change to a ChangeSet.
|
ChangeSet |
addTradeRoute(ServerPlayer serverPlayer,
TradeRoute tradeRoute)
Helper function to add a new trade route change to a ChangeSet.
|
ChangeSet |
addTrivial(ChangeSet.See see,
java.lang.String name,
ChangeSet.ChangePriority cp,
java.lang.String... attributes)
Helper function to add a trivial element to a ChangeSet.
|
org.w3c.dom.Element |
build(ServerPlayer serverPlayer)
Build a generalized update.
|
private static boolean |
canSeeUnit(ServerPlayer serverPlayer,
Unit unit)
Checks if a player can see a unit.
|
private static java.util.List<org.w3c.dom.Element> |
collapseElementList(java.util.List<org.w3c.dom.Element> elements)
Collapse adjacent elements in a list with the same tag.
|
private static void |
collapseElements(org.w3c.dom.Element head,
org.w3c.dom.Element tail)
Collapse one element into another.
|
private static boolean |
collapseOK(org.w3c.dom.Element e1,
org.w3c.dom.Element e2)
Can two elements be collapsed?
They need to have the same name and attributes.
|
void |
remove(FreeColGameObject fcgo)
Sometimes we need to backtrack on making a change.
|
java.lang.String |
toString() |
private static final java.util.Comparator<ChangeSet.Change> changeComparator
private final java.util.ArrayList<ChangeSet.Change> changes
public ChangeSet()
public ChangeSet(ChangeSet other)
other - The other ChangeSet to copy.public void remove(FreeColGameObject fcgo)
fcgo - A FreeColGameObject to remove a matching
change for.public ChangeSet add(ChangeSet.See see, FreeColGameObject... objects)
see - The visibility of this change.objects - The FreeColGameObjects that changed.ChangeSet.public ChangeSet add(ChangeSet.See see, java.util.Collection<? extends FreeColGameObject> objects)
see - The visibility of this change.objects - The FreeColGameObjects that changed.ChangeSet.public ChangeSet add(ChangeSet.See see, ChangeSet.ChangePriority cp, DOMMessage message)
see - The visibility of this change.cp - The priority of this change.message - The Message to add.ChangeSet.public ChangeSet addAttack(ChangeSet.See see, Unit attacker, Unit defender, boolean success)
see - The visibility of this change.attacker - The Unit that is attacking.defender - The Unit that is defending.success - Did the attack succeed?ChangeSet.public ChangeSet addAttribute(ChangeSet.See see, java.lang.String key, java.lang.String value)
see - The visibility of this change.key - A key String.value - The corresponding value as a String.ChangeSet.public ChangeSet addDead(ServerPlayer serverPlayer)
serverPlayer - The ServerPlayer that died.ChangeSet.public ChangeSet addDisappear(ServerPlayer owner, Tile tile, FreeColGameObject fcgo)
owner - The ServerPlayer that owns this object.tile - The Tile where the object was.fcgo - The FreeColGameObject that disappears.ChangeSet.public ChangeSet addFather(ServerPlayer serverPlayer, FoundingFather father)
serverPlayer - The ServerPlayer adding the father.father - The FoundingFather to add.ChangeSet.public ChangeSet addFeatureChange(ServerPlayer serverPlayer, FreeColGameObject object, Ability ability, boolean add)
serverPlayer - a ServerPlayer valueobject - a FreeColGameObject valueability - an Ability valueadd - a boolean valueChangeSet valuepublic ChangeSet addFeatureChange(ServerPlayer serverPlayer, FreeColGameObject object, Modifier modifier, boolean add)
serverPlayer - a ServerPlayer valueobject - a FreeColGameObject valuemodifier - a Modifier valueadd - a boolean valueChangeSet valuepublic ChangeSet addGlobalHistory(Game game, HistoryEvent history)
game - The Game to find players in.history - The HistoryEvent to add.ChangeSet.public ChangeSet addHistory(ServerPlayer serverPlayer, HistoryEvent history)
serverPlayer - The ServerPlayer making history.history - The HistoryEvent to add.ChangeSet.public ChangeSet addMessage(ChangeSet.See see, ModelMessage message)
see - The visibility of this change.message - The ModelMessage to add.ChangeSet.public ChangeSet addMove(ChangeSet.See see, Unit unit, Location loc, Tile tile)
see - The visibility of this change.unit - The Unit that is moving.loc - The location from which the unit is moving.tile - The Tile to which the unit is moving.ChangeSet.public ChangeSet addPartial(ChangeSet.See see, FreeColGameObject fcgo, java.lang.String... fields)
see - The visibility of this change.fcgo - The FreeColGameObject to update.fields - The fields to update.ChangeSet.public ChangeSet addPlayer(ServerPlayer serverPlayer)
serverPlayer - The new ServerPlayer to add.ChangeSet.public ChangeSet addRemove(ChangeSet.See see, Location loc, FreeColGameObject obj)
see - The visibility of this change.loc - The Location where the object was.obj - The FreeColGameObject to remove.ChangeSet.public ChangeSet addRemoves(ChangeSet.See see, Location loc, java.util.List<? extends FreeColGameObject> objects)
see - The visibility of this change.loc - The Location where the object was.objects - A list of FreeColGameObjects to remove.ChangeSet.public ChangeSet addSale(ServerPlayer serverPlayer, Settlement settlement, GoodsType type, int price)
serverPlayer - The ServerPlayer making the sale.settlement - The Settlement that is buying.type - The GoodsType bought.price - The per unit price.ChangeSet.public ChangeSet addSpy(ChangeSet.See see, Settlement settlement)
see - The visibility of this change.settlement - The Settlement to spy on.ChangeSet.public ChangeSet addStance(ChangeSet.See see, Player first, Stance stance, Player second)
see - The visibility of this change.first - The Player changing stance.stance - The Stance to change to.second - The Player wrt with to change.ChangeSet.public ChangeSet addTradeRoute(ServerPlayer serverPlayer, TradeRoute tradeRoute)
serverPlayer - The ServerPlayer adding the route.tradeRoute - The new TradeRoute.ChangeSet.public ChangeSet addTrivial(ChangeSet.See see, java.lang.String name, ChangeSet.ChangePriority cp, java.lang.String... attributes)
see - The visibility of this change.name - The name of the element.cp - The ChangePriority for this change.attributes - Attributes to add to this trivial change.ChangeSet.private static boolean canSeeUnit(ServerPlayer serverPlayer, Unit unit)
serverPlayer - The ServerPlayer looking for the unit.unit - The Unit to check.Unit is visible to the player.private static void collapseElements(org.w3c.dom.Element head,
org.w3c.dom.Element tail)
head - The Element to collapse into.tail - The Element to extract nodes from.private static boolean collapseOK(org.w3c.dom.Element e1,
org.w3c.dom.Element e2)
e1 - The first Element.e2 - The second Element.private static java.util.List<org.w3c.dom.Element> collapseElementList(java.util.List<org.w3c.dom.Element> elements)
elements - The list of Elements to consider.public org.w3c.dom.Element build(ServerPlayer serverPlayer)
serverPlayer - The ServerPlayer to send the
update to.public java.lang.String toString()
toString in class java.lang.Object