Merge remote-tracking branch 'upstream/master'

Conflicts:
	src/laws.c
This commit is contained in:
CTD 2014-08-14 00:23:41 +02:00
commit 6afd8ab586
195 changed files with 10476 additions and 9073 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
eressea.ini
# SlickEdit # SlickEdit
*.vtg *.vtg
*.vpwhistu *.vpwhistu

View File

@ -1,2 +1,5 @@
all: all:
@echo "Please use the cmake build system by running configure" @echo "Please use the cmake build system by running configure"
clean:
@find . -name "*~" | xargs rm -f

View File

@ -6,7 +6,7 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI <rewriteURI
uriStartString="config:///core/" uriStartString="config:///core/"
rewritePrefix="../../core/res/" /> rewritePrefix="../../res/core/" />
<rewriteURI <rewriteURI
uriStartString="config:///game/" uriStartString="config:///game/"
rewritePrefix="../../res/eressea/" /> rewritePrefix="../../res/eressea/" />

View File

@ -6,7 +6,7 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI <rewriteURI
uriStartString="config:///core/" uriStartString="config:///core/"
rewritePrefix="../../core/res/" /> rewritePrefix="../../res/core/" />
<rewriteURI <rewriteURI
uriStartString="config:///game/" uriStartString="config:///game/"
rewritePrefix="../../res/e3a/" /> rewritePrefix="../../res/e3a/" />

View File

@ -6,7 +6,7 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI <rewriteURI
uriStartString="config:///core/" uriStartString="config:///core/"
rewritePrefix="../../core/res/" /> rewritePrefix="../../res/core/" />
<rewriteURI <rewriteURI
uriStartString="config:///game/" uriStartString="config:///game/"
rewritePrefix="../../res/e3a/" /> rewritePrefix="../../res/e3a/" />

View File

@ -6,11 +6,13 @@ lomem = 0
debug = 0 debug = 0
memcheck = 0 memcheck = 0
locales = de,en locales = de,en
;game_id = 0
[config] [lua]
source_dir = ../git install = ../git
paths = ../git/lunit:../git/scripts
maxnmrs = 20 maxnmrs = 20
rules = eressea ; use -r to override rules = e2 ; can use -r to override
[editor] [editor]
color = 1 color = 1

1
configure vendored
View File

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
git submodule update --init git submodule update --init
ln -sf conf/eressea.ini
s/cmake-init s/cmake-init
echo "configuration complete. run s/build to build the server" echo "configuration complete. run s/build to build the server"

16
core/.gitignore vendored
View File

@ -1,16 +0,0 @@
bin/
Debug/
Release/
*~
*.user
*.pdb
*.suo
*.sdf
*.opensdf
*.ipch
*.sh
*.tmp
src/*.vcproj.*.user
tags
build-vs2010
config

View File

@ -1,11 +0,0 @@
callbacks = {}
callbacks["attrib_init"] = function(attr)
if attr.name ~= nil then
local init = callbacks["init_" .. attr.name]
if init ~=nil then
init(attr)
end
end
end

View File

@ -1,118 +0,0 @@
function change_locales(localechange)
for loc, flist in pairs(localechange) do
for index, name in pairs(flist) do
f = get_faction(atoi36(name))
if f ~= nil then
f.locale = loc
print("LOCALECHANGE ", f, loc)
end
end
end
end
function dbupdate()
update_scores()
edb = db.open(config.basepath.."/eressea.db")
if edb~=nil then
edb:update_factions()
edb:update_scores()
else
print("could not open "..config.basepath.."/eressea.db")
end
end
function nmr_check(maxnmrs)
local nmrs = get_nmrs(1)
if nmrs >= maxnmrs then
print("Shit. More than " .. maxnmrs .. " factions with 1 NMR (" .. nmrs .. ")")
write_summary()
eressea.write_game("aborted.dat")
return -1
end
print (nmrs .. " Factions with 1 NMR")
return 0
end
function open_game(turn)
file = "" .. get_turn()
return eressea.read_game(file .. ".dat")
end
function write_emails(locales)
local files = {}
local key
local locale
local file
for key, locale in pairs(locales) do
files[locale] = io.open(config.basepath .. "/emails." .. locale, "w")
end
local faction
for faction in factions() do
if faction.email~="" then
files[faction.locale]:write(faction.email .. "\n")
end
end
for key, file in pairs(files) do
file:close()
end
end
function write_addresses()
local file
local faction
file = io.open(config.basepath .. "/adressen", "w")
for faction in factions() do
-- print(faction.id .. " - " .. faction.locale)
file:write(tostring(faction) .. ":" .. faction.email .. ":" .. faction.info .. "\n")
end
file:close()
end
function write_aliases()
local file
local faction
file = io.open(config.basepath .. "/aliases", "w")
for faction in factions() do
local unit
if faction.email ~= "" then
file:write("partei-" .. itoa36(faction.id) .. ": " .. faction.email .. "\n")
for unit in faction.units do
file:write("einheit-" .. itoa36(unit.id) .. ": " .. faction.email .. "\n")
end
end
end
file:close()
end
function write_files(locales)
write_passwords()
write_reports()
write_summary()
-- write_emails(locales)
-- write_aliases()
-- write_addresses()
end
function write_scores()
scores = {}
for r in regions() do
f = r.owner
if f~=nil then
value = scores[f.id]
if value==nil then value=0 end
value = value + r:get_resource("money")/100
scores[f.id] = value
end
end
for f in factions() do
score=scores[f.id]
if score==nil then score=0 end
print(math.floor(score)..":"..f.name..":"..itoa36(f.id))
end
end

View File

@ -1,43 +0,0 @@
require(config.rules .. ".modules")
require "default"
require "resources"
function run_editor()
local turn = get_turn()
if turn<0 then
turn = read_turn()
set_turn(turn)
end
eressea.read_game(turn .. ".dat")
gmtool.editor()
end
function run_tests()
print("running tests")
require "lunit"
lunit.clearstats()
local argv = tests or {}
local stats = lunit.main(argv)
if stats.errors > 0 or stats.failed > 0 then
assert(stats.errors == 0 and stats.failed == 0)
end
return 0
end
function run_turn()
require(config.rules .. ".main")
local turn = get_turn()
if turn<0 then
turn = read_turn()
set_turn(turn)
end
orderfile = orderfile or config.basepath .. '/orders.' .. turn
print("executing turn " .. get_turn() .. " with " .. orderfile .. " with rules=" .. config.rules)
local result = process(orderfile)
if result==0 then
dbupdate()
end
return result
end

View File

@ -1,93 +0,0 @@
function kill_multis(multis, destructive)
for idx, fno in ipairs(multis) do
local f = get_faction(fno)
if f~=nil and f.email=="doppelspieler@eressea.de" then
kill_faction(f, destructive)
end
end
end
function mark_multis(multis, block)
if multis~=nil then
for idx, fno in ipairs(multis) do
local f = get_faction(fno)
if f~=nil and f.email~="doppelspieler@eressea.de" then
print("* multi-player " .. tostring(f))
mark_multi(f, block)
end
end
end
end
-- destroy a faction
-- destructive: kill all of its buildings and the home region, too.
function kill_faction(f, destructive)
for u in f.units do
local r = u.region
local b = u.building
unit.destroy(u)
if destructive and b~=nil then
building.destroy(b)
local nuke = true
for v in r.units do
if v.faction.id~=f.id then
-- print("cannot nuke: " .. tostring(v.faction))
nuke = false
break
end
end
r.terrain_name = nil
if nuke and num_oceans(r)<=1 then
-- print("nuke!")
r.terrain = "ocean"
else
-- print("cannot nuke: > 1 oceans")
r.terrain = "glacier"
r.peasants = 10
r:set_resource("money", 100)
b = building.create(r, "monument")
b.size = 1
b.name = "Memento Mori"
b.info = "Eine kleine " .. translate("race::" .. f.race .."_x") .. "-Statue erinnert hier an ein verschwundenes Volk"
end
end
end
faction.destroy(f)
end
local function mark_multi(f, block)
f.password = "doppelspieler"
f.email = "doppelspieler@eressea.de"
f.banner = "Diese Partei steht wegen vermuteten Doppelspiels unter Beobachtung."
for u in f.units do
u.race_name = "toad"
if block and u.building~=nil then
local found = false
for u2 in u.region.units do
if u2.faction.id~=u.faction.id then
found = true
break
end
end
if not found then
u.region.terrain_name = "firewall"
u.region:set_flag(2) -- RF_BLOCKED
end
end
end
end
local function num_oceans(r)
local oceans = 0
local p = r:next(5)
for d = 0,5 do
local n = r:next(d)
if p.terrain~="ocean" and n.terrain=="ocean" then
oceans = oceans +1
end
p = n
end
return oceans
end

View File

@ -1,6 +0,0 @@
CREATE TABLE email(id INTEGER PRIMARY KEY, md5 VARCHAR(32) UNIQUE NOT NULL, email VARCHAR(32), bounces INT DEFAULT 0, confirmed TIMESTAMP DEFAULT NULL);
CREATE TABLE faction (id INTEGER PRIMARY KEY, user_id INTEGER REFERENCES user(id), no INTEGER, name VARCHAR(64), game_id INTEGER REFERENCES game(id), race VARCHAR(10), lang CHAR(2));
CREATE TABLE faction_email (faction_id INTEGER REFERENCES faction(id), email_id INTEGER REFERENCES email(id));
CREATE TABLE game (id INTEGER PRIMARY KEY, name VARCHAR(20), last_turn INTEGER);
CREATE TABLE score (turn INTEGER, faction_id INTEGER REFERENCES faction(id), value INTEGER, UNIQUE(turn, faction_id));
CREATE TABLE user(id INTEGER PRIMARY KEY, email_id INTEGER REFERENCES email(id), creation TIMESTAMP DEFAULT CURRENT_TIMESTAMP);

View File

@ -1,16 +0,0 @@
local srcpath = config.source_dir
local respath = srcpath .. '/' .. config.rules .. '/res/'
local paths = { config.rules..'/scripts/?.lua';'lunit/?.lua','external/lunit/?.lua','scripts/?.lua';'scripts/?' }
tests = {'common'}
for idx, test in pairs(tests) do
tests[idx] = srcpath .. '/scripts/tests/' .. test .. '.lua'
end
for idx, path in pairs(paths) do
package.path = srcpath .. '/' .. path .. ';' .. package.path
end
read_xml('config.xml', 'catalog.xml')
require "init"

View File

@ -1,97 +0,0 @@
require "lunit"
module("tests.eressea.spells", package.seeall, lunit.testcase)
local r, f, u
function setup()
eressea.free_game()
eressea.settings.set("magic.regeneration.enable", "0")
eressea.settings.set("magic.fumble.enable", "0")
eressea.settings.set("rules.economy.food", "4")
r = region.create(0, 0, "plain")
f = faction.create("spell_payment@eressea.de", "elf", "de")
u = unit.create(f, r, 1)
u.magic = "gray"
u:set_skill("magic", 12)
end
function test_spell_payment()
u:add_spell("create_roi")
local permaura = u:get_pooled("permaura")
u:add_item("money", 3000)
u.aura = 50
u:clear_orders()
u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ")
process_orders()
write_reports()
assert_equal(1, u:get_item("roi"))
assert_equal(0, u:get_item("money"))
assert_equal(0, u.aura)
assert_equal(permaura-1, u:get_pooled("permaura"))
end
function test_spell_not_found_no_payment()
local permaura = u:get_pooled("permaura")
u:add_item("money", 3000)
u.aura = 50
u:clear_orders()
u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ")
process_orders()
assert_equal(0, u:get_item("roi"))
assert_equal(3000, u:get_item("money"))
assert_equal(50, u.aura)
assert_equal(permaura, u:get_pooled("permaura"))
end
function test_create_roi()
u:add_spell('create_roi')
u:cast_spell('create_roi')
assert_equal(1, u:get_item("roi"))
end
function test_create_roqf()
u:add_spell('create_roqf')
u:cast_spell('create_roqf')
assert_equal(1, u:get_item("roqf"))
end
function test_create_aots()
u:add_spell('create_aots')
u:cast_spell('create_aots')
assert_equal(1, u:get_item("aots"))
end
function test_create_ror()
u:add_spell('create_ror')
u:cast_spell('create_ror')
assert_equal(1, u:get_item("ror"))
end
function test_create_trollbelt()
u:add_spell('create_trollbelt')
u:cast_spell('create_trollbelt')
assert_equal(1, u:get_item("trollbelt"))
end
function test_create_dreameye()
u:add_spell('create_dreameye')
u:cast_spell('create_dreameye')
assert_equal(1, u:get_item("dreameye"))
end
function test_create_antimagic()
u:add_spell('create_antimagic')
u:cast_spell('create_antimagic')
assert_equal(1, u:get_item("antimagic"))
end
function test_create_rop()
u:add_spell('create_rop')
u:cast_spell('create_rop')
assert_equal(1, u:get_item("rop"))
end

View File

@ -1,15 +0,0 @@
[eressea]
base = .
report = reports
verbose = 0
lomem = 0
debug = 0
memcheck = 0
locales = de,en
[config]
source_dir = ..
maxnmrs = 10
[editor]
color = 1

@ -1 +1 @@
Subproject commit 537ba2f174d51cb06c3a97a1a0285b384b0e3d1a Subproject commit a636c47ebdaf602de6a5db81b5cb1b0309dfdae0

View File

@ -1,10 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="eressea:///core/"
rewritePrefix="../core/res/" />
</catalog>

View File

@ -1,110 +0,0 @@
<?xml version="1.0"?>
<eressea xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="eressea:///core/messages.xml"/>
<!-- Localization -->
<xi:include href="eressea:///core/de/strings.xml"/>
<xi:include href="eressea:///core/en/strings.xml"/>
<xi:include href="eressea:///core/prefixes.xml"/>
<xi:include href="eressea:///core/calendar.xml"/>
<calendar name="secondage" newyear="month_1" start="0" />
<xi:include href="eressea:///core/common/resources.xml"/>
<xi:include href="eressea:///core/common/items.xml" />
<xi:include href="eressea:///core/common/potions.xml" />
<xi:include href="armor.xml" />
<xi:include href="weapons.xml" />
<xi:include href="items.xml" />
<xi:include href="races.xml"/>
<!-- <xi:include href="ships.xml"/> -->
<xi:include href="eressea:///core/ships.xml"/>
<xi:include href="buildings.xml"/>
<xi:include href="eressea:///core/common/buildings.xml"/>
<xi:include href="eressea:///core/spells.xml"/>
<xi:include href="terrains.xml"/>
<equipment>
<set name="first_unit">
<!-- this is given to a faction's first unit -->
<item name="log" amount="30"/>
<item name="stone" amount="30"/>
<item name="money" amount="4200"/>
</set>
<set name="new_faction">
<!-- this goes into the faction's global pool -->
<item name="sword" amount="1"/>
</set>
</equipment>
<game name="Demonstration">
<!-- Game specific settings -->
<order name="GM" disable="yes"/>
<order name="SPIONIEREN" disable="yes"/>
<skill name="espionage" enable="false"/>
<skill name="alchemy" enable="true"/>
<skill name="armorer" enable="true"/>
<skill name="bow" enable="true"/>
<skill name="building" enable="true"/>
<skill name="cartmaking" enable="true"/>
<skill name="catapult" enable="true"/>
<skill name="crossbow" enable="true"/>
<skill name="entertainment" enable="true"/>
<skill name="espionage" enable="true"/>
<skill name="forestry" enable="true"/>
<skill name="herbalism" enable="true"/>
<skill name="magic" enable="true"/>
<skill name="melee" enable="true"/>
<skill name="mining" enable="true"/>
<skill name="perception" enable="true"/>
<skill name="polearm" enable="true"/>
<skill name="quarrying" enable="true"/>
<skill name="riding" enable="true"/>
<skill name="roadwork" enable="true"/>
<skill name="sailing" enable="true"/>
<skill name="shipcraft" enable="true"/>
<skill name="stamina" enable="true"/>
<skill name="stealth" enable="true"/>
<skill name="tactics" enable="true"/>
<skill name="taxation" enable="true"/>
<skill name="trade" enable="true"/>
<skill name="training" enable="true"/>
<skill name="unarmed" enable="true"/>
<skill name="weaponsmithing" enable="true"/>
<param name="NewbieImmunity" value="8"/>
<param name="entertain.base" value="0"/>
<param name="entertain.perlevel" value="20"/>
<param name="nmr.timeout" value="4"/>
<param name="nmr.removenewbie" value="2"/>
<param name="GiveRestriction" value="3"/>
<param name="hunger.long" value="1"/>
<param name="rules.limit.faction" value="500"/>
<param name="modules.astralspace" value="0"/>
<param name="modules.wormholes" value="0"/>
<param name="modules.markets" value="0"/>
</game>
<strings>
<string name="mailto">
<text locale="de">arda-server@example.com</text>
<text locale="en">arda-server@example.com</text>
</string>
<string name="newbie_info_1">
<text locale="de">Bitte denke daran, deine Befehle mit dem Betreff
ERESSEA BEFEHLE an arda-server@example.com zu senden.</text>
<text locale="en">Remember to send your orders to
arda-server@example.com with the subject ERESSEA ORDERS.</text>
</string>
<string name="mailcmd">
<text locale="de">ARDA BEFEHLE</text>
<text locale="en">ARDA ORDERS</text>
</string>
<string name="defaultorder">
<text locale="de">ARBEITEN</text>
<text locale="en">WORK</text>
</string>
</strings>
</eressea>

158
s/preview Executable file
View File

@ -0,0 +1,158 @@
#!/bin/bash
function usage() {
cat <<HEREDOC
usage: $0 [-t <turn>] [-g <game>] [-f <file>] command [args]
commands:
build -- pull and rebuild the code
version -- print the current build number
setup -- create base directory and config files
run -- run a turn
send [id ...] -- send reports to one or more factions, or to all ids in <file>
HEREDOC
exit 1
}
function abort() {
echo $1
[ -z $2 ] && exit -1
exit $2 # otherwise
}
function build() {
assert_dir $SOURCE
cd $SOURCE
git pull || abort "failed to update source. do you have local changes?"
s/build || abort "build failed."
}
function assert_file() {
[ -e $1 ] || abort "missing file: $1"
}
function assert_files() {
while [ ! -z $1 ] ; do
assert_file $1
shift
done
}
function assert_dir() {
[ -d $1 ] || abort "missing directory: $1"
}
function version() {
assert_dir $SOURCE
cd $SOURCE
build=$(grep BUILD src/build.h | awk '{ print $3 }')
echo "eressea build $build"
}
function setup() {
assert_dir $SOURCE
assert_dir $LIVE
mkdir -p $TESTROOT
assert_dir $TESTROOT
cd $TESTROOT
cat >| eressea.ini <<HEREDOC
[lua]
dbname = preview.db
install = $SOURCE
paths = $SOURCE/lunit:$SOURCE/git/scripts
rules = e$game
HEREDOC
}
function run() {
echo "testing turn $turn of game $game"
assert_dir $TESTROOT
cd $TESTROOT
[ -d data ] || mkdir data
assert_dir data
assert_files $LIVE/orders.$turn $LIVE/data/$turn.dat
cp $LIVE/eressea.db preview.db
ln -f $LIVE/orders.$turn
ln -f $LIVE/data/$turn.dat data/
rm -rf reports
mkdir -p reports
$SOURCE/build-x86_64-gcc-Debug/eressea/eressea -v$verbose -t$turn -re$game $SOURCE/scripts/run-turn.lua
let turn=$turn+1
[ -e data/$turn.dat ] || abort "no data file created"
}
function send() {
echo "sending reports to $1"
zip="$turn-$1.zip"
zip -q -u $yip $turn-$1.?r
email=$(grep "faction=$1:" reports.txt | cut -d: -f2 | sed 's/email=//')
cat /dev/null | mutt -F $ERESSEA/etc/muttrc -s "Testauswertung Spiel $GAME Partei $1" -a $zip -- $email
}
game=0
turn=0
verbose=1
factions="testers.txt"
while getopts :g:t:f:v: o; do
case "${o}" in
f)
factions=${OPTARG}
;;
v)
verbose=${OPTARG}
;;
g)
game=${OPTARG}
;;
t)
turn=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
[ -d $ERESSEA ] || echo "invalid or missing env variable ERESSEA ($ERESSEA)"
[ -z $1 ] && usage
[ -z $SOURCE ] && SOURCE=$ERESSEA/git
[ -d $SOURCE ] || abort "missing source directory: $SOURCE"
[ -d LIVE ] || LIVE=$ERESSEA/game-$game
[ -d TESTROOT ] || TESTROOT=$LIVE/test
while [ ! -z $1 ]; do
case "$1" in
"version")
version
;;
"build")
build
;;
"setup")
setup
;;
"run")
if [ $turn -eq 0 ]; then
[ -f $LIVE/turn ] || abort "missing turn file, and no turn specified"
let turn=$(cat $LIVE/turn)-1
fi
run
;;
"send")
shift
for faction in $* ; do
send $faction
done
cd $TESTROOT
if [ -e $factions ]; then
for faction in $(cat $factions) ; do
send $faction
done
fi
break
;;
esac
shift
done

View File

@ -17,6 +17,6 @@ fi
$ROOT/$BIN_DIR/eressea/test_eressea $ROOT/$BIN_DIR/eressea/test_eressea
cd $ROOT cd $ROOT
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/runtests.lua $ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua
#grep ERROR eressea.log #grep ERROR eressea.log
cd $OLDWPD cd $OLDWPD

72
s/setup Executable file
View File

@ -0,0 +1,72 @@
#!/bin/bash
function abort() {
echo $1
[ -z $2 ] && exit -1
exit $2 # otherwise
}
function usage() {
cat <<USAGE
Usage: $u [-hf] [-d DIR] [-g <game>] [-r <rules>] [-s DIR]
-h print this message
-f force overwrite of existing game
-g game id
-r name of ruleset
-s server installation directory
-d override directory name
USAGE
}
game=0
force=0
src=server
while getopts :d:g:r:s:hf o; do
case "${o}" in
h) usage ; exit 0 ;;
s) src=${OPTARG} ;;
d) dir=${OPTARG} ;;
f) force=1 ;;
g) game=${OPTARG} ;;
r) rules=${OPTARG} ;;
*) echo "not implemented ${o} ${OPTARG}" ;;
esac
done
[ $game -gt 0 ] || abort "must use a positive integer for game id"
[ -d $ERESSEA ] || abort "invalid or missing env variable ERESSEA ($ERESSEA)"
[ -z $SOURCE ] && SOURCE=$ERESSEA/$src
[ -d $SOURCE ] || abort "invalid source directory $SOURCE"
[ -z $rules ] && rules=e$game
[ -z $dir ] && dir=game-$game
[ -z $TOOLS ] && TOOLS=$SOURCE/build-x86_64-gcc-Debug
[ -e $TOOLS ] || TOOLS=$SOURCE/bin
[ -z $INIFILE ] && INIFILE=$TOOLS/inifile
[ -e $INIFILE ] || INIFILE=$TOOLS/iniparser/inifile
[ -e $INIFILE ] || abort "tool is not installed: $INIFILE"
cd $ERESSEA
if [ -d $dir ] ; then
[ $force -eq 1 ] || abort "$dir directory exists. Use -f to force"
fi
mkdir -p $dir
cd $dir || abort "could not chdir to game-$game"
mkdir -p data reports
function ini_sec() {
$INIFILE eressea.ini add $1
}
function ini_add() {
$INIFILE eressea.ini add $1 $2
}
touch eressea.ini
ini_sec eressea
ini_add eressea:locales de,en
ini_sec lua
ini_add lua:install $SOURCE
ini_add lua:install $SOURCE
ini_add lua:paths $SOURCE/scripts:$SOURCE/lunit
ini_add lua:rules $rules
ln -f $SOURCE/scripts/run-turn.lua

View File

@ -1,50 +0,0 @@
-- Enno was here
require "multis"
function process(orders)
local confirmed_multis = { }
local suspected_multis = { }
if open_game(get_turn())~=0 then
print("could not read game")
return -1
end
init_summary()
-- kill multi-players (external script)
kill_multis(confirmed_multis, false)
mark_multis(suspected_multis, false)
-- run the turn:
if read_orders(orders) ~= 0 then
print("could not read " .. orders)
return -1
end
-- plan_monsters()
if nmr_check(config.maxnmrs or 80)~=0 then
return -1
end
process_orders()
-- create new monsters:
spawn_braineaters(0.25)
-- post-turn updates:
update_guards()
update_scores()
local localechange = { de = { "ii" } }
change_locales(localechange)
write_files(config.locales)
file = "" .. get_turn() .. ".dat"
if write_game(file, "binary")~=0 then
print("could not write game")
return -1
end
return 0
end

View File

@ -1,12 +0,0 @@
require "spells"
require "arda.rules"
local srcpath = config.source_dir
tests = {
-- srcpath .. '/eressea/scripts/tests/bson.lua',
srcpath .. '/eressea/scripts/tests/spells.lua',
srcpath .. '/eressea/scripts/tests/common.lua',
srcpath .. '/eressea/scripts/tests/orders.lua',
srcpath .. '/eressea/scripts/tests/bindings.lua',
srcpath .. '/scripts/tests/rules.lua',
}

View File

@ -1,8 +0,0 @@
function item_canuse(u, iname)
local race = u.race
if iname=="greatbow" then
-- only elves use greatbow
return race=="elf"
end
return true
end

View File

@ -61,7 +61,6 @@ end
function clean() function clean()
for r in regions() do for r in regions() do
if r.terrain=="ocean" then if r.terrain=="ocean" then
-- print(r)
region.destroy(r) region.destroy(r)
end end
end end

View File

@ -1,37 +0,0 @@
require "callbacks"
require "dumptable"
local function trigger_alp_destroyed(alp, event)
m = message.create("alp_destroyed")
m:set_region("region", alp.region)
m:send_faction(alp.faction)
end
local function trigger_alp_dissolve(u, event, attr)
local alp = attr.alp
attr.alp.number = 0 -- kills the alp
end
local function init_alp(attr)
-- dumptable(attr)
eventbus.register(attr.alp, "destroy", trigger_alp_destroyed)
eventbus.register(attr.mage, "destroy", trigger_alp_dissolve, attr)
eventbus.register(attr.target, "destroy", trigger_alp_dissolve, attr)
end
callbacks["init_alp"] = init_alp
-- Spell: summon alp
function summon_alp(r, mage, level, force, params)
local alp = unit.create(mage.faction, r, 1, "alp")
local target = params[1]
alp:set_skill("stealth", 7)
alp.status = 5 -- FLEE
attr = attrib.create(alp, { ['name'] = 'alp', ['target'] = target, ['alp'] = alp, ['mage'] = mage })
init_alp(attr)
msg = message.create("summon_alp_effect")
m:set_unit("mage", mage)
m:set_unit("alp", alp)
m:set_unit("target", target)
m:send_faction(mage.faction)
end

View File

@ -0,0 +1,10 @@
-- Astralraum
astral = {}
function astral.update()
eressea.log.info('spawn braineaters')
spawn_braineaters(0.25)
end
return astral

View File

@ -0,0 +1,16 @@
require 'eressea.spells'
eressea.log.debug("rules for game E2")
return {
require('eressea'),
require('eressea.xmas2004'),
require('eressea.xmas2005'),
require('eressea.xmas2006'),
require('eressea.wedding'),
require('eressea.embassy'),
require('eressea.eternath'),
require('eressea.tunnels'),
require('eressea.ponnuki'),
require('eressea.astral'),
require('eressea.ents')
}

View File

@ -0,0 +1,12 @@
require 'eressea.e3.rules'
require 'eressea.spells'
eressea.log.debug("rules for game E3")
return {
require('eressea'),
require('eressea.xmas2009'),
require('eressea.markets'),
require('eressea.frost'),
require('eressea.ents')
}

View File

@ -0,0 +1,77 @@
-- when appending to this, make sure the item has a canuse-function!
local goblin_denied = " plate lance mallornlance greatbow axe greatsword halberd rustyaxe rustyhalberd towershield scale "
function item_canuse(u, iname)
local race = u.race
if race=="goblin" then
if string.find(goblin_denied, " " .. iname .. " ") then
return false
end
end
if iname=="rep_crossbow" then
-- only dwarves and halflings allowed to use repeating crossbow
return race=="dwarf" or race=="halfling"
end
if iname=="scale" then
-- only dwarves and halflings can use scale
return race=="dwarf" or race=="halfling"
end
if iname=="towershield" then
-- only dwarves allowed to use towershield
return race=="dwarf"
end
if iname=="greatbow" then
-- only elves use greatbow
return race=="elf"
end
return true
end
function building_protection(b, u)
return 1
end
function building_taxes(b, blevel)
btype = b.type
if btype=="castle" then
return blevel * 0.01
elseif btype=="watch" then
return blevel * 0.005
end
return 0.0
end
-- the "raindance" spell
function raindance(r, mage, level, force)
if (create_curse(mage, r, "blessedharvest", force, 1+force*2, 100 * force)) then
-- slightly crooked way of reporting an action to everyone in the region
local msg = message.create("raindance_effect")
msg:set_unit("mage", mage)
if (msg:report_action(r, mage, 3)) then
local msg2 = message.create("raindance_effect")
msg2:set_unit("mage", nil)
msg2:report_action(r, mage, 4)
end
end
return level
end
-- the "blessed harvest" spell
function blessedharvest(r, mage, level, force)
if create_curse(mage, r, "blessedharvest", force, 1+force*2, 50 * force) then
-- slightly crooked way of reporting an action to everyone in the region
local msg = message.create("harvest_effect")
msg:set_unit("mage", mage)
if (msg:report_action(r, mage, 3)) then
local msg2 = message.create("harvest_effect")
msg2:set_unit("mage", nil)
msg2:report_action(r, mage, 4)
end
for idx, rn in ipairs(r.adj) do
-- nur landregionen haben moral>=0
if r.morale>=0 then
create_curse(mage, r, "blessedharvest", force, force*2, 50 * force)
end
end
end
return level
end

View File

@ -0,0 +1,11 @@
require 'eressea.e3.rules'
require 'eressea.spells'
eressea.log.debug("rules for game E3")
return {
require('eressea'),
require('eressea.markets'),
require('eressea.frost'),
require('eressea.ents')
}

View File

@ -1,30 +1,41 @@
-- Muschelplateau
local embassy = {}
local home = nil
-- global exports (use item)
function use_seashell(u, amount) function use_seashell(u, amount)
-- Muschelplateau... -- Muschelplateau...
local r = get_region(165,30)
local visit = u.faction.objects:get("embassy_muschel") local visit = u.faction.objects:get("embassy_muschel")
if visit~=nil and u.region~= r then if visit and u.region~= home then
local turns = get_turn() - visit local turns = get_turn() - visit
local msg = message.create("msg_event") local msg = message.create('msg_event')
msg:set_string("string", u.name .. "(" .. itoa36(u.id) .. ") erzählt den Bewohnern von " .. u.region.name .. " von Muschelplateau, das die Partei " .. u.faction.name .. " vor " .. turns .. " Wochen besucht hat." ) msg:set_string("string", u.name .. "(" .. itoa36(u.id) .. ") erzählt den Bewohnern von " .. u.region.name .. " von Muschelplateau, das die Partei " .. u.faction.name .. " vor " .. turns .. " Wochen besucht hat." )
msg:send_region(u.region) msg:send_region(u.region)
return 0 return 0
end end
return -4 return -4
end end
function update_embassies() function embassy.init()
-- Muschelplateau home = get_region(165,30)
local r = get_region(165,30) if home==nil then
if r~=nil then eressea.log.error("cannot find embassy region 'Muschelplateau'")
local u
for u in r.units do
if u.faction.objects:get("embassy_muschel")==nil then
if (u.faction:add_item("seashell", 1)>0) then
print(u.faction)
u.faction.objects:set("embassy_muschel", get_turn())
end end
end end
function embassy.update()
-- Muschelplateau
eressea.log.debug("updating embassies in " .. tostring(home))
local u
for u in home.units do
if u.faction.objects:get('embassy_muschel')==nil then
if (u.faction:add_item('seashell', 1)>0) then
eressea.log.debug("new seashell for " .. tostring(u.faction))
u.faction.objects:set('embassy_muschel', get_turn())
end
end end
end end
end end
return embassy

Some files were not shown because too many files have changed in this diff Show More