Skip to content

Commit

Permalink
Update rules and fix a backwards comparison in the snapshot diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
jt-traub committed May 3, 2024
1 parent afe85f1 commit 900190a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 110 deletions.
45 changes: 20 additions & 25 deletions genrules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,7 @@ int Game::GenRules(const AString &rules, const AString &css, const AString &intr
<< "A Quartermaster unit may accept " << url("#transport", "TRANSPORT") << "ed items from "
<< "any unit within " << Globals->LOCAL_TRANSPORT << ' ' << plural(Globals->LOCAL_TRANSPORT, "hex", "hexes")
<< " distance from the hex containing the quartermaster. Quartermasters may also "
<< url("#distribute", "DISTRIBUTE") << " items to any unit within " << Globals->LOCAL_TRANSPORT
<< url("#transport", "TRANSPORT") << " items to any unit within " << Globals->LOCAL_TRANSPORT
<< ' ' << plural(Globals->LOCAL_TRANSPORT, "hex", "hexes") << " distance from the hex containing the "
<< "quartermaster and may " << url("#transport", "TRANSPORT") << " items to another quartermaster up to "
<< Globals->NONLOCAL_TRANSPORT << ' ' << plural(Globals->NONLOCAL_TRANSPORT, "hex", "hexes") << " distant.";
Expand Down Expand Up @@ -2754,13 +2754,13 @@ int Game::GenRules(const AString &rules, const AString &css, const AString &intr
<< (Globals->FACTION_LIMIT_TYPE == GameDefs::FACLIM_FACTION_TYPES
? ", and a faction is limited in the number of quartermasters it may have at any one time"
: "")
<< ". Both the " << url("#transport", "TRANSPORT") << " and " << url("#distribute", "DISTRIBUTE")
<< " orders count as trade activity in the hex of the unit issuing the order. The target unit must be at "
<< "least FRIENDLY to the unit which issues the order.\n"
<< ". The " << url("#transport", "TRANSPORT") << " order counts as trade activity in "
<< "the hex of the unit issuing the order. The target unit must be at least FRIENDLY "
<< "to the unit which issues the order.\n"
<< enclose("p", false);

f << enclose("p", true) << "Not all type of items can be " << url("#transport", "TRANSPORT") << "ed to "
<< "or " << url("#distribute", "DISTRIBUTE") << "d by a quartermaster. Men (including Leaders), "
<< "or " << url("#transport", "TRANSPORT") << "ed by a quartermaster. Men (including Leaders), "
<< "summoned creatures (including illusionary ones), ships, mounts, war machines, and items created "
<< "using artifact lore need to be carried/sailed from one location to another by a unit.\n"
<< enclose("p", false);
Expand Down Expand Up @@ -3893,23 +3893,6 @@ int Game::GenRules(const AString &rules, const AString &css, const AString &intr
<< "DESTROY\n"
<< example_end();

if (qm_exist) {
f << enclose(class_tag("div", "rule"), true) << '\n' << enclose("div", false);
f << anchor("distribute") << '\n';
f << enclose("h4", true) << "DISTRIBUTE [unit] [num] [item]\n" << enclose("h4", false);
f << enclose("h4", true) << "DISTRIBUTE [unit] ALL [item]\n" << enclose("h4", false);
f << enclose("h4", true) << "DISTRIBUTE [unit] ALL [item] EXCEPT [amount]\n" << enclose("h4", false);
f << enclose("p", true) << "Distribute the specified items to the given friendly unit. In the second form, "
<< "all of that item are distributed. In the last form, all of that item except for the specified amount "
<< "are distributed. The unit issuing the distribute order must have the quartermaster skill, and be the "
<< "owner of a transport structure. Use of this order counts as trade activity in the hex.\n"
<< enclose("p", false);
f << enclose("p", true) << "Examples:\n" << enclose("p", false);
f << example_start("Distribute 10 STON to unit 1234")
<< "DISTRIBUTE 1234 10 STON\n"
<< example_end();
}

f << enclose(class_tag("div", "rule"), true) << '\n' << enclose("div", false);
f << anchor("enter") << '\n';
f << enclose("h4", true) << "ENTER [object]\n" << enclose("h4", false);
Expand Down Expand Up @@ -4761,6 +4744,9 @@ int Game::GenRules(const AString &rules, const AString &css, const AString &intr
<< "unit must also be a quartermaster and be the owner of a transport structure. Use of this order "
<< "counts as trade activity in the hex.\n"
<< enclose("p", false);
f << enclose("p", true) << "For historical reasons, the order DISTRIBUTE can be "
<< "used in place of TRANSPORT and has the same meaning and syntax.\n"
<< enclose("p", false);
f << enclose("p", true) << "Examples:\n" << enclose("p", false);
f << example_start("Transport 10 STON to unit 1234")
<< "TRANSPORT 1234 10 STON\n"
Expand Down Expand Up @@ -4988,9 +4974,18 @@ int Game::GenRules(const AString &rules, const AString &css, const AString &intr
f << enclose("li", true) << "Teleportation spells are " << url("#cast", "CAST") << ".\n" << enclose("li", false);

if (qm_exist) {
f << enclose("li", true) << url("#transport", "TRANSPORT") << " and " << url("#distribute", "DISTRIBUTE")
<< " orders are processed.\n"
<< enclose("li", false);
f << enclose("li", true) << url("#transport", "TRANSPORT") << " orders are processed "
<< "in multiple phases. In each phase all units in all hexes are processed before "
<< "starting the next phase. Items may move in each of the phases but only once in each phase.\n";
f << enclose("ol", true);
f << enclose("li", true) << "Items are sent from non-quartermaster units to "
<< "quartermaster units.\n" << enclose("li", false);
f << enclose("li", true) << "Items are sent from one quartermaster unit to "
<< "another quartermaster units.\n" << enclose("li", false);
f << enclose("li", true) << "Items are sent a quartermaster unit to "
<< "non-quartermaster units.\n" << enclose("li", false);
f << enclose("ol", false);
f << enclose("li", false);
}
f << enclose("li", true) << "Maintenance costs are assessed.\n" << enclose("li", false);
f << enclose("OL", false);
Expand Down
69 changes: 27 additions & 42 deletions snapshot-tests/rules/fracas.html
Original file line number Diff line number Diff line change
Expand Up @@ -3364,7 +3364,7 @@ <H3>
Trade factions may train Quartermaster units. A Quartermaster unit may
accept <a href="#transport">TRANSPORT</a>ed items from any unit within 2
hexes distance from the hex containing the quartermaster. Quartermasters
may also <a href="#distribute">DISTRIBUTE</a> items to any unit within 2
may also <a href="#transport">TRANSPORT</a> items to any unit within 2
hexes distance from the hex containing the quartermaster and may <a
href="#transport">TRANSPORT</a> items to another quartermaster up to 6
hexes distant. The distance a quartermaster can <a
Expand All @@ -3385,15 +3385,14 @@ <H3>
</p>
<p>
Quartermasters must be single man units, and a faction is limited in the
number of quartermasters it may have at any one time. Both the <a
href="#transport">TRANSPORT</a> and <a href="#distribute">DISTRIBUTE</a>
orders count as trade activity in the hex of the unit issuing the order.
The target unit must be at least FRIENDLY to the unit which issues the
order.
number of quartermasters it may have at any one time. The <a
href="#transport">TRANSPORT</a> order counts as trade activity in the
hex of the unit issuing the order. The target unit must be at least
FRIENDLY to the unit which issues the order.
</p>
<p>
Not all type of items can be <a href="#transport">TRANSPORT</a>ed to or
<a href="#distribute">DISTRIBUTE</a>d by a quartermaster. Men (including
<a href="#transport">TRANSPORT</a>ed by a quartermaster. Men (including
Leaders), summoned creatures (including illusionary ones), ships,
mounts, war machines, and items created using artifact lore need to be
carried/sailed from one location to another by a unit.
Expand Down Expand Up @@ -5379,39 +5378,6 @@ <h4>
</pre>
<div class="rule">

</div>
<a name="distribute"></a>
<h4>
DISTRIBUTE [unit] [num] [item]
</h4>
<h4>
DISTRIBUTE [unit] ALL [item]
</h4>
<h4>
DISTRIBUTE [unit] ALL [item] EXCEPT [amount]
</h4>
<p>
Distribute the specified items to the given friendly unit. In the second
form, all of that item are distributed. In the last form, all of that
item except for the specified amount are distributed. The unit issuing
the distribute order must have the quartermaster skill, and be the owner
of a transport structure. Use of this order counts as trade activity in
the hex.
</p>
<p>
Examples:
</p>
<p>
Distribute 10 STON to unit 1234
</p>
<p>

</p>
<pre>
DISTRIBUTE 1234 10 STON
</pre>
<div class="rule">

</div>
<a name="enter"></a>
<h4>
Expand Down Expand Up @@ -6889,6 +6855,10 @@ <h4>
transport structure. Use of this order counts as trade activity in the
hex.
</p>
<p>
For historical reasons, the order DISTRIBUTE can be used in place of
TRANSPORT and has the same meaning and syntax.
</p>
<p>
Examples:
</p>
Expand Down Expand Up @@ -7274,8 +7244,23 @@ <h2>
Teleportation spells are <a href="#cast">CAST</a>.
</li>
<li>
<a href="#transport">TRANSPORT</a> and <a
href="#distribute">DISTRIBUTE</a> orders are processed.
<a href="#transport">TRANSPORT</a> orders are processed in multiple
phases. In each phase all units in all hexes are processed before
starting the next phase. Items may move in each of the phases but
only once in each phase.
<ol>
<li>
Items are sent from non-quartermaster units to quartermaster
units.
</li>
<li>
Items are sent from one quartermaster unit to another
quartermaster units.
</li>
<li>
Items are sent a quartermaster unit to non-quartermaster units.
</li>
</ol>
</li>
<li>
Maintenance costs are assessed.
Expand Down
69 changes: 27 additions & 42 deletions snapshot-tests/rules/neworigins.html
Original file line number Diff line number Diff line change
Expand Up @@ -3755,7 +3755,7 @@ <H3>
Trade factions may train Quartermaster units. A Quartermaster unit may
accept <a href="#transport">TRANSPORT</a>ed items from any unit within 2
hexes distance from the hex containing the quartermaster. Quartermasters
may also <a href="#distribute">DISTRIBUTE</a> items to any unit within 2
may also <a href="#transport">TRANSPORT</a> items to any unit within 2
hexes distance from the hex containing the quartermaster and may <a
href="#transport">TRANSPORT</a> items to another quartermaster up to 3
hexes distant. The distance a quartermaster can <a
Expand All @@ -3776,15 +3776,14 @@ <H3>
</p>
<p>
Quartermasters must be single man units, and a faction is limited in the
number of quartermasters it may have at any one time. Both the <a
href="#transport">TRANSPORT</a> and <a href="#distribute">DISTRIBUTE</a>
orders count as trade activity in the hex of the unit issuing the order.
The target unit must be at least FRIENDLY to the unit which issues the
order.
number of quartermasters it may have at any one time. The <a
href="#transport">TRANSPORT</a> order counts as trade activity in the
hex of the unit issuing the order. The target unit must be at least
FRIENDLY to the unit which issues the order.
</p>
<p>
Not all type of items can be <a href="#transport">TRANSPORT</a>ed to or
<a href="#distribute">DISTRIBUTE</a>d by a quartermaster. Men (including
<a href="#transport">TRANSPORT</a>ed by a quartermaster. Men (including
Leaders), summoned creatures (including illusionary ones), ships,
mounts, war machines, and items created using artifact lore need to be
carried/sailed from one location to another by a unit.
Expand Down Expand Up @@ -5778,39 +5777,6 @@ <h4>
</pre>
<div class="rule">

</div>
<a name="distribute"></a>
<h4>
DISTRIBUTE [unit] [num] [item]
</h4>
<h4>
DISTRIBUTE [unit] ALL [item]
</h4>
<h4>
DISTRIBUTE [unit] ALL [item] EXCEPT [amount]
</h4>
<p>
Distribute the specified items to the given friendly unit. In the second
form, all of that item are distributed. In the last form, all of that
item except for the specified amount are distributed. The unit issuing
the distribute order must have the quartermaster skill, and be the owner
of a transport structure. Use of this order counts as trade activity in
the hex.
</p>
<p>
Examples:
</p>
<p>
Distribute 10 STON to unit 1234
</p>
<p>

</p>
<pre>
DISTRIBUTE 1234 10 STON
</pre>
<div class="rule">

</div>
<a name="enter"></a>
<h4>
Expand Down Expand Up @@ -7329,6 +7295,10 @@ <h4>
transport structure. Use of this order counts as trade activity in the
hex.
</p>
<p>
For historical reasons, the order DISTRIBUTE can be used in place of
TRANSPORT and has the same meaning and syntax.
</p>
<p>
Examples:
</p>
Expand Down Expand Up @@ -7715,8 +7685,23 @@ <h2>
Teleportation spells are <a href="#cast">CAST</a>.
</li>
<li>
<a href="#transport">TRANSPORT</a> and <a
href="#distribute">DISTRIBUTE</a> orders are processed.
<a href="#transport">TRANSPORT</a> orders are processed in multiple
phases. In each phase all units in all hexes are processed before
starting the next phase. Items may move in each of the phases but
only once in each phase.
<ol>
<li>
Items are sent from non-quartermaster units to quartermaster
units.
</li>
<li>
Items are sent from one quartermaster unit to another
quartermaster units.
</li>
<li>
Items are sent a quartermaster unit to non-quartermaster units.
</li>
</ol>
</li>
<li>
Maintenance costs are assessed.
Expand Down
2 changes: 1 addition & 1 deletion snapshot-tests/run-rules-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rm -f ./engine-output.txt
# Clean up the Last Change: timestamp line so that comparisons can work
sed -e 's/Last Change:.*$/Last Change: __STRIPPED_FOR_COMPARISON__/' ${game}.html > ${game}.html.strip

diff -ur ${game}.html.strip rules/${game}.html &> rules-difference.txt
diff -ur rules/${game}.html ${game}.html.strip &> rules-difference.txt
if [[ $? != 0 ]]; then
echo "output differed. -- Test failed."
cat rules-difference.txt
Expand Down

0 comments on commit 900190a

Please sign in to comment.