Navigation

    TripleA Logo

    TripleA Forum

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

    Cannot cast TriggerAttachment to RulesAttachment

    Map Making
    3
    7
    455
    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'm getting a new (to me) error message for one of my custom triggers, and I don't understand what it means or how to fix it.

      The error message is:
      Could not parse:file:///C:/Users/jason/triplea/downloadedMaps/bbr5/games/bbr5.xml, map name: 'file:///C:/Users/jason/triplea/downloadedMaps/bbr5/games/bbr5.xml', Unexpected Exception while setting values for attachment: TriggerAttachment attached to: PlayerId named:Germans with name: triggerAttachment_Germans_AttemptMatureTech_0, Cannot cast games.strategy.triplea.attachments.TriggerAttachment to games.strategy.triplea.attachments.RulesAttachment java.lang.ClassCastException: Cannot cast games.strategy.triplea.attachments.TriggerAttachment to games.strategy.triplea.attachments.RulesAttachment

      fe6f979d-22ab-4b40-af61-e0dd02a1303d-image.png

      The code triggering this error is:

          <attachment foreach="$MatureTechDice$:$MatureTechOdds$^$AllTechPlayers$" name="triggerAttachment_@AllTechPlayers@_AttemptMatureTech_@MatureTechDice@" attachTo="@AllTechPlayers@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            <option name="chance" value="@MatureTechOdds@:100"/>
            <option name="trigger" value="triggerAttachment_@AllTechPlayers@_DiscoverTech"/>
            <option name="trigger" value="triggerAttachment_@AllTechPlayers@_ClearTech"/>
          </attachment>
      

      Note that MatureTechDice and MatureTechOdds are each a <variableList> containing 11 variables, each of which is a string containing a positive integer, and AllTechPlayers is a <variableList> containing 8 variables, each of which is a string containing the name of a player.

      This is a relatively complicated trigger, with double-nesting, but I have not had any problems with this type of nesting elsewhere in my code, and I don't understand what's going wrong here.

      Does anyone have any advice?

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

        Try swapping these around so AllTechPlayers is first. IIRC it matters that the paired variables lists must be the second set.

        "$AllTechPlayers$^$MatureTechDice$:$MatureTechOdds$"

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

          @thedog Thanks, but I tried that already -- got the same error message.

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

            It doesn't seem to be a problem with the foreach mapping at all -- I get the same error message when I remove all the variables:

                <attachment name="triggerAttachment_Germans_AttemptMatureTech_2" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                  <option name="chance" value="2:100"/>
                  <option name="trigger" value="triggerAttachment_Germans_DiscoverTech"/>
                  <option name="trigger" value="triggerAttachment_Germans_ClearTech"/>
                </attachment>
            
            1 Reply Last reply Reply Quote 0
            • Jason Green-Lowe
              Jason Green-Lowe last edited by

              The immediate problem was that I can't use "trigger" inside a triggerAttachment; the correct syntax is "activateTrigger."

              However, I'm still getting an error message, although now it's a new error message. Here's the relevant code:

               <attachment foreach="$AllTechPlayers$^$Technologies$" name="triggerAttachment_@AllTechPlayers@_DiscoverTech" attachTo="@AllTechPlayers@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                        <option name="conditions" value="conditionAttachment_@AllTechPlayers@_IsDeveloping_@Technologies@"/>
                        <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_@AllTechPlayers@_HasDeveloped_@Technologies@"/>
                        <option name="playerProperty" value="switch" count="true"/>
                  </attachment>
              
              <attachment foreach="$AllTechPlayers$^$Technologies$" name="triggerAttachment_@AllTechPlayers@_ClearTech" attachTo="@AllTechPlayers@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                        <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_@AllTechPlayers@_IsDeveloping_@Technologies@"/>
                        <option name="playerProperty" value="switch" count="false"/>
                        <option name="removeUnits" value="all:tech_token" count="50"/>
                  </attachment>
              
              <attachment foreach="$AllTechPlayers$^$Technologies$" name="triggerAttachment_@AllTechPlayers@_AttemptMatureTech" attachTo="@AllTechPlayers@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                        <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_@AllTechPlayers@_HasDeveloped_@Technologies@"/>
                        <option name="playerProperty" value="switch" count="true"/>
                  </attachment>
                  
                  <attachment foreach="$AllTechPlayers$^$MatureTechDice$:$MatureTechOdds$" name="triggerAttachment_@AllTechPlayers@_AttemptMatureTech_@MatureTechDice@" attachTo="@AllTechPlayers@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                    <option name="chance" value="@MatureTechOdds@:100"/>    
                    <option name="activateTrigger" value="triggerAttachment_@AllTechPlayers@_DiscoverTech"/>
                    <option name="activateTrigger" value="triggerAttachment_@AllTechPlayers@_ClearTech"/>
                    
                  </attachment>
                  
                  <attachment foreach="$AllTechPlayers$^$MatureTechDice$:$MatureTechOdds$" name="userActionAttachment_@AllTechPlayers@_Choose_Mature_Tech_Effort_@MatureTechDice@" attachTo="Germans" javaClass="games.strategy.triplea.attachments.UserActionAttachment" type="player">
                    <option name="conditions" value="conditionAttachment_@AllTechPlayers@_HasFourTechTokens:conditionAttachment_@AllTechPlayers@_TechActionNotYetUsedThisTurn"/>
                    <option name="activateTrigger" value="triggerAttachment_@AllTechPlayers@_AttemptMatureTech_@MatureTechDice@:1:false:false:false:false"/>
                    <option name="activateTrigger" value="triggerAttachment_@AllTechPlayers@_TechActionUsed:1:false:false:false:false"/>
                    <option name="text" value="BUY_TECH_@MatureTechDice@"/>
                    <option name="attemptsPerTurn" value="1"/>
                    <option name="costPU" value="@MatureTechDice@"/>
                  </attachment>
              

              And here's the error message:

              Could not parse:file:///C:/Users/jason/triplea/downloadedMaps/bbr5/games/bbr5.xml, map name: 'file:///C:/Users/jason/triplea/downloadedMaps/bbr5/games/bbr5.xml', Unexpected Exception while setting values for attachment: TriggerAttachment attached to: PlayerId named:Germans with name: triggerAttachment_Germans_AttemptMatureTech_0, failed to set string property value to 'triggerAttachment_Germans_DiscoverTech' games.strategy.engine.data.MutableProperty$InvalidValueException: failed to set string property value to 'triggerAttachment_Germans_DiscoverTech'

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

                @jason-green-lowe

                Try completing "activateTrigger":

                <attachment foreach="$AllTechPlayers$^$MatureTechDice$:$MatureTechOdds$" name="triggerAttachment_@AllTechPlayers@_AttemptMatureTech_@MatureTechDice@" attachTo="@AllTechPlayers@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                      <option name="chance" value="@MatureTechOdds@:100"/>    
                      <option name="activateTrigger" value="triggerAttachment_@AllTechPlayers@_DiscoverTech:1:false:false:false:false"/>
                      <option name="activateTrigger" value="triggerAttachment_@AllTechPlayers@_ClearTech:1:false:false:false:false"/>
                </attachment>
                

                Cheers...

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

                  @wc_sumpton said in Cannot cast TriggerAttachment to RulesAttachment:

                  :1:false:false:false:false

                  Eeey, there we go, that works. Thank you! 🙂

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