Class InGameController


  • public final class InGameController
    extends Controller
    The main server controller.
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • coronadoPred

        private static final java.util.function.Predicate<Player> coronadoPred
      • random

        private java.util.Random random
        The server random number source.
      • debugOnlyAITurns

        private int debugOnlyAITurns
        Debug helpers, do not serialize.
      • debugMonarchPlayer

        private ServerPlayer debugMonarchPlayer
    • Constructor Detail

      • InGameController

        public InGameController​(FreeColServer freeColServer)
        The constructor to use.
        Parameters:
        freeColServer - The main server object.
    • Method Detail

      • setRandom

        public void setRandom​(java.util.Random random)
        Set the PRNG.
        Parameters:
        random - The new Random to use in this controller.
      • getTimeout

        private long getTimeout()
        Get the timeout for this game.
        Returns:
        A timeout.
      • getSkippedTurns

        public int getSkippedTurns()
        Gets the number of AI turns to skip through.
        Returns:
        The number of terms to skip.
      • setSkippedTurns

        public void setSkippedTurns​(int turns)
        Sets the number of AI turns to skip through as a debug helper.
        Parameters:
        turns - The number of turns to skip through.
      • setMonarchAction

        public void setMonarchAction​(ServerPlayer serverPlayer,
                                     Monarch.MonarchAction action)
        Sets a monarch action to debug/test.
        Parameters:
        serverPlayer - The ServerPlayer whose monarch should act.
        action - The MonarchAction to be taken.
      • stepRandom

        public int stepRandom()
        Debug convenience to step the random number generator.
        Returns:
        The next random number in series, in the range 0-99.
      • addFoundingFather

        public void addFoundingFather​(Player player,
                                      FoundingFather father)
        Public version of csAddFoundingFather so it can be used in the test code and DebugMenu.
        Parameters:
        player - The Player who gains a father.
        father - The FoundingFather to add.
      • changeStance

        public void changeStance​(Player player,
                                 Stance stance,
                                 Player other,
                                 boolean symmetric)
        Public change stance and inform all routine. Mostly used in the test suite, but the AIs also call it.
        Parameters:
        player - The originating Player.
        stance - The new Stance.
        other - The Player wrt which the stance changes.
        symmetric - If true, change the otherPlayer stance as well.
      • debugChangeOwner

        public void debugChangeOwner​(ServerColony colony,
                                     ServerPlayer serverPlayer)
        Change colony owner. Public for DebugUtils.
        Parameters:
        colony - The ServerColony to change.
        serverPlayer - The ServerPlayer to change to.
      • debugChangeOwner

        public void debugChangeOwner​(ServerUnit unit,
                                     ServerPlayer serverPlayer)
        Change unit owner. Public for DebugUtils.
        Parameters:
        unit - The ServerUnit to change.
        serverPlayer - The ServerPlayer to change to.
      • debugApplyDisaster

        public int debugApplyDisaster​(ServerColony colony,
                                      Disaster disaster)
        Apply a disaster to a colony. Public for DebugUtils.
        Parameters:
        colony - The Colony to apply the disaster to.
        disaster - The Disaster to apply.
        Returns:
        The number of messages generated.
      • createREFPlayer

        public ServerPlayer createREFPlayer​(ServerPlayer serverPlayer)
        Create the Royal Expeditionary Force player corresponding to a given player that is about to rebel. Public for the test suite. FIXME: this should eventually generate changes for the REF player.
        Parameters:
        serverPlayer - The ServerPlayer about to rebel.
        Returns:
        The REF player.
      • csBuy

        private void csBuy​(ServerUnit unit,
                           Goods goods,
                           int price,
                           ServerIndianSettlement sis,
                           ChangeSet cs)
        Buy goods from a native settlement.
        Parameters:
        unit - The Unit that is buying.
        goods - The Goods to buy.
        price - The price to pay.
        sis - The ServerIndianSettlement to give to.
        cs - A ChangeSet to update.
      • csSell

        private void csSell​(ServerUnit unit,
                            Goods goods,
                            int price,
                            ServerIndianSettlement sis,
                            ChangeSet cs)
        Sell goods to a native settlement.
        Parameters:
        unit - The Unit that is selling.
        goods - The Goods to sell.
        price - The price to charge.
        sis - The ServerIndianSettlement to sell to.
        cs - A ChangeSet to update.
      • csGift

        private void csGift​(ServerUnit unit,
                            Goods goods,
                            int price,
                            ServerIndianSettlement sis,
                            ChangeSet cs)
        Give goods to a native settlement.
        Parameters:
        unit - The Unit that is giving.
        goods - The Goods to give.
        price - A price that the natives might have been willing to pay.
        sis - The ServerIndianSettlement to give to.
        cs - A ChangeSet to update.
      • csLaunchREF

        private void csLaunchREF​(ServerPlayer serverPlayer,
                                 boolean teleport,
                                 ChangeSet cs)
        Launch the REF.
        Parameters:
        serverPlayer - The REF ServerPlayer.
        teleport - If true, teleport the REF in.
        cs - A ChangeSet to update.
      • csGiveIndependence

        private void csGiveIndependence​(ServerPlayer serverPlayer,
                                        Player independent,
                                        ChangeSet cs)
        Give independence. Note that the REF player is granting, but most of the changes happen to the newly independent player. hence the special handling.
        Parameters:
        serverPlayer - The REF ServerPlayer that is granting.
        independent - The newly independent Player.
        cs - A ChangeSet to update.
      • unitTemplate

        private StringTemplate unitTemplate​(java.lang.String base,
                                            java.util.List<Unit> units)
      • csMonarchAction

        private void csMonarchAction​(ServerPlayer serverPlayer,
                                     Monarch.MonarchAction action,
                                     ChangeSet cs)
        Performs a monarch action. Note that CHANGE_LATE is used so that these actions follow setting the current player, so that it is the players turn when they respond to a monarch action.
        Parameters:
        serverPlayer - The ServerPlayer being acted upon.
        action - The monarch action.
        cs - A ChangeSet to update.
      • abandonSettlement

        public ChangeSet abandonSettlement​(ServerPlayer serverPlayer,
                                           Settlement settlement)
        Abandon a settlement.
        Parameters:
        serverPlayer - The ServerPlayer that is abandoning.
        settlement - The Settlement to abandon.
        Returns:
        A ChangeSet encapsulating this action.
      • askLearnSkill

        public ChangeSet askLearnSkill​(ServerPlayer serverPlayer,
                                       ServerUnit unit,
                                       IndianSettlement is)
        Ask about learning a skill at a native settlement.
        Parameters:
        serverPlayer - The ServerPlayer that is learning.
        unit - The Unit that is learning.
        is - The IndianSettlement to learn from.
        Returns:
        A ChangeSet encapsulating this action.
      • assignTeacher

        public ChangeSet assignTeacher​(ServerPlayer serverPlayer,
                                       Unit student,
                                       Unit teacher)
        Assign a student to a teacher.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        student - The student Unit.
        teacher - The teacher Unit.
        Returns:
        A ChangeSet encapsulating this action.
      • assignTradeRoute

        public ChangeSet assignTradeRoute​(ServerPlayer serverPlayer,
                                          Unit unit,
                                          TradeRoute tradeRoute)
        Assign a trade route to a unit.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The unit Unit to assign to.
        tradeRoute - The TradeRoute to assign.
        Returns:
        A ChangeSet encapsulating this action.
      • buildSettlement

        public ChangeSet buildSettlement​(ServerPlayer serverPlayer,
                                         Unit unit,
                                         java.lang.String name)
        Build a settlement. +til: Resolves many tile appearance changes.
        Parameters:
        serverPlayer - The ServerPlayer that is building.
        unit - The Unit that is building.
        name - The new settlement name.
        Returns:
        A ChangeSet encapsulating this action.
      • buyGoods

        private ChangeSet buyGoods​(ServerPlayer serverPlayer,
                                   GoodsType type,
                                   int amount,
                                   Unit carrier)
        Buy goods in Europe.
        Parameters:
        serverPlayer - The ServerPlayer that is buying.
        type - The GoodsType to buy.
        amount - The amount of goods to buy.
        carrier - The Unit to carry the goods.
        Returns:
        A ChangeSet encapsulating this action.
      • cashInTreasureTrain

        public ChangeSet cashInTreasureTrain​(ServerPlayer serverPlayer,
                                             Unit unit)
        Cash in a treasure train.
        Parameters:
        serverPlayer - The ServerPlayer that is cashing in.
        unit - The treasure train Unit to cash in.
        Returns:
        A ChangeSet encapsulating this action.
      • changeState

        public ChangeSet changeState​(ServerPlayer serverPlayer,
                                     Unit unit,
                                     Unit.UnitState state)
        Change a units state.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to change the state of.
        state - The new UnitState.
        Returns:
        A ChangeSet encapsulating this action.
      • changeWorkImprovementType

        public ChangeSet changeWorkImprovementType​(ServerPlayer serverPlayer,
                                                   Unit unit,
                                                   TileImprovementType type)
        Change improvement work type.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to change the work type of.
        type - The new TileImprovementType to produce.
        Returns:
        A ChangeSet encapsulating this action.
      • changeWorkType

        public ChangeSet changeWorkType​(ServerPlayer serverPlayer,
                                        Unit unit,
                                        GoodsType type)
        Change work type.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to change the work type of.
        type - The new GoodsType to produce.
        Returns:
        A ChangeSet encapsulating this action.
      • chat

        public ChangeSet chat​(ServerPlayer serverPlayer,
                              java.lang.String message,
                              boolean pri)
        Chat.
        Parameters:
        serverPlayer - The ServerPlayer that is chatting.
        message - The chat message.
        pri - A privacy setting, currently a noop.
        Returns:
        A ChangeSet encapsulating this action.
      • chooseFoundingFather

        public ChangeSet chooseFoundingFather​(ServerPlayer serverPlayer,
                                              FoundingFather ff)
        Choose a founding father.
        Parameters:
        serverPlayer - The ServerPlayer that is choosing.
        ff - A FoundingFather to select.
        Returns:
        A ChangeSet encapsulating this action.
      • claimLand

        public ChangeSet claimLand​(ServerPlayer serverPlayer,
                                   Tile tile,
                                   Settlement settlement,
                                   int price)
        Claim land.
        Parameters:
        serverPlayer - The ServerPlayer claiming.
        tile - The Tile to claim.
        settlement - The Settlement to claim for.
        price - The price to pay for the land, which must agree with the owner valuation, unless negative which denotes stealing.
        Returns:
        A ChangeSet encapsulating this action.
      • clearSpeciality

        public ChangeSet clearSpeciality​(ServerPlayer serverPlayer,
                                         Unit unit)
        Clear the specialty of a unit. FIXME: why not clear speciality in the open? You can disband! If we implement this remember to fix the visibility.
        Parameters:
        serverPlayer - The owner of the unit.
        unit - The Unit to clear the speciality of.
        Returns:
        A ChangeSet encapsulating this action.
      • combat

        public ChangeSet combat​(ServerPlayer attackerPlayer,
                                FreeColGameObject attacker,
                                FreeColGameObject defender,
                                java.util.List<CombatModel.CombatResult> crs)
        Combat. Public for the test suite.
        Parameters:
        attackerPlayer - The ServerPlayer who is attacking.
        attacker - The FreeColGameObject that is attacking.
        defender - The FreeColGameObject that is defending.
        crs - A list of CombatResults defining the result.
        Returns:
        A ChangeSet encapsulating this action.
      • continuePlaying

        public ChangeSet continuePlaying​(ServerPlayer serverPlayer)
        Continue playing after winning.
        Parameters:
        serverPlayer - The ServerPlayer that plays on.
        Returns:
        Null.
      • declareIndependence

        public ChangeSet declareIndependence​(ServerPlayer serverPlayer,
                                             java.lang.String nationName,
                                             java.lang.String countryName)
        Declare independence.
        Parameters:
        serverPlayer - The ServerPlayer that is declaring.
        nationName - The new name for the independent nation.
        countryName - The new name for its residents.
        Returns:
        A ChangeSet containing the response.
      • declineMounds

        public ChangeSet declineMounds​(ServerPlayer serverPlayer,
                                       Tile tile)
        Decline to investigate strange mounds.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        tile - The Tile where the mounds are.
        Returns:
        A ChangeSet encapsulating this action.
      • deleteTradeRoute

        public ChangeSet deleteTradeRoute​(ServerPlayer serverPlayer,
                                          TradeRoute tradeRoute)
        Delete a trade route.
        Parameters:
        serverPlayer - The ServerPlayer to delete a trade route for.
        tradeRoute - The TradeRoute to delete.
        Returns:
        A ChangeSet encapsulating this action.
      • deliverGiftToSettlement

        public ChangeSet deliverGiftToSettlement​(ServerPlayer serverPlayer,
                                                 ServerUnit unit,
                                                 Settlement settlement,
                                                 Goods goods)
        Deliver gift to settlement. Note that this includes both European and native gifts.
        Parameters:
        serverPlayer - The ServerPlayer that is delivering.
        unit - The Unit that is delivering.
        settlement - The Settlement to deliver to.
        goods - The Goods to deliver.
        Returns:
        A ChangeSet encapsulating this action.
      • demandTribute

        public ChangeSet demandTribute​(ServerPlayer serverPlayer,
                                       ServerUnit unit,
                                       IndianSettlement is)
        Demand a tribute from a native settlement. FIXME: Move TURNS_PER_TRIBUTE magic number to the spec.
        Parameters:
        serverPlayer - The ServerPlayer demanding the tribute.
        unit - The Unit that is demanding the tribute.
        is - The IndianSettlement demanded of.
        Returns:
        A ChangeSet encapsulating this action.
      • denounceMission

        public ChangeSet denounceMission​(ServerPlayer serverPlayer,
                                         ServerUnit sUnit,
                                         IndianSettlement is)
        Denounce an existing mission.
        Parameters:
        serverPlayer - The ServerPlayer that is denouncing.
        sUnit - The ServerUnit denouncing.
        is - The IndianSettlement containing the mission to denounce.
        Returns:
        A ChangeSet encapsulating this action.
      • diplomacy

        public ChangeSet diplomacy​(ServerPlayer serverPlayer,
                                   Unit ourUnit,
                                   Colony otherColony,
                                   DiplomaticTrade agreement)
        Diplomacy.
        Parameters:
        serverPlayer - The ServerPlayer that is trading.
        ourUnit - The Unit that is trading.
        otherColony - The Colony to trade with.
        agreement - The DiplomaticTrade to consider.
        Returns:
        A ChangeSet encapsulating this action.
      • diplomacy

        public ChangeSet diplomacy​(ServerPlayer serverPlayer,
                                   Colony ourColony,
                                   Unit otherUnit,
                                   DiplomaticTrade agreement)
        Diplomacy.
        Parameters:
        serverPlayer - The ServerPlayer that is trading.
        ourColony - Our Colony.
        otherUnit - The other Unit that is trading.
        agreement - The DiplomaticTrade to consider.
        Returns:
        A ChangeSet encapsulating this action.
      • disbandUnit

        public ChangeSet disbandUnit​(ServerPlayer serverPlayer,
                                     Unit unit)
        Disband a unit.
        Parameters:
        serverPlayer - The owner of the unit.
        unit - The Unit to disband.
        Returns:
        A ChangeSet encapsulating this action.
      • disconnect

        public ChangeSet disconnect​(ServerPlayer serverPlayer)
        Disconnect the client.
        Parameters:
        serverPlayer - The ServerPlayer to disconnect.
        Returns:
        Null, we never reply to a disconnect.
      • disembarkUnit

        public ChangeSet disembarkUnit​(ServerPlayer serverPlayer,
                                       ServerUnit serverUnit)
        Disembark unit from a carrier.
        Parameters:
        serverPlayer - The ServerPlayer whose unit is embarking.
        serverUnit - The ServerUnit that is disembarking.
        Returns:
        A ChangeSet encapsulating this action.
      • embarkUnit

        public ChangeSet embarkUnit​(ServerPlayer serverPlayer,
                                    ServerUnit serverUnit,
                                    Unit carrier)
        Embark a unit onto a carrier. Checking that the locations are appropriate is not done here.
        Parameters:
        serverPlayer - The ServerPlayer embarking.
        serverUnit - The ServerUnit that is embarking.
        carrier - The Unit to embark onto.
        Returns:
        A ChangeSet encapsulating this action.
      • emigrate

        public ChangeSet emigrate​(ServerPlayer serverPlayer,
                                  int slot,
                                  Europe.MigrationType type)
        A unit migrates from Europe.
        Parameters:
        serverPlayer - The ServerPlayer whose unit it will be.
        slot - The slot within Europe to select the unit from.
        type - The type of migration occurring.
        Returns:
        A ChangeSet encapsulating this action.
      • endTurn

        public ChangeSet endTurn​(ServerPlayer serverPlayer)
        Ends the turn of the given player. Note: sends messages to other players.
        Parameters:
        serverPlayer - The ServerPlayer to end the turn of.
        Returns:
        A ChangeSet encapsulating the end of turn changes.
      • enterRevengeMode

        public ChangeSet enterRevengeMode​(ServerPlayer serverPlayer)
        Enters revenge mode against those evil AIs.
        Parameters:
        serverPlayer - The ServerPlayer entering revenge mode.
        Returns:
        A ChangeSet encapsulating this action.
      • equipForRole

        public ChangeSet equipForRole​(ServerPlayer serverPlayer,
                                      Unit unit,
                                      Role role,
                                      int roleCount)
        Equip a unit for a specific role. Currently the unit is either in Europe or in a settlement. Might one day allow the unit to be on a tile co-located with an equipment-bearing wagon.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to equip.
        role - The Role to equip for.
        roleCount - The role count.
        Returns:
        A ChangeSet encapsulating this action.
      • establishMission

        public ChangeSet establishMission​(ServerPlayer serverPlayer,
                                          ServerUnit sUnit,
                                          IndianSettlement is)
        Establish a new mission.
        Parameters:
        serverPlayer - The ServerPlayer that is establishing.
        sUnit - The missionary ServerUnit.
        is - The IndianSettlement to establish at.
        Returns:
        A ChangeSet encapsulating this action.
      • europeanFirstContact

        public ChangeSet europeanFirstContact​(ServerPlayer serverPlayer,
                                              Unit ourUnit,
                                              Colony ourColony,
                                              Unit otherUnit,
                                              Colony otherColony,
                                              DiplomaticTrade agreement)
        Handle first contact between European players.
        Parameters:
        serverPlayer - The ServerPlayer making contact.
        ourUnit - The Unit making contact (may be null).
        ourColony - The Colony making contact (may be null).
        otherUnit - The other Unit making contact (may be null).
        otherColony - The other Colony making contact (may be null).
        agreement - The DiplomaticTrade to consider.
        Returns:
        A ChangeSet encapsulating this action.
      • gameState

        public ChangeSet gameState()
        Get the game state.
        Returns:
        A ChangeSet encapsulating this action.
      • getHighScores

        public ChangeSet getHighScores​(ServerPlayer serverPlayer,
                                       java.lang.String key)
        Gets the list of high scores.
        Parameters:
        serverPlayer - The ServerPlayer querying the scores.
        key - A score category key.
        Returns:
        A ChangeSet encapsulating this action.
      • incite

        public ChangeSet incite​(ServerPlayer serverPlayer,
                                ServerUnit unit,
                                IndianSettlement is,
                                Player enemy,
                                int gold)
        Incite a settlement against an enemy.
        Parameters:
        serverPlayer - The ServerPlayer that is inciting.
        unit - The missionary Unit inciting.
        is - The IndianSettlement to incite.
        enemy - The Player to be incited against.
        gold - The amount of gold in the bribe.
        Returns:
        A ChangeSet encapsulating this action.
      • indianDemand

        public ChangeSet indianDemand​(ServerPlayer serverPlayer,
                                      Unit unit,
                                      Colony colony,
                                      GoodsType type,
                                      int amount,
                                      Constants.IndianDemandAction result)
        Indians making demands of a colony.
        Parameters:
        serverPlayer - The ServerPlayer that sent the message.
        unit - The Unit making the demands.
        colony - The Colony that is demanded of.
        type - The GoodsType being demanded, null implies gold.
        amount - The amount of goods/gold being demanded.
        result - The demand result (null initially).
        Returns:
        A ChangeSet encapsulating this action.
      • joinColony

        public ChangeSet joinColony​(ServerPlayer serverPlayer,
                                    Unit unit,
                                    Colony colony)
        Join a colony.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit that is joining.
        colony - The Colony to join.
        Returns:
        A ChangeSet encapsulating this action.
      • learnFromIndianSettlement

        public ChangeSet learnFromIndianSettlement​(ServerPlayer serverPlayer,
                                                   ServerUnit sUnit,
                                                   IndianSettlement is)
        Learn a skill at an IndianSettlement.
        Parameters:
        serverPlayer - The ServerPlayer that is learning.
        sUnit - The ServerUnit that is learning.
        is - The IndianSettlement to learn from.
        Returns:
        A ChangeSet encapsulating this action.
      • loadGoods

        public ChangeSet loadGoods​(ServerPlayer serverPlayer,
                                   Location loc,
                                   GoodsType goodsType,
                                   int amount,
                                   Unit carrier)
        Load goods.
        Parameters:
        serverPlayer - The ServerPlayer that is loading.
        loc - The Location where the goods are.
        goodsType - The GoodsType to load.
        amount - The amount of goods to load.
        carrier - The Unit to load.
        Returns:
        A ChangeSet encapsulating this action.
      • lootCargo

        public ChangeSet lootCargo​(ServerPlayer serverPlayer,
                                   Unit winner,
                                   java.lang.String loserId,
                                   java.util.List<Goods> loot)
        Loot cargo. Note loser is passed by identifier, as by the time we get here the unit may have been sunk.
        Parameters:
        serverPlayer - The ServerPlayer that owns the winner.
        winner - The Unit that looting.
        loserId - The object identifier of the Unit that is looted.
        loot - The Goods to loot.
        Returns:
        A ChangeSet encapsulating this action.
      • monarchAction

        public ChangeSet monarchAction​(ServerPlayer serverPlayer,
                                       Monarch.MonarchAction action,
                                       boolean result)
        Respond to a monarch action.
        Parameters:
        serverPlayer - The ServerPlayer that is to respond.
        action - The MonarchAction to respond to.
        result - The player response.
        Returns:
        A ChangeSet containing the response.
      • move

        public ChangeSet move​(ServerPlayer serverPlayer,
                              ServerUnit unit,
                              Tile newTile)
        Move a unit.
        Parameters:
        serverPlayer - The ServerPlayer that is moving.
        unit - The ServerUnit to move.
        newTile - The Tile to move to.
        Returns:
        A ChangeSet encapsulating this action.
      • moveTo

        public ChangeSet moveTo​(ServerPlayer serverPlayer,
                                Unit unit,
                                Location destination)
        Move a unit across the high seas.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to move.
        destination - The Location to move to.
        Returns:
        A ChangeSet encapsulating this action.
      • nationSummary

        public ChangeSet nationSummary​(ServerPlayer serverPlayer,
                                       Player player)
        Get a nation summary.
        Parameters:
        serverPlayer - The ServerPlayer to make the summary for.
        player - The Player to summarize.
        Returns:
        A ChangeSet encapsulating this action.
      • nativeFirstContact

        public ChangeSet nativeFirstContact​(ServerPlayer serverPlayer,
                                            Player other,
                                            Tile tile,
                                            boolean result)
        Handle first contact between European and native player. Note that we check for a diplomacy session, but only bother in the case of tile!=null as that is the only possibility for some benefit.
        Parameters:
        serverPlayer - The ServerPlayer making contact.
        other - The native Player to contact.
        tile - A Tile on offer at first landing.
        result - Whether the initial peace treaty was accepted.
        Returns:
        A ChangeSet encapsulating this action.
      • nativeGift

        public ChangeSet nativeGift​(ServerPlayer serverPlayer,
                                    Unit unit,
                                    Colony colony)
        A native unit delivers its gift to a colony.
        Parameters:
        serverPlayer - The ServerPlayer that is delivering.
        unit - The Unit that is delivering.
        colony - The Colony to deliver to.
        Returns:
        A ChangeSet encapsulating this action.
      • nativeTrade

        public ChangeSet nativeTrade​(ServerPlayer serverPlayer,
                                     NativeTrade.NativeTradeAction action,
                                     NativeTrade nt)
        Handle native trade sessions.
        Parameters:
        serverPlayer - The ServerPlayer that is trading.
        action - The NativeTradeAction to perform.
        nt - The NativeTrade underway.
        Returns:
        A ChangeSet encapsulating this action.
      • newTradeRoute

        public ChangeSet newTradeRoute​(ServerPlayer serverPlayer)
        Create a new trade route for a player.
        Parameters:
        serverPlayer - The ServerPlayer that needs a new route.
        Returns:
        A ChangeSet encapsulating this action.
      • payArrears

        public ChangeSet payArrears​(ServerPlayer serverPlayer,
                                    GoodsType type)
        Pay arrears.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        type - The GoodsType to pay the arrears for.
        Returns:
        A ChangeSet encapsulating this action.
      • payForBuilding

        public ChangeSet payForBuilding​(ServerPlayer serverPlayer,
                                        Colony colony)
        Pay for a building.
        Parameters:
        serverPlayer - The ServerPlayer that owns the colony.
        colony - The Colony that is building.
        Returns:
        A ChangeSet encapsulating this action.
      • putOutsideColony

        public ChangeSet putOutsideColony​(ServerPlayer serverPlayer,
                                          Unit unit)
        Put outside colony.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to be put out.
        Returns:
        A ChangeSet encapsulating this action.
      • rearrangeColony

        public ChangeSet rearrangeColony​(ServerPlayer serverPlayer,
                                         Colony colony,
                                         java.util.List<RearrangeColonyMessage.Arrangement> arrangements)
        Rearrange a colony.
        Parameters:
        serverPlayer - The ServerPlayer that is querying.
        colony - The Colony to rearrange.
        arrangements - A list of Arrangements to apply.
        Returns:
        A ChangeSet encapsulating this action.
      • renameObject

        public ChangeSet renameObject​(ServerPlayer serverPlayer,
                                      Nameable object,
                                      java.lang.String newName)
        Rename an object.
        Parameters:
        serverPlayer - The ServerPlayer that is naming.
        object - The Nameable to rename.
        newName - The new name.
        Returns:
        A ChangeSet encapsulating this action.
      • retire

        public ChangeSet retire​(ServerPlayer serverPlayer)
        Handle a player retiring.
        Parameters:
        serverPlayer - The ServerPlayer that is retiring.
        Returns:
        A ChangeSet containing the response.
      • scoutIndianSettlement

        public ChangeSet scoutIndianSettlement​(ServerPlayer serverPlayer,
                                               ServerUnit unit,
                                               IndianSettlement is)
        Scout a native settlement, that is, the contacting action that generates the greeting dialog.
        Parameters:
        serverPlayer - The ServerPlayer that is scouting.
        unit - The scout Unit.
        is - The IndianSettlement to scout.
        Returns:
        A ChangeSet encapsulating this action.
      • scoutSpeakToChief

        public ChangeSet scoutSpeakToChief​(ServerPlayer serverPlayer,
                                           ServerUnit sUnit,
                                           IndianSettlement is)
        Speak to the chief at a native settlement.
        Parameters:
        serverPlayer - The ServerPlayer that is scouting.
        sUnit - The scout ServerUnit.
        is - The IndianSettlement to scout.
        Returns:
        A ChangeSet encapsulating this action.
      • sellGoods

        private ChangeSet sellGoods​(ServerPlayer serverPlayer,
                                    GoodsType type,
                                    int amount,
                                    Unit carrier)
        Sell goods in Europe.
        Parameters:
        serverPlayer - The ServerPlayer that is selling.
        type - The GoodsType to sell.
        amount - The amount of goods to sell.
        carrier - The Unit carrying the goods.
        Returns:
        A ChangeSet encapsulating this action.
      • setBuildQueue

        public ChangeSet setBuildQueue​(ServerPlayer serverPlayer,
                                       Colony colony,
                                       java.util.List<BuildableType> queue)
        Set build queue.
        Parameters:
        serverPlayer - The ServerPlayer that owns the colony.
        colony - The Colony to set the queue of.
        queue - The new build queue.
        Returns:
        A ChangeSet encapsulating this action.
      • setCurrentStop

        public ChangeSet setCurrentStop​(ServerPlayer serverPlayer,
                                        Unit unit,
                                        int index)
        Set a unit stop.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to set the destination for.
        index - The stop index.
        Returns:
        A ChangeSet encapsulating this action.
      • setDestination

        public ChangeSet setDestination​(ServerPlayer serverPlayer,
                                        Unit unit,
                                        Location destination)
        Set a unit destination.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to set the destination for.
        destination - The Location to set as destination.
        Returns:
        A ChangeSet encapsulating this action.
      • setGoodsLevels

        public ChangeSet setGoodsLevels​(ServerPlayer serverPlayer,
                                        Colony colony,
                                        ExportData exportData)
        Set goods levels.
        Parameters:
        serverPlayer - The ServerPlayer that owns the colony.
        colony - The Colony to set the goods levels in.
        exportData - The new ExportData.
        Returns:
        A ChangeSet encapsulating this action.
      • setNewLandName

        public ChangeSet setNewLandName​(ServerPlayer serverPlayer,
                                        Unit unit,
                                        java.lang.String name)
        Set land name.
        Parameters:
        serverPlayer - The ServerPlayer who landed.
        unit - The Unit that has come ashore.
        name - The new land name.
        Returns:
        A ChangeSet encapsulating this action.
      • setNewRegionName

        public ChangeSet setNewRegionName​(ServerPlayer serverPlayer,
                                          Unit unit,
                                          Region region,
                                          java.lang.String name)
        Set region name.
        Parameters:
        serverPlayer - The ServerPlayer discovering.
        unit - The Unit that is discovering.
        region - The Region to discover.
        name - The new region name.
        Returns:
        A ChangeSet encapsulating this action.
      • spySettlement

        public ChangeSet spySettlement​(ServerPlayer serverPlayer,
                                       Unit unit,
                                       Settlement settlement)
        Spy on a settlement.
        Parameters:
        serverPlayer - The ServerPlayer that is spying.
        unit - The Unit that is spying.
        settlement - The Settlement to spy on.
        Returns:
        A ChangeSet encapsulating this action.
      • trainUnitInEurope

        public ChangeSet trainUnitInEurope​(ServerPlayer serverPlayer,
                                           UnitType type)
        Train a unit in Europe.
        Parameters:
        serverPlayer - The ServerPlayer that is demanding.
        type - The UnitType to train.
        Returns:
        A ChangeSet encapsulating this action.
      • unloadGoods

        public ChangeSet unloadGoods​(ServerPlayer serverPlayer,
                                     GoodsType goodsType,
                                     int amount,
                                     Unit carrier)
        Unload goods.
        Parameters:
        serverPlayer - The ServerPlayer that is unloading.
        goodsType - The GoodsType to unload.
        amount - The amount of goods to unload.
        carrier - The Unit to unload.
        Returns:
        A ChangeSet encapsulating this action.
      • updateTradeRoute

        public ChangeSet updateTradeRoute​(ServerPlayer serverPlayer,
                                          TradeRoute tradeRoute)
        Update a trade route for a player.
        Parameters:
        serverPlayer - The ServerPlayer to set trade routes for.
        tradeRoute - An uninterned TradeRoute to update.
        Returns:
        A ChangeSet encapsulating this action.
      • work

        public ChangeSet work​(ServerPlayer serverPlayer,
                              Unit unit,
                              WorkLocation workLocation)
        Change work location.
        Parameters:
        serverPlayer - The ServerPlayer that owns the unit.
        unit - The Unit to change the work location of.
        workLocation - The WorkLocation to change to.
        Returns:
        A ChangeSet encapsulating this action.