Class GameDataMerger


  • public class GameDataMerger
    extends java.lang.Object
    Utility class to merge two reports.
    Author:
    stm
    • Field Detail

      • astral

        protected static java.lang.String astral
      • pattern

        protected static java.lang.String pattern
      • regionsPattern1

        protected static java.lang.String regionsPattern1
      • regionsPattern2

        protected static java.lang.String regionsPattern2
    • Constructor Detail

      • GameDataMerger

        public GameDataMerger()
    • Method Detail

      • merge

        public static GameData merge​(GameData gd1,
                                     GameData gd2)
        Merges the specified dataset with this dataset.
        Parameters:
        gd1 - the first game data object for merging
        gd2 - the second game data object for merging
        Returns:
        the new merged game data object
        Throws:
        java.lang.IllegalArgumentException - if first and second game data object are from different game types.
      • merge

        public static GameData merge​(GameData gd,
                                     ReportTransformer transformer)
        Returns a new report that is the given report translated by the given transformer.
      • mergeGroup

        public static void mergeGroup​(GameData curGD,
                                      Group curGroup,
                                      GameData newGD,
                                      Group newGroup)
        Transfers all available information from the current group to the new one.
        Parameters:
        curGD - fully loaded game data
        curGroup - a fully initialized and valid group
        newGD - the game data to be updated
        newGroup - a group to be updated with the data from curGroup
      • mergeFaction

        public static void mergeFaction​(GameData curGD,
                                        Faction curFaction,
                                        GameData newGD,
                                        Faction newFaction,
                                        boolean adjustTrustLevels,
                                        ReportTransformer transformer)
        Copies the values of curFaction to newFaction.
        Parameters:
        adjustTrustLevels - Only if this is true will the trust levels of newFaction be copied.
        transformer -
      • mergeMessage

        public static void mergeMessage​(GameData curGD,
                                        Message curMsg,
                                        GameData newGD,
                                        Message newMsg,
                                        ReportTransformer transformer)
        Transfers all available information from the current message to the new one. This is generally a localization problem: if newMsg.text == null then newMsg=curMsg (also in case the locale is different) if curMsg.locale == newGD.local then newMsg=curMsg => if correct locale available use it => otherwise take wrong locale msg, to have at least a half localized msg if the msgtype is available in locale => you can notice this half localized msg because msg.locale=gm.locale, also msg.rerender=true
        Parameters:
        curGD - fully loaded game data
        curMsg - a fully initialized and valid message
        newGD - the game data to be updated
        newMsg - a message to be updated with the data from curMsg
        transformer -
      • buildPattern

        protected static void buildPattern()
      • mergeBuilding

        public static void mergeBuilding​(GameData curGD,
                                         Building curBuilding,
                                         GameData newGD,
                                         Building newBuilding,
                                         ReportTransformer transformer)
        Merges buildings. The new one get the name, comments etc. from the current one, effects etc. are added, not written over.
        Parameters:
        curGD - current GameData
        curBuilding - the current Building
        newGD - new GameData
        newBuilding - the new Building
        transformer -
      • mergeCombatSpell

        public static void mergeCombatSpell​(GameData curGD,
                                            CombatSpell curCS,
                                            GameData newGD,
                                            CombatSpell newCS)
        Merges two combat spells.
        Parameters:
        curGD - the current GameData.
        curCS - the current CombatSpell.
        newGD - the new GameData.
        newCS - the new CombatSpell.
      • mergeRegion

        public static void mergeRegion​(GameData curGD,
                                       Region curRegion,
                                       GameData resultGD,
                                       Region resultRegion,
                                       boolean newTurn,
                                       boolean firstPass,
                                       ReportTransformer transformer)
        Merges all info from curRegion into newRegion. The result is influenced by the sameRound parameter (indicating if the region infos are from the same round) and the firstPass parameter. Merging is usually done in two passes. In the first pass, the old info is copied into an intermediate object. In the second pass, the new object is merged into this intermediate object.
        Parameters:
        curGD - The GameData of curUnit
        curRegion - The region where the info is taken from
        resultGD - The GameData of resultRegion
        resultRegion - The info is merged into this region
        newTurn - notifies if both game data objects have been from the same round
        firstPass - notifies if this is the first of two passes
        transformer -
      • mergeScheme

        public static void mergeScheme​(GameData curGD,
                                       Scheme curScheme,
                                       GameData newGD,
                                       Scheme newScheme)
        Merges two Scheme objects.
      • mergeSpell

        public static void mergeSpell​(GameData curGD,
                                      Spell curSpell,
                                      GameData newGD,
                                      Spell newSpell)
        Merges spells.
      • merge

        public static void merge​(GameData curGD,
                                 TempUnit curTemp,
                                 GameData newGD,
                                 TempUnit newTemp,
                                 boolean sameRound,
                                 boolean firstPass,
                                 ReportTransformer transformer)
        Merges two temp units.
        Parameters:
        sameRound - notifies if both game data objects have been from the same round
        transformer -
      • mergeComments

        public static void mergeComments​(UnitContainer curShip,
                                         UnitContainer newShip)
        Merges only the comments of curShip to newShip. Use if you don't want to do a full merge.
        Parameters:
        curShip -
        newShip -
      • mergeUnit

        public static void mergeUnit​(GameData curGD,
                                     Unit curUnit,
                                     GameData resultGD,
                                     Unit resultUnit,
                                     boolean sameRound,
                                     boolean firstPass,
                                     ReportTransformer transformer)
        Merges all info from curUnit into newUnit. The result is influenced by the sameRound parameter (indicating if the unit infos are from the same round) and the firstPass parameter. Merging is usually done in two passes. In the first pass, the old info is copied into an intermediate object. In the second pass, the new object is merged into this intermediate object.
        Parameters:
        curGD - The GameData of curUnit
        curUnit - The unit where the info is taken from
        resultGD - The GameData of newUnit
        resultUnit - The info is merged into this unit
        sameRound - notifies if both game data objects have been from the same round
        firstPass - notifies if this is the first of two passes
        transformer -