TripleA Logo TripleA Forum
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags
    • Register
    • Login

    Roll a die and activate different triggers based on the result?

    Scheduled Pinned Locked Moved Map Making
    6 Posts 2 Posters 916 Views 2 Watching
    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-LoweJ Offline
      Jason Green-Lowe
      last edited by

      I'm trying to simulate Russian Lend-Lease rules from BBR in TripleA. According to those rules, if Russia owns Archangel then it should roll one die and then receive different units in Archangel depending on the result of the roll -- an artillery for a 1, a tank for a 2, a fighter for a 3, and so on.

      I have worked out the arithmetic for the "chance" option; if the first result has a 1:6 chance, and the second result has a 1:5 chance (but only if the first result was not triggered), the third result has a 1:4 chance (but only if neither of the first two results were triggered), and so on, then I can simulate a fair die roll.

      What I cannot figure out how to do is how to make the second, third, fourth, fifth, and sixth triggers only fire if the first result misses. I set up "switch" options for each result, but the engine seems to be ignoring them. I tried to add a new condition for each result to force the engine to reevaluate whether the switches were true, but this does not work for me. Perhaps all the conditions are only checked once at the start of each phase, and then the engine just uses the value of those switches for the rest of the phase even if they are updated. I really would prefer to avoid having to create 12 new phases to the game (6 each for Atlantic and Pacific lend-lease) just to get these triggers checked. I also do not want to use the technology system for this, because the BBR game also has tech in it and I will want to use the tech system to model that.

      Does anyone have any suggestions? The relevant code is below.

      <attachment name="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Available" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="directOwnershipTerritories" value="Archangel:Moscow" count="2"/>
                <option name="atWarPlayers" value="Germans:Italians" count="1"/>
              </attachment>
          
              <attachment name="conditionAttachment_Russians_1a_Atlantic_Lend_Lease_Missed" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="switch" value="true"/>
              </attachment> 
              <attachment name="conditionAttachment_Russians_1b_Atlantic_Lend_Lease_Missed" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="switch" value="true"/>
              </attachment> 
              <attachment name="conditionAttachment_Russians_1c_Atlantic_Lend_Lease_Missed" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="switch" value="true"/>
              </attachment> 
              <attachment name="conditionAttachment_Russians_1d_Atlantic_Lend_Lease_Missed" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="switch" value="true"/>
              </attachment> 
              <attachment name="conditionAttachment_Russians_1e_Atlantic_Lend_Lease_Missed" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="switch" value="true"/>
              </attachment> 
      
              
              
          
          
              <attachment name="conditionAttachment_Russians_1a_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="conditions" value="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Available"/>
              </attachment> 
              <attachment name="triggerAttachment_Russians_1a_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="trigger" value="conditionAttachment_Russians_1a_Atlantic_Lend_Lease_Delivery"/>
                <option name="chance" value="1:6"/>
                <option name="placement" value="Archangel:artillery" count="1"/>
                <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_Russians_1a_Atlantic_Lend_Lease_Missed"/>
                <option name="playerProperty" value="switch" count="false"/>       
              </attachment>
          
              <attachment name="conditionAttachment_Russians_1b_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="conditions" value="conditionAttachment_Russians_1a_Atlantic_Lend_Lease_Missed"/>
              </attachment> 
              <attachment name="triggerAttachment_Russians_1b_Atlantic_Lend_Lease" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="trigger" value="conditionAttachment_Russians_1b_Atlantic_Lend_Lease_Delivery"/>
                <option name="chance" value="1:5"/>
                <option name="placement" value="Archangel:mech_infantry" count="1"/>
                <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_Russians_1b_Atlantic_Lend_Lease_Missed"/>
                <option name="playerProperty" value="switch" count="false"/>       
              </attachment>
          
              <attachment name="conditionAttachment_Russians_1c_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="conditions" value="conditionAttachment_Russians_1b_Atlantic_Lend_Lease_Missed"/>
              </attachment> 
              <attachment name="triggerAttachment_Russians_1c_Atlantic_Lend_Lease" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="trigger" value="conditionAttachment_Russians_1c_Atlantic_Lend_Lease_Delivery"/>
                <option name="chance" value="1:4"/>
                <option name="placement" value="Archangel:armour" count="1"/>
                <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_Russians_1c_Atlantic_Lend_Lease_Missed"/>
                <option name="playerProperty" value="switch" count="false"/>       
              </attachment>
          
              <attachment name="conditionAttachment_Russians_1d_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="conditions" value="conditionAttachment_Russians_1c_Atlantic_Lend_Lease_Missed"/>
              </attachment> 
              <attachment name="triggerAttachment_Russians_1d_Atlantic_Lend_Lease" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="trigger" value="conditionAttachment_Russians_1c_Atlantic_Lend_Lease_Delivery"/>
                <option name="chance" value="1:3"/>
                <option name="placement" value="Archangel:artillery" count="2"/>
                <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_Russians_1d_Atlantic_Lend_Lease_Missed"/>
                <option name="playerProperty" value="switch" count="false"/>       
              </attachment>
          
              <attachment name="conditionAttachment_Russians_1e_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="conditions" value="conditionAttachment_Russians_1d_Atlantic_Lend_Lease_Missed"/>
              </attachment> 
              <attachment name="triggerAttachment_Russians_1e_Atlantic_Lend_Lease" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="trigger" value="conditionAttachment_Russians_1e_Atlantic_Lend_Lease_Delivery"/>
                <option name="chance" value="1:2"/>
                <option name="placement" value="Archangel:fighter" count="1"/>
                <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_Russians_1e_Atlantic_Lend_Lease_Missed"/>
                <option name="playerProperty" value="switch" count="false"/>       
              </attachment>
      
              <attachment name="conditionAttachment_Russians_1f_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="conditions" value="conditionAttachment_Russians_1e_Atlantic_Lend_Lease_Missed"/>
              </attachment> 
              <attachment name="triggerAttachment_Russians_1f_Atlantic_Lend_Lease" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="trigger" value="conditionAttachment_Russians_1e_Atlantic_Lend_Lease_Delivery"/>
                <option name="placement" value="Archangel:artillery" count="1"/>
                <option name="placement" value="Archangel:armour" count="1"/>
              </attachment>
      
      wc_sumptonW 1 Reply Last reply Reply Quote 0
      • wc_sumptonW Offline
        wc_sumpton
        last edited by

        @Jason-Green-Lowe

        You are right in assuming that triggers in a given phase fire simultaneously. If you could split up the firing times, after combat, prior to non-combat movement, etc... then everything should work fine. Also 1 switch will do .

        If changing when the fire is not an option, then have each trigger place a 'invisible token', then have triggers check for their token. If token 1 is there, then place those units. If token 2 is there, and not token 1, then place those units. etc...

        Hope this gives you something to work with.

        Cheers...

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

          @jason-green-lowe

          This post made in error. Network going in and out.

          Cheers...

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

            @wc_sumpton Thanks! I tried reorganizing the code around placing tokens, and it is now mostly working. The one part that isn't working is the blockade rule. If there is a ship in the lend-lease sea zone, then there should be a 50% chance that lend-lease fails and no lend-lease at all is provided. However, the relevant trigger

            name="triggerAttachment_Russians_1_Atlantic_Lend_Lease_Blocked_Once"
            

            is not firing at all, not even to roll a die, and I don't understand why not. Any advice?

                    <attachment name="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Possible" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                      <option name="directOwnershipTerritories" value="Archangel:Moscow" count="2"/>
                      <option name="atWarPlayers" value="Germans:Italians" count="1"/>
                    </attachment>
                
                    <attachment name="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Not_Sunk" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                      <option name="switch" value="true"/>
                    </attachment>
                    
                    <attachment name="conditionAttachment_Russians_1_Atlantic_Convoy_Blocked_Once" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                      <option name="enemyPresenceTerritories" value="Sea Zone 126" count="1"/>
                      <option name="unitPresence" value="battleship:carrier:submarine:destroyer:cruiser" count="1"/>
                    </attachment>
                    <attachment name="triggerAttachment_Russians_1_Atlantic_Lend_Lease_Blocked_Once" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                      <option name="trigger" value="conditionAttachment_Russians_1_Atlantic_Convoy_Blocked_Once"/>
                      <option name="chance" value="1:2"/>
                      <option name="when" value="before:russiansNonCombatMove"/>          
                      <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Not_Sunk"/>
                      <option name="playerProperty" value="switch" count="false"/>       
                    </attachment>
                    
                    <attachment name="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Delivery" attachTo="Russians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                      <option name="conditions" value="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Possible:conditionAttachment_Russians_1_Atlantic_Lend_Lease_Not_Sunk"/>
                    </attachment> 
                
                    <attachment name="triggerAttachment_Russians_1a_Atlantic_Lend_Lease_Token" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                      <option name="trigger" value="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Delivery"/>
                      <option name="chance" value="1:6"/>
                      <option name="when" value="after:russiansNonCombatMove"/>
                      <option name="placement" value="Sea Zone 121:token" count="1"/>
                    </attachment>
            
            wc_sumptonW 1 Reply Last reply Reply Quote 0
            • wc_sumptonW Offline
              wc_sumpton @Jason Green-Lowe
              last edited by

              @jason-green-lowe

              I do not see anything wrong with the code. All I would change is placing the conditions from the last conditionsAttachment in to the last trigger.:

              <attachment name="triggerAttachment_Russians_1a_Atlantic_Lend_Lease_Token" attachTo="Russians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                 <option name="trigger" value="conditionAttachment_Russians_1_Atlantic_Lend_Lease_Possible:conditionAttachment_Russians_1_Atlantic_Lend_Lease_Not_Sunk"/>
                 <option name="chance" value="1:6"/>
                 <option name="when" value="after:russiansNonCombatMove"/>
                 <option name="placement" value="Sea Zone 121:token" count="1"/>
              </attachment>
              

              For the first trigger to fire, there needs to be units in 'Sea Zone 126', and they must be enemies of Russia, not natural.

              Cheers...

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

                @wc_sumpton Lol, yes, you've found the problem. There's nothing wrong with the code, but I put the enemy ships in Sea Zone 127 while I was testing, instead of Sea Zone 126. If I put the ships in the correct zone, everything works exactly as intended. Anyway, thanks again for all the support. 🙂

                1 Reply Last reply Reply Quote 1

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1 / 1
                • First post
                  Last post
                Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums