Navigation

    TripleA Logo

    TripleA Forum

    • Register
    • Login
    • Search
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags

    Reference the PU Value of a Territory in Triggers?

    Map Making
    3
    19
    1180
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jason Green-Lowe
      Jason Green-Lowe last edited by

      I'd like to have factories automatically generate 1 railroad unit per turn per value of the territory. So, if the territory is worth 3 PUs, then it should generate 3 railroad units each turn.

      Is there any way to access or reference the PU value of the territory while writing the triggers and conditions that will do this, or do I have to manually type out a list of all 2-PU territories, all 3-PU territories, etc.? If the latter, how would I word that? Right now I have:

          <attachment name="conditionAttachmentGermansHasTwoValueFactory" attachTo="Germans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
            <option name="unitPresence" value="factory_minor:factory_major" count="1"/>
            <option name="directOwnershipTerritories" value="Scotland:Finland:Yugoslavia:Greece" count="each"/>
          </attachment>
              
          <attachment name="triggerAttachmentGermansMakeRailroad2" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            <option name="when" value="after:germansBattle"/>
            <option name="conditions" value="conditionAttachmentGermansHasTwoValueFactory"/>
            <option name="placement" value="each:railroad" count="2"/>
          </attachment>
      
      

      which doesn't look quite right to me.

      W 1 Reply Last reply Reply Quote 0
      • W
        wc_sumpton @Jason Green-Lowe last edited by wc_sumpton

        @jason-green-lowe

        No, there is no way to check the PUs value of a given territory. Also you are correct in assuming that the sample xml will not produce the desired results.
        To understand what is wanted, lets try to breakdown the request: Generate 1 railroad per PUs on a territory with a factory. For this, each territory will need to be checked seperately:

        <!-- Check to see if Germany has a factory on Scotland -->
        <attachment name="conditionAttachmentGermansHasFactoryScotland" attachTo="Germans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
           <option name="directPresenceTerritories" value="Scotland" count="1"/>
           <option name="unitPresence" value="factory_minor:factory_major" count="1"/>
        </attachment>
        
        <!-- Place 2 railroad if Germans have factory on Scotland -->
        <attachment name="triggerAttachmentGermansMakeRailroadScotland" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
           <option name="conditions" value="conditionAttachmentGermansHasFactoryScotland"/>
           <option name="placement" value="Scotland:railroad" count="2"/>
           <option name="when" value="after:germansBattle"/>
        </attachment>
        

        Please note that I am not checking for the ownership of the territory, I am only checking to see if Germans own a factory on the territory. If the Germans own the factory then I am assuming that they also own that territory. Also I am only checking 1 territory at a time because I want the railroad placed in that territory.

        If tested, and the above works, then by using variableList, and foreach, I would create a check for each territory and player.

        Hope this helps!!

        Cheers...

        Jason Green-Lowe 1 Reply Last reply Reply Quote 2
        • Jason Green-Lowe
          Jason Green-Lowe @wc_sumpton last edited by

          @wc_sumpton Hey, thanks as always for the thoughtful advice!

          So your test code mostly works, in that it produces the railroad units, however those units are completely unable to move -- for some reason the game engine thinks that they have zero movement when they're created with your code. When I make the units manually, using Edit Mode, they move appropriately.

          I tried writing a foreach loop, but it isn't working -- I keep getting error messages saying that "directPresenceTerritories" isn't a defined property. Any more insights?

          <attachment foreach="$Players$:$Phases$^$TwoValueTerritories$" name="conditionAttachmentMakeRailroad@Players@In@TwoValueTerritories@" attachTo="@Players@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="when" value="after:@Phases@"/>
                <option name="players" value="@Players@"/>
                <option name="directPresenceTerritories" value="@TwoValueTerritories@" count="1"/>
                <option name="unitPresence" value="factory_minor:factory_major" count="1"/>
              </attachment>
              
              <attachment foreach="$Players$:$Phases$^$TwoValueTerritories$" name="triggerAttachmentMakeRailroad@Players@In@TwoValueTerritories@" attachTo="@Players@"
              javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="conditions" value="conditionAttachmentMakeRailroad@Players@In@TwoValueTerritories@"/>
                <option name="when" value="after:@Phases@"/>
                <option name="players" value="@Players@"/>
                <option name="placement" value="@TwoValueTerritories@:railroad" count="2"/>
              </attachment>  
          
          W 1 Reply Last reply Reply Quote 0
          • W
            wc_sumpton @Jason Green-Lowe last edited by

            @jason-green-lowe

            So we are talking about two different problems, unable to move placed units, and the foreach xml code not working.

            For the first problem, units placed with 'placement' are placed as moved units, and movement is not reset until the end of a phase that ends with 'NonCombatMovement'. One workaround is to place the units prior to the 'CombatMovement' phase, and the reset the unit stats at the beginning of the phase.

            You tested the xml with 'directPresenceTerritories' and it worked, it wasn't until you added the foreach that 'directPresentTerritories' didn't work. Try changing the order inside the foreach to "$TwoValueTerritories$^$Players$:$Phases$".

            Cheers...

            Jason Green-Lowe 1 Reply Last reply Reply Quote 1
            • Jason Green-Lowe
              Jason Green-Lowe @wc_sumpton last edited by

              @wc_sumpton Hmm, I still get the same error message when I try reversing the order that way:

              games.strategy.engine.data.gameparser.GameParseException: Missing property definition for option 'directPresenceTerritories' in attachment 'conditionAttachmentMakeRailroadGermansInDenmark'
              

              I'm not sure I understand your other piece of advice here. Is there a way to manually reset the unit stats? I tried placing the units as early as before:Purchase, and they still had no movement by the time the noncombat phase rolled around.

              W 2 Replies Last reply Reply Quote 0
              • W
                wc_sumpton @Jason Green-Lowe last edited by

                @jason-green-lowe

                When the phases, gremansCombatMove, germansBattle, germansNonCombatMove, etc... are defined within the xml a 'stepProperty' can be used to change what happens during that phase. Review pack_of_steel_2.xml to understand. Basically when are the unit stats reset, 'resetUnitStateAtEnd' and 'resetUnitStateAtStart' which can be set/changed during 'Move' type phases, CombatMove, NonCombatMove, etc... 'resetUnitStateAtEnd' default setting is true only with the NonCombatMove phase, otherwise both are always false. So to move units which are placed with 'placement' their UnitState will need to be reset. Using 'resetUnitStateAt...' will reset the stats of all units, so the placement of units should happen prior to any unit action, i.e. before CombatMove, then the 'stepProperty' 'resetUnitStateAtStart' can be set to true to allow these units to move.

                As to the error message, I will look into it soon.

                Cheers...

                Jason Green-Lowe 1 Reply Last reply Reply Quote 2
                • W
                  wc_sumpton @Jason Green-Lowe last edited by

                  @jason-green-lowe

                  Try taking out the 'when' option in the condition statement, you may also consider removing 'players' since attachTo defines which player is affected by the condition.

                  Cheers...

                  Jason Green-Lowe 3 Replies Last reply Reply Quote 1
                  • Jason Green-Lowe
                    Jason Green-Lowe @wc_sumpton last edited by Jason Green-Lowe

                    @wc_sumpton The stepProperty trick worked, thanks! 🙂

                    1 Reply Last reply Reply Quote 0
                    • Jason Green-Lowe
                      Jason Green-Lowe @wc_sumpton last edited by

                      @wc_sumpton Removing the players and when statements from the condition did not help. When I use:

                          <attachment foreach="$TwoValueTerritories$^$Players$:$Phases$" name="conditionAttachmentMakeRailroad@Players@In@TwoValueTerritories@" attachTo="@Players@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                            <option name="directPresenceTerritories" value="@TwoValueTerritories@" count="1"/>
                            <option name="unitPresence" value="factory_minor:factory_major" count="1"/>
                          </attachment>
                          
                          <attachment foreach="$TwoValueTerritories$^$Players$:$Phases$" name="triggerAttachmentMakeRailroad@Players@In@TwoValueTerritories@" attachTo="@Players@"
                          javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                            <option name="conditions" value="conditionAttachmentMakeRailroad@Players@In@TwoValueTerritories@"/>
                            <option name="when" value="after:@Phases@"/>
                            <option name="players" value="@Players@"/>
                            <option name="placement" value="@TwoValueTerritories@:railroad" count="2"/>
                          </attachment> 
                      

                      I get this error message:

                      Could not parse:file:///C:/Users/jason/triplea/downloadedMaps/bbr5/games/bbr5.xml, Missing property definition for option 'directPresenceTerritories' in attachment 'conditionAttachmentMakeRailroadGermansInNormandy Bordeaux'  games.strategy.engine.data.gameparser.GameParseException: Missing property definition for option 'directPresenceTerritories' in attachment 'conditionAttachmentMakeRailroadGermansInNormandy Bordeaux'
                      

                      I have tested the code with a one-word territory name, and the space in the name does not seem to be the problem; I get the same error message for, e.g., Denmark.

                      1 Reply Last reply Reply Quote 0
                      • Jason Green-Lowe
                        Jason Green-Lowe @wc_sumpton last edited by

                        @wc_sumpton Never mind, I see the problem -- I had my condition using "TriggerAttachment" instead of "RulesAttachment." No wonder it couldn't find "DirectPresenceTerritories."

                        1 Reply Last reply Reply Quote 2
                        • Jason Green-Lowe
                          Jason Green-Lowe @wc_sumpton last edited by

                          @wc_sumpton I think this is going to work! Thanks for all the help. 🙂

                          W 1 Reply Last reply Reply Quote 2
                          • W
                            wc_sumpton @Jason Green-Lowe last edited by

                            @jason-green-lowe

                            Good find on the 'RulesAttachment' and 'TriggerAttachment'. Happy to hear everything is working.👍

                            Cheers...

                            Jason Green-Lowe 1 Reply Last reply Reply Quote 2
                            • Jason Green-Lowe
                              Jason Green-Lowe @wc_sumpton last edited by

                              @wc_sumpton All right, one last issue on this feature. I also want to remove all the railroads from the map at the end of each player's turn, but the code below does not seem to have any effect. It runs OK, but it does nothing. Any idea why?

                                  <attachment name="triggerAttachmentGermansDestroyRailroad" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                                    <option name="when" value="after:germansNonCombatMove"/>
                                    <option name="removeUnits" value="all:railroad" count="20"/>
                                  </attachment>
                              
                              W 1 Reply Last reply Reply Quote 0
                              • W
                                wc_sumpton @Jason Green-Lowe last edited by

                                @jason-green-lowe

                                May need a condition to activate. TripleA engine can sometimes be tricky about such things.

                                 <attachment name="conditionAttachment_AlwaysTrue" attachTo="Germans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                                   <option name="switch" value="true"/>
                                </attachment>
                                

                                Nice thing about a switch is it can be referenced by all players.

                                Cheers...

                                Jason Green-Lowe 1 Reply Last reply Reply Quote 2
                                • Jason Green-Lowe
                                  Jason Green-Lowe @wc_sumpton last edited by

                                  @wc_sumpton Amazing. That does it! Railroads are now appearing and disappearing on schedule. You've made the trains run on time...thank you. 🙂

                                  f2a552dd-3590-4d63-b159-2f37ca730aaa-image.png

                                  W B 2 Replies Last reply Reply Quote 3
                                  • W
                                    wc_sumpton @Jason Green-Lowe last edited by

                                    @jason-green-lowe
                                    👍

                                    Cheers...

                                    1 Reply Last reply Reply Quote 0
                                    • B
                                      beelee @Jason Green-Lowe last edited by

                                      @jason-green-lowe that's a cool lookin map. Is that the blood bath one ?

                                      Jason Green-Lowe 1 Reply Last reply Reply Quote 1
                                      • Jason Green-Lowe
                                        Jason Green-Lowe @beelee last edited by

                                        @beelee Yup!

                                        B 1 Reply Last reply Reply Quote 1
                                        • B
                                          beelee @Jason Green-Lowe last edited by

                                          @jason-green-lowe sweet never seen it on triplea before. Nice job. Look forward to checkin it out

                                          1 Reply Last reply Reply Quote 1
                                          • 1 / 1
                                          • First post
                                            Last post
                                          Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums