forked from github/server
Merge branch 'develop'
This commit is contained in:
commit
0dc4027984
|
@ -1,6 +1,3 @@
|
||||||
[submodule "lunit"]
|
|
||||||
path = lunit
|
|
||||||
url = https://github.com/ennorehling/lunit.git
|
|
||||||
[submodule "dlmalloc"]
|
[submodule "dlmalloc"]
|
||||||
path = dlmalloc
|
path = dlmalloc
|
||||||
url = https://github.com/ennorehling/dlmalloc.git
|
url = https://github.com/ennorehling/dlmalloc.git
|
||||||
|
|
|
@ -17,6 +17,7 @@ addons:
|
||||||
- valgrind
|
- valgrind
|
||||||
- cppcheck
|
- cppcheck
|
||||||
- shellcheck
|
- shellcheck
|
||||||
|
- luarocks
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
notifications:
|
notifications:
|
||||||
|
|
|
@ -48,8 +48,12 @@ endif()
|
||||||
find_package(EXPAT REQUIRED)
|
find_package(EXPAT REQUIRED)
|
||||||
find_package (ToLua REQUIRED)
|
find_package (ToLua REQUIRED)
|
||||||
if (TOLUA_FOUND)
|
if (TOLUA_FOUND)
|
||||||
if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
|
if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.3")
|
||||||
|
find_package (Lua 5.3 REQUIRED)
|
||||||
|
elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
|
||||||
find_package (Lua 5.2 REQUIRED)
|
find_package (Lua 5.2 REQUIRED)
|
||||||
|
elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.3")
|
||||||
|
find_package ( Lua 5.3 REQUIRED)
|
||||||
else ()
|
else ()
|
||||||
find_package (Lua51 REQUIRED)
|
find_package (Lua51 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Befehlsverarbeitung in Eressea
|
||||||
|
|
||||||
|
Einheiten haben zwei Listen von Befehlen: orders und old_orders.
|
||||||
|
|
||||||
|
1. `read_unit`: Aus dem Datenfile gelesene (Default-)Befehl der Vorwoche werden in u->orders gespeichert.
|
||||||
|
2. `begin_orders`: Wenn die Einheit neue Befehle erhält, werden "wiederholbare" Befehle (Handel, lange Befehle ausser NACH) aus u->orders nach u->old_orders kopiert.
|
||||||
|
3. `unitorders`: Die neuen Befehle werden in u->orders gelesen.
|
||||||
|
4. `update_long_order`: u->thisorder wird auf den ersten "langen" Befehl in u->orders gesetzt.
|
||||||
|
5. Auswertung: Für lange Befehle wird in u->thisorder geschaut, für kurze und andere (inkl. KAUFE/ATTACKIERE) in u->orders.
|
||||||
|
6. `movement`: NACH löscht u->thisorder, damit es nicht bei Auswertung der Zielregion ein zweites Mal ausgeführt werden kann. Das hat allerdings keine Auswirkung auf die beiden Listen.
|
||||||
|
7. `build_building`: Wenn ein MACHE GEBAEUDE Befehl "fertig" ist, wird der Befehl in u->orders durch ein ARBEITE ersetzt (aber u->thisorder nicht geändert, das sollte also nichts tun).
|
||||||
|
8. `defaultorders`: Nach allen langen Befehlen wird der DEFAULT Befehl gesetzt. Dieser löscht zuerst alle nicht-kurzen Befehle aus u->orders und u->old_orders, und hängt dann den neuen Befehl in u->old_orders an.
|
||||||
|
9.1: `cr_output_unit`: In den CR werden alle "dauerhaften" Befehle aus u->old_orders geschrieben, d.h. kurze Befehle mit @ Prefix, Kommentare mit // und lange Befehle ausser NACH.
|
||||||
|
9.2: `cr_output_unit`: In den CR werden alle "dauerhaften" Befehle aus u->orders geschrieben, d.h. kurze Befehle mit @ Prefix, Kommentare mit // und lange Befehle ausser NACH. Wenn u->old_orders nicht leer ist, werden "wiederholbare" Befehle dabei ignoriert.
|
||||||
|
|
1
lunit
1
lunit
|
@ -1 +0,0 @@
|
||||||
Subproject commit 155c96594435413b4f704eb17558ea0b70631bad
|
|
|
@ -3,6 +3,7 @@
|
||||||
[ "$PREVIEW" != "yes" ] && exit
|
[ "$PREVIEW" != "yes" ] && exit
|
||||||
[ -z "${ERESSEA}" ] && ERESSEA="$HOME/eressea"
|
[ -z "${ERESSEA}" ] && ERESSEA="$HOME/eressea"
|
||||||
|
|
||||||
|
eval $(luarocks path)
|
||||||
branch="develop"
|
branch="develop"
|
||||||
if [ -e "${ERESSEA}/build/.preview" ]; then
|
if [ -e "${ERESSEA}/build/.preview" ]; then
|
||||||
branch=$(cat "${ERESSEA}/build/.preview")
|
branch=$(cat "${ERESSEA}/build/.preview")
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
eval $(luarocks path)
|
||||||
GAME=$1
|
GAME=$1
|
||||||
(
|
(
|
||||||
[ "$ENABLED" != "yes" ] && exit
|
[ "$ENABLED" != "yes" ] && exit
|
||||||
|
|
|
@ -17,8 +17,6 @@ fi
|
||||||
cd "$GAME/reports" || exit
|
cd "$GAME/reports" || exit
|
||||||
for REPORT in *.sh
|
for REPORT in *.sh
|
||||||
do
|
do
|
||||||
#echo -n "Sending "
|
|
||||||
#basename "$REPORT" .sh
|
|
||||||
bash "$REPORT"
|
bash "$REPORT"
|
||||||
done
|
done
|
||||||
cd - || exit
|
cd - || exit
|
||||||
|
|
|
@ -391,16 +391,6 @@
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
<message name="curseinfo::godcurseocean" section="events">
|
|
||||||
<type>
|
|
||||||
<arg name="id" type="int"/>
|
|
||||||
</type>
|
|
||||||
</message>
|
|
||||||
<message name="curseinfo::godcurse" section="events">
|
|
||||||
<type>
|
|
||||||
<arg name="id" type="int"/>
|
|
||||||
</type>
|
|
||||||
</message>
|
|
||||||
<message name="curseinfo::disorientationzone" section="events">
|
<message name="curseinfo::disorientationzone" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
|
@ -712,11 +702,6 @@
|
||||||
<arg name="password" type="string"/>
|
<arg name="password" type="string"/>
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
<message name="godcurse_destroy_ship" section="events">
|
|
||||||
<type>
|
|
||||||
<arg name="ship" type="ship"/>
|
|
||||||
</type>
|
|
||||||
</message>
|
|
||||||
<message name="skillpotion_use" section="events">
|
<message name="skillpotion_use" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
|
@ -2690,6 +2675,70 @@
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message name="error321" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="error322" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="error323" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="error324" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="error325" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="error326" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="error327" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="error328" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
|
||||||
<message name="error319" section="errors">
|
<message name="error319" section="errors">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
|
@ -3740,6 +3789,62 @@
|
||||||
<arg name="command" type="order"/>
|
<arg name="command" type="order"/>
|
||||||
</type>
|
</type>
|
||||||
</message>
|
</message>
|
||||||
|
<message name="error321" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
<message name="error322" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
<message name="error323" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
<message name="error324" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
<message name="error325" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
<message name="error326" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
<message name="error327" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
|
<message name="error328" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
</message>
|
||||||
<message name="error181" section="errors">
|
<message name="error181" section="errors">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
|
|
|
@ -721,7 +721,7 @@
|
||||||
<attack type="4" damage="3d30"/>
|
<attack type="4" damage="3d30"/>
|
||||||
<attack type="6" spell="icy_dragonbreath" level="6" />
|
<attack type="6" spell="icy_dragonbreath" level="6" />
|
||||||
</race>
|
</race>
|
||||||
<race name="youngdragon" magres="50" maxaura="1.000000" regaura="1.000000" weight="20000" capacity="10000" speed="1.000000" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
|
<race name="youngdragon" magres="50" maxaura="1.000000" regaura="1.000000" weight="20000" capacity="10000" speed="1.000000" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes" dragon="yes">
|
||||||
<ai splitsize="6" killpeasants="yes" learn="yes" scarepeasants="yes"/>
|
<ai splitsize="6" killpeasants="yes" learn="yes" scarepeasants="yes"/>
|
||||||
<skill name="magic" modifier="4"/>
|
<skill name="magic" modifier="4"/>
|
||||||
<skill name="tactics" modifier="4"/>
|
<skill name="tactics" modifier="4"/>
|
||||||
|
|
|
@ -437,9 +437,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Pferde kann man
|
||||||
msgid "error307"
|
msgid "error307"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Snotlinge sind zu dumm, um auf den Feldern zu arbeiten.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Snotlinge sind zu dumm, um auf den Feldern zu arbeiten.\""
|
||||||
|
|
||||||
msgid "godcurse_destroy_ship"
|
|
||||||
msgstr "\"Die Mannschaft krank vom vergifteten Wasser, Planken, Ruder und Segel zerfressen von den Wassern des verfluchten Meeres, ergibt sich die $ship($ship) in ihr Schicksal und sinkt.\""
|
|
||||||
|
|
||||||
msgid "too_many_units_in_faction"
|
msgid "too_many_units_in_faction"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Eine Partei darf nicht aus mehr als $int($allowed) Einheiten bestehen.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Eine Partei darf nicht aus mehr als $int($allowed) Einheiten bestehen.\""
|
||||||
|
|
||||||
|
@ -1034,9 +1031,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Auf dem Schiff
|
||||||
msgid "sp_icastle_effect"
|
msgid "sp_icastle_effect"
|
||||||
msgstr "\"Verwundert blicken die Bauern von $region($region) auf ein neues Gebäude.\""
|
msgstr "\"Verwundert blicken die Bauern von $region($region) auf ein neues Gebäude.\""
|
||||||
|
|
||||||
msgid "curseinfo::godcurse"
|
|
||||||
msgstr "\"Diese Region wurde von den Göttern verflucht. Stinkende Nebel ziehen über die tote Erde und furchtbare Kreaturen ziehen über das Land. Die Brunnen sind vergiftet, und die wenigen essbaren Früchte sind von einem rosa Pilz überzogen. Niemand kann hier lange überleben. ($int36($id))\""
|
|
||||||
|
|
||||||
msgid "recruit_archetype"
|
msgid "recruit_archetype"
|
||||||
msgstr "\"$unit($unit) rekrutiert $int($amount) $localize($archetype).\""
|
msgstr "\"$unit($unit) rekrutiert $int($amount) $localize($archetype).\""
|
||||||
|
|
||||||
|
@ -2555,9 +2549,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Man benötigt m
|
||||||
msgid "error177"
|
msgid "error177"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Diesen Spruch kann der Vertraute nicht zaubern.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Diesen Spruch kann der Vertraute nicht zaubern.\""
|
||||||
|
|
||||||
msgid "curseinfo::godcurseocean"
|
|
||||||
msgstr "\"Diese Region wurde von den Göttern verflucht. Das Meer ist eine ekelige Brühe, braunschwarze, stinkende Gase steigen aus den unergründlichen Tiefen hervor, und untote Seeungeheuer, Schiffe zerfressend und giftige grüne Galle geifernd, sind der Schrecken aller Seeleute, die diese Gewässer durchqueren. Niemand kann hier lange überleben. ($int36($id))\""
|
|
||||||
|
|
||||||
msgid "curseinfo::sparkle_4"
|
msgid "curseinfo::sparkle_4"
|
||||||
msgstr "\"Ein schimmernder Lichterkranz umgibt $unit($unit). ($int36($id))\""
|
msgstr "\"Ein schimmernder Lichterkranz umgibt $unit($unit). ($int36($id))\""
|
||||||
|
|
||||||
|
@ -2775,7 +2766,7 @@ msgid "error324"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit gehört nicht zu unserer Partei.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit gehört nicht zu unserer Partei.\""
|
||||||
|
|
||||||
msgid "error322"
|
msgid "error322"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Die Einheit ist bereits auf einem Schiff.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Nur Schiffe gleicher Bauart können einen Konvoi bilden.\""
|
||||||
|
|
||||||
msgid "error323"
|
msgid "error323"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist verzaubert.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist verzaubert.\""
|
||||||
|
@ -2783,6 +2774,9 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - Das Schiff ist
|
||||||
msgid "error327"
|
msgid "error327"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - So viele Schiffe kann die Einheit nicht übergeben.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - So viele Schiffe kann die Einheit nicht übergeben.\""
|
||||||
|
|
||||||
|
msgid "error328"
|
||||||
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Dafür müssen die Schiffe an derselben Küste liegen.\""
|
||||||
|
|
||||||
msgid "error326"
|
msgid "error326"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Diese Schiffe können keinen Konvoi bilden.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Diese Schiffe können keinen Konvoi bilden.\""
|
||||||
|
|
||||||
|
|
|
@ -437,9 +437,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - You can only br
|
||||||
msgid "error307"
|
msgid "error307"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - We snotlings is too stupid fer dat!\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - We snotlings is too stupid fer dat!\""
|
||||||
|
|
||||||
msgid "godcurse_destroy_ship"
|
|
||||||
msgstr "\"Her sailors sick from the poisened ocean, planks, rudder und sails corroded by the waters of the cursed ocean, the $ship($ship) finally succumbs to her destiny and sinks.\""
|
|
||||||
|
|
||||||
msgid "too_many_units_in_faction"
|
msgid "too_many_units_in_faction"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - A faction may not consist of more than $int($allowed) units.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - A faction may not consist of more than $int($allowed) units.\""
|
||||||
|
|
||||||
|
@ -1034,9 +1031,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - There are not e
|
||||||
msgid "sp_icastle_effect"
|
msgid "sp_icastle_effect"
|
||||||
msgstr "\"Flabbergasted, the peasants of $region($region) behold a new building.\""
|
msgstr "\"Flabbergasted, the peasants of $region($region) behold a new building.\""
|
||||||
|
|
||||||
msgid "curseinfo::godcurse"
|
|
||||||
msgstr "\"This region was cursed by the gods. Stinking vapors billow over the dead ground and hideous creatures move about the country. The wells are poisened and the edible plants are covered by a pink fungus. Noone can live here for long. ($int36($id))\""
|
|
||||||
|
|
||||||
msgid "recruit_archetype"
|
msgid "recruit_archetype"
|
||||||
msgstr "\"$unit($unit) recruits $int($amount) $localize($archetype).\""
|
msgstr "\"$unit($unit) recruits $int($amount) $localize($archetype).\""
|
||||||
|
|
||||||
|
@ -1251,7 +1245,7 @@ msgid "error184"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit does not move.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit does not move.\""
|
||||||
|
|
||||||
msgid "income_entertainment"
|
msgid "income_entertainment"
|
||||||
msgstr "\"$unit($unit) earns $int($amount) in $region($region) with entertainment.\""
|
msgstr "\"$unit($unit) earns $int($amount) in $region($region) from entertainment.\""
|
||||||
|
|
||||||
msgid "error180"
|
msgid "error180"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The spell fails.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The spell fails.\""
|
||||||
|
@ -1620,7 +1614,7 @@ msgid "curseinfo::deathcloud"
|
||||||
msgstr "\"A poison elemental is spreading pestilence and death. ($int36($id))\""
|
msgstr "\"A poison elemental is spreading pestilence and death. ($int36($id))\""
|
||||||
|
|
||||||
msgid "income"
|
msgid "income"
|
||||||
msgstr "\"$unit($unit) earns $int($amount)$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") in $region($region) $if($eq($mode,1),\" by entertainment\",$if($eq($mode,2),\" by taxes\",$if($eq($mode,3),\" by trade\",$if($eq($mode,5),\" by stealing\",$if($eq($mode,6),\" by magic\",$if($eq($mode,7),\" by pillaging\",\"\")))))).\""
|
msgstr "\"$unit($unit) in $region($region) earns $int($amount)$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") silver.\""
|
||||||
|
|
||||||
msgid "researchherb"
|
msgid "researchherb"
|
||||||
msgstr "\"$unit($unit) discovers that $localize($amount) $resource($herb,0) grow in $region($region).\""
|
msgstr "\"$unit($unit) discovers that $localize($amount) $resource($herb,0) grow in $region($region).\""
|
||||||
|
@ -2115,7 +2109,7 @@ msgid "deathcloud_effect"
|
||||||
msgstr "\"$unit($mage) summons a poison elemental in $region($region).\""
|
msgstr "\"$unit($mage) summons a poison elemental in $region($region).\""
|
||||||
|
|
||||||
msgid "nr_population"
|
msgid "nr_population"
|
||||||
msgstr "\"Your faction has $int($population) people in $int($units) of $int($limit) possible units.\""
|
msgstr "\"Your faction has $int($population) $if($eq($population,1), \"person\", \"persons\") in $int($units) of $int($limit) possible units.\""
|
||||||
|
|
||||||
msgid "curseinfo::shipdisorientation"
|
msgid "curseinfo::shipdisorientation"
|
||||||
msgstr "This ship has lost its path. ($int36($id))"
|
msgstr "This ship has lost its path. ($int36($id))"
|
||||||
|
@ -2223,7 +2217,7 @@ msgid "curseinfo::healingzone"
|
||||||
msgstr "Healing in this region is affected by magic. ($int36($id))"
|
msgstr "Healing in this region is affected by magic. ($int36($id))"
|
||||||
|
|
||||||
msgid "income_entertainment_reduced"
|
msgid "income_entertainment_reduced"
|
||||||
msgstr "\"In $region($region), $unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),\"\",\" of$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") \") with entertainment.\""
|
msgstr "\"In $region($region), $unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),\"\",\" of$if($eq($wanted,$amount),\"\",\" of $int($wanted)\") \") from entertainment.\""
|
||||||
|
|
||||||
msgid "errusingpotion"
|
msgid "errusingpotion"
|
||||||
msgstr "\"$unit($unit): '$order($command)' - The unit already uses $resource($using,0).\""
|
msgstr "\"$unit($unit): '$order($command)' - The unit already uses $resource($using,0).\""
|
||||||
|
@ -2555,9 +2549,6 @@ msgstr "\"$unit($unit) in $region($region): '$order($command)' - You need at lea
|
||||||
msgid "error177"
|
msgid "error177"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The familiar cannot cast this spell.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The familiar cannot cast this spell.\""
|
||||||
|
|
||||||
msgid "curseinfo::godcurseocean"
|
|
||||||
msgstr "\"This region was cursed by the gods. The sea is a foul cesspool, noxious gases rise from the deep, undead seamonsters attack all ships. Noone can live here for long. ($int36($id))\""
|
|
||||||
|
|
||||||
msgid "curseinfo::sparkle_4"
|
msgid "curseinfo::sparkle_4"
|
||||||
msgstr "\"A circle of shimmering lights surrounds $unit($unit). ($int36($id))\""
|
msgstr "\"A circle of shimmering lights surrounds $unit($unit). ($int36($id))\""
|
||||||
|
|
||||||
|
@ -2781,11 +2772,14 @@ msgid "error324"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is not one of ours.\""
|
||||||
|
|
||||||
msgid "error322"
|
msgid "error322"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The unit is already on a ship.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Only ships of the same type can form a convoy.\""
|
||||||
|
|
||||||
msgid "error323"
|
msgid "error323"
|
||||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The ship is under a spell.\""
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - The ship is under a spell.\""
|
||||||
|
|
||||||
|
msgid "error328"
|
||||||
|
msgstr "\"$unit($unit) in $region($region): '$order($command)' - All ships of a convoy must be on the same coast.\""
|
||||||
|
|
||||||
msgid "dissolve_units_2"
|
msgid "dissolve_units_2"
|
||||||
msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) turned into $if($eq($number,1),\"a tree\", \"trees\").\""
|
msgstr "\"$unit($unit) in $region($region): $int($number) $race($race,$number) turned into $if($eq($number,1),\"a tree\", \"trees\").\""
|
||||||
|
|
||||||
|
|
|
@ -2331,10 +2331,6 @@ msgstr "Seelenfrieden"
|
||||||
msgid "list_and"
|
msgid "list_and"
|
||||||
msgstr " und "
|
msgstr " und "
|
||||||
|
|
||||||
msgctxt "spell"
|
|
||||||
msgid "godcursezone"
|
|
||||||
msgstr "Fluch der Götter"
|
|
||||||
|
|
||||||
msgid "sptype_postcombat"
|
msgid "sptype_postcombat"
|
||||||
msgstr "Postkampfzauber"
|
msgstr "Postkampfzauber"
|
||||||
|
|
||||||
|
@ -3894,7 +3890,7 @@ msgstr "Ent"
|
||||||
|
|
||||||
msgctxt "iteminfo"
|
msgctxt "iteminfo"
|
||||||
msgid "dwarfspoil"
|
msgid "dwarfspoil"
|
||||||
msgstr "Beim Barte des Proheten! Ach nein, Zwergen. Irgendetwas riecht hier ranzig."
|
msgstr "Beim Barte des Propheten! Ach nein, Zwergen. Irgendetwas riecht hier ranzig."
|
||||||
|
|
||||||
msgctxt "race"
|
msgctxt "race"
|
||||||
msgid "clone"
|
msgid "clone"
|
||||||
|
@ -6324,3 +6320,44 @@ msgctxt "race"
|
||||||
msgid "wolf"
|
msgid "wolf"
|
||||||
msgstr "Wolf"
|
msgstr "Wolf"
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "elfspoil"
|
||||||
|
msgstr "Die Ohren sind spitz und beinahe trapezförmig. Wie kann
|
||||||
|
damit hören?"
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "goblinspoil"
|
||||||
|
msgstr "Die Fratze des kleinen Kopfs wirkt beinahe etwas kindlich
|
||||||
|
zierlich, aber dennoch liegt etwas Listiges darin."
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "halflingspoil"
|
||||||
|
msgstr "Die Sohle des behaarten Fußes ist deutlich dicker, beinahe
|
||||||
|
wie ein Huf."
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "aquarianspoil"
|
||||||
|
msgstr "Die kleine, türkisfarbene Schuppe glänzt in der Sonne. Dennoch ist sie erstaunlich hart."
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "humanspoil"
|
||||||
|
msgstr "Ob blond oder braun, ob kurz oder lang, du hast ein Büschel Haare mit einem Stück Haut in der Hand."
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "catspoil"
|
||||||
|
msgstr "Wie ein kleines Seil aus weichem Fell."
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "insectspoil"
|
||||||
|
msgstr "Das am Kopf der meisten Gliederfüßer auftretende,
|
||||||
|
gegliederte Extremitätenpaar, das mit Sensillen (Tastsinn, Geruchssinn)
|
||||||
|
ausgestattet ist."
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "orcspoil"
|
||||||
|
msgstr "Große, spitze Zähne. Ob sie früher einem Ork oder doch einem Wildschwein gehörten ist nicht so leicht zu unterscheiden."
|
||||||
|
|
||||||
|
msgctxt "iteminfo"
|
||||||
|
msgid "demonspoil"
|
||||||
|
msgstr "Eine giftige und grüne Flüssigkeit in einer kleinen Phiole,
|
||||||
|
keine humanoide Rasse außer Dämonen wagt damit in Kontakt zu kommen."
|
||||||
|
|
|
@ -1976,10 +1976,6 @@ msgstr " and "
|
||||||
msgid "h18_p"
|
msgid "h18_p"
|
||||||
msgstr "ice begonias"
|
msgstr "ice begonias"
|
||||||
|
|
||||||
msgctxt "spell"
|
|
||||||
msgid "godcursezone"
|
|
||||||
msgstr "Curse of the Gods"
|
|
||||||
|
|
||||||
msgid "sptype_postcombat"
|
msgid "sptype_postcombat"
|
||||||
msgstr "post-combat spell"
|
msgstr "post-combat spell"
|
||||||
|
|
||||||
|
|
2
s/build
2
s/build
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
ROOT=$(git rev-parse --show-toplevel)
|
ROOT=$(git rev-parse --show-toplevel)
|
||||||
|
eval $(luarocks path)
|
||||||
[ -z "$BUILD" ] && BUILD=Debug
|
[ -z "$BUILD" ] && BUILD=Debug
|
||||||
if [ -z "$JOBS" ] ; then
|
if [ -z "$JOBS" ] ; then
|
||||||
if [ -e /usr/sbin/sysctl ]; then
|
if [ -e /usr/sbin/sysctl ]; then
|
||||||
|
|
13
s/cmake-init
13
s/cmake-init
|
@ -6,6 +6,7 @@ pkg-config --exists sqlite3 && ERESSEA_DB=sqlite
|
||||||
GETOPT=getopt
|
GETOPT=getopt
|
||||||
GETOPT_LONG=1
|
GETOPT_LONG=1
|
||||||
|
|
||||||
|
luarocks install lunitx --local
|
||||||
if [ "Darwin" = "$(uname)" ] ; then
|
if [ "Darwin" = "$(uname)" ] ; then
|
||||||
if [ -x "/usr/local/opt/gnu-getopt/bin/getopt" ] ; then
|
if [ -x "/usr/local/opt/gnu-getopt/bin/getopt" ] ; then
|
||||||
GETOPT="/usr/local/opt/gnu-getopt/bin/getopt"
|
GETOPT="/usr/local/opt/gnu-getopt/bin/getopt"
|
||||||
|
@ -74,18 +75,19 @@ fi
|
||||||
|
|
||||||
DEST=$(dirname $ROOT)/server
|
DEST=$(dirname $ROOT)/server
|
||||||
|
|
||||||
git submodule update --init
|
|
||||||
|
|
||||||
LUA_VERSION="5.2"
|
LUA_VERSION="5.2"
|
||||||
LUA_INCLUDE=/usr/include
|
LUA_INCLUDE=/usr/include
|
||||||
LUA_DIR=/usr
|
LUA_DIR=/usr
|
||||||
if [ -d /usr/include/lua5.1 ]; then
|
if [ -d /usr/local/include/lua5.3 ]; then
|
||||||
LUA_VERSION="5.1"
|
LUA_VERSION="5.3"
|
||||||
LUA_INCLUDE=/usr/include/lua5.1
|
LUA_INCLUDE=/usr/local/include/lua5.3
|
||||||
elif [ -d /usr/include/lua5.2 ]; then
|
elif [ -d /usr/include/lua5.2 ]; then
|
||||||
export LUA_DIR=/usr
|
export LUA_DIR=/usr
|
||||||
LUA_VERSION="5.2"
|
LUA_VERSION="5.2"
|
||||||
LUA_INCLUDE=/usr/include/lua5.2
|
LUA_INCLUDE=/usr/include/lua5.2
|
||||||
|
elif [ -d /usr/include/lua5.1 ]; then
|
||||||
|
LUA_VERSION="5.1"
|
||||||
|
LUA_INCLUDE=/usr/include/lua5.1
|
||||||
elif [ -d /usr/local/include/lua5.1 ]; then
|
elif [ -d /usr/local/include/lua5.1 ]; then
|
||||||
export LUA_DIR=/usr/local
|
export LUA_DIR=/usr/local
|
||||||
LUA_VERSION="5.1"
|
LUA_VERSION="5.1"
|
||||||
|
@ -125,6 +127,7 @@ TOLUA
|
||||||
else
|
else
|
||||||
echo "tolua is $path"
|
echo "tolua is $path"
|
||||||
fi
|
fi
|
||||||
|
luarocks --local install lunitx
|
||||||
unset path
|
unset path
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
eval $(luarocks path)
|
||||||
ROOT=$(git rev-parse --show-toplevel)
|
ROOT=$(git rev-parse --show-toplevel)
|
||||||
[ -z $BUILD ] && BUILD=Debug ; export BUILD
|
[ -z $BUILD ] && BUILD=Debug ; export BUILD
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,3 @@ if config.paths ~= nil then
|
||||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- print(package.path)
|
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
-- Tests that work in all games. With game config of E2.
|
-- Tests that work in all games. With game config of E2.
|
||||||
-- Tests are under scripts/test/e2 and all files must be in scripts/test/e2/init.lua
|
-- Tests are under scripts/test/e2 and all files must be in scripts/test/e2/init.lua
|
||||||
|
|
||||||
|
lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
module = lunit.module
|
||||||
|
end
|
||||||
|
|
||||||
path = 'scripts'
|
path = 'scripts'
|
||||||
if config.install then
|
if config.install then
|
||||||
path = config.install .. '/' .. path
|
path = config.install .. '/' .. path
|
||||||
package.path = package.path .. ';' .. config.install .. '/lunit/?.lua'
|
|
||||||
--needed to find lunit if not run from eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder)
|
|
||||||
end
|
end
|
||||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
|
|
||||||
config.rules = 'e2'
|
config.rules = 'e2'
|
||||||
|
|
||||||
lunit = require 'lunit'
|
|
||||||
require 'eressea'
|
require 'eressea'
|
||||||
require 'eressea.xmlconf'
|
require 'eressea.xmlconf'
|
||||||
require 'eressea.path'
|
require 'eressea.path'
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
-- Tests that work in E3. With game config of E3.
|
-- Tests that work in E3. With game config of E3.
|
||||||
-- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua
|
-- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua
|
||||||
|
|
||||||
|
lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
module = lunit.module
|
||||||
|
end
|
||||||
|
|
||||||
path = 'scripts'
|
path = 'scripts'
|
||||||
if config.install then
|
if config.install then
|
||||||
path = config.install .. '/' .. path
|
path = config.install .. '/' .. path
|
||||||
package.path = package.path .. ';' .. config.install .. '/lunit/?.lua'
|
|
||||||
--needed to find lunit if not run form eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder)
|
|
||||||
end
|
end
|
||||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
|
|
||||||
config.rules = 'e3'
|
config.rules = 'e3'
|
||||||
|
|
||||||
lunit = require 'lunit'
|
|
||||||
require 'eressea'
|
require 'eressea'
|
||||||
require 'eressea.path'
|
require 'eressea.path'
|
||||||
require 'eressea.xmlconf'
|
require 'eressea.xmlconf'
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
-- Basic test without loading XML Config. Test care about needed settings.
|
-- Basic test without loading XML Config. Test care about needed settings.
|
||||||
-- Tests are under scripts/test/ and all files must be in scripts/test/init.lua
|
-- Tests are under scripts/test/ and all files must be in scripts/test/init.lua
|
||||||
|
|
||||||
|
lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
module = lunit.module
|
||||||
|
end
|
||||||
|
|
||||||
path = 'scripts'
|
path = 'scripts'
|
||||||
if config.install then
|
if config.install then
|
||||||
path = config.install .. '/' .. path
|
path = config.install .. '/' .. path
|
||||||
package.path = package.path .. ';' .. config.install .. '/lunit/?.lua'
|
|
||||||
--needed to find lunit if not run form eressea root. Needs right [lua] install setting in eressea.ini (point to eressea root from the start folder)
|
|
||||||
end
|
end
|
||||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
|
|
||||||
lunit = require 'lunit'
|
|
||||||
require 'eressea'
|
require 'eressea'
|
||||||
require 'eressea.path'
|
require 'eressea.path'
|
||||||
require 'tests'
|
require 'tests'
|
||||||
|
|
|
@ -130,8 +130,9 @@ function process(rules, orders)
|
||||||
end
|
end
|
||||||
|
|
||||||
turn_begin()
|
turn_begin()
|
||||||
|
-- create orders for monsters:
|
||||||
-- run the turn:
|
plan_monsters()
|
||||||
|
-- read orders for players:
|
||||||
if eressea.read_orders(orders) ~= 0 then
|
if eressea.read_orders(orders) ~= 0 then
|
||||||
print("could not read " .. orders)
|
print("could not read " .. orders)
|
||||||
return -1
|
return -1
|
||||||
|
@ -140,8 +141,9 @@ function process(rules, orders)
|
||||||
if nmr_check(config.maxnmrs or 80)~=0 then
|
if nmr_check(config.maxnmrs or 80)~=0 then
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
plan_monsters()
|
|
||||||
callbacks(rules, 'init')
|
callbacks(rules, 'init')
|
||||||
|
|
||||||
|
-- run the turn:
|
||||||
turn_process()
|
turn_process()
|
||||||
callbacks(rules, 'update')
|
callbacks(rules, 'update')
|
||||||
turn_end() -- ageing, etc.
|
turn_end() -- ageing, etc.
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
require "lunit"
|
local tcname = 'tests.bindings'
|
||||||
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local eressea = eressea
|
|
||||||
local _G = _G
|
local _G = _G
|
||||||
|
|
||||||
module("tests.bindings", lunit.testcase)
|
|
||||||
|
|
||||||
function test_eressea()
|
function test_eressea()
|
||||||
assert_equal("function", _G.type(eressea.free_game))
|
assert_equal("function", _G.type(eressea.free_game))
|
||||||
assert_equal("function", _G.type(eressea.read_game))
|
assert_equal("function", _G.type(eressea.read_game))
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.common'
|
||||||
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local function _test_create_ship(r)
|
local function _test_create_ship(r)
|
||||||
local s = ship.create(r, config.ships[1])
|
local s = ship.create(r, config.ships[1])
|
||||||
|
@ -26,8 +32,6 @@ local function two_factions()
|
||||||
return f1, f2
|
return f1, f2
|
||||||
end
|
end
|
||||||
|
|
||||||
module("tests.common", package.seeall, lunit.testcase)
|
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
eressea.settings.set("nmr.timeout", "0")
|
eressea.settings.set("nmr.timeout", "0")
|
||||||
|
@ -894,308 +898,3 @@ function test_walk_and_carry_the_cart()
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(1, u.region.x)
|
assert_equal(1, u.region.x)
|
||||||
end
|
end
|
||||||
|
|
||||||
module("tests.recruit", package.seeall, lunit.testcase)
|
|
||||||
|
|
||||||
function setup()
|
|
||||||
eressea.free_game()
|
|
||||||
eressea.settings.set("rules.food.flags", "4")
|
|
||||||
eressea.settings.set("rules.peasants.growth", "0")
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_bug_1795_limit()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = create_faction('human')
|
|
||||||
local u1 = one_unit(r,f)
|
|
||||||
u1:add_item("money", 100000000)
|
|
||||||
u1:add_order("REKRUTIEREN 9999")
|
|
||||||
r:set_resource("peasant", 2000) -- no fractional growth!
|
|
||||||
local peasants = r:get_resource("peasant")
|
|
||||||
local limit,frac = math.modf(peasants/40) -- one day this should be a parameter
|
|
||||||
|
|
||||||
process_orders()
|
|
||||||
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
|
|
||||||
assert_equal(peasants-limit, r:get_resource("peasant"))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_bug_1795_demons()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = create_faction('demon')
|
|
||||||
local u1 = one_unit(r,f)
|
|
||||||
r:set_resource("peasant", 2000)
|
|
||||||
local peasants = r:get_resource("peasant")
|
|
||||||
local limit,frac = math.modf(peasants/40)
|
|
||||||
|
|
||||||
u1:add_item("money", 100000000)
|
|
||||||
u1:add_order("REKRUTIEREN 9999")
|
|
||||||
|
|
||||||
process_orders()
|
|
||||||
|
|
||||||
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
|
|
||||||
assert_equal(peasants, r:get_resource("peasant"))
|
|
||||||
end
|
|
||||||
|
|
||||||
module("tests.parser", package.seeall, lunit.testcase)
|
|
||||||
|
|
||||||
function setup()
|
|
||||||
eressea.free_game()
|
|
||||||
eressea.settings.set("rules.food.flags", "4") -- FOOD_IS_FREE
|
|
||||||
eressea.settings.set("rules.move.owner_leave", "0")
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_parser()
|
|
||||||
local r = region.create(0, 0, "mountain")
|
|
||||||
local f = create_faction('human')
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
local filename = "orders.txt"
|
|
||||||
|
|
||||||
local file = io.open(filename, "w")
|
|
||||||
assert_not_nil(file)
|
|
||||||
f.password = 'Hodor'
|
|
||||||
file:write('ERESSEA ' .. itoa36(f.id) .. ' "Hodor"\n')
|
|
||||||
file:write('EINHEIT ' .. itoa36(u.id) .. "\n")
|
|
||||||
file:write("BENENNEN EINHEIT 'Goldene Herde'\n")
|
|
||||||
file:close()
|
|
||||||
|
|
||||||
eressea.read_orders(filename)
|
|
||||||
process_orders()
|
|
||||||
os.remove(filename)
|
|
||||||
assert_equal("Goldene Herde", u.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function set_order(u, str)
|
|
||||||
u:clear_orders()
|
|
||||||
u:add_order(str)
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_prefix()
|
|
||||||
local r0 = region.create(0, 0, "plain")
|
|
||||||
local f1 = create_faction('human')
|
|
||||||
local u1 = unit.create(f1, r0, 1)
|
|
||||||
|
|
||||||
set_order(u1, "PRAEFIX See")
|
|
||||||
process_orders()
|
|
||||||
assert_not_nil(u1:show():find("Seemensch"))
|
|
||||||
|
|
||||||
u1.race = "elf"
|
|
||||||
assert_not_nil(u1:show():find("Seeelf"))
|
|
||||||
|
|
||||||
set_order(u1, "PRAEFIX Mond")
|
|
||||||
process_orders()
|
|
||||||
assert_not_nil(u1:show():find("Mondelf"))
|
|
||||||
|
|
||||||
set_order(u1, "PRAEFIX")
|
|
||||||
process_orders()
|
|
||||||
assert_not_nil(u1:show():find("Elf"))
|
|
||||||
|
|
||||||
set_order(u1, "PRAEFIX Erz")
|
|
||||||
process_orders()
|
|
||||||
assert_not_nil(u1:show():find("Erzelf"))
|
|
||||||
u1.faction.locale = "en"
|
|
||||||
assert_not_nil(u1:show():find("archelf"))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_recruit()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = create_faction('human')
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
|
|
||||||
u:add_item("money", 1000)
|
|
||||||
set_order(u, "REKRUTIERE 5")
|
|
||||||
process_orders()
|
|
||||||
for u in f.units do
|
|
||||||
assert_equal(6, u.number)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_give_horses()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = faction.create("human", "noreply@eressea.de", "de")
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
|
|
||||||
r:set_resource("horse", 0)
|
|
||||||
u:add_item("horse", 21)
|
|
||||||
u:add_item("dolphin", 10)
|
|
||||||
u:add_order("GIB 0 7 PFERD")
|
|
||||||
u:add_order("GIB 0 5 DELPHIN")
|
|
||||||
process_orders()
|
|
||||||
assert_equal(7, r:get_resource("horse"))
|
|
||||||
assert_equal(5, u:get_item("dolphin"))
|
|
||||||
assert_equal(14, u:get_item("horse"))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_give_silver()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = faction.create("human", "noreply@eressea.de", "de")
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
|
|
||||||
r:set_resource("peasant", 0)
|
|
||||||
r:set_resource("money", 11)
|
|
||||||
u:clear_orders()
|
|
||||||
u:add_item("money", 20)
|
|
||||||
u:add_order("GIB 0 10 SILBER")
|
|
||||||
process_orders()
|
|
||||||
assert_equal(21, r:get_resource("money"))
|
|
||||||
assert_equal(10, u:get_item("money"))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_give_horses()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = create_faction('human')
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
|
|
||||||
r:set_resource("horse", 0)
|
|
||||||
u:add_item("horse", 21)
|
|
||||||
u:add_item("dolphin", 10)
|
|
||||||
u:add_order("GIB 0 7 PFERD")
|
|
||||||
u:add_order("GIB 0 5 DELPHIN")
|
|
||||||
process_orders()
|
|
||||||
assert_equal(7, r:get_resource("horse"))
|
|
||||||
assert_equal(5, u:get_item("dolphin"))
|
|
||||||
assert_equal(14, u:get_item("horse"))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_give_silver()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = create_faction('human')
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
|
|
||||||
r:set_resource("peasant", 0)
|
|
||||||
r:set_resource("money", 11)
|
|
||||||
u:clear_orders()
|
|
||||||
u:add_item("money", 20)
|
|
||||||
u:add_order("GIB 0 10 SILBER")
|
|
||||||
process_orders()
|
|
||||||
assert_equal(21, r:get_resource("money"))
|
|
||||||
assert_equal(10, u:get_item("money"))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_build_castle_one_stage()
|
|
||||||
local r = region.create(0, 0, 'plain')
|
|
||||||
local f = faction.create('human')
|
|
||||||
local u = unit.create(f, r, 2)
|
|
||||||
|
|
||||||
u:add_item('stone', 4)
|
|
||||||
|
|
||||||
u:set_skill('building', 1)
|
|
||||||
u:add_order('MACHE BURG')
|
|
||||||
|
|
||||||
process_orders()
|
|
||||||
assert_equal(2, u.building.size)
|
|
||||||
assert_equal(2, u:get_item('stone'))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_build_castle()
|
|
||||||
local r = region.create(0, 0, "plain")
|
|
||||||
local f = create_faction('human')
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
|
|
||||||
u:add_item('stone', 1)
|
|
||||||
u:set_skill('building', 1)
|
|
||||||
u:add_order("MACHE BURG")
|
|
||||||
process_orders()
|
|
||||||
assert_not_nil(u.building)
|
|
||||||
assert_equal(1, u.building.size)
|
|
||||||
assert_equal(u.building.name, "Burg")
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_route()
|
|
||||||
local r1 = region.create(0, 0, "plain")
|
|
||||||
local r2 = region.create(1, 0, "plain")
|
|
||||||
local f = faction.create("human", "route@example.com")
|
|
||||||
local u = unit.create(f, r1, 1)
|
|
||||||
u:add_order("ROUTE O W P")
|
|
||||||
process_orders()
|
|
||||||
assert_equal("ROUTE West PAUSE Ost", u:get_order(0))
|
|
||||||
assert_equal(r2, u.region)
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_route_horse()
|
|
||||||
local r1 = region.create(0, 0, "plain")
|
|
||||||
local r2 = region.create(1, 0, "plain")
|
|
||||||
local f = faction.create("human", "route@example.com")
|
|
||||||
local u = unit.create(f, r1, 1)
|
|
||||||
u:add_order("ROUTE O P W P")
|
|
||||||
u:add_item('horse', 1)
|
|
||||||
u:set_skill('riding', 1)
|
|
||||||
process_orders()
|
|
||||||
assert_equal("ROUTE West PAUSE Ost PAUSE", u:get_order(0))
|
|
||||||
assert_equal(r2, u.region)
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_route_pause()
|
|
||||||
local r1 = region.create(0, 0, "plain")
|
|
||||||
local r2 = region.create(1, 0, "plain")
|
|
||||||
local f = faction.create("human", "route@example.com")
|
|
||||||
local u = unit.create(f, r1, 1)
|
|
||||||
u:add_order("ROUTE P O W")
|
|
||||||
process_orders()
|
|
||||||
assert_equal("ROUTE P O W", u:get_order(0))
|
|
||||||
assert_equal(r1, u.region)
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_immunity_stops_guard()
|
|
||||||
eressea.settings.set("NewbieImmunity", 2)
|
|
||||||
local f = faction.create('human')
|
|
||||||
local r = region.create(0, 0, 'plain')
|
|
||||||
local u = unit.create(f, r)
|
|
||||||
u:set_skill('polearm', 2)
|
|
||||||
u:add_item('lance', 1)
|
|
||||||
u:add_order('BEWACHE')
|
|
||||||
process_orders()
|
|
||||||
assert_equal(f.age, 1)
|
|
||||||
assert_true(not u.guard)
|
|
||||||
process_orders()
|
|
||||||
assert_equal(f.age, 2)
|
|
||||||
assert_true(u.guard)
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_region_keys()
|
|
||||||
local r = region.create(0, 0, 'plain')
|
|
||||||
assert_nil(r:get_key('test'))
|
|
||||||
assert_nil(r:get_key('more'))
|
|
||||||
r:set_key('test', 42)
|
|
||||||
r:set_key('more') -- default is 1
|
|
||||||
assert_equal(42, r:get_key('test'))
|
|
||||||
assert_equal(1, r:get_key('more'))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_faction_keys()
|
|
||||||
local f = faction.create('human')
|
|
||||||
assert_nil(f:get_key('test'))
|
|
||||||
assert_nil(f:get_key('more'))
|
|
||||||
f:set_key('test', 42)
|
|
||||||
f:set_key('more') -- default is 1
|
|
||||||
assert_equal(42, f:get_key('test'))
|
|
||||||
assert_equal(1, f:get_key('more'))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_cartmaking()
|
|
||||||
local f = faction.create('human')
|
|
||||||
local r = region.create(0, 0, 'plain')
|
|
||||||
local u = unit.create(f, r)
|
|
||||||
u:set_skill('cartmaking', 1)
|
|
||||||
u:add_item('log', 10)
|
|
||||||
u:add_order('MACHE Wagen')
|
|
||||||
process_orders()
|
|
||||||
assert_equal(1, u:get_item('cart'))
|
|
||||||
assert_equal(5, u:get_item('log'))
|
|
||||||
end
|
|
||||||
|
|
||||||
function test_promote_after_recruit()
|
|
||||||
local f = faction.create('human')
|
|
||||||
local r1 = region.create(0, 0, 'plain')
|
|
||||||
local r2 = region.create(1, 0, 'plain')
|
|
||||||
local u1 = unit.create(f, r1, 1)
|
|
||||||
u1.name = 'Xolgrim'
|
|
||||||
local u2 = unit.create(f, r2, 55)
|
|
||||||
u2:add_order('REKRUTIERE 1')
|
|
||||||
u1:add_order('BEFOERDERE')
|
|
||||||
u1:add_item('money', 57)
|
|
||||||
u2:add_item('money', 150)
|
|
||||||
local fl = u1.flags
|
|
||||||
process_orders()
|
|
||||||
assert_equal(56, u2.number)
|
|
||||||
assert_equal(fl + 128, u1.flags) -- UFL_HERO
|
|
||||||
assert_equal(0, u1:get_item('money'))
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.config'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.eressea.config", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.adamantium'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.adamantium", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.allies'
|
||||||
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
module("tests.e2.allies", package.seeall, lunit.testcase)
|
function setup()
|
||||||
|
eressea.free_game()
|
||||||
function skip_test_get_set_ally()
|
|
||||||
local f1 = faction.create("human")
|
|
||||||
local f2 = faction.create("human")
|
|
||||||
|
|
||||||
assert_equal(false, f1:get_ally(f2, "guard"))
|
|
||||||
f1:set_ally(f2, "guard", true)
|
|
||||||
assert_equal(true, f1:get_ally(f2, "guard"))
|
|
||||||
assert_equal(false, f1:get_ally(f2, "give"))
|
|
||||||
f1:set_ally(f2, "give", true)
|
|
||||||
assert_equal(true, f1:get_ally(f2, "give"))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_get_allies()
|
function test_get_allies()
|
||||||
|
@ -28,3 +24,16 @@ function test_get_allies()
|
||||||
assert_equal(1, #allies[f2.id])
|
assert_equal(1, #allies[f2.id])
|
||||||
assert_equal("give", allies[f2.id][1])
|
assert_equal("give", allies[f2.id][1])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_get_set_ally()
|
||||||
|
local f1 = faction.create("human")
|
||||||
|
local f2 = faction.create("human")
|
||||||
|
|
||||||
|
assert_equal(false, f1:get_ally(f2, "guard"))
|
||||||
|
f1:set_ally(f2, "guard", true)
|
||||||
|
assert_equal(true, f1:get_ally(f2, "guard"))
|
||||||
|
assert_equal(false, f1:get_ally(f2, "give"))
|
||||||
|
f1:set_ally(f2, "give", true)
|
||||||
|
assert_equal(true, f1:get_ally(f2, "give"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.astral'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.astral", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
@ -17,7 +21,7 @@ function test_fetch_astral()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local ra = r:get_astral('fog')
|
local ra = r:get_astral('fog')
|
||||||
local rb = region.create(ra.x + 1, ra.y, 'fog')
|
local rb = region.create(ra.x + 1, ra.y, 'fog')
|
||||||
local f = faction.create("human")
|
local f = faction.create("human");
|
||||||
local u1 = unit.create(f, r, 1)
|
local u1 = unit.create(f, r, 1)
|
||||||
local u2 = unit.create(f, r, 1)
|
local u2 = unit.create(f, r, 1)
|
||||||
local u3 = unit.create(f, rb, 1)
|
local u3 = unit.create(f, rb, 1)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.buildings'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.buildings", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
@ -41,7 +45,6 @@ function test_build_tunnel_limited()
|
||||||
u:add_item('iron', 2)
|
u:add_item('iron', 2)
|
||||||
u:add_item('money', 700)
|
u:add_item('money', 700)
|
||||||
u.building = b
|
u.building = b
|
||||||
u.name = 'Xolgrim'
|
|
||||||
u:add_order('MACHE 2 BURG ' .. itoa36(b.id))
|
u:add_order('MACHE 2 BURG ' .. itoa36(b.id))
|
||||||
b.size = 99
|
b.size = 99
|
||||||
process_orders()
|
process_orders()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.carts'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.carts", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.destroy'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.destroy", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
@ -41,8 +45,8 @@ function test_destroy_is_long()
|
||||||
local u = unit.create(faction.create("human", "one@example.com", "de"), r1, 10)
|
local u = unit.create(faction.create("human", "one@example.com", "de"), r1, 10)
|
||||||
u.building = building.create(u.region, "castle")
|
u.building = building.create(u.region, "castle")
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
u:add_order("LERNE Unterhaltung")
|
|
||||||
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
|
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
|
||||||
|
u:add_order("LERNE Unterhaltung")
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(0, u:get_skill("entertainment"))
|
assert_equal(0, u:get_skill("entertainment"))
|
||||||
assert_equal(nil, u.building)
|
assert_equal(nil, u.building)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.features'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.e2features", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
@ -12,6 +16,26 @@ function setup()
|
||||||
eressea.settings.set("rules.peasants.growth.factor", "0")
|
eressea.settings.set("rules.peasants.growth.factor", "0")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function disabled_double_default()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("human")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
region.create(1, 0, "plain")
|
||||||
|
region.create(2, 0, "plain")
|
||||||
|
region.create(3, 0, "plain")
|
||||||
|
|
||||||
|
u:add_order('NACH O')
|
||||||
|
u:add_order('DEFAULT "NACH O"')
|
||||||
|
u:add_order('DEFAULT "DEFAULT ARBEITE"')
|
||||||
|
process_orders()
|
||||||
|
assert_equal(1, u.region.x)
|
||||||
|
process_orders()
|
||||||
|
assert_equal(2, u.region.x)
|
||||||
|
process_orders()
|
||||||
|
assert_equal(2, u.region.x)
|
||||||
|
assert_equal("ARBEITE", u:get_order())
|
||||||
|
end
|
||||||
|
|
||||||
function test_give_unit()
|
function test_give_unit()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f1 = faction.create('elf')
|
local f1 = faction.create('elf')
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.guard'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.guard", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
require 'tests.e2.trolls'
|
||||||
|
require 'tests.e2.trees'
|
||||||
require 'tests.e2.buildings'
|
require 'tests.e2.buildings'
|
||||||
require 'tests.e2.allies'
|
|
||||||
require 'tests.e2.quit'
|
|
||||||
require 'tests.e2.movement'
|
require 'tests.e2.movement'
|
||||||
require 'tests.e2.carts'
|
require 'tests.e2.carts'
|
||||||
require 'tests.e2.quit'
|
|
||||||
require 'tests.e2.astral'
|
require 'tests.e2.astral'
|
||||||
require 'tests.e2.spells'
|
require 'tests.e2.spells'
|
||||||
require 'tests.e2.e2features'
|
require 'tests.e2.e2features'
|
||||||
require 'tests.e2.insects'
|
require 'tests.e2.insects'
|
||||||
require 'tests.e2.production'
|
require 'tests.e2.production'
|
||||||
|
require 'tests.e2.allies'
|
||||||
require 'tests.e2.adamantium'
|
require 'tests.e2.adamantium'
|
||||||
require 'tests.e2.undead'
|
require 'tests.e2.undead'
|
||||||
require 'tests.e2.shiplanding'
|
require 'tests.e2.shiplanding'
|
||||||
|
@ -22,6 +22,8 @@ require 'tests.items'
|
||||||
require 'tests.economy'
|
require 'tests.economy'
|
||||||
require 'tests.orders'
|
require 'tests.orders'
|
||||||
require 'tests.common'
|
require 'tests.common'
|
||||||
|
require 'tests.recruit'
|
||||||
|
require 'tests.parser'
|
||||||
require 'tests.report'
|
require 'tests.report'
|
||||||
require 'tests.storage'
|
require 'tests.storage'
|
||||||
require 'tests.magicbag'
|
require 'tests.magicbag'
|
||||||
|
@ -30,3 +32,4 @@ require 'tests.xmas'
|
||||||
require 'tests.production'
|
require 'tests.production'
|
||||||
require 'tests.spells'
|
require 'tests.spells'
|
||||||
require 'tests.undead'
|
require 'tests.undead'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.insects'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.insects", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.items'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.items", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.movement'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.movement", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.production'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.production", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.quit'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.quit", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function test_quit_faction()
|
function test_quit_faction()
|
||||||
local r = region.create(47, 0, "plain")
|
local r = region.create(47, 0, "plain")
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.shiplanding'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.shiplanding", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.ships'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.ships", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.spells'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.spells", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.game.reset()
|
||||||
eressea.settings.set("nmr.removenewbie", "0")
|
eressea.settings.set("nmr.removenewbie", "0")
|
||||||
eressea.settings.set("nmr.timeout", "0")
|
eressea.settings.set("nmr.timeout", "0")
|
||||||
eressea.settings.set("NewbieImmunity", "0")
|
eressea.settings.set("NewbieImmunity", "0")
|
||||||
|
@ -14,6 +18,26 @@ function setup()
|
||||||
eressea.settings.set("magic.regeneration.enable", "0")
|
eressea.settings.set("magic.regeneration.enable", "0")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_undead_cannot_enter_holyground()
|
||||||
|
local r1 = region.create(0, 0, 'plain')
|
||||||
|
local r2 = region.create(1, 0, 'plain')
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u1 = unit.create(f, r1, 1)
|
||||||
|
local u2 = unit.create(f, r2, 1)
|
||||||
|
|
||||||
|
u2.magic = 'gwyrrd'
|
||||||
|
u2:set_skill('magic', 100)
|
||||||
|
u2.aura = 200
|
||||||
|
u2:add_spell('holyground')
|
||||||
|
u2:add_order('ZAUBERE STUFE 10 "Heiliger Boden"')
|
||||||
|
|
||||||
|
u1.race = "skeleton"
|
||||||
|
u1:add_order("NACH Osten")
|
||||||
|
process_orders()
|
||||||
|
assert_not_nil(r2:get_curse('holyground'))
|
||||||
|
assert_equal(r1, u1.region)
|
||||||
|
end
|
||||||
|
|
||||||
function test_shapeshift()
|
function test_shapeshift()
|
||||||
local r = region.create(42, 0, "plain")
|
local r = region.create(42, 0, "plain")
|
||||||
local f = faction.create("demon", "noreply@eressea.de", "de")
|
local f = faction.create("demon", "noreply@eressea.de", "de")
|
||||||
|
@ -204,7 +228,6 @@ function test_bug_2517()
|
||||||
local uf = nil
|
local uf = nil
|
||||||
eressea.settings.set("magic.familiar.race", "lynx")
|
eressea.settings.set("magic.familiar.race", "lynx")
|
||||||
f.magic = 'gwyrrd'
|
f.magic = 'gwyrrd'
|
||||||
um.name = 'Xolgrim'
|
|
||||||
um.magic = 'gwyrrd'
|
um.magic = 'gwyrrd'
|
||||||
um.race = 'elf'
|
um.race = 'elf'
|
||||||
um:set_skill('magic', 10)
|
um:set_skill('magic', 10)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.stealth'
|
||||||
|
local lunit = require('lunit')
|
||||||
module('tests.e2.stealth', package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local f
|
local f
|
||||||
local u
|
local u
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
local tcname = 'tests.e2.trees'
|
||||||
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
|
function setup()
|
||||||
|
eressea.game.reset()
|
||||||
|
eressea.settings.set("rules.food.flags", "4") -- food is free
|
||||||
|
eressea.settings.set("rules.treeseeds.chance", "0.0") -- trees make no seeds
|
||||||
|
eressea.settings.set("rules.grow.formula", "0") -- no tree or seed growth
|
||||||
|
eressea.settings.set("NewbieImmunity", "0")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_no_growth()
|
||||||
|
eressea.settings.set("rules.grow.formula", "2") -- E2 growth rules
|
||||||
|
set_turn(204)
|
||||||
|
assert_equal('spring', get_season())
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
r:set_flag(1, false) -- no mallorn
|
||||||
|
r:set_resource('seed', 0)
|
||||||
|
r:set_resource('sapling', 0)
|
||||||
|
r:set_resource('tree', 0)
|
||||||
|
process_orders()
|
||||||
|
assert_equal(0, r:get_resource('seed'))
|
||||||
|
assert_equal(0, r:get_resource('sapling'))
|
||||||
|
assert_equal(0, r:get_resource('tree'))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_spring_growth()
|
||||||
|
eressea.settings.set("rules.grow.formula", "2") -- E2 growth rules
|
||||||
|
set_turn(204)
|
||||||
|
assert_equal('spring', get_season())
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
r:set_flag(1, false) -- no mallorn
|
||||||
|
r:set_resource('seed', 6)
|
||||||
|
r:set_resource('sapling', 17)
|
||||||
|
r:set_resource('tree', 0)
|
||||||
|
process_orders()
|
||||||
|
assert_equal(5, r:get_resource('seed'))
|
||||||
|
assert_equal(16, r:get_resource('sapling'))
|
||||||
|
assert_equal(2, r:get_resource('tree'))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- hebalism < T6 cannot plant
|
||||||
|
function test_plant_fail()
|
||||||
|
set_turn(184)
|
||||||
|
assert_equal('summer', get_season())
|
||||||
|
local f = faction.create('goblin')
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
r:set_flag(1, false) -- no mallorn
|
||||||
|
r:set_resource('seed', 0)
|
||||||
|
r:set_resource('sapling', 0)
|
||||||
|
r:set_resource('tree', 0)
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
u:set_skill('herbalism', 5)
|
||||||
|
u:add_item('seed', 40)
|
||||||
|
u:add_order("PFLANZE 20 Samen")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(0, r:get_resource('seed'))
|
||||||
|
assert_equal(0, r:get_resource('sapling'))
|
||||||
|
assert_equal(0, r:get_resource('tree'))
|
||||||
|
assert_equal(40, u:get_item('seed'))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- T6+ herbalism allows planting seeds at 1:1 rates
|
||||||
|
function test_plant_summer()
|
||||||
|
set_turn(184)
|
||||||
|
assert_equal('summer', get_season())
|
||||||
|
local f = faction.create('goblin')
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
r:set_flag(1, false) -- no mallorn
|
||||||
|
r:set_resource('seed', 0)
|
||||||
|
r:set_resource('sapling', 0)
|
||||||
|
r:set_resource('tree', 0)
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
u:set_skill('herbalism', 20)
|
||||||
|
u:add_item('seed', 40)
|
||||||
|
u:add_order("PFLANZE 20 Samen")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(20, r:get_resource('seed'))
|
||||||
|
assert_equal(0, r:get_resource('sapling'))
|
||||||
|
assert_equal(0, r:get_resource('tree'))
|
||||||
|
assert_equal(20, u:get_item('seed'))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- in spring, herbalism >= T12 plants saplings at 10:1 rate
|
||||||
|
function test_plant_spring_saplings()
|
||||||
|
set_turn(203)
|
||||||
|
assert_equal('spring', get_season())
|
||||||
|
local f = faction.create('goblin')
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
r:set_flag(1, false) -- no mallorn
|
||||||
|
r:set_resource('seed', 0)
|
||||||
|
r:set_resource('sapling', 0)
|
||||||
|
r:set_resource('tree', 0)
|
||||||
|
|
||||||
|
assert_equal('spring', get_season())
|
||||||
|
process_orders() -- to initialize at_germs
|
||||||
|
assert_equal(0, r:get_resource('sapling'))
|
||||||
|
assert_equal(0, r:get_resource('seed'))
|
||||||
|
assert_equal(0, r:get_resource('tree'))
|
||||||
|
|
||||||
|
assert_equal('spring', get_season())
|
||||||
|
u:set_skill('herbalism', 12)
|
||||||
|
u:add_item('seed', 20)
|
||||||
|
u:add_order("PFLANZE 20 Samen") -- limited by herbalism
|
||||||
|
process_orders()
|
||||||
|
assert_equal(1, r:get_resource('sapling'))
|
||||||
|
assert_equal(2, r:get_resource('seed'))
|
||||||
|
assert_equal(0, r:get_resource('tree'))
|
||||||
|
assert_equal(8, u:get_item('seed'))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- herbalism < T12 means we are still planting seeds at 1:1
|
||||||
|
function test_plant_spring_seeds()
|
||||||
|
set_turn(204)
|
||||||
|
local f = faction.create('goblin')
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
r:set_flag(1, false) -- no mallorn
|
||||||
|
r:set_resource('seed', 0)
|
||||||
|
r:set_resource('sapling', 0)
|
||||||
|
r:set_resource('tree', 0)
|
||||||
|
|
||||||
|
assert_equal('spring', get_season())
|
||||||
|
process_orders() -- to initialize at_germs
|
||||||
|
assert_equal(0, r:get_resource('sapling'))
|
||||||
|
assert_equal(0, r:get_resource('seed'))
|
||||||
|
assert_equal(0, r:get_resource('tree'))
|
||||||
|
|
||||||
|
assert_equal('spring', get_season())
|
||||||
|
u:set_skill('herbalism', 10)
|
||||||
|
u:add_item('seed', 40)
|
||||||
|
u:add_order("PFLANZE 10 Samen")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(0, r:get_resource('sapling'))
|
||||||
|
assert_equal(10, r:get_resource('seed'))
|
||||||
|
assert_equal(0, r:get_resource('tree'))
|
||||||
|
assert_equal(30, u:get_item('seed'))
|
||||||
|
end
|
|
@ -0,0 +1,54 @@
|
||||||
|
local tcname = 'tests.e2.trolls'
|
||||||
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
|
function setup()
|
||||||
|
eressea.free_game()
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_trolls_with_horses()
|
||||||
|
local r0 = region.create(0, 0, 'plain')
|
||||||
|
local r1 = region.create(1, 0, 'plain')
|
||||||
|
local r2 = region.create(2, 0, 'plain')
|
||||||
|
local r3 = region.create(3, 0, 'plain')
|
||||||
|
local r4 = region.create(4, 0, 'plain')
|
||||||
|
local r5 = region.create(5, 0, 'plain')
|
||||||
|
|
||||||
|
local f = faction.create('troll')
|
||||||
|
-- 1. 20 trolls can pull 5 loaded carts:
|
||||||
|
assert_not_nil(r0)
|
||||||
|
local u1 = unit.create(f, r0, 20)
|
||||||
|
u1:add_item('cart', 5)
|
||||||
|
-- trolls carry 10.8 GE, carts carry 100 GE:
|
||||||
|
u1:add_item('money', 100 * (5 * 100 + 2 * 108))
|
||||||
|
u1:add_order('NACH O O O')
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
assert_equal(r1, u1.region)
|
||||||
|
|
||||||
|
-- 20 trolls can also lead 20 horses
|
||||||
|
u1:add_item('horse', 20)
|
||||||
|
u1:add_item('money', 100 * 20 * 20)
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
assert_equal(r2, u1.region)
|
||||||
|
|
||||||
|
-- test if trolls are still "lazy". If yes they should still manage 10 full carts behind the 20 horses (5 more)
|
||||||
|
u1:add_item('cart', 5)
|
||||||
|
u1:add_item('money', 100 * 5 * 100)
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
assert_equal(r3, u1.region)
|
||||||
|
|
||||||
|
-- test if trolls are still "lazy". If not they should manage 15 full carts, 5 behind trolls and 10 behind 20 horses (again 5 more)
|
||||||
|
u1:add_item('cart', 5)
|
||||||
|
u1:add_item('money', 100 * 5 * 100)
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
assert_equal(r4, u1.region)
|
||||||
|
|
||||||
|
end
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e2.undead'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e2.undead", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
@ -28,7 +32,6 @@ function test_undead_reserve_other()
|
||||||
u1.race = "undead"
|
u1.race = "undead"
|
||||||
u1:clear_orders()
|
u1:clear_orders()
|
||||||
u1:add_order("RESERVIERE 1 Holz")
|
u1:add_order("RESERVIERE 1 Holz")
|
||||||
u1.name = 'Xolgrim'
|
|
||||||
process_orders()
|
process_orders()
|
||||||
|
|
||||||
if 0 ~= u1:get_item("log") then
|
if 0 ~= u1:get_item("log") then
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.buildings'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.buildings", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -10,6 +10,8 @@ require 'tests.spells'
|
||||||
require 'tests.economy'
|
require 'tests.economy'
|
||||||
require 'tests.orders'
|
require 'tests.orders'
|
||||||
require 'tests.common'
|
require 'tests.common'
|
||||||
|
require 'tests.recruit'
|
||||||
|
require 'tests.parser'
|
||||||
require 'tests.items'
|
require 'tests.items'
|
||||||
require 'tests.magicbag'
|
require 'tests.magicbag'
|
||||||
require 'tests.process'
|
require 'tests.process'
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.items'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.items", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.morale'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.morale", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
@ -171,7 +175,7 @@ function test_morale_change()
|
||||||
run_a_turn()
|
run_a_turn()
|
||||||
assert_equal(4, r.morale)
|
assert_equal(4, r.morale)
|
||||||
|
|
||||||
-- regel: ohne herrscher fällt die moral jede woche um 1 punkt, bis sie 1 erreicht
|
-- regel: ohne herrscher fällt die moral jede woche um 1 punkt, bis sie 1 erreicht
|
||||||
assert_false(r.is_mourning)
|
assert_false(r.is_mourning)
|
||||||
u1.building = nil
|
u1.building = nil
|
||||||
update_owners()
|
update_owners()
|
||||||
|
@ -186,7 +190,7 @@ function test_morale_change()
|
||||||
run_a_turn()
|
run_a_turn()
|
||||||
assert_equal(1, r.morale)
|
assert_equal(1, r.morale)
|
||||||
|
|
||||||
-- ohne herrscher ändert sich auch beschissene Moral nicht:
|
-- ohne herrscher ändert sich auch beschissene Moral nicht:
|
||||||
r.morale = 0
|
r.morale = 0
|
||||||
run_a_turn()
|
run_a_turn()
|
||||||
assert_equal(0, r.morale)
|
assert_equal(0, r.morale)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require 'lunit'
|
local tcname = 'tests.e3.parser'
|
||||||
|
local lunit = require('lunit')
|
||||||
module('tests.e3.parser', package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.production'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.production", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.rules'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.e3features", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local settings
|
local settings
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.e2spells'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.spells-e2", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local r, f, u
|
local r, f, u
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.spells'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.spells", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.e3.stealth'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.e3.stealth", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local f
|
local f
|
||||||
local u
|
local u
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.economy'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.economy", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.faction'
|
||||||
|
local lunit = require('lunit')
|
||||||
module ('tests.eressea.faction', package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local f
|
local f
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.hunger'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.hunger", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.items'
|
||||||
|
local lunit = require("lunit")
|
||||||
module("tests.items", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.laws'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.laws", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
@ -115,3 +119,4 @@ function test_force_leave_postcombat()
|
||||||
assert_equal(nil, u3.building)
|
assert_equal(nil, u3.building)
|
||||||
assert_equal(1, u3.number)
|
assert_equal(1, u3.number)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.locale'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.eressea.locale", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.magicbag'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.magicbag", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local u
|
local u
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.movement'
|
||||||
|
local lunit = require("lunit")
|
||||||
module("tests.movement", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname , 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.orders'
|
||||||
|
local lunit = require("lunit")
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname , 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local _G = _G
|
local _G = _G
|
||||||
local eressea = eressea
|
|
||||||
local default_ship = config.ships[1]
|
local default_ship = config.ships[1]
|
||||||
local default_building = config.buildings[1]
|
local default_building = config.buildings[1]
|
||||||
|
|
||||||
module('tests.eressea.orders', package.seeall, lunit.testcase)
|
|
||||||
|
|
||||||
local r, f, u
|
local r, f, u
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
|
|
|
@ -0,0 +1,270 @@
|
||||||
|
local tcname = 'tests.shared.parser'
|
||||||
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
|
function setup()
|
||||||
|
eressea.free_game()
|
||||||
|
eressea.settings.set("rules.food.flags", "4") -- FOOD_IS_FREE
|
||||||
|
eressea.settings.set("rules.move.owner_leave", "0")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_parser()
|
||||||
|
local r = region.create(0, 0, "mountain")
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
local filename = "orders.txt"
|
||||||
|
|
||||||
|
local file = io.open(filename, "w")
|
||||||
|
assert_not_nil(file)
|
||||||
|
f.password = 'Hodor'
|
||||||
|
file:write('ERESSEA ' .. itoa36(f.id) .. ' "Hodor"\n')
|
||||||
|
file:write('EINHEIT ' .. itoa36(u.id) .. "\n")
|
||||||
|
file:write("BENENNEN EINHEIT 'Goldene Herde'\n")
|
||||||
|
file:close()
|
||||||
|
|
||||||
|
eressea.read_orders(filename)
|
||||||
|
process_orders()
|
||||||
|
os.remove(filename)
|
||||||
|
assert_equal("Goldene Herde", u.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_order(u, str)
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order(str)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_prefix()
|
||||||
|
local r0 = region.create(0, 0, "plain")
|
||||||
|
local f1 = faction.create('human')
|
||||||
|
local u1 = unit.create(f1, r0, 1)
|
||||||
|
|
||||||
|
set_order(u1, "PRAEFIX See")
|
||||||
|
process_orders()
|
||||||
|
assert_not_nil(u1:show():find("Seemensch"))
|
||||||
|
|
||||||
|
u1.race = "elf"
|
||||||
|
assert_not_nil(u1:show():find("Seeelf"))
|
||||||
|
|
||||||
|
set_order(u1, "PRAEFIX Mond")
|
||||||
|
process_orders()
|
||||||
|
assert_not_nil(u1:show():find("Mondelf"))
|
||||||
|
|
||||||
|
set_order(u1, "PRAEFIX")
|
||||||
|
process_orders()
|
||||||
|
assert_not_nil(u1:show():find("Elf"))
|
||||||
|
|
||||||
|
set_order(u1, "PRAEFIX Erz")
|
||||||
|
process_orders()
|
||||||
|
assert_not_nil(u1:show():find("Erzelf"))
|
||||||
|
u1.faction.locale = "en"
|
||||||
|
assert_not_nil(u1:show():find("archelf"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_recruit()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
|
||||||
|
u:add_item("money", 1000)
|
||||||
|
set_order(u, "REKRUTIERE 5")
|
||||||
|
process_orders()
|
||||||
|
for u in f.units do
|
||||||
|
assert_equal(6, u.number)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_give_horses()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("human", "noreply@eressea.de", "de")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
|
||||||
|
r:set_resource("horse", 0)
|
||||||
|
u:add_item("horse", 21)
|
||||||
|
u:add_item("dolphin", 10)
|
||||||
|
u:add_order("GIB 0 7 PFERD")
|
||||||
|
u:add_order("GIB 0 5 DELPHIN")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(7, r:get_resource("horse"))
|
||||||
|
assert_equal(5, u:get_item("dolphin"))
|
||||||
|
assert_equal(14, u:get_item("horse"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_give_silver()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("human", "noreply@eressea.de", "de")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
|
||||||
|
r:set_resource("peasant", 0)
|
||||||
|
r:set_resource("money", 11)
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_item("money", 20)
|
||||||
|
u:add_order("GIB 0 10 SILBER")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(21, r:get_resource("money"))
|
||||||
|
assert_equal(10, u:get_item("money"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_give_horses()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
|
||||||
|
r:set_resource("horse", 0)
|
||||||
|
u:add_item("horse", 21)
|
||||||
|
u:add_item("dolphin", 10)
|
||||||
|
u:add_order("GIB 0 7 PFERD")
|
||||||
|
u:add_order("GIB 0 5 DELPHIN")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(7, r:get_resource("horse"))
|
||||||
|
assert_equal(5, u:get_item("dolphin"))
|
||||||
|
assert_equal(14, u:get_item("horse"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_give_silver()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
|
||||||
|
r:set_resource("peasant", 0)
|
||||||
|
r:set_resource("money", 11)
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_item("money", 20)
|
||||||
|
u:add_order("GIB 0 10 SILBER")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(21, r:get_resource("money"))
|
||||||
|
assert_equal(10, u:get_item("money"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_build_castle_one_stage()
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u = unit.create(f, r, 2)
|
||||||
|
|
||||||
|
u:add_item('stone', 4)
|
||||||
|
|
||||||
|
u:set_skill('building', 1)
|
||||||
|
u:add_order('MACHE BURG')
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
assert_equal(2, u.building.size)
|
||||||
|
assert_equal(2, u:get_item('stone'))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_build_castle()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
|
||||||
|
u:add_item('stone', 1)
|
||||||
|
u:set_skill('building', 1)
|
||||||
|
u:add_order("MACHE BURG")
|
||||||
|
process_orders()
|
||||||
|
assert_not_nil(u.building)
|
||||||
|
assert_equal(1, u.building.size)
|
||||||
|
assert_equal(u.building.name, "Burg")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_route()
|
||||||
|
local r1 = region.create(0, 0, "plain")
|
||||||
|
local r2 = region.create(1, 0, "plain")
|
||||||
|
local f = faction.create("human", "route@example.com")
|
||||||
|
local u = unit.create(f, r1, 1)
|
||||||
|
u:add_order("ROUTE O W P")
|
||||||
|
process_orders()
|
||||||
|
assert_equal("ROUTE West PAUSE Ost", u:get_order(0))
|
||||||
|
assert_equal(r2, u.region)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_route_horse()
|
||||||
|
local r1 = region.create(0, 0, "plain")
|
||||||
|
local r2 = region.create(1, 0, "plain")
|
||||||
|
local f = faction.create("human", "route@example.com")
|
||||||
|
local u = unit.create(f, r1, 1)
|
||||||
|
u:add_order("ROUTE O P W P")
|
||||||
|
u:add_item('horse', 1)
|
||||||
|
u:set_skill('riding', 1)
|
||||||
|
process_orders()
|
||||||
|
assert_equal("ROUTE West PAUSE Ost PAUSE", u:get_order(0))
|
||||||
|
assert_equal(r2, u.region)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_route_pause()
|
||||||
|
local r1 = region.create(0, 0, "plain")
|
||||||
|
local r2 = region.create(1, 0, "plain")
|
||||||
|
local f = faction.create("human", "route@example.com")
|
||||||
|
local u = unit.create(f, r1, 1)
|
||||||
|
u:add_order("ROUTE P O W")
|
||||||
|
process_orders()
|
||||||
|
assert_equal("ROUTE P O W", u:get_order(0))
|
||||||
|
assert_equal(r1, u.region)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_immunity_stops_guard()
|
||||||
|
eressea.settings.set("NewbieImmunity", 2)
|
||||||
|
local f = faction.create('human')
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
u:set_skill('polearm', 2)
|
||||||
|
u:add_item('lance', 1)
|
||||||
|
u:add_order('BEWACHE')
|
||||||
|
process_orders()
|
||||||
|
assert_equal(f.age, 1)
|
||||||
|
assert_true(not u.guard)
|
||||||
|
process_orders()
|
||||||
|
assert_equal(f.age, 2)
|
||||||
|
assert_true(u.guard)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_region_keys()
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
assert_nil(r:get_key('test'))
|
||||||
|
assert_nil(r:get_key('more'))
|
||||||
|
r:set_key('test', 42)
|
||||||
|
r:set_key('more') -- default is 1
|
||||||
|
assert_equal(42, r:get_key('test'))
|
||||||
|
assert_equal(1, r:get_key('more'))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_faction_keys()
|
||||||
|
local f = faction.create('human')
|
||||||
|
assert_nil(f:get_key('test'))
|
||||||
|
assert_nil(f:get_key('more'))
|
||||||
|
f:set_key('test', 42)
|
||||||
|
f:set_key('more') -- default is 1
|
||||||
|
assert_equal(42, f:get_key('test'))
|
||||||
|
assert_equal(1, f:get_key('more'))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_cartmaking()
|
||||||
|
local f = faction.create('human')
|
||||||
|
local r = region.create(0, 0, 'plain')
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
u:set_skill('cartmaking', 1)
|
||||||
|
u:add_item('log', 10)
|
||||||
|
u:add_order('MACHE Wagen')
|
||||||
|
process_orders()
|
||||||
|
assert_equal(1, u:get_item('cart'))
|
||||||
|
assert_equal(5, u:get_item('log'))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_promote_after_recruit()
|
||||||
|
local f = faction.create('human')
|
||||||
|
local r1 = region.create(0, 0, 'plain')
|
||||||
|
local r2 = region.create(1, 0, 'plain')
|
||||||
|
local u1 = unit.create(f, r1, 1)
|
||||||
|
u1.name = 'Xolgrim'
|
||||||
|
local u2 = unit.create(f, r2, 55)
|
||||||
|
u2:add_order('REKRUTIERE 1')
|
||||||
|
u1:add_order('BEFOERDERE')
|
||||||
|
u1:add_item('money', 57)
|
||||||
|
u2:add_item('money', 150)
|
||||||
|
local fl = u1.flags
|
||||||
|
process_orders()
|
||||||
|
assert_equal(56, u2.number)
|
||||||
|
assert_equal(fl + 128, u1.flags) -- UFL_HERO
|
||||||
|
assert_equal(0, u1:get_item('money'))
|
||||||
|
end
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.pool'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.eressea.pool", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.process'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.process", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
local u, r, f
|
local u, r, f
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.production'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.production", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
local tcname = 'tests.shared.recruit'
|
||||||
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
|
function setup()
|
||||||
|
eressea.free_game()
|
||||||
|
eressea.settings.set("rules.food.flags", "4")
|
||||||
|
eressea.settings.set("rules.peasants.growth", "0")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_bug_1795_limit()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create('human')
|
||||||
|
local u1 = unit.create(f, r, 1)
|
||||||
|
u1:add_item("money", 100000000)
|
||||||
|
u1:add_order("REKRUTIEREN 9999")
|
||||||
|
r:set_resource("peasant", 2000) -- no fractional growth!
|
||||||
|
local peasants = r:get_resource("peasant")
|
||||||
|
local limit,frac = math.modf(peasants/40) -- one day this should be a parameter
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
|
||||||
|
local np = r:get_resource("peasant")
|
||||||
|
assert_equal(peasants-limit, np)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_bug_1795_demons()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create('demon')
|
||||||
|
local u1 = unit.create(f, r, 1)
|
||||||
|
r:set_resource("peasant", 2000)
|
||||||
|
local peasants = r:get_resource("peasant")
|
||||||
|
local limit,frac = math.modf(peasants/40)
|
||||||
|
|
||||||
|
u1:add_item("money", 100000000)
|
||||||
|
u1:add_order("REKRUTIEREN 9999")
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
|
||||||
|
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
|
||||||
|
assert_equal(peasants, r:get_resource("peasant"))
|
||||||
|
end
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.regions'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.regions", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.game.reset()
|
eressea.game.reset()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.report'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.report", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require 'lunit'
|
local tcname = 'tests.settings'
|
||||||
|
local lunit = require('lunit')
|
||||||
module('tests.eressea.settings', package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
require 'lunit'
|
local tcname = 'tests.shared.spells'
|
||||||
module("tests.spells", package.seeall, lunit.testcase)
|
local lunit = require('lunit')
|
||||||
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.storage'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.storage", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.study'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.eressea.study", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
conf = [[{
|
conf = [[{
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.undead'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.undead", package.seeall, lunit.testcase)
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require "lunit"
|
local tcname = 'tests.shared.xmas'
|
||||||
|
local lunit = require('lunit')
|
||||||
module("tests.xmas", package.seeall, lunit.testcase )
|
if _VERSION >= 'Lua 5.2' then
|
||||||
|
_ENV = module(tcname, 'seeall')
|
||||||
|
else
|
||||||
|
module(tcname, lunit.testcase, package.seeall)
|
||||||
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.free_game()
|
||||||
|
|
|
@ -37,8 +37,13 @@ int u_geteffstealth(const unit *u)
|
||||||
if (skill_enabled(SK_STEALTH)) {
|
if (skill_enabled(SK_STEALTH)) {
|
||||||
if (u->flags & UFL_STEALTH) {
|
if (u->flags & UFL_STEALTH) {
|
||||||
attrib *a = a_find(u->attribs, &at_stealth);
|
attrib *a = a_find(u->attribs, &at_stealth);
|
||||||
if (a != NULL)
|
if (a != NULL) {
|
||||||
|
int eff = effskill(u, SK_STEALTH, u->region);
|
||||||
|
if (eff < a->data.i) {
|
||||||
|
return eff;
|
||||||
|
}
|
||||||
return a->data.i;
|
return a->data.i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -20,7 +20,7 @@ static void test_stealth(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
|
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
|
||||||
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
|
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
|
||||||
u_seteffstealth(u, 3);
|
u_seteffstealth(u, 3);
|
||||||
CuAssertIntEquals(tc, 3, u_geteffstealth(u));
|
CuAssertIntEquals(tc, 2, u_geteffstealth(u));
|
||||||
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
|
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
|
||||||
u_seteffstealth(u, 1);
|
u_seteffstealth(u, 1);
|
||||||
CuAssertIntEquals(tc, 1, u_geteffstealth(u));
|
CuAssertIntEquals(tc, 1, u_geteffstealth(u));
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
static int cmp_scholars(const void *lhs, const void *rhs) {
|
static int cmp_scholars(const void *lhs, const void *rhs) {
|
||||||
const scholar *a = (const scholar *)lhs;
|
const scholar *a = (const scholar *)lhs;
|
||||||
const scholar *b = (const scholar *)rhs;
|
const scholar *b = (const scholar *)rhs;
|
||||||
return b->level - a->level;
|
int diff = b->level - a->level;
|
||||||
|
return (diff != 0) ? diff : b->u->number - a->u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int autostudy_init(scholar scholars[], int max_scholars, unit **units, skill_t *o_skill)
|
int autostudy_init(scholar scholars[], int max_scholars, unit **units, skill_t *o_skill)
|
||||||
|
@ -77,6 +78,7 @@ int autostudy_init(scholar scholars[], int max_scholars, unit **units, skill_t *
|
||||||
|
|
||||||
static void teaching(scholar *s, int n) {
|
static void teaching(scholar *s, int n) {
|
||||||
assert(n <= s->u->number);
|
assert(n <= s->u->number);
|
||||||
|
// doppelter Effekt mit Lehrer:
|
||||||
s->learn += n;
|
s->learn += n;
|
||||||
s->u->flags |= UFL_LONGACTION;
|
s->u->flags |= UFL_LONGACTION;
|
||||||
}
|
}
|
||||||
|
@ -91,27 +93,31 @@ void autostudy_run(scholar scholars[], int nscholars)
|
||||||
{
|
{
|
||||||
int ti = 0;
|
int ti = 0;
|
||||||
while (ti != nscholars) {
|
while (ti != nscholars) {
|
||||||
int t, se, ts = 0, tt = 0, si = ti;
|
int t, ts = 0, tt = 0, si = ti, mint = 0, ns = 0;
|
||||||
for (se = ti; se != nscholars; ++se) {
|
for (t = ti; t != nscholars; ++t) {
|
||||||
int mint;
|
ts += scholars[t].u->number; /* count total scholars */
|
||||||
ts += scholars[se].u->number; /* count total scholars */
|
|
||||||
mint = (ts + 10) / 11; /* need a minimum of ceil(ts/11) teachers */
|
mint = (ts + 10) / 11; /* need a minimum of ceil(ts/11) teachers */
|
||||||
for (; mint > tt && si != nscholars; ++si) {
|
for (; mint > tt && si != nscholars; ++si) {
|
||||||
tt += scholars[si].u->number;
|
tt += scholars[si].u->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mint < tt) {
|
||||||
|
/* die Einheit si-1 hat einen Mix aus Lehrer und Schüler */
|
||||||
|
--si;
|
||||||
|
ns = tt - mint;
|
||||||
|
}
|
||||||
/* now si splits the teachers and students 1:10 */
|
/* now si splits the teachers and students 1:10 */
|
||||||
/* first student must be 2 levels below first teacher: */
|
/* first student must be 2 levels below first teacher: */
|
||||||
for (; si != se; ++si) {
|
for (; si != nscholars; ++si) {
|
||||||
if (scholars[si].level + TEACHDIFFERENCE <= scholars[ti].level) {
|
if (scholars[si].level + TEACHDIFFERENCE <= scholars[ti].level) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tt += scholars[si].u->number;
|
ns = 0;
|
||||||
}
|
}
|
||||||
/* now si is the first unit we can teach, if we can teach any */
|
/* now si is the first unit we can teach, if we can teach any */
|
||||||
if (si == se) {
|
if (si == nscholars) {
|
||||||
/* there are no students, so standard learning for everyone */
|
/* there are no students, so standard learning for everyone */
|
||||||
for (t = ti; t != se; ++t) {
|
for (t = ti; t != nscholars; ++t) {
|
||||||
learning(scholars + t, scholars[t].u->number);
|
learning(scholars + t, scholars[t].u->number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,16 +125,17 @@ void autostudy_run(scholar scholars[], int nscholars)
|
||||||
/* invariant: unit ti can still teach i students */
|
/* invariant: unit ti can still teach i students */
|
||||||
int i = scholars[ti].u->number * STUDENTS_PER_TEACHER;
|
int i = scholars[ti].u->number * STUDENTS_PER_TEACHER;
|
||||||
/* invariant: unit si has n students that can still be taught */
|
/* invariant: unit si has n students that can still be taught */
|
||||||
int s, n = scholars[si].u->number;
|
int s, n = (ns > 0) ? ns : scholars[si].u->number;
|
||||||
for (t = ti, s = si; t != si && s != se; ) {
|
for (t = ti, s = si; t != si && s != nscholars; ) {
|
||||||
if (i >= n) {
|
if (i >= n) {
|
||||||
/* t has more than enough teaching capacity for s */
|
/* t has more than enough teaching capacity for s */
|
||||||
i -= n;
|
i -= n;
|
||||||
teaching(scholars + s, n);
|
teaching(scholars + s, n);
|
||||||
learning(scholars + s, scholars[s].u->number);
|
learning(scholars + s, scholars[s].u->number);
|
||||||
/* next student, please: */
|
/* next student, please: */
|
||||||
if (++s == se) {
|
if (++s == nscholars) {
|
||||||
continue;
|
/* no more students */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
n = scholars[s].u->number;
|
n = scholars[s].u->number;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +154,7 @@ void autostudy_run(scholar scholars[], int nscholars)
|
||||||
do {
|
do {
|
||||||
/* remaining students learn without a teacher: */
|
/* remaining students learn without a teacher: */
|
||||||
learning(scholars + s, n);
|
learning(scholars + s, n);
|
||||||
if (++s == se) {
|
if (++s == nscholars) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
n = scholars[s].u->number;
|
n = scholars[s].u->number;
|
||||||
|
@ -163,10 +170,15 @@ void autostudy_run(scholar scholars[], int nscholars)
|
||||||
}
|
}
|
||||||
++t;
|
++t;
|
||||||
for (; t < si; ++t) {
|
for (; t < si; ++t) {
|
||||||
|
/* teachers that did not teach */
|
||||||
learning(scholars + t, scholars[t].u->number);
|
learning(scholars + t, scholars[t].u->number);
|
||||||
}
|
}
|
||||||
|
for (; s < nscholars; ++s) {
|
||||||
|
/* students that were not taught */
|
||||||
|
learning(scholars + s, scholars[s].u->number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ti = se;
|
ti = nscholars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,111 @@ static void test_autostudy_run_twoteachers(CuTest *tc) {
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reproduce Bug 2640
|
||||||
|
*/
|
||||||
|
static void test_autostudy_run_bigunit(CuTest *tc) {
|
||||||
|
scholar scholars[4];
|
||||||
|
int nscholars;
|
||||||
|
unit *u1, *u2, *ulist;
|
||||||
|
faction *f;
|
||||||
|
region *r;
|
||||||
|
skill_t skill;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
r = test_create_plain(0, 0);
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
u1 = test_create_unit(f, r);
|
||||||
|
set_number(u1, 20);
|
||||||
|
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||||
|
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
u2 = test_create_unit(f, r);
|
||||||
|
set_number(u2, 1000);
|
||||||
|
set_level(u2, SK_ENTERTAINMENT, 10);
|
||||||
|
u2->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
|
||||||
|
ulist = r->units;
|
||||||
|
CuAssertIntEquals(tc, 2, nscholars = autostudy_init(scholars, 4, &ulist, &skill));
|
||||||
|
CuAssertPtrEquals(tc, NULL, ulist);
|
||||||
|
autostudy_run(scholars, nscholars);
|
||||||
|
CuAssertIntEquals(tc, SK_ENTERTAINMENT, skill);
|
||||||
|
CuAssertIntEquals(tc, 0, scholars[0].learn);
|
||||||
|
CuAssertIntEquals(tc, 1200, scholars[1].learn);
|
||||||
|
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_autostudy_run_few_teachers(CuTest *tc) {
|
||||||
|
scholar scholars[4];
|
||||||
|
int nscholars;
|
||||||
|
unit *u1, *u2, *u3, *ulist;
|
||||||
|
faction *f;
|
||||||
|
region *r;
|
||||||
|
skill_t skill;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
r = test_create_plain(0, 0);
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
u1 = test_create_unit(f, r);
|
||||||
|
set_number(u1, 20);
|
||||||
|
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||||
|
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
u2 = test_create_unit(f, r);
|
||||||
|
set_number(u2, 500);
|
||||||
|
set_level(u2, SK_ENTERTAINMENT, 10);
|
||||||
|
u2->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
u3 = test_create_unit(f, r);
|
||||||
|
set_number(u3, 100);
|
||||||
|
set_level(u3, SK_ENTERTAINMENT, 9);
|
||||||
|
u3->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
|
||||||
|
ulist = r->units;
|
||||||
|
CuAssertIntEquals(tc, 3, nscholars = autostudy_init(scholars, 4, &ulist, &skill));
|
||||||
|
CuAssertPtrEquals(tc, NULL, ulist);
|
||||||
|
autostudy_run(scholars, nscholars);
|
||||||
|
CuAssertIntEquals(tc, SK_ENTERTAINMENT, skill);
|
||||||
|
CuAssertIntEquals(tc, 0, scholars[0].learn);
|
||||||
|
CuAssertIntEquals(tc, 700, scholars[1].learn);
|
||||||
|
CuAssertIntEquals(tc, 100, scholars[2].learn);
|
||||||
|
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_autostudy_run_few_teachers_reverse(CuTest *tc) {
|
||||||
|
scholar scholars[4];
|
||||||
|
int nscholars;
|
||||||
|
unit *u1, *u2, *u3, *ulist;
|
||||||
|
faction *f;
|
||||||
|
region *r;
|
||||||
|
skill_t skill;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
r = test_create_plain(0, 0);
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
u1 = test_create_unit(f, r);
|
||||||
|
set_number(u1, 20);
|
||||||
|
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||||
|
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
u2 = test_create_unit(f, r);
|
||||||
|
set_number(u2, 100);
|
||||||
|
set_level(u2, SK_ENTERTAINMENT, 10);
|
||||||
|
u2->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
u3 = test_create_unit(f, r);
|
||||||
|
set_number(u3, 500);
|
||||||
|
set_level(u3, SK_ENTERTAINMENT, 9);
|
||||||
|
u3->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||||
|
|
||||||
|
ulist = r->units;
|
||||||
|
CuAssertIntEquals(tc, 3, nscholars = autostudy_init(scholars, 4, &ulist, &skill));
|
||||||
|
CuAssertPtrEquals(tc, NULL, ulist);
|
||||||
|
autostudy_run(scholars, nscholars);
|
||||||
|
CuAssertIntEquals(tc, SK_ENTERTAINMENT, skill);
|
||||||
|
CuAssertIntEquals(tc, 0, scholars[0].learn);
|
||||||
|
CuAssertIntEquals(tc, 800, scholars[1].learn + scholars[2].learn);
|
||||||
|
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_autostudy_run(CuTest *tc) {
|
static void test_autostudy_run(CuTest *tc) {
|
||||||
scholar scholars[4];
|
scholar scholars[4];
|
||||||
int nscholars;
|
int nscholars;
|
||||||
|
@ -325,6 +430,9 @@ CuSuite *get_automate_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_autostudy_run_noteachers);
|
SUITE_ADD_TEST(suite, test_autostudy_run_noteachers);
|
||||||
SUITE_ADD_TEST(suite, test_autostudy_run_teachers_learn);
|
SUITE_ADD_TEST(suite, test_autostudy_run_teachers_learn);
|
||||||
SUITE_ADD_TEST(suite, test_autostudy_run_twoteachers);
|
SUITE_ADD_TEST(suite, test_autostudy_run_twoteachers);
|
||||||
|
SUITE_ADD_TEST(suite, test_autostudy_run_bigunit);
|
||||||
|
SUITE_ADD_TEST(suite, test_autostudy_run_few_teachers);
|
||||||
|
SUITE_ADD_TEST(suite, test_autostudy_run_few_teachers_reverse);
|
||||||
SUITE_ADD_TEST(suite, test_autostudy_run_skilldiff);
|
SUITE_ADD_TEST(suite, test_autostudy_run_skilldiff);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2933,7 +2933,7 @@ static void print_stats(battle * b)
|
||||||
header = LOC(f->locale, "battle_helpers");
|
header = LOC(f->locale, "battle_helpers");
|
||||||
|
|
||||||
for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) {
|
for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) {
|
||||||
if (friendly(s2, s)) {
|
if (s2 != s && friendly(s2, s)) {
|
||||||
const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-";
|
const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-";
|
||||||
rsize = slprintf(bufp, size, "%s %s %d(%s)",
|
rsize = slprintf(bufp, size, "%s %s %d(%s)",
|
||||||
komma++ ? "," : (const char *)header, loc_army, army_index(s2),
|
komma++ ? "," : (const char *)header, loc_army, army_index(s2),
|
||||||
|
|
|
@ -28,9 +28,6 @@ static int tolua_levitate_ship(lua_State * L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void spawn_undead(void);
|
|
||||||
extern void plan_monsters(struct faction *f);
|
|
||||||
|
|
||||||
static int tolua_planmonsters(lua_State * L)
|
static int tolua_planmonsters(lua_State * L)
|
||||||
{
|
{
|
||||||
faction *f = (faction *)tolua_tousertype(L, 1, get_monsters());
|
faction *f = (faction *)tolua_tousertype(L, 1, get_monsters());
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
|
|
||||||
void tolua_bind_open(lua_State * L) {
|
void tolua_bind_open(lua_State * L)
|
||||||
|
{
|
||||||
tolua_eressea_open(L);
|
tolua_eressea_open(L);
|
||||||
tolua_process_open(L);
|
tolua_process_open(L);
|
||||||
tolua_settings_open(L);
|
tolua_settings_open(L);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "bindings.h"
|
#include "bindings.h"
|
||||||
|
#include "bind_tolua.h"
|
||||||
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "gamedb.h"
|
#include "gamedb.h"
|
||||||
|
@ -259,7 +260,7 @@ static int tolua_dice_rand(lua_State * L)
|
||||||
|
|
||||||
static int tolua_get_season(lua_State * L)
|
static int tolua_get_season(lua_State * L)
|
||||||
{
|
{
|
||||||
int turn_no = (int)tolua_tonumber(L, 1, 0);
|
int turn_no = (int)tolua_tonumber(L, 1, turn);
|
||||||
season_t season = calendar_season(turn_no);
|
season_t season = calendar_season(turn_no);
|
||||||
tolua_pushstring(L, seasonnames[season]);
|
tolua_pushstring(L, seasonnames[season]);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -865,8 +866,6 @@ static int lua_rng_default(lua_State *L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tolua_bind_open(lua_State * L);
|
|
||||||
|
|
||||||
int tolua_bindings_open(lua_State * L, const dictionary *inifile)
|
int tolua_bindings_open(lua_State * L, const dictionary *inifile)
|
||||||
{
|
{
|
||||||
tolua_open(L);
|
tolua_open(L);
|
||||||
|
|
|
@ -12,6 +12,8 @@ extern "C" {
|
||||||
int tolua_selist_push(struct lua_State *L, const char *list_type,
|
int tolua_selist_push(struct lua_State *L, const char *list_type,
|
||||||
const char *elem_type, struct selist *list);
|
const char *elem_type, struct selist *list);
|
||||||
|
|
||||||
|
void bind_monsters(struct lua_State *L);
|
||||||
|
|
||||||
int log_lua_error(struct lua_State *L);
|
int log_lua_error(struct lua_State *L);
|
||||||
|
|
||||||
void lua_done(struct lua_State *L);
|
void lua_done(struct lua_State *L);
|
||||||
|
|
18
src/chaos.c
18
src/chaos.c
|
@ -76,7 +76,7 @@ static unit *random_unit(const region * r)
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chaos(region * r)
|
static void chaos(region * r, faction *monsters)
|
||||||
{
|
{
|
||||||
if (rng_int() % 100 < 8) {
|
if (rng_int() % 100 < 8) {
|
||||||
switch (rng_int() % 3) {
|
switch (rng_int() % 3) {
|
||||||
|
@ -84,10 +84,10 @@ static void chaos(region * r)
|
||||||
if (!(r->terrain->flags & SEA_REGION)) {
|
if (!(r->terrain->flags & SEA_REGION)) {
|
||||||
unit *u = random_unit(r);
|
unit *u = random_unit(r);
|
||||||
if (u && !undeadrace(u_race(u))) {
|
if (u && !undeadrace(u_race(u))) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u));
|
if (join_monsters(u, monsters)) {
|
||||||
u_setfaction(u, get_monsters());
|
ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u));
|
||||||
u_freeorders(u);
|
u_setrace(u, get_race(RC_GHOUL));
|
||||||
u_setrace(u, get_race(RC_GHOUL));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -99,17 +99,17 @@ static void chaos(region * r)
|
||||||
case 0:
|
case 0:
|
||||||
mfac = 100;
|
mfac = 100;
|
||||||
u =
|
u =
|
||||||
create_unit(r, get_monsters(), rng_int() % 8 + 1,
|
create_unit(r, monsters, rng_int() % 8 + 1,
|
||||||
get_race(RC_FIREDRAGON), 0, NULL, NULL);
|
get_race(RC_FIREDRAGON), 0, NULL, NULL);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mfac = 500;
|
mfac = 500;
|
||||||
u = create_unit(r, get_monsters(), rng_int() % 4 + 1,
|
u = create_unit(r, monsters, rng_int() % 4 + 1,
|
||||||
get_race(RC_DRAGON), 0, NULL, NULL);
|
get_race(RC_DRAGON), 0, NULL, NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mfac = 1000;
|
mfac = 1000;
|
||||||
u = create_unit(r, get_monsters(), rng_int() % 2 + 1,
|
u = create_unit(r, monsters, rng_int() % 2 + 1,
|
||||||
get_race(RC_WYRM), 0, NULL, NULL);
|
get_race(RC_WYRM), 0, NULL, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ void chaos_update(void) {
|
||||||
/* Chaos */
|
/* Chaos */
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
if ((r->flags & RF_CHAOTIC)) {
|
if ((r->flags & RF_CHAOTIC)) {
|
||||||
chaos(r);
|
chaos(r, get_monsters());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ static char g_bigbuf[BUFFERSIZE];
|
||||||
bool opt_cr_absolute_coords = false;
|
bool opt_cr_absolute_coords = false;
|
||||||
|
|
||||||
/* globals */
|
/* globals */
|
||||||
#define C_REPORT_VERSION 67
|
#define C_REPORT_VERSION 68
|
||||||
|
|
||||||
struct locale *crtag_locale(void) {
|
struct locale *crtag_locale(void) {
|
||||||
static struct locale * lang;
|
static struct locale * lang;
|
||||||
|
@ -495,38 +495,6 @@ static int cr_curse(variant var, char *buffer, const void *userdata)
|
||||||
|
|
||||||
/*static int msgno; */
|
/*static int msgno; */
|
||||||
|
|
||||||
#define MTMAXHASH 1021
|
|
||||||
|
|
||||||
static struct known_mtype {
|
|
||||||
const struct message_type *mtype;
|
|
||||||
struct known_mtype *nexthash;
|
|
||||||
} *mtypehash[MTMAXHASH];
|
|
||||||
|
|
||||||
static void report_crtypes(FILE * F, const struct locale *lang)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i != MTMAXHASH; ++i) {
|
|
||||||
struct known_mtype *kmt;
|
|
||||||
for (kmt = mtypehash[i]; kmt; kmt = kmt->nexthash) {
|
|
||||||
char buffer[DISPLAYSIZE];
|
|
||||||
int hash = (int)kmt->mtype->key;
|
|
||||||
assert(hash > 0);
|
|
||||||
fprintf(F, "MESSAGETYPE %d\n", hash);
|
|
||||||
fputc('\"', F);
|
|
||||||
fputs(crescape(nrt_string(kmt->mtype, lang), buffer, sizeof(buffer)), F);
|
|
||||||
fputs("\";text\n", F);
|
|
||||||
if (kmt->mtype->section) {
|
|
||||||
fprintf(F, "\"%s\";section\n", kmt->mtype->section);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (mtypehash[i]) {
|
|
||||||
kmt = mtypehash[i];
|
|
||||||
mtypehash[i] = mtypehash[i]->nexthash;
|
|
||||||
free(kmt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int message_id(const struct message *msg)
|
static int message_id(const struct message *msg)
|
||||||
{
|
{
|
||||||
variant var;
|
variant var;
|
||||||
|
@ -594,19 +562,6 @@ static void render_messages(FILE * F, faction * f, message_list * msgs)
|
||||||
else {
|
else {
|
||||||
log_error("could not render cr-message %p: %s\n", m->msg, m->msg->type->name);
|
log_error("could not render cr-message %p: %s\n", m->msg, m->msg->type->name);
|
||||||
}
|
}
|
||||||
if (printed) {
|
|
||||||
unsigned int ihash = hash % MTMAXHASH;
|
|
||||||
struct known_mtype *kmt = mtypehash[ihash];
|
|
||||||
while (kmt && kmt->mtype != mtype)
|
|
||||||
kmt = kmt->nexthash;
|
|
||||||
if (kmt == NULL) {
|
|
||||||
kmt = (struct known_mtype *)malloc(sizeof(struct known_mtype));
|
|
||||||
if (!kmt) abort();
|
|
||||||
kmt->nexthash = mtypehash[ihash];
|
|
||||||
kmt->mtype = mtype;
|
|
||||||
mtypehash[ihash] = kmt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m = m->next;
|
m = m->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1714,7 +1669,6 @@ report_computer(const char *filename, report_context * ctx, const char *bom)
|
||||||
cr_output_region(F, ctx, r);
|
cr_output_region(F, ctx, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
report_crtypes(F, f->locale);
|
|
||||||
if (f->locale != crtag_locale()) {
|
if (f->locale != crtag_locale()) {
|
||||||
report_translations(F);
|
report_translations(F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,10 +290,10 @@ static int forget_cmd(unit * u, order * ord)
|
||||||
else {
|
else {
|
||||||
unit *ufam = get_familiar(u);
|
unit *ufam = get_familiar(u);
|
||||||
if (ufam) {
|
if (ufam) {
|
||||||
a_removeall(&ufam->attribs, NULL);
|
if (join_monsters(ufam, NULL)) {
|
||||||
u_setfaction(ufam, get_monsters());
|
a_removeall(&ufam->attribs, NULL);
|
||||||
u_freeorders(ufam);
|
unit_convert_race(ufam, NULL, "ghost");
|
||||||
unit_convert_race(ufam, NULL, "ghost");
|
}
|
||||||
}
|
}
|
||||||
a_removeall(&u->attribs, &at_mage);
|
a_removeall(&u->attribs, &at_mage);
|
||||||
a_removeall(&u->attribs, &at_familiar);
|
a_removeall(&u->attribs, &at_familiar);
|
||||||
|
@ -1680,84 +1680,41 @@ static void plant(unit * u, int raw)
|
||||||
u, r, planted, itype->rtype));
|
u, r, planted, itype->rtype));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void planttrees(unit * u, int raw)
|
static void planttrees(region * r, int type, int n)
|
||||||
{
|
{
|
||||||
int n, i, skill, planted = 0;
|
if (n > 0) {
|
||||||
const resource_type *rtype;
|
rsettrees(r, type, rtrees(r, type) + n);
|
||||||
region * r = u->region;
|
|
||||||
|
|
||||||
if (!fval(r->terrain, LAND_REGION)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mallornbaeume kann man nur in Mallornregionen zuechten */
|
|
||||||
rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORN_SEED : R_SEED);
|
|
||||||
|
|
||||||
/* Skill pruefen */
|
|
||||||
skill = effskill(u, SK_HERBALISM, NULL);
|
|
||||||
if (skill < 6) {
|
|
||||||
ADDMSG(&u->faction->msgs,
|
|
||||||
msg_feedback(u, u->thisorder, "plant_skills",
|
|
||||||
"skill minskill product", SK_HERBALISM, 6, rtype, 1));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (fval(r, RF_MALLORN) && skill < 7) {
|
|
||||||
ADDMSG(&u->faction->msgs,
|
|
||||||
msg_feedback(u, u->thisorder, "plant_skills",
|
|
||||||
"skill minskill product", SK_HERBALISM, 7, rtype, 1));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wenn eine Anzahl angegeben wurde, nur soviel verbrauchen */
|
|
||||||
if (raw > skill * u->number) raw = skill * u->number;
|
|
||||||
n = get_pooled(u, rtype, GET_DEFAULT, raw);
|
|
||||||
if (n == 0) {
|
|
||||||
ADDMSG(&u->faction->msgs,
|
|
||||||
msg_feedback(u, u->thisorder, "resource_missing", "missing", rtype));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (n > raw) n = raw;
|
|
||||||
|
|
||||||
/* Fuer jeden Samen Talent*10% Erfolgschance. */
|
|
||||||
for (i = n; i > 0; i--) {
|
|
||||||
if (rng_int() % 10 < skill)
|
|
||||||
planted++;
|
|
||||||
}
|
|
||||||
rsettrees(r, 0, rtrees(r, 0) + planted);
|
|
||||||
|
|
||||||
/* Alles ok. Abziehen. */
|
|
||||||
produceexp(u, SK_HERBALISM, u->number);
|
|
||||||
use_pooled(u, rtype, GET_DEFAULT, n);
|
|
||||||
|
|
||||||
ADDMSG(&u->faction->msgs, msg_message("plant",
|
|
||||||
"unit region amount herb", u, r, planted, rtype));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* zuechte baeume */
|
/* zuechte baeume */
|
||||||
static void breedtrees(unit * u, int raw)
|
static void breedtrees(unit * u, int raw)
|
||||||
{
|
{
|
||||||
int n, i, skill, planted = 0;
|
int n, i, skill;
|
||||||
const resource_type *rtype;
|
const resource_type *rtype;
|
||||||
season_t current_season = calendar_season(turn);
|
season_t current_season = calendar_season(turn);
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
|
int minskill = 6;
|
||||||
/* Baeume zuechten geht nur im Fruehling */
|
|
||||||
if (current_season != SEASON_SPRING) {
|
|
||||||
planttrees(u, raw);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fval(r->terrain, LAND_REGION)) {
|
if (!fval(r->terrain, LAND_REGION)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mallornbaeume kann man nur in Mallornregionen zuechten */
|
/* Mallornbaeume kann man nur in Mallornregionen zuechten */
|
||||||
rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORN_SEED : R_SEED);
|
if (fval(r, RF_MALLORN)) {
|
||||||
|
++minskill;
|
||||||
|
rtype = get_resourcetype(R_MALLORN_SEED);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rtype = get_resourcetype(R_SEED);
|
||||||
|
}
|
||||||
|
|
||||||
/* Skill pruefen */
|
/* Skill pruefen */
|
||||||
skill = effskill(u, SK_HERBALISM, NULL);
|
skill = effskill(u, SK_HERBALISM, NULL);
|
||||||
if (skill < 12) {
|
if (skill < minskill) {
|
||||||
planttrees(u, raw);
|
ADDMSG(&u->faction->msgs,
|
||||||
|
msg_feedback(u, u->thisorder, "plant_skills",
|
||||||
|
"skill minskill product", SK_HERBALISM, 6, rtype, 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1773,19 +1730,21 @@ static void breedtrees(unit * u, int raw)
|
||||||
}
|
}
|
||||||
if (n > raw) n = raw;
|
if (n > raw) n = raw;
|
||||||
|
|
||||||
/* Fuer jeden Samen Talent*5% Erfolgschance. */
|
if (skill >= 12 && current_season == SEASON_SPRING) {
|
||||||
for (i = n; i > 0; i--) {
|
// Plant saplings for every 10 seeds
|
||||||
if (rng_int() % 100 < skill * 5)
|
planttrees(r, 0, n % 10);
|
||||||
planted++;
|
planttrees(r, 1, n / 10);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
planttrees(r, 0, n);
|
||||||
}
|
}
|
||||||
rsettrees(r, 1, rtrees(r, 1) + planted);
|
|
||||||
|
|
||||||
/* Alles ok. Abziehen. */
|
/* Alles ok. Samen abziehen. */
|
||||||
produceexp(u, SK_HERBALISM, u->number);
|
produceexp(u, SK_HERBALISM, u->number);
|
||||||
use_pooled(u, rtype, GET_DEFAULT, n);
|
use_pooled(u, rtype, GET_DEFAULT, n);
|
||||||
|
|
||||||
ADDMSG(&u->faction->msgs, msg_message("plant",
|
ADDMSG(&u->faction->msgs, msg_message("plant",
|
||||||
"unit region amount herb", u, r, planted, rtype));
|
"unit region amount herb", u, r, n, rtype));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* zuechte pferde */
|
/* zuechte pferde */
|
||||||
|
|
|
@ -371,7 +371,7 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord)
|
||||||
u2->ship->coast = u1->ship->coast;
|
u2->ship->coast = u1->ship->coast;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return msg_error(u1, ord, 182);
|
return msg_error(u1, ord, 328);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -799,6 +799,9 @@ static void give_all_items(unit *u, unit *u2, order *ord) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
cmistake(u, ord, 123, MSG_COMMERCE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
static int g_quit;
|
static int g_quit;
|
||||||
int force_color = 0;
|
int force_color = 0;
|
||||||
newfaction * new_players = 0;
|
newfaction * new_players = NULL;
|
||||||
|
|
||||||
state *current_state = NULL;
|
state *current_state = NULL;
|
||||||
|
|
||||||
|
|
|
@ -746,10 +746,6 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||||
variant vm;
|
variant vm;
|
||||||
|
|
||||||
/* Godcurse: Income -10 */
|
/* Godcurse: Income -10 */
|
||||||
c = get_curse(r->attribs, &ct_godcursezone);
|
|
||||||
if (c && curse_active(c)) {
|
|
||||||
wage = (wage < 10) ? 0 : (wage - 10);
|
|
||||||
}
|
|
||||||
vm = frac_make(wage, 1);
|
vm = frac_make(wage, 1);
|
||||||
|
|
||||||
/* Bei einer Duerre verdient man nur noch ein Viertel */
|
/* Bei einer Duerre verdient man nur noch ein Viertel */
|
||||||
|
|
|
@ -129,6 +129,7 @@ static int read_ccompat(const char *cursename, struct storage *store)
|
||||||
} *seek, old_curses[] = {
|
} *seek, old_curses[] = {
|
||||||
{ "disorientationzone", "" },
|
{ "disorientationzone", "" },
|
||||||
{ "shipdisorientation", "" },
|
{ "shipdisorientation", "" },
|
||||||
|
{ "godcursezone", "" },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
for (seek = old_curses; seek->name; ++seek) {
|
for (seek = old_curses; seek->name; ++seek) {
|
||||||
|
|
|
@ -62,6 +62,7 @@ static message *missing_feedback(const char *name, const struct unit *u,
|
||||||
log_error("trying to create undefined feedback of type \"%s\"\n", name);
|
log_error("trying to create undefined feedback of type \"%s\"\n", name);
|
||||||
}
|
}
|
||||||
else if (missing_message_mode == MESSAGE_MISSING_REPLACE) {
|
else if (missing_message_mode == MESSAGE_MISSING_REPLACE) {
|
||||||
|
log_warning("trying to create undefined message of type \"%s\"\n", name);
|
||||||
if (strcmp(name, "missing_feedback") != 0) {
|
if (strcmp(name, "missing_feedback") != 0) {
|
||||||
if (!mt_find("missing_feedback")) {
|
if (!mt_find("missing_feedback")) {
|
||||||
mt_create_va(mt_new("missing_feedback", NULL), "unit:unit",
|
mt_create_va(mt_new("missing_feedback", NULL), "unit:unit",
|
||||||
|
|
|
@ -292,7 +292,7 @@ static race *rc_find_i(const char *name)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const race * rc_find(const char *name) {
|
race * rc_find(const char *name) {
|
||||||
return rc_find_i(name);
|
return rc_find_i(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ extern "C" {
|
||||||
race *rc_create(const char *zName);
|
race *rc_create(const char *zName);
|
||||||
race *rc_get_or_create(const char *name);
|
race *rc_get_or_create(const char *name);
|
||||||
bool rc_changed(int *cache);
|
bool rc_changed(int *cache);
|
||||||
const race *rc_find(const char *);
|
race *rc_find(const char *);
|
||||||
void free_races(void);
|
void free_races(void);
|
||||||
|
|
||||||
bool rc_can_use(const struct race *rc, const struct item_type *itype);
|
bool rc_can_use(const struct race *rc, const struct item_type *itype);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#ifndef ERESSEA_VERSION
|
#ifndef ERESSEA_VERSION
|
||||||
/* the version number, if it was not passed to make with -D */
|
/* the version number, if it was not passed to make with -D */
|
||||||
#define ERESSEA_VERSION "3.22.0"
|
#define ERESSEA_VERSION "3.24.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *eressea_version(void) {
|
const char *eressea_version(void) {
|
||||||
|
|
149
src/laws.c
149
src/laws.c
|
@ -463,10 +463,7 @@ static void horses(region * r)
|
||||||
maxhorses = region_maxworkers(r) / 10;
|
maxhorses = region_maxworkers(r) / 10;
|
||||||
horses = rhorses(r);
|
horses = rhorses(r);
|
||||||
if (horses > 0) {
|
if (horses > 0) {
|
||||||
if (is_cursed(r->attribs, &ct_godcursezone)) {
|
if (maxhorses > 0) {
|
||||||
rsethorses(r, (int)(horses * 0.9));
|
|
||||||
}
|
|
||||||
else if (maxhorses > 0) {
|
|
||||||
double growth =
|
double growth =
|
||||||
(RESOURCE_QUANTITY * (HORSEGROWTH * 200.0 * ((double)maxhorses -
|
(RESOURCE_QUANTITY * (HORSEGROWTH * 200.0 * ((double)maxhorses -
|
||||||
horses))) / (double)maxhorses;
|
horses))) / (double)maxhorses;
|
||||||
|
@ -594,14 +591,21 @@ growing_trees_e3(region * r, const int current_season,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cap_int(int i, int imin, int imax) {
|
||||||
|
if (i > imin) {
|
||||||
|
return ((i < imax) ? i : imax);
|
||||||
|
}
|
||||||
|
return imin;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
growing_trees(region * r, const season_t current_season, const season_t last_weeks_season)
|
growing_trees(region * r, const season_t current_season, const season_t last_weeks_season)
|
||||||
{
|
{
|
||||||
int grownup_trees, i, seeds, sprout;
|
int grownup_trees, i, seeds, sprout;
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
double seedchance = config_get_flt("rules.treeseeds.chance", 0.01F) * RESOURCE_QUANTITY;
|
||||||
|
|
||||||
if (current_season == SEASON_SUMMER || current_season == SEASON_AUTUMN) {
|
if (current_season == SEASON_SUMMER || current_season == SEASON_AUTUMN) {
|
||||||
double seedchance = 0.01F * RESOURCE_QUANTITY;
|
|
||||||
int mp, elves = count_race(r, get_race(RC_ELF));
|
int mp, elves = count_race(r, get_race(RC_ELF));
|
||||||
direction_t d;
|
direction_t d;
|
||||||
|
|
||||||
|
@ -618,12 +622,6 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
|
||||||
a_removeall(&r->attribs, &at_germs);
|
a_removeall(&r->attribs, &at_germs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_cursed(r->attribs, &ct_godcursezone)) {
|
|
||||||
rsettrees(r, 1, (int)(rtrees(r, 1) * 0.9));
|
|
||||||
rsettrees(r, 2, (int)(rtrees(r, 2) * 0.9));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mp = max_production(r);
|
mp = max_production(r);
|
||||||
if (mp <= 0)
|
if (mp <= 0)
|
||||||
return;
|
return;
|
||||||
|
@ -655,84 +653,63 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
|
||||||
|
|
||||||
/* Gesamtzahl der Samen:
|
/* Gesamtzahl der Samen:
|
||||||
* bis zu 6% (FORESTGROWTH*3) der Baeume samen in die Nachbarregionen */
|
* bis zu 6% (FORESTGROWTH*3) der Baeume samen in die Nachbarregionen */
|
||||||
seeds = (rtrees(r, 2) * FORESTGROWTH * 3) / 1000000;
|
if (seedchance > 0) {
|
||||||
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
seeds = (rtrees(r, 2) * FORESTGROWTH * 3) / 1000000;
|
||||||
region *r2 = rconnect(r, d);
|
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
||||||
if (r2 && fval(r2->terrain, LAND_REGION) && r2->terrain->size) {
|
region *r2 = rconnect(r, d);
|
||||||
/* Eine Landregion, wir versuchen Samen zu verteilen:
|
if (r2 && fval(r2->terrain, LAND_REGION) && r2->terrain->size) {
|
||||||
* Die Chance, das Samen ein Stueck Boden finden, in dem sie
|
/* Eine Landregion, wir versuchen Samen zu verteilen:
|
||||||
* keimen koennen, haengt von der Bewuchsdichte und der
|
* Die Chance, das Samen ein Stueck Boden finden, in dem sie
|
||||||
* verfuegbaren Flaeche ab. In Gletschern gibt es weniger
|
* keimen koennen, haengt von der Bewuchsdichte und der
|
||||||
* Moeglichkeiten als in Ebenen. */
|
* verfuegbaren Flaeche ab. In Gletschern gibt es weniger
|
||||||
sprout = 0;
|
* Moeglichkeiten als in Ebenen. */
|
||||||
seedchance = (1000.0 * region_maxworkers(r2)) / r2->terrain->size;
|
sprout = 0;
|
||||||
for (i = 0; i < seeds / MAXDIRECTIONS; i++) {
|
seedchance = (1000.0 * region_maxworkers(r2)) / r2->terrain->size;
|
||||||
if (rng_int() % 10000 < seedchance)
|
for (i = 0; i < seeds / MAXDIRECTIONS; i++) {
|
||||||
sprout++;
|
if (rng_int() % 10000 < seedchance)
|
||||||
|
sprout++;
|
||||||
|
}
|
||||||
|
rsettrees(r2, 0, rtrees(r2, 0) + sprout);
|
||||||
}
|
}
|
||||||
rsettrees(r2, 0, rtrees(r2, 0) + sprout);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (current_season == SEASON_SPRING) {
|
else if (current_season == SEASON_SPRING) {
|
||||||
int growth;
|
|
||||||
|
|
||||||
if (is_cursed(r->attribs, &ct_godcursezone))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* in at_germs merken uns die Zahl der Samen und Sproesslinge, die
|
/* in at_germs merken uns die Zahl der Samen und Sproesslinge, die
|
||||||
* dieses Jahr aelter werden duerfen, damit nicht ein Same im selben
|
* dieses Jahr aelter werden duerfen, damit nicht ein Same im selben
|
||||||
* Zyklus zum Baum werden kann */
|
* Zyklus zum Baum werden kann */
|
||||||
a = a_find(r->attribs, &at_germs);
|
a = a_find(r->attribs, &at_germs);
|
||||||
if (!a) {
|
if (!a) {
|
||||||
a = a_add(&r->attribs, a_new(&at_germs));
|
a = a_add(&r->attribs, a_new(&at_germs));
|
||||||
a->data.sa[0] = (short)rtrees(r, 0);
|
a->data.sa[0] = (short)cap_int(rtrees(r, 0), 0, SHRT_MAX);
|
||||||
a->data.sa[1] = (short)rtrees(r, 1);
|
a->data.sa[1] = (short)cap_int(rtrees(r, 1), 0, SHRT_MAX);
|
||||||
}
|
}
|
||||||
/* wir haben 6 Wochen zum wachsen, jeder Same/Spross hat 18% Chance
|
else if (a->data.sa[0] < 0 || a->data.sa[1] < 0) {
|
||||||
* zu wachsen, damit sollten nach 5-6 Wochen alle gewachsen sein */
|
a->data.sa[0] = (short)cap_int(a->data.sa[0], 0, SHRT_MAX);
|
||||||
growth = 1800;
|
a->data.sa[1] = (short)cap_int(a->data.sa[1], 0, SHRT_MAX);
|
||||||
|
|
||||||
/* Samenwachstum */
|
|
||||||
|
|
||||||
/* Raubbau abfangen, es duerfen nie mehr Samen wachsen, als aktuell
|
|
||||||
* in der Region sind */
|
|
||||||
seeds = rtrees(r, 0);
|
|
||||||
if (seeds > a->data.sa[0]) seeds = a->data.sa[0];
|
|
||||||
sprout = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < seeds; i++) {
|
|
||||||
if (rng_int() % 10000 < growth)
|
|
||||||
sprout++;
|
|
||||||
}
|
}
|
||||||
/* aus dem Samenpool dieses Jahres abziehen */
|
|
||||||
a->data.sa[0] = (short)(seeds - sprout);
|
|
||||||
/* aus dem gesamt Samenpool abziehen */
|
|
||||||
rsettrees(r, 0, rtrees(r, 0) - sprout);
|
|
||||||
/* zu den Sproesslinge hinzufuegen */
|
|
||||||
rsettrees(r, 1, rtrees(r, 1) + sprout);
|
|
||||||
|
|
||||||
/* Baumwachstum */
|
/* Baumwachstum */
|
||||||
|
|
||||||
/* hier gehen wir davon aus, das Jungbaeume nicht ohne weiteres aus
|
|
||||||
* der Region entfernt werden koennen, da Jungbaeume in der gleichen
|
|
||||||
* Runde nachwachsen, wir also nicht mehr zwischen diesjaehrigen und
|
|
||||||
* 'alten' Jungbaeumen unterscheiden koennten */
|
|
||||||
sprout = rtrees(r, 1);
|
sprout = rtrees(r, 1);
|
||||||
if (sprout > a->data.sa[1]) sprout = a->data.sa[1];
|
if (sprout > a->data.sa[1]) sprout = a->data.sa[1];
|
||||||
grownup_trees = 0;
|
grownup_trees = sprout / 6;
|
||||||
|
|
||||||
for (i = 0; i < sprout; i++) {
|
|
||||||
if (rng_int() % 10000 < growth)
|
|
||||||
grownup_trees++;
|
|
||||||
}
|
|
||||||
/* aus dem Sproesslingepool dieses Jahres abziehen */
|
/* aus dem Sproesslingepool dieses Jahres abziehen */
|
||||||
a->data.sa[1] = (short)(sprout - grownup_trees);
|
a->data.sa[1] = (short)(sprout - grownup_trees);
|
||||||
/* aus dem gesamt Sproesslingepool abziehen */
|
/* aus dem gesamt Sproesslingepool abziehen */
|
||||||
rsettrees(r, 1, rtrees(r, 1) - grownup_trees);
|
rsettrees(r, 1, rtrees(r, 1) - grownup_trees);
|
||||||
/* zu den Baeumen hinzufuegen */
|
/* zu den Baeumen hinzufuegen */
|
||||||
rsettrees(r, 2, rtrees(r, 2) + grownup_trees);
|
rsettrees(r, 2, rtrees(r, 2) + grownup_trees);
|
||||||
|
|
||||||
|
/* Samenwachstum */
|
||||||
|
seeds = rtrees(r, 0);
|
||||||
|
if (seeds > a->data.sa[0]) seeds = a->data.sa[0];
|
||||||
|
sprout = seeds / 6;
|
||||||
|
/* aus dem Samenpool dieses Jahres abziehen */
|
||||||
|
a->data.sa[0] = (short)(seeds - sprout);
|
||||||
|
/* aus dem gesamt Samenpool abziehen */
|
||||||
|
rsettrees(r, 0, rtrees(r, 0) - sprout);
|
||||||
|
/* zu den Sproesslinge hinzufuegen */
|
||||||
|
rsettrees(r, 1, rtrees(r, 1) + sprout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,7 +980,7 @@ int quit_cmd(unit * u, struct order *ord)
|
||||||
if (p == P_FACTION) {
|
if (p == P_FACTION) {
|
||||||
#ifdef QUIT_WITH_TRANSFER
|
#ifdef QUIT_WITH_TRANSFER
|
||||||
faction *f2 = getfaction();
|
faction *f2 = getfaction();
|
||||||
if (f2 == NULL) {
|
if (f2 == NULL || f2 == u->faction) {
|
||||||
cmistake(u, ord, 66, MSG_EVENT);
|
cmistake(u, ord, 66, MSG_EVENT);
|
||||||
flags = 0;
|
flags = 0;
|
||||||
}
|
}
|
||||||
|
@ -1249,13 +1226,6 @@ void do_enter(struct region *r, bool is_final_attempt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ulast != NULL) {
|
if (ulast != NULL) {
|
||||||
/* Wenn wir hier angekommen sind, war der Befehl
|
|
||||||
* erfolgreich und wir loeschen ihn, damit er im
|
|
||||||
* zweiten Versuch nicht nochmal ausgefuehrt wird. */
|
|
||||||
*ordp = ord->next;
|
|
||||||
ord->next = NULL;
|
|
||||||
free_order(ord);
|
|
||||||
|
|
||||||
if (ulast != u) {
|
if (ulast != u) {
|
||||||
/* put u behind ulast so it's the last unit in the building */
|
/* put u behind ulast so it's the last unit in the building */
|
||||||
*uptr = u->next;
|
*uptr = u->next;
|
||||||
|
@ -3121,14 +3091,7 @@ void update_long_order(unit * u)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (kwd > thiskwd) {
|
cmistake(u, ord, 52, MSG_EVENT);
|
||||||
/* swap out thisorder for the new one */
|
|
||||||
cmistake(u, u->thisorder, 52, MSG_EVENT);
|
|
||||||
set_order(&u->thisorder, copy_order(ord));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cmistake(u, ord, 52, MSG_EVENT);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3712,8 +3675,9 @@ void process(void)
|
||||||
|
|
||||||
log_debug("- Step %u", prio);
|
log_debug("- Step %u", prio);
|
||||||
while (proc && proc->priority == prio) {
|
while (proc && proc->priority == prio) {
|
||||||
if (proc->name)
|
if (proc->name) {
|
||||||
log_debug(" - %s", proc->name);
|
log_debug(" - %s", proc->name);
|
||||||
|
}
|
||||||
proc = proc->next;
|
proc = proc->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3721,8 +3685,9 @@ void process(void)
|
||||||
pglobal->data.global.process();
|
pglobal->data.global.process();
|
||||||
pglobal = pglobal->next;
|
pglobal = pglobal->next;
|
||||||
}
|
}
|
||||||
if (pglobal == NULL || pglobal->priority != prio)
|
if (pglobal == NULL || pglobal->priority != prio) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
unit *u;
|
unit *u;
|
||||||
|
@ -3733,8 +3698,9 @@ void process(void)
|
||||||
pregion->data.per_region.process(r);
|
pregion->data.per_region.process(r);
|
||||||
pregion = pregion->next;
|
pregion = pregion->next;
|
||||||
}
|
}
|
||||||
if (pregion == NULL || pregion->priority != prio)
|
if (pregion == NULL || pregion->priority != prio) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (r->units) {
|
if (r->units) {
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
|
@ -3744,14 +3710,16 @@ void process(void)
|
||||||
punit->data.per_unit.process(u);
|
punit->data.per_unit.process(u);
|
||||||
punit = punit->next;
|
punit = punit->next;
|
||||||
}
|
}
|
||||||
if (punit == NULL || punit->priority != prio)
|
if (punit == NULL || punit->priority != prio) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
porder = punit;
|
porder = punit;
|
||||||
while (porder && porder->priority == prio && porder->type == PR_ORDER) {
|
while (porder && porder->priority == prio && porder->type == PR_ORDER) {
|
||||||
order **ordp = &u->orders;
|
order **ordp = &u->orders;
|
||||||
if (porder->flags & PROC_THISORDER)
|
if (porder->flags & PROC_THISORDER) {
|
||||||
ordp = &u->thisorder;
|
ordp = &u->thisorder;
|
||||||
|
}
|
||||||
while (*ordp) {
|
while (*ordp) {
|
||||||
order *ord = *ordp;
|
order *ord = *ordp;
|
||||||
if (getkeyword(ord) == porder->data.per_order.kword) {
|
if (getkeyword(ord) == porder->data.per_order.kword) {
|
||||||
|
@ -3780,8 +3748,9 @@ void process(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ord || *ordp == ord)
|
if (!ord || *ordp == ord) {
|
||||||
ordp = &(*ordp)->next;
|
ordp = &(*ordp)->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
porder = porder->next;
|
porder = porder->next;
|
||||||
}
|
}
|
||||||
|
@ -3798,9 +3767,9 @@ void process(void)
|
||||||
pregion->data.per_region.process(r);
|
pregion->data.per_region.process(r);
|
||||||
pregion = pregion->next;
|
pregion = pregion->next;
|
||||||
}
|
}
|
||||||
if (pregion == NULL || pregion->priority != prio)
|
if (pregion == NULL || pregion->priority != prio) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,8 +290,6 @@ void locale_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void bind_monsters(lua_State *L);
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue