Difference between revisions of "Testing Notepad"

From FreeOrionWiki
Jump to: navigation, search
(Chance Condition)
(added full techs.xml for chance condition case)
Line 183: Line 183:
 
===Chance Condition===
 
===Chance Condition===
  
Using this condition in an effects group scope in a tech crashes the game when the tech is clicked on in the research screen:
+
Replace techs.xml with the following:
 +
 
 +
<pre>
 +
<?xml version="1.0"?>
 +
<GG::XMLDoc>
 +
<Category>LEARNING_CATEGORY</Category>
 +
  <Tech>
 +
    <name>LRN_PHYS_BRAIN</name>
 +
    <description>LRN_PHYS_BRAIN_DESC</description>
 +
    <type>TT_THEORY</type>
 +
    <category>LEARNING_CATEGORY</category>
 +
    <research_cost>10</research_cost>
 +
    <research_turns>1</research_turns>
 +
    <effects>
 +
    <EffectsGroup>
 +
      <scope>
 +
        <Condition::Chance>
 +
          <chance>0.3</chance>
 +
        </Condition::Chance>
 +
      </scope>
 +
      <activation><Condition::Self/></activation>
 +
      <effects>
 +
        <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
 +
      </effects>
 +
    </EffectsGroup>
 +
    </effects>
 +
    <prerequisites></prerequisites>
 +
    <unlocked_items></unlocked_items>
 +
  </Tech>
 +
</GG::XMLDoc>
 +
</pre>
 +
 
 +
Run the game, open up the research screen, and click on the tech.  The game crashes.
 +
 
 +
The problem occurs when the Chance condition is used.  That is, this part of the above tech:
  
 
<pre>
 
<pre>

Revision as of 19:42, 3 May 2005

Problematic Test Cases

Primary Focus Condition: Specialized includes Balanced

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::FocusType>
           <primary>1</primary>
           <FocusType>FOCUS_RESEARCH</FocusType>
         </Condition::FocusType>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a game and set your planet's focus to Primary Balanced (and any Secondary setting). Research the tech.

The effect of the tech fires upon the planet with Primary Balanced focus (including all uninhabited planets). It also fires if the planet's focus is set to Primary Research.

The effect does not fire on Primary Farming or other non-Balanced and non-Research focus. The Secondary Focus setting does not matter.

This effect should fire only on planets with Primary Research focus. That is, the FocusType condition should not include Primary Balanced planets when the condition requesets Primary Research, Primary Farming, Primary Mining, Primary Industry or Primary Trade focus.

As well, the FocusType condition should not include uninhabited planets, regardless of the specified FocusType.

Also note that thet effect description text (appears below tech description on research screen) says the scope include primary balanced or primary research planets. This text should not be shown as is, but should be replaced with an optional effects desription text in the stringtable, perhaps as part of the tech description entry.

Secondary Focus Condition: Functions as Primary

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::FocusType>
           <primary>0</primary>
           <FocusType>FOCUS_RESEARCH</FocusType>
         </Condition::FocusType>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a game and set your planet's focus to Primary Farming and Secondary Research. Research the tech, and end turn a few times to give the effect a chance to fire. It does not fire. Change the planet focus to Primary Research and Secondary Farming. End the turn. The effect fires, changing the planet's environment to Gaia.

The effect only fires on Primary Research focused worlds. The Secondary focus setting does not matter.

The effect should fire on Secondary Research focused worlds, and the Primary focus setting should not matter. That is, the FocusType condition should include Secondary Research focused planets, and not include other planets whose Secondary focus is not Research, when the specified focus is Secondary Research

Also note that thet effect description text (appears below tech description on research screen) says the scope include primary focus unknown or research. As above, this text should not be shown as is, and should be replaced with something from the stringtable.

Changing PlanetType of Gas Giants / Asteroids

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::Type>OBJ_POP_CENTER</Condition::Type>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a new game. Find a gas giant or asteroid belt planet. Research the tech.

On the turn the tech is researched, nothing happens. This is standard for all tech effects, so may not be a bug, but IMO it would be better if techs took effect the turn they were reserached, rather than the turn after.

End the turn. Once.

The effect fires on all planets, turning them into Gaia planets.

The MaxPopulation of planets is not updated this turn. It is still what it was for the previous planet environment. Even if effects take a turn to work, once they do, any consequences to things like MaxPopulation need to happen the same turn as the change that should cause the consequence.

End the turn again.

The MaxPopulation of most planets updates, but the MaxPopulation of planets the used to be Gas Giants or Asteroid Belts does not update. This is probably because the PlanetSize for these planets is still SZ_ASTEROIDS or SZ_GASGIANT.

IMO this should not happen, and it should not have to be checked for with special conditions in an effect. I suggest treating planets of size SZ_ASTEROIDS as the smallest planet size, and SZ_GASGIANT as the largest planet size. Keep the size parameter what it was before though... it might be useful.


Setting MaxPopulation of Gas Giants / Asteriods

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>

 <Category>LEARNING_CATEGORY</Category>

  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::All/>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetMeter>
           <meter>METER_POPULATION</meter>
           <value>Target.MaxPopulation + 1</value>
           <max>1</max>
         </Effect::SetMeter>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a new game, and research the tech. Find a gas giant or asteroid belt planet and colonize it (it should have MaxPopulation = 1 due to the effect). The colony starves to death on the next turn, even if you had enough food surplus available to feed it.


Chance Condition

Replace techs.xml with the following:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::Chance>
          <chance>0.3</chance>
         </Condition::Chance>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Run the game, open up the research screen, and click on the tech. The game crashes.

The problem occurs when the Chance condition is used. That is, this part of the above tech:

<Condition::Chance>
  <chance>0.3</chance>
</Condition::Chance>

The error in the text window is:

1115148965 ERROR  : main() caught exception(boost::io::format_error): boost::bad
_format_string: format-string is ill-formed

Working Effects and Conditions

The following effects and conditions seem to be working:

  • <Condition::And>
  • <Condition::StarType>
    • STAR_YELLOW
    • STAR_ORANGE
  • <Condition::Type>
    • OBJ_PLANET
    • OBJ_SHIP
  • <Condition::Self/>
    • Home planet of race that knows a tech
  • Destroy
    • On planets
  • SetPlanetType
    • On habitable environments to other habitable environments (Not involving Gas Giant or Asteroids)
  • <Effect::SetMeter>
    • METER_POPULATION, max value, except for previously uninhabitable planets
  • <Condition::WithinDistance>