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

    Limit total number of Chinese fighters?

    Scheduled Pinned Locked Moved Maps & Mods
    4 Posts 2 Posters 1.3k 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 building a map where China produces units mostly based on territories it controls, as in WW2v3, using the ProductionPerXTerritories. However, I've added a national objective that gives China a fighter each turn if America controls a suitable port (e.g. Manila, Guam, Fukien, etc.) to deliver that fighter. I want to cap the total number of Chinese fighters on the map at a time at 2.

      I'm not sure how to do this using a sane number of lines of code -- maxBuiltPerPlayer doesn't work because that cap triggers when you try to purchase a unit in the purchase phase, which is bypassed by the "purchase" instruction in my national objective. placementLimit doesn't work, because it only stops you from stacking 3+ fighters in the same territory; it won't stop you from placing one fighter in each Chinese territory. directPresenceTerritories plus invert doesn't work for the same reason.

      Anyone have any suggestions?

      823cb474-90d1-4653-8a32-afc64a9654a7-image.png

      Relevant code is below:

      	<attachment name="conditionAttachmentFlyingTigersAvail" attachTo="Chinese" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
            <option name="alliedOwnershipTerritories" value="Western United States:Hawaiian Islands:Szechuan" count="3"/>
            <option name="alliedOwnershipTerritories" value="Fukien:Indochina:Kwangtung:Formosa:Philippine Islands:Okinawa:Guam" count="1"/>
          </attachment>
      	
      	<attachment name="objectiveAttachment2" attachTo="Chinese" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
            <option name="conditions" value="conditionAttachmentFlyingTigers"/>
          </attachment>
          <attachment name="triggerAttachmentFlyingTigers" attachTo="Chinese" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            <option name="conditions" value="conditionAttachmentFlyingTigers"/>
            <option name="when" value="before:chinesePurchase"/>
      	  <option name="purchase" value="flyingTiger" count="1"/>
          </attachment>	
      
          <attachment name="unitAttachment" attachTo="flyingTiger" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
            <option name="movement" value="4"/>
            <option name="carrierCost" value="1"/>
            <option name="isAir" value="true"/>
            <option name="attack" value="3"/>
            <option name="defense" value="4"/>
            <option name="canIntercept" value="true"/>
            <option name="canEscort" value="true"/>
            <option name="airDefense" value="1"/>
            <option name="airAttack" value="1"/>
      	  <option name='maxBuiltPerPlayer' value='2'/>
      	</attachment>
      
          <attachment name="rulesAttachment" attachTo="Chinese" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
            <option name="movementRestrictionTerritories" value="Xinjiang:Chinghai:Ningxia:Tibet:Szechuan:Yunnan:Fukien:Suiyuan:Henan:Hubei:Hunan:Manchuria:Hulunbuir:Korea:Kiangsu:Kwangtung:Burma:Thailand:Indochina:Malaya"/>
            <option name="movementRestrictionType" value="allowed"/>
            <option name="productionPerXTerritories" value="2"/>
            <option name="placementAnyTerritory" value="true"/>
            <option name="placementCapturedTerritory" value="true"/>
            <option name="placementPerTerritory" value="4"/>
          </attachment>
      
      wc_sumptonW 1 Reply Last reply Reply Quote 0
      • wc_sumptonW Offline
        wc_sumpton @Jason Green-Lowe
        last edited by wc_sumpton

        @jason-green-lowe

        In this case you will have to create 2 counts, one to check for 2 fighters in one territory, and one to check for 1 fighter in 2 territories. Since these will be "and conditions" they can be place as a condition.

        <attachment name="conditionAttachmentFlyingTigersAvail" attachTo="Chinese" javaClass="RulesAttachment" type="player">
           <option name="alliedOwnershipTerritories" value="Western United States:Hawaiian Islands:Szechuan" count="3"/>
           <option name="alliedOwnershipTerritories" value="Fukien:Indochina:Kwangtung:Formosa:Philippine Islands:Okinawa:Guam" count="1"/>
        </attachment>
        
        <attachment name="conditionAttachment2FlyingTigersIn1" attachTo="Chinese" javaClass="RulesAttachment" type="player">
           <option name="conditions" value="conditionAttachmentFlyingTigersAvail"/>
           <option name="directPresenceTerritories" value="@ChinaTerritories@" count="2"/>
           <option name="unitPresence" value="flyingTiger" count="1"/>
           <option name="invert" value="true"/>
        </attachment>
        
        <attachment name="conditionAttachment1FlyingTigersIn2" attachTo="Chinese" javaClass="RulesAttachment" type="player">
           <option name="conditions" value="conditionAttachment2FlyingTigersIn1"/>
           <option name="directPresenceTerritories" value="@ChinaTerritories@" count="2"/>
           <option name="unitPresence" value="flyingTiger" count="1"/>
           <option name="invert" value="true"/>
        </attachment>
        

        Because all the conditions are chained together, only the last condition needs to be checked for the trigger.

        Hope this helps.

        Cheers...

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

          @wc_sumpton Brilliant, thanks! Works great. I swear I tried hard to think of this on my own and couldn't, but it seems so obvious once you point it out.

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

            @jason-green-lowe said in Limit total number of Chinese fighters?:

            I swear I tried hard to think of this on my own and couldn't, but it seems so obvious once you point it out.

            I have said the same thing! @beelee, @TheDog and many others have pointed stuff out to me, and I'll just go "WOW! I could have had a V8!" (Head-slap emoji)

            Cheers...

            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