Allow unit property “givesMovement” to use variable lists


  • Admin

    As discussed here:
    https://forums.triplea-game.org/topic/1585/variable-lists-do-not-seem-to-work

    It would be nice and clean ho have units be able to have attachments like…

    <option name="givesMovement" value="-1:$AllLandUnits$"/>
    

    Instead of …

    <option name="givesMovement" value="-1:unit1"/>
    <option name="givesMovement" value="-1:unit2"/>
    <option name="givesMovement" value="-1:unit3"/>
    <option name="givesMovement" value="-1:unit4"/>
    <option name="givesMovement" value="-1:unit5"/>
    <option name="givesMovement" value="-1:unit6"/>
    (…)
    

  • Admin

    @Frostion Yep, this is a good one and really surprised no one ever asked for this before as even without variable lists, it would often save a lot of lines.

    Here is the PR: https://github.com/triplea-game/triplea/pull/5316

    If you are working on things today, I can merge the PR here in a few minutes so you can test and move forward. Let me know.

    Here is an example I tested in TWW:

            <attachment name="unitAttachment" attachTo="germanAirfield" javaClass="UnitAttachment" type="unitType">
                <option name="isInfrastructure" value="true"/>
                <option name="movement" value="0"/>
                <option name="attack" value="0"/>
                <option name="defense" value="0"/>
                <option name="canBeDamaged" value="true"/>
                <option name="maxDamage" value="8"/>
                <option name="maxOperationalDamage" value="5"/>
                <option name="canDieFromReachingMaxDamage" value="true"/>
                <option name="isAirBase" value="true"/>
                <option name="isConstruction" value="true"/>
                <option name="constructionType" value="Airfield"/>
                <option name="constructionsPerTerrPerTypePerTurn" value="3"/>
                <option name="maxScrambleCount" value="2"/>
                <option name="maxConstructionsPerTypePerTerr" value="3"/>
                <option name="givesMovement" value="2:germanFighter:germanNavalFighter"/>
            </attachment>  
    

  • Admin

    @redrum said in Allow unit property “givesMovement” to use variable lists:

    If you are working on things today, I can merge the PR here in a few minutes so you can test

    I am and I can 😉


  • Admin

    @Frostion Alright. PR is merged now so should have a new pre-release build in a bit.

    I also made a small update to POS2 XML for this update: https://github.com/triplea-maps/the_pact_of_steel/pull/37/files


  • Moderators

    @redrum What do you generally think about having multiple options with the same name in the same attachment?

    I think it would be better that being not allowed, as, then, I've no idea how you can change values with triggers.

    For example, if you have:
    <option name="givesMovement" value="2:germanFighter:germanNavalFighter"/>
    you can trigger-change it to:
    <option name="givesMovement" value="1:germanFighter:germanNavalFighter"/>

    But if you have:
    <option name="givesMovement" value="2:germanFighter"/>
    <option name="givesMovement" value="2:germanNavalFighter"/>
    you cannot trigger-change them to:
    <option name="givesMovement" value="1:germanFighter"/>
    <option name="givesMovement" value="1:germanNavalFighter"/>

    Am I right?

    p.s.: I'm not proposing to actually rework all such cases, or even only disallowing multiple for this case, as that would imply having to fix a lot of games. Just wondering if anyone else believes that the practice of having multiple options with the same name per attachment is bad, at least since this creates black spots for triggers to influence them, if I'm right.


  • Admin

    @Cernel You need multiple options for options like givesMovement because often you have something like an airBase giving different bonus movement to different types of air units (this is what TWW does currently). So with the update, TWW would still need to have multiple givesMovement just less than it does now. You would need to allow further chaining of multiple movement amounts then list of units in a single line otherwise.

            <attachment name="unitAttachment" attachTo="germanAirfield" javaClass="UnitAttachment" type="unitType">
                <option name="isInfrastructure" value="true"/>
                <option name="movement" value="0"/>
                <option name="attack" value="0"/>
                <option name="defense" value="0"/>
                <option name="canBeDamaged" value="true"/>
                <option name="maxDamage" value="8"/>
                <option name="maxOperationalDamage" value="5"/>
                <option name="canDieFromReachingMaxDamage" value="true"/>
                <option name="isAirBase" value="true"/>
                <option name="isConstruction" value="true"/>
                <option name="constructionType" value="Airfield"/>
                <option name="constructionsPerTerrPerTypePerTurn" value="3"/>
                <option name="maxScrambleCount" value="2"/>
                <option name="maxConstructionsPerTypePerTerr" value="3"/>
                <option name="givesMovement" value="2:germanFighter:germanNavalFighter"/>
                <option name="givesMovement" value="4:germanAdvancedFighter"/>
                <!-- <option name="givesMovement" value="2:germanNavalFighter"/> -->
                <option name="givesMovement" value="4:germanAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:germanTacticalBomber"/>
                <option name="givesMovement" value="5:germanAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:germanStrategicBomber"/>
                <option name="givesMovement" value="6:germanHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:germanAirTransport"/>
                <option name="givesMovement" value="2:germanRocket"/>
                <option name="givesMovement" value="4:germanAdvancedRocket"/>
                <option name="givesMovement" value="2:italianFighter"/>
                <option name="givesMovement" value="4:italianAdvancedFighter"/>
                <option name="givesMovement" value="2:italianNavalFighter"/>
                <option name="givesMovement" value="4:italianAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:italianTacticalBomber"/>
                <option name="givesMovement" value="5:italianAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:italianStrategicBomber"/>
                <option name="givesMovement" value="6:italianHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:italianAirTransport"/>
                <option name="givesMovement" value="2:italianRocket"/>
                <option name="givesMovement" value="4:italianAdvancedRocket"/>
                <option name="givesMovement" value="2:japaneseFighter"/>
                <option name="givesMovement" value="4:japaneseAdvancedFighter"/>
                <option name="givesMovement" value="2:japaneseNavalFighter"/>
                <option name="givesMovement" value="4:japaneseAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:japaneseTacticalBomber"/>
                <option name="givesMovement" value="5:japaneseAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:japaneseStrategicBomber"/>
                <option name="givesMovement" value="6:japaneseHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:japaneseAirTransport"/>
                <option name="givesMovement" value="2:japaneseRocket"/>
                <option name="givesMovement" value="4:japaneseAdvancedRocket"/>
                <option name="givesMovement" value="2:russianFighter"/>
                <option name="givesMovement" value="4:russianAdvancedFighter"/>
                <option name="givesMovement" value="2:russianNavalFighter"/>
                <option name="givesMovement" value="4:russianAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:russianTacticalBomber"/>
                <option name="givesMovement" value="5:russianAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:russianStrategicBomber"/>
                <option name="givesMovement" value="6:russianHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:russianAirTransport"/>
                <option name="givesMovement" value="2:russianRocket"/>
                <option name="givesMovement" value="4:russianAdvancedRocket"/>
                <option name="givesMovement" value="2:britishFighter"/>
                <option name="givesMovement" value="4:britishAdvancedFighter"/>
                <option name="givesMovement" value="2:britishNavalFighter"/>
                <option name="givesMovement" value="4:britishAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:britishTacticalBomber"/>
                <option name="givesMovement" value="5:britishAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:britishStrategicBomber"/>
                <option name="givesMovement" value="6:britishHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:britishAirTransport"/>
                <option name="givesMovement" value="2:britishRocket"/>
                <option name="givesMovement" value="4:britishAdvancedRocket"/>
                <option name="givesMovement" value="2:americanFighter"/>
                <option name="givesMovement" value="4:americanAdvancedFighter"/>
                <option name="givesMovement" value="2:americanNavalFighter"/>
                <option name="givesMovement" value="4:americanAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:americanTacticalBomber"/>
                <option name="givesMovement" value="5:americanAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:americanStrategicBomber"/>
                <option name="givesMovement" value="6:americanHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:americanAirTransport"/>
                <option name="givesMovement" value="2:americanRocket"/>
                <option name="givesMovement" value="4:americanAdvancedRocket"/>
                <option name="givesMovement" value="2:chineseFighter"/>
                <option name="givesMovement" value="3:chineseTacticalBomber"/>
                <option name="givesMovement" value="2:brazilianFighter"/>
                <option name="givesMovement" value="2:spanishFighter"/>
                <option name="givesMovement" value="2:swedishFighter"/>
                <option name="givesMovement" value="2:turkishFighter"/>
                <option name="requiresUnits" value="germanCombatEngineer"/>
                <option name="consumesUnits" value="1:Material"/>
                <option name="destroyedWhenCapturedBy" value="China:Russia:Germany:Britain:Italy:Japan:Usa:Spain:Sweden:Turkey:Brazil"/>
            </attachment>
    

  • Moderators

    @redrum Ok, but, that way, can you somehow change such things with triggers, for example changing this:

                <option name="givesMovement" value="2:germanFighter:germanNavalFighter"/>
                <option name="givesMovement" value="4:germanAdvancedFighter"/>
                <option name="givesMovement" value="4:germanAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:germanTacticalBomber"/>
                <option name="givesMovement" value="5:germanAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:germanStrategicBomber"/>
                <option name="givesMovement" value="6:germanHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:germanAirTransport"/>
                <option name="givesMovement" value="2:germanRocket"/>
                <option name="givesMovement" value="4:germanAdvancedRocket"/>
                <option name="givesMovement" value="2:italianFighter"/>
                <option name="givesMovement" value="4:italianAdvancedFighter"/>
                <option name="givesMovement" value="2:italianNavalFighter"/>
                <option name="givesMovement" value="4:italianAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:italianTacticalBomber"/>
                <option name="givesMovement" value="5:italianAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:italianStrategicBomber"/>
                <option name="givesMovement" value="6:italianHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:italianAirTransport"/>
                <option name="givesMovement" value="2:italianRocket"/>
                <option name="givesMovement" value="4:italianAdvancedRocket"/>
                <option name="givesMovement" value="2:japaneseFighter"/>
                <option name="givesMovement" value="4:japaneseAdvancedFighter"/>
                <option name="givesMovement" value="2:japaneseNavalFighter"/>
                <option name="givesMovement" value="4:japaneseAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:japaneseTacticalBomber"/>
                <option name="givesMovement" value="5:japaneseAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:japaneseStrategicBomber"/>
                <option name="givesMovement" value="6:japaneseHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:japaneseAirTransport"/>
                <option name="givesMovement" value="2:japaneseRocket"/>
                <option name="givesMovement" value="4:japaneseAdvancedRocket"/>
                <option name="givesMovement" value="2:russianFighter"/>
                <option name="givesMovement" value="4:russianAdvancedFighter"/>
                <option name="givesMovement" value="2:russianNavalFighter"/>
                <option name="givesMovement" value="4:russianAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:russianTacticalBomber"/>
                <option name="givesMovement" value="5:russianAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:russianStrategicBomber"/>
                <option name="givesMovement" value="6:russianHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:russianAirTransport"/>
                <option name="givesMovement" value="2:russianRocket"/>
                <option name="givesMovement" value="4:russianAdvancedRocket"/>
                <option name="givesMovement" value="2:britishFighter"/>
                <option name="givesMovement" value="4:britishAdvancedFighter"/>
                <option name="givesMovement" value="2:britishNavalFighter"/>
                <option name="givesMovement" value="4:britishAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:britishTacticalBomber"/>
                <option name="givesMovement" value="5:britishAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:britishStrategicBomber"/>
                <option name="givesMovement" value="6:britishHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:britishAirTransport"/>
                <option name="givesMovement" value="2:britishRocket"/>
                <option name="givesMovement" value="4:britishAdvancedRocket"/>
                <option name="givesMovement" value="2:americanFighter"/>
                <option name="givesMovement" value="4:americanAdvancedFighter"/>
                <option name="givesMovement" value="2:americanNavalFighter"/>
                <option name="givesMovement" value="4:americanAdvancedNavalFighter"/>
                <option name="givesMovement" value="3:americanTacticalBomber"/>
                <option name="givesMovement" value="5:americanAdvancedTacticalBomber"/>
                <option name="givesMovement" value="4:americanStrategicBomber"/>
                <option name="givesMovement" value="6:americanHeavyStrategicBomber"/>
                <option name="givesMovement" value="3:americanAirTransport"/>
                <option name="givesMovement" value="2:americanRocket"/>
                <option name="givesMovement" value="4:americanAdvancedRocket"/>
                <option name="givesMovement" value="2:chineseFighter"/>
                <option name="givesMovement" value="3:chineseTacticalBomber"/>
                <option name="givesMovement" value="2:brazilianFighter"/>
                <option name="givesMovement" value="2:spanishFighter"/>
                <option name="givesMovement" value="2:swedishFighter"/>
                <option name="givesMovement" value="2:turkishFighter"/>
    

    to this:

    
                <option name="givesMovement" value="4:germanFighter:germanNavalFighter"/>
                <option name="givesMovement" value="8:germanAdvancedFighter"/>
                <option name="givesMovement" value="8:germanAdvancedNavalFighter"/>
                <option name="givesMovement" value="6:germanTacticalBomber"/>
                <option name="givesMovement" value="10:germanAdvancedTacticalBomber"/>
                <option name="givesMovement" value="8:germanStrategicBomber"/>
                <option name="givesMovement" value="14:germanHeavyStrategicBomber"/>
                <option name="givesMovement" value="6:germanAirTransport"/>
                <option name="givesMovement" value="4:germanRocket"/>
                <option name="givesMovement" value="8:germanAdvancedRocket"/>
                <option name="givesMovement" value="4:italianFighter"/>
                <option name="givesMovement" value="8:italianAdvancedFighter"/>
                <option name="givesMovement" value="4:italianNavalFighter"/>
                <option name="givesMovement" value="8:italianAdvancedNavalFighter"/>
                <option name="givesMovement" value="6:italianTacticalBomber"/>
                <option name="givesMovement" value="10:italianAdvancedTacticalBomber"/>
                <option name="givesMovement" value="8:italianStrategicBomber"/>
                <option name="givesMovement" value="14:italianHeavyStrategicBomber"/>
                <option name="givesMovement" value="6:italianAirTransport"/>
                <option name="givesMovement" value="4:italianRocket"/>
                <option name="givesMovement" value="8:italianAdvancedRocket"/>
                <option name="givesMovement" value="4:japaneseFighter"/>
                <option name="givesMovement" value="8:japaneseAdvancedFighter"/>
                <option name="givesMovement" value="4:japaneseNavalFighter"/>
                <option name="givesMovement" value="8:japaneseAdvancedNavalFighter"/>
                <option name="givesMovement" value="6:japaneseTacticalBomber"/>
                <option name="givesMovement" value="10:japaneseAdvancedTacticalBomber"/>
                <option name="givesMovement" value="8:japaneseStrategicBomber"/>
                <option name="givesMovement" value="14:japaneseHeavyStrategicBomber"/>
                <option name="givesMovement" value="6:japaneseAirTransport"/>
                <option name="givesMovement" value="4:japaneseRocket"/>
                <option name="givesMovement" value="8:japaneseAdvancedRocket"/>
                <option name="givesMovement" value="4:russianFighter"/>
                <option name="givesMovement" value="8:russianAdvancedFighter"/>
                <option name="givesMovement" value="4:russianNavalFighter"/>
                <option name="givesMovement" value="8:russianAdvancedNavalFighter"/>
                <option name="givesMovement" value="6:russianTacticalBomber"/>
                <option name="givesMovement" value="10:russianAdvancedTacticalBomber"/>
                <option name="givesMovement" value="8:russianStrategicBomber"/>
                <option name="givesMovement" value="14:russianHeavyStrategicBomber"/>
                <option name="givesMovement" value="6:russianAirTransport"/>
                <option name="givesMovement" value="4:russianRocket"/>
                <option name="givesMovement" value="8:russianAdvancedRocket"/>
                <option name="givesMovement" value="4:britishFighter"/>
                <option name="givesMovement" value="8:britishAdvancedFighter"/>
                <option name="givesMovement" value="4:britishNavalFighter"/>
                <option name="givesMovement" value="8:britishAdvancedNavalFighter"/>
                <option name="givesMovement" value="6:britishTacticalBomber"/>
                <option name="givesMovement" value="10:britishAdvancedTacticalBomber"/>
                <option name="givesMovement" value="8:britishStrategicBomber"/>
                <option name="givesMovement" value="14:britishHeavyStrategicBomber"/>
                <option name="givesMovement" value="6:britishAirTransport"/>
                <option name="givesMovement" value="4:britishRocket"/>
                <option name="givesMovement" value="8:britishAdvancedRocket"/>
                <option name="givesMovement" value="4:americanFighter"/>
                <option name="givesMovement" value="8:americanAdvancedFighter"/>
                <option name="givesMovement" value="4:americanNavalFighter"/>
                <option name="givesMovement" value="8:americanAdvancedNavalFighter"/>
                <option name="givesMovement" value="6:americanTacticalBomber"/>
                <option name="givesMovement" value="10:americanAdvancedTacticalBomber"/>
                <option name="givesMovement" value="8:americanStrategicBomber"/>
                <option name="givesMovement" value="14:americanHeavyStrategicBomber"/>
                <option name="givesMovement" value="6:americanAirTransport"/>
                <option name="givesMovement" value="4:americanRocket"/>
                <option name="givesMovement" value="8:americanAdvancedRocket"/>
                <option name="givesMovement" value="4:chineseFighter"/>
                <option name="givesMovement" value="6:chineseTacticalBomber"/>
                <option name="givesMovement" value="4:brazilianFighter"/>
                <option name="givesMovement" value="4:spanishFighter"/>
                <option name="givesMovement" value="4:swedishFighter"/>
                <option name="givesMovement" value="4:turkishFighter"/>
    

    during the game?


  • Admin

    @Cernel I believe you can. givesMovement is essentially a list in the engine so you can use -reset- to clear then add multiple lines to it to achieve your example.

        <!-- Clarification on changing properties and resetting/clearing of properties. (Any property not in this list overwrites itself if you set it multiple times)
    				The following attachments may have MULTIPLE instances, meaning that they are adding to some variable, meaning that they may be cleared/reset by triggers if you want to (by prefixing with "-reset-"):
    				Unit Attachments:
    					canBeGivenByTerritoryTo
    					canBeCapturedOnEnteringBy
    					destroyedWhenCapturedBy 
    					destroyedWhenCapturedFrom (Can't be used by triggers, use destroyedWhenCapturedBy instead)
    					requiresUnits
    					repairsUnits
    					givesMovement
    

  • Moderators

    @redrum Ok, but if reset before an addition of a "givesMovement" option would delete all current ones, then can I make multiple of those, firing at the same time, or would they reset what the ones firing at the same time did? I could test it, but I'm more interested to know what is intended. All I understand from that is that I can reset and add a single instance or add additional without resetting, but can I reset and add multiple, without each new one resetting everything?

    What I understand, in practice is that, if I have something like this:

                <option name="givesMovement" value="2:germanFighter:germanNavalFighter"/>
                <option name="givesMovement" value="4:germanAdvancedFighter"/>
    

    I can add another case, without reset, getting something like this:

                <option name="givesMovement" value="2:germanFighter:germanNavalFighter"/>
                <option name="givesMovement" value="4:germanAdvancedFighter"/>
                <option name="givesMovement" value="4:germanAdvancedNavalFighter"/>
    

    Or, if I reset, I would remove what is there, and get something like this:

                <option name="givesMovement" value="4:germanAdvancedNavalFighter"/>
    

    But pos2 is not clear about what would be the process if starting from this:

                <option name="givesMovement" value="2:germanFighter:germanNavalFighter"/>
                <option name="givesMovement" value="4:germanAdvancedFighter"/>
    

    I want to get this:

                <option name="givesMovement" value="4:germanFighter:germanNavalFighter"/>
                <option name="givesMovement" value="8:germanAdvancedFighter"/>
    

    I know I could do a trigger chain with the first one resetting and adding the first line and the second one adding the second line without resetting, but here I'm talking about no workarounds.


  • Admin

    @Cernel Uh, not sure exactly what you are asking but after you reset it you can then add multiple instances as long as you don't reset it again.


  • Moderators

    @redrum Right, but resetting is integrated in adding, and triggers are displayed in no particular order in history, and supposedly fire at the same time, if they do. So, I'm talking doing it before or after a same phase. I know I could reset on a phase and, then, add all I want, without resetting, in a phase thereafter, but that is a workaround.


  • Moderators

    @Cernel For example, I see I could do it by having a trigger that reset and adds the first line and also activates a number of other triggers that add the remaining lines without resetting, and I suppose that would work, but it would be a workaround, so I was curious if there was a proper process for changing or anyways managing multiple options with the same name, for example doubling all "givesMovement" of TWW.


  • Admin

    @Cernel I believe you can just do it all in the same trigger and that the trigger should always execute the lines as they are listed so something like this (I haven't tested this):

        <attachment name="triggerAttachmentExample" attachTo="Germany" javaClass="TriggerAttachment" type="player">
          <option name="conditions" value="someCondition"/>
          <option name="unitType" value="germanAirfield"/>
          <option name="unitProperty" value="givesMovement" count="-reset-:4:germanFighter:germanNavalFighter"/>
          <option name="unitProperty" value="givesMovement" count="8:germanAdvancedFighter"/>
        </attachment>
    

  • Moderators

    @redrum Ah, ok, I didn't know that the lines of a trigger were meant to be a sequence, not just a set. I will eventually test that, and see if it works, as I intend to eventually do something where you have different bonus for combat and non combat movement. Then I suppose updating pos2, if we can assume that is the proper process, as currently I've no idea how any normal mapmaker can really understand that out of this description alone.

    The following attachments may have MULTIPLE instances, meaning that they are adding to some variable, meaning that they may be cleared/reset by triggers if you want to (by prefixing with "-reset-")
    

  • Admin

    @redrum I tried the latest pre-release and it seems to work now 😊 Great Work!


Log in to reply
 

27480
1435
1666
Who's Online
Visitors Today