forked from github/server
deleting the core directory.
This commit is contained in:
parent
64ef71143a
commit
d44656189d
20 changed files with 0 additions and 2948 deletions
|
@ -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
|
||||
|
|
@ -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
|
|
@ -1,95 +0,0 @@
|
|||
---------------------------------------------
|
||||
-- Return indentation string for passed level
|
||||
---------------------------------------------
|
||||
local function tabs(i)
|
||||
return string.rep(".",i).." " -- Dots followed by a space
|
||||
end
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Return string representation of parameter's value & type
|
||||
-----------------------------------------------------------
|
||||
local function toStrType(t)
|
||||
local function fttu2hex(t) -- Grab hex value from tostring() output
|
||||
local str = tostring(t);
|
||||
if str == nil then
|
||||
return "tostring() failure! \n"
|
||||
else
|
||||
local str2 = string.match(str,"[ :][ (](%x+)")
|
||||
if str2 == nil then
|
||||
return "string.match() failure: "..str.."\n"
|
||||
else
|
||||
return "0x"..str2
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Stringify a value of a given type using a table of functions keyed
|
||||
-- by the name of the type (Lua's version of C's switch() statement).
|
||||
local stringify = {
|
||||
-- Keys are all possible strings that type() may return,
|
||||
-- per http://www.lua.org/manual/5.1/manual.html#pdf-type.
|
||||
["nil"] = function(v) return "nil (nil)" end,
|
||||
["string"] = function(v) return '"'..v..'" (string)' end,
|
||||
["number"] = function(v) return v.." (number)" end,
|
||||
["boolean"] = function(v) return tostring(v).." (boolean)" end,
|
||||
["function"] = function(v) return fttu2hex(v).." (function)" end,
|
||||
["table"] = function(v) return fttu2hex(v).." (table)" end,
|
||||
["thread"] = function(v) return fttu2hex(v).." (thread)" end,
|
||||
["userdata"] = function(v) return fttu2hex(v).." (userdata)" end
|
||||
}
|
||||
return stringify[type(t)](t)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Count elements in the passed table
|
||||
-------------------------------------
|
||||
local function lenTable(t) -- What Lua builtin does this simple thing?
|
||||
local n=0 -- '#' doesn't work with mixed key types
|
||||
if ("table" == type(t)) then
|
||||
for key in pairs(t) do -- Just count 'em
|
||||
n = n + 1
|
||||
end
|
||||
return n
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------
|
||||
-- Pretty-print the passed table
|
||||
--------------------------------
|
||||
local function do_dumptable(t, indent, seen)
|
||||
-- "seen" is an initially empty table used to track all tables
|
||||
-- that have been dumped so far. No table is dumped twice.
|
||||
-- This also keeps the code from following self-referential loops,
|
||||
-- the need for which was found when first dumping "_G".
|
||||
if ("table" == type(t)) then -- Dump passed table
|
||||
seen[t] = 1
|
||||
if (indent == 0) then
|
||||
print ("The passed table has "..lenTable(t).." entries:")
|
||||
indent = 1
|
||||
end
|
||||
for f,v in pairsByKeys(t) do
|
||||
if ("table" == type(v)) and (seen[v] == nil) then -- Recurse
|
||||
print( tabs(indent)..toStrType(f).." has "..lenTable(v).." entries: {")
|
||||
do_dumptable(v, indent+1, seen)
|
||||
print( tabs(indent).."}" )
|
||||
else
|
||||
print( tabs(indent)..toStrType(f).." = "..toStrType(v))
|
||||
end
|
||||
end
|
||||
else
|
||||
print (tabs(indent).."Not a table!")
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------
|
||||
-- Wrapper to handle persistence
|
||||
--------------------------------
|
||||
function dumptable(t) -- Only global declaration in the package
|
||||
-- This wrapper exists only to set the environment for the first run:
|
||||
-- The second param is the indentation level.
|
||||
-- The third param is the list of tables dumped during this call.
|
||||
-- Getting this list allocated and freed was a pain, and this
|
||||
-- wrapper was the best solution I came up with...
|
||||
return do_dumptable(t, 0, {})
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
-- implements gates and travel between them
|
||||
-- used in HSE and Eressea
|
||||
|
||||
function gate_travel(b, units)
|
||||
-- we've found which units we want to exchange, now swap them:
|
||||
local u
|
||||
for key, u in pairs(units) do
|
||||
u.region = b.region
|
||||
u.building = b
|
||||
end
|
||||
end
|
||||
|
||||
function gate_units(b, maxsize)
|
||||
local size = maxsize
|
||||
local units = {}
|
||||
local u
|
||||
|
||||
for u in b.units do
|
||||
if u.number<=size and u.weight<=u.capacity then
|
||||
units[u] = u
|
||||
size = size - u.number
|
||||
end
|
||||
end
|
||||
return units
|
||||
end
|
|
@ -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
|
|
@ -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
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
function peasant_getresource(u)
|
||||
return u.region:get_resource("peasant")
|
||||
end
|
||||
|
||||
function peasant_changeresource(u, delta)
|
||||
local p = u.region:get_resource("peasant")
|
||||
p = p + delta
|
||||
if p < 0 then
|
||||
p = 0
|
||||
end
|
||||
u.region:set_resource("peasant", p)
|
||||
return p
|
||||
end
|
||||
|
||||
function hp_getresource(u)
|
||||
return u.hp
|
||||
end
|
||||
|
||||
function hp_changeresource(u, delta)
|
||||
local hp = u.hp + delta
|
||||
|
||||
if hp < u.number then
|
||||
if hp < 0 then
|
||||
hp = 0
|
||||
end
|
||||
u.number = hp
|
||||
end
|
||||
u.hp = hp
|
||||
return hp
|
||||
end
|
||||
|
||||
function horse_limit(r)
|
||||
return r:get_resource("horse")
|
||||
end
|
||||
|
||||
function horse_produce(r, n)
|
||||
local horses = r:get_resource("horse")
|
||||
if horses>=n then
|
||||
r:set_resource("horse", horses-n)
|
||||
else
|
||||
r:set_resource("horse", 0)
|
||||
end
|
||||
end
|
||||
|
||||
function log_limit(r)
|
||||
-- if r:get_flag(1) then -- RF_MALLORN
|
||||
-- return 0
|
||||
-- end
|
||||
return r:get_resource("tree") + r:get_resource("sapling")
|
||||
end
|
||||
|
||||
function log_produce(r, n)
|
||||
local trees = r:get_resource("tree")
|
||||
if trees>=n then
|
||||
r:set_resource("tree", trees-n)
|
||||
else
|
||||
r:set_resource("tree", 0)
|
||||
n = n - trees
|
||||
trees = r:get_resource("sapling")
|
||||
if trees>=n then
|
||||
r:set_resource("sapling", trees-n)
|
||||
else
|
||||
r:set_resource("sapling", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mallorn_limit(r)
|
||||
if not r:get_flag(1) then -- RF_MALLORN
|
||||
return 0
|
||||
end
|
||||
return r:get_resource("tree") + r:get_resource("sapling")
|
||||
end
|
||||
|
||||
function mallorn_produce(r, n)
|
||||
local trees = r:get_resource("tree")
|
||||
if trees>=n then
|
||||
r:set_resource("tree", trees-n)
|
||||
else
|
||||
r:set_resource("tree", 0)
|
||||
n = n - trees
|
||||
trees = r:get_resource("sapling")
|
||||
if trees>=n then
|
||||
r:set_resource("sapling", trees-n)
|
||||
else
|
||||
r:set_resource("sapling", 0)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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);
|
|
@ -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"
|
|
@ -1,156 +0,0 @@
|
|||
function creation_message(mage, type, number)
|
||||
local msg = message.create("item_create_spell")
|
||||
local err = 0
|
||||
err = err + msg:set_unit("mage", mage)
|
||||
err = err + msg:set_int("number", number)
|
||||
err = err + msg:set_resource("item", type)
|
||||
if err ~= 0 then
|
||||
return nil
|
||||
else
|
||||
return msg
|
||||
end
|
||||
end
|
||||
|
||||
local function create_item(mage, level, name, number)
|
||||
local count = number or 1
|
||||
mage:add_item(name, count);
|
||||
local msg = creation_message(mage, name, count)
|
||||
msg:send_faction(mage.faction)
|
||||
return level
|
||||
end
|
||||
|
||||
-- Wasser des Lebens
|
||||
function create_potion_p2(r, mage, level, force)
|
||||
return create_item(mage, level, "p2", level)
|
||||
end
|
||||
|
||||
-- Siebenmeilentee
|
||||
function create_potion_p0(r, mage, level, force)
|
||||
return create_item(mage, level, "p0", level)
|
||||
end
|
||||
|
||||
-- Wundsalbe
|
||||
function create_potion_ointment(r, mage, level, force)
|
||||
return create_item(mage, level, "ointment", level)
|
||||
end
|
||||
|
||||
-- Bauernblut
|
||||
function create_potion_peasantblood(r, mage, level, force)
|
||||
return create_item(mage, level, "peasantblood", level)
|
||||
end
|
||||
|
||||
-- Pferdeglueck
|
||||
function create_potion_p9(r, mage, level, force)
|
||||
return create_item(mage, level, "p9", level)
|
||||
end
|
||||
|
||||
-- Schaffenstrunk
|
||||
function create_potion_p3(r, mage, level, force)
|
||||
return create_item(mage, level, "p3", level)
|
||||
end
|
||||
|
||||
-- Heiltrank
|
||||
function create_potion_p14(r, mage, level, force)
|
||||
return create_item(mage, level, "p14", level)
|
||||
end
|
||||
|
||||
-- Elixier der Macht
|
||||
function create_potion_p13(r, mage, level, force)
|
||||
return create_item(mage, level, "p13", level)
|
||||
end
|
||||
|
||||
-- Erschaffe ein Flammenschwert
|
||||
function create_firesword(r, mage, level, force)
|
||||
return create_item(mage, level, "firesword")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Guertel der Trollstaerke
|
||||
function create_trollbelt(r, mage, level, force)
|
||||
return create_item(mage, level, "trollbelt")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Ring der Unsichtbarkeit
|
||||
function create_roi(r, mage, level, force)
|
||||
return create_item(mage, level, "roi")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Ring der flinken Finger
|
||||
function create_roqf(r, mage, level, force)
|
||||
return create_item(mage, level, "roqf")
|
||||
end
|
||||
|
||||
-- Erschaffe ein Amulett des wahren Sehens
|
||||
function create_aots(r, mage, level, force)
|
||||
return create_item(mage, level, "aots")
|
||||
end
|
||||
|
||||
-- Erschaffe einen magischen Kraeuterbeutel
|
||||
function create_magicherbbag(r, mage, level, force)
|
||||
return create_item(mage, level, "magicherbbag")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Taktikkristal
|
||||
function create_dreameye(r, mage, level, force)
|
||||
return create_item(mage, level, "dreameye")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Antimagiekristall
|
||||
function create_antimagic(r, mage, level, force)
|
||||
return create_item(mage, level, "antimagic")
|
||||
end
|
||||
|
||||
-- Erschaffe eine Sphaere der Unsichtbarkeit
|
||||
function create_invisibility_sphere(r, mage, level, force)
|
||||
return create_item(mage, level, "sphereofinv")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Guertel der Keuschheit
|
||||
function create_chastitybelt(r, mage, level, force)
|
||||
return create_item(mage, level, "ao_chastity")
|
||||
end
|
||||
|
||||
-- Erschaffe ein Runenschwert
|
||||
function create_runesword(r, mage, level, force)
|
||||
return create_item(mage, level, "runesword")
|
||||
end
|
||||
|
||||
-- Erschaffe ein Aurafokus
|
||||
function create_focus(r, mage, level, force)
|
||||
return create_item(mage, level, "aurafocus")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Ring der Macht
|
||||
function create_rop(r, mage, level, force)
|
||||
return create_item(mage, level, "rop")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Ring der Regeneration
|
||||
function create_ror(r, mage, level, force)
|
||||
return create_item(mage, level, "ror")
|
||||
end
|
||||
|
||||
-- Erschaffe einen Zauberbeutel
|
||||
function create_bagofholding(r, mage, level, force)
|
||||
return create_item(mage, level, "magicbag")
|
||||
end
|
||||
|
||||
-- TODO:
|
||||
function earn_silver(r, mage, level, force)
|
||||
local money = r:get_resource("money")
|
||||
local wanted = 50 * force
|
||||
local amount = wanted
|
||||
if wanted > money then
|
||||
amount = money
|
||||
end
|
||||
r:set_resource("money", money - amount)
|
||||
mage:add_item("money", amount)
|
||||
|
||||
local msg = message.create("income")
|
||||
msg:set_unit("unit", mage)
|
||||
msg:set_region("region", r)
|
||||
msg:set_int("mode", 6)
|
||||
msg:set_int("wanted", wanted)
|
||||
msg:set_int("amount", amount)
|
||||
msg:send_faction(mage.faction)
|
||||
return level
|
||||
end
|
|
@ -1,53 +0,0 @@
|
|||
require "lunit"
|
||||
|
||||
module("tests.eressea.attrib", package.seeall, lunit.testcase)
|
||||
|
||||
function has_attrib(u, value)
|
||||
for a in u.attribs do
|
||||
if (a.data==value) then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function test_attrib_global()
|
||||
a = attrib.create('global', {})
|
||||
eressea.write_game('attrib.dat')
|
||||
eressea.free_game()
|
||||
eressea.read_game('attrib.dat')
|
||||
end
|
||||
|
||||
function test_attrib()
|
||||
local r = region.create(0,0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u = unit.create(f, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
data = { arr = { 'a', 'b', 'c' }, name = 'familiar', events = { die = 'familiar_died' }, data = { mage = u2 } }
|
||||
a = { 'a' }
|
||||
b = { 'a' }
|
||||
uno = u.id
|
||||
u2no = u2.id
|
||||
a = attrib.create(u, 12)
|
||||
a = attrib.create(u, "enno")
|
||||
a = attrib.create(u, u2)
|
||||
a = attrib.create(u, data)
|
||||
eressea.write_game("attrib.dat")
|
||||
eressea.free_game()
|
||||
eressea.read_game("attrib.dat")
|
||||
u = get_unit(uno)
|
||||
u2 = get_unit(u2no)
|
||||
assert_false(has_attrib(u, 42))
|
||||
assert_true(has_attrib(u, "enno"))
|
||||
assert_true(has_attrib(u, 12))
|
||||
|
||||
for a in u.attribs do
|
||||
x = a.data
|
||||
if (type(x)=="table") then
|
||||
assert_equal('a', x.arr[1])
|
||||
assert_equal('familiar', x.name)
|
||||
assert_equal('familiar_died', x.events.die)
|
||||
assert_equal(u2, x.data.mage)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
require "lunit"
|
||||
|
||||
local eressea = eressea
|
||||
local _G = _G
|
||||
|
||||
module("tests.bindings", lunit.testcase)
|
||||
|
||||
function test_eressea()
|
||||
assert_equal("function", _G.type(eressea.free_game))
|
||||
assert_equal("function", _G.type(eressea.read_game))
|
||||
assert_equal("function", _G.type(eressea.write_game))
|
||||
assert_equal("function", _G.type(eressea.read_orders))
|
||||
end
|
||||
|
||||
function test_process()
|
||||
assert_equal("function", _G.type(eressea.process.update_long_order))
|
||||
assert_equal("function", _G.type(eressea.process.markets))
|
||||
assert_equal("function", _G.type(eressea.process.produce))
|
||||
|
||||
assert_equal("function", _G.type(eressea.process.make_temp))
|
||||
assert_equal("function", _G.type(eressea.process.settings))
|
||||
assert_equal("function", _G.type(eressea.process.set_allies))
|
||||
assert_equal("function", _G.type(eressea.process.set_prefix))
|
||||
assert_equal("function", _G.type(eressea.process.set_stealth))
|
||||
assert_equal("function", _G.type(eressea.process.set_status))
|
||||
assert_equal("function", _G.type(eressea.process.set_name))
|
||||
assert_equal("function", _G.type(eressea.process.set_group))
|
||||
assert_equal("function", _G.type(eressea.process.set_origin))
|
||||
assert_equal("function", _G.type(eressea.process.quit))
|
||||
assert_equal("function", _G.type(eressea.process.study))
|
||||
assert_equal("function", _G.type(eressea.process.movement))
|
||||
assert_equal("function", _G.type(eressea.process.use))
|
||||
assert_equal("function", _G.type(eressea.process.battle))
|
||||
assert_equal("function", _G.type(eressea.process.siege))
|
||||
assert_equal("function", _G.type(eressea.process.leave))
|
||||
assert_equal("function", _G.type(eressea.process.promote))
|
||||
assert_equal("function", _G.type(eressea.process.renumber))
|
||||
assert_equal("function", _G.type(eressea.process.restack))
|
||||
assert_equal("function", _G.type(eressea.process.set_spells))
|
||||
assert_equal("function", _G.type(eressea.process.set_help))
|
||||
assert_equal("function", _G.type(eressea.process.contact))
|
||||
assert_equal("function", _G.type(eressea.process.enter))
|
||||
assert_equal("function", _G.type(eressea.process.magic))
|
||||
assert_equal("function", _G.type(eressea.process.give_control))
|
||||
assert_equal("function", _G.type(eressea.process.regeneration))
|
||||
assert_equal("function", _G.type(eressea.process.guard_on))
|
||||
assert_equal("function", _G.type(eressea.process.guard_off))
|
||||
assert_equal("function", _G.type(eressea.process.explain))
|
||||
assert_equal("function", _G.type(eressea.process.messages))
|
||||
assert_equal("function", _G.type(eressea.process.reserve))
|
||||
assert_equal("function", _G.type(eressea.process.claim))
|
||||
assert_equal("function", _G.type(eressea.process.follow))
|
||||
assert_equal("function", _G.type(eressea.process.alliance))
|
||||
assert_equal("function", _G.type(eressea.process.idle))
|
||||
assert_equal("function", _G.type(eressea.process.set_default))
|
||||
end
|
||||
|
||||
function test_settings()
|
||||
assert_equal("function", _G.type(eressea.settings.set))
|
||||
assert_equal("function", _G.type(eressea.settings.get))
|
||||
end
|
|
@ -1,65 +0,0 @@
|
|||
require "lunit"
|
||||
|
||||
module("tests.eressea.bson", package.seeall, lunit.testcase)
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
end
|
||||
|
||||
function test_bson_create()
|
||||
local a = attrib.create("global", 12)
|
||||
assert_not_equal(nil, a)
|
||||
for a in attrib.get("global") do
|
||||
assert_equal(a.data, 12)
|
||||
end
|
||||
end
|
||||
|
||||
function test_illegal_arg()
|
||||
local a = attrib.create(nil, 42)
|
||||
assert_equal(nil, a)
|
||||
a = attrib.create("fred", 42)
|
||||
assert_equal(nil, a)
|
||||
end
|
||||
|
||||
function test_bson_readwrite()
|
||||
local i, r = region.create(0, 0, "mountain")
|
||||
attrib.create(r, 42)
|
||||
i = eressea.write_game("test_read_write.dat")
|
||||
assert_equal(0, i)
|
||||
eressea.free_game()
|
||||
r = get_region(0, 0)
|
||||
assert_equal(nil, r)
|
||||
i = eressea.read_game("test_read_write.dat")
|
||||
assert_equal(0, i)
|
||||
r = get_region(0, 0)
|
||||
assert_not_equal(nil, r)
|
||||
for a in attrib.get(r) do
|
||||
assert_equal(a.data, 42)
|
||||
end
|
||||
end
|
||||
|
||||
function test_bson()
|
||||
local r = region.create(0, 0, "mountain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u = unit.create(f, r, 1)
|
||||
assert_not_equal(nil, u)
|
||||
assert_not_equal(nil, r)
|
||||
assert_not_equal(nil, f)
|
||||
attrib.create(r, 1)
|
||||
assert_equal(attrib.get(r)().data, 1)
|
||||
attrib.create(u, 3)
|
||||
assert_equal(attrib.get(u)().data, 3)
|
||||
attrib.create(f, 5)
|
||||
assert_equal(attrib.get(f)().data, 5)
|
||||
end
|
||||
|
||||
function test_bson_with_multiple_attribs()
|
||||
local r = region.create(0, 0, "mountain")
|
||||
attrib.create(r, { a=1})
|
||||
attrib.create(r, { a=5})
|
||||
local total = 0
|
||||
for a in attrib.get(r) do
|
||||
total = total + a.data.a;
|
||||
end
|
||||
assert_equal(6, total)
|
||||
end
|
File diff suppressed because it is too large
Load diff
|
@ -1,266 +0,0 @@
|
|||
require "lunit"
|
||||
|
||||
local _G = _G
|
||||
local eressea = eressea
|
||||
local default_ship = config.ships[1]
|
||||
local default_building = config.buildings[1]
|
||||
|
||||
module("tests.orders", lunit.testcase)
|
||||
|
||||
local r, f, u
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
r = _G.region.create(0, 0, "mountain")
|
||||
f = _G.faction.create("noreply@eressea.de", "human", "de")
|
||||
u = _G.unit.create(f, r, 1)
|
||||
u:clear_orders()
|
||||
eressea.settings.set("rules.economy.food", "4")
|
||||
eressea.settings.set("nmr.removenewbie", "0")
|
||||
eressea.settings.set("nmr.timeout", "0")
|
||||
eressea.settings.set("NewbieImmunity", "0")
|
||||
end
|
||||
|
||||
function test_learn()
|
||||
u:add_order("LERNEN Hiebwaffen")
|
||||
_G.process_orders()
|
||||
assert_not_equal(0, u:get_skill("melee"))
|
||||
end
|
||||
|
||||
function test_give()
|
||||
local u2 = _G.unit.create(f, r, 1)
|
||||
u:add_item("money", 10)
|
||||
u:add_order("GIB " .. u2.id .. "5 SILBER")
|
||||
_G.process_orders()
|
||||
assert_not_equal(5, u:get_item("money"))
|
||||
assert_not_equal(5, u2:get_item("money"))
|
||||
end
|
||||
|
||||
function test_make_temp()
|
||||
u:add_order("MACHE TEMP 123 'Herpderp'")
|
||||
u:add_order("// this comment will be copied")
|
||||
u:add_order("ENDE")
|
||||
eressea.process.make_temp()
|
||||
|
||||
for x in f.units do
|
||||
if x.name == 'Herpderp' then u=x end
|
||||
end
|
||||
assert_equal('Herpderp', u.name)
|
||||
assert_equal(0, u.number)
|
||||
local c = 0
|
||||
for o in u.orders do
|
||||
assert_equal('// this comment will be copied', o)
|
||||
c = c + 1
|
||||
end
|
||||
assert_equal(1, c)
|
||||
end
|
||||
|
||||
function test_give_temp()
|
||||
u.number = 2
|
||||
u:add_order("GIB TEMP 123 1 PERSON")
|
||||
u:add_order("MACHE TEMP 123 'Herpderp'")
|
||||
u:add_order("ENDE")
|
||||
_G.process_orders()
|
||||
assert_equal(1, u.number)
|
||||
|
||||
for x in f.units do
|
||||
if x.name == 'Herpderp' then u=x end
|
||||
end
|
||||
assert_equal('Herpderp', u.name)
|
||||
assert_equal(1, u.number)
|
||||
end
|
||||
|
||||
function test_process_settings()
|
||||
f.options = 0
|
||||
u:add_order("EMAIL herp@derp.com")
|
||||
u:add_order("BANNER 'Herpderp'")
|
||||
u:add_order("PASSWORT 'HerpDerp'")
|
||||
u:add_order("OPTION AUSWERTUNG")
|
||||
eressea.process.settings()
|
||||
assert_equal("herp@derp.com", f.email)
|
||||
assert_equal("Herpderp", f.info)
|
||||
assert_equal("HerpDerp", f.password)
|
||||
assert_equal(1, f.options)
|
||||
end
|
||||
|
||||
function test_process_group()
|
||||
u:add_order("GRUPPE herp")
|
||||
eressea.process.set_group()
|
||||
assert_equal('herp', u.group)
|
||||
end
|
||||
|
||||
function test_process_origin()
|
||||
u:add_order("URSPRUNG 1 2")
|
||||
eressea.process.set_origin()
|
||||
x, y = u.faction:get_origin()
|
||||
assert_equal(1, x)
|
||||
assert_equal(2, y)
|
||||
end
|
||||
|
||||
function test_process_quit()
|
||||
fno = f.id
|
||||
u:add_order("STIRB '" .. u.faction.password .. "'")
|
||||
assert_not_equal(nil, _G.get_faction(fno))
|
||||
eressea.process.quit()
|
||||
eressea.write_game('test.dat')
|
||||
eressea.free_game()
|
||||
eressea.read_game('test.dat')
|
||||
assert_equal(nil, _G.get_faction(fno))
|
||||
end
|
||||
|
||||
function test_process_make()
|
||||
u.region:set_resource('tree', 100)
|
||||
u:set_skill('forestry', 1)
|
||||
u:add_order('MACHE HOLZ')
|
||||
eressea.process.produce()
|
||||
assert_equal(1, u:get_item('log'))
|
||||
end
|
||||
|
||||
function test_process_study()
|
||||
u:add_order("LERNEN Holzfaellen")
|
||||
eressea.process.update_long_order()
|
||||
eressea.process.study()
|
||||
x, y = u.faction:get_origin()
|
||||
assert_equal(1, u:get_skill('forestry'))
|
||||
end
|
||||
|
||||
function test_process_teach()
|
||||
eressea.settings.set("study.random_progress", "0")
|
||||
u:set_skill('forestry', 3)
|
||||
u2 = _G.unit.create(f, r, 10)
|
||||
u2:clear_orders()
|
||||
u2:set_skill('forestry', 1)
|
||||
u2:add_order("LERNEN Holzfaellen")
|
||||
u:add_order("LEHREN " .. _G.itoa36(u2.id))
|
||||
eressea.process.update_long_order()
|
||||
eressea.process.study()
|
||||
assert_equal(2, u2:get_skill('forestry'))
|
||||
end
|
||||
|
||||
function test_process_move()
|
||||
r2 = _G.region.create(1, 0, 'plain')
|
||||
u:add_order('NACH O')
|
||||
assert_not_equal(r2.id, u.region.id)
|
||||
eressea.process.update_long_order()
|
||||
eressea.process.movement()
|
||||
assert_equal(r2, u.region)
|
||||
end
|
||||
|
||||
function test_process_leave()
|
||||
r2 = _G.region.create(1, 0, 'plain')
|
||||
b = _G.building.create(r, default_building)
|
||||
u.building = b
|
||||
assert_equal(b, u.building)
|
||||
u:add_order('VERLASSEN')
|
||||
eressea.process.leave()
|
||||
assert_not_equal(b, u.building)
|
||||
end
|
||||
|
||||
function test_process_name_unit()
|
||||
u:add_order("BENENNE EINHEIT 'Weasel'")
|
||||
u:add_order("BESCHREIBE EINHEIT 'Juanita'")
|
||||
eressea.process.set_name()
|
||||
assert_equal('Weasel', u.name)
|
||||
assert_equal('Juanita', u.info)
|
||||
end
|
||||
|
||||
function test_process_name_faction()
|
||||
u:add_order("BENENNE PARTEI 'Herpderp'")
|
||||
eressea.process.set_name()
|
||||
assert_equal('Herpderp', f.name)
|
||||
end
|
||||
|
||||
function test_process_name_building()
|
||||
u:add_order("BENENNE GEBAEUDE 'Herpderp'")
|
||||
u.building = _G.building.create(r, default_building)
|
||||
eressea.process.set_name()
|
||||
assert_equal('Herpderp', u.building.name)
|
||||
end
|
||||
|
||||
function test_process_name_ship()
|
||||
u:add_order("BENENNE SCHIFF 'Herpderp'")
|
||||
u.ship = _G.ship.create(r, default_ship)
|
||||
eressea.process.set_name()
|
||||
assert_equal('Herpderp', u.ship.name)
|
||||
end
|
||||
|
||||
function test_process_renumber()
|
||||
u:add_order("NUMMER EINHEIT 'ii'")
|
||||
eressea.process.renumber()
|
||||
assert_equal(666, u.id)
|
||||
end
|
||||
|
||||
function test_process_enter()
|
||||
b = _G.building.create(r, default_building)
|
||||
u:add_order("BETRETEN GEBAEUDE " .. _G.itoa36(b.id))
|
||||
eressea.process.enter(1)
|
||||
assert_equal(b, u.building)
|
||||
end
|
||||
|
||||
function test_process_restack()
|
||||
eressea.process.restack()
|
||||
end
|
||||
|
||||
function test_process_setspells()
|
||||
eressea.process.set_spells()
|
||||
end
|
||||
|
||||
function test_process_help()
|
||||
eressea.process.set_help()
|
||||
end
|
||||
|
||||
function test_process_contact()
|
||||
eressea.process.contact()
|
||||
end
|
||||
|
||||
function test_process_battle()
|
||||
eressea.process.battle()
|
||||
end
|
||||
|
||||
function test_process_magic()
|
||||
eressea.process.magic()
|
||||
end
|
||||
|
||||
function test_process_give_control()
|
||||
eressea.process.give_control()
|
||||
end
|
||||
|
||||
function test_process_regeneration()
|
||||
eressea.process.regeneration()
|
||||
end
|
||||
|
||||
function test_process_guard_on()
|
||||
eressea.process.guard_on()
|
||||
end
|
||||
|
||||
function test_process_guard_off()
|
||||
eressea.process.guard_off()
|
||||
end
|
||||
|
||||
function test_process_explain()
|
||||
eressea.process.explain()
|
||||
end
|
||||
|
||||
function test_process_messages()
|
||||
eressea.process.messages()
|
||||
end
|
||||
|
||||
function test_process_reserve()
|
||||
eressea.process.reserve()
|
||||
end
|
||||
|
||||
function test_process_claim()
|
||||
eressea.process.claim()
|
||||
end
|
||||
|
||||
function test_process_follow()
|
||||
eressea.process.follow()
|
||||
end
|
||||
|
||||
function test_process_idle()
|
||||
eressea.process.idle()
|
||||
end
|
||||
|
||||
function test_process_set_default()
|
||||
eressea.process.set_default()
|
||||
end
|
|
@ -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
|
|
@ -1,36 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <base36.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i = 1, reverse = 0;
|
||||
if (strstr(argv[0], "itoa36"))
|
||||
reverse = 1;
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "-r") == 0) {
|
||||
i = 2;
|
||||
reverse = 1;
|
||||
}
|
||||
}
|
||||
for (; i != argc; ++i) {
|
||||
if (reverse) {
|
||||
printf("%s -> %s\n", argv[i], itoa36(atoi(argv[i])));
|
||||
} else
|
||||
printf("%s -> %d\n", argv[i], atoi36(argv[i]));
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char key[4];
|
||||
char code[4];
|
||||
char result[4];
|
||||
int a, i, rot;
|
||||
for (a = 1; a < argc; ++a) {
|
||||
const char *str = argv[a];
|
||||
size_t len = strlen(str);
|
||||
str = str + len - 6;
|
||||
memcpy(key, str, 3);
|
||||
memcpy(code, str + 3, 3);
|
||||
result[3] = key[3] = code[3] = 0;
|
||||
rot = atoi(key);
|
||||
for (i = 0; i != 3; ++i)
|
||||
result[(i + rot) % 3] = ((code[i] + 10 - key[i]) % 10) + '0';
|
||||
printf("%s %s\n", argv[a], result);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,244 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <config.h>
|
||||
#include <eressea.h>
|
||||
|
||||
static char *dwarf_syllable1[] = {
|
||||
"B", "D", "F", "G", "Gl", "H", "K", "L", "M", "N", "R", "S", "T", "Th", "V",
|
||||
};
|
||||
|
||||
static char *dwarf_syllable2[] = {
|
||||
"a", "e", "i", "o", "oi", "u",
|
||||
};
|
||||
|
||||
static char *dwarf_syllable3[] = {
|
||||
"bur", "fur", "gan", "gnus", "gnar", "li", "lin", "lir", "mli", "nar", "nus",
|
||||
"rin", "ran", "sin", "sil", "sur",
|
||||
};
|
||||
|
||||
static char *elf_syllable1[] = {
|
||||
"Al", "An", "Bal", "Bel", "Cal", "Cel", "El", "Elr", "Elv", "Eow", "Ear", "F",
|
||||
"Fal", "Fel", "Fin", "G", "Gal", "Gel", "Gl", "Is", "Lan", "Leg", "Lom",
|
||||
"N", "Nal", "Nel", "S", "Sal", "Sel", "T", "Tal", "Tel", "Thr", "Tin",
|
||||
};
|
||||
|
||||
static char *elf_syllable2[] = {
|
||||
"a", "adrie", "ara", "e", "ebri", "ele", "ere", "i", "io", "ithra", "ilma",
|
||||
"il-Ga", "ili", "o", "orfi", "u", "y",
|
||||
};
|
||||
|
||||
static char *elf_syllable3[] = {
|
||||
"l", "las", "lad", "ldor", "ldur", "linde", "lith", "mir", "n", "nd", "ndel",
|
||||
"ndil", "ndir", "nduil", "ng", "mbor", "r", "rith", "ril", "riand", "rion",
|
||||
"s", "thien", "viel", "wen", "wyn",
|
||||
};
|
||||
|
||||
static char *gnome_syllable1[] = {
|
||||
"Aar", "An", "Ar", "As", "C", "H", "Han", "Har", "Hel", "Iir", "J", "Jan",
|
||||
"Jar", "K", "L", "M", "Mar", "N", "Nik", "Os", "Ol", "P", "R", "S", "Sam",
|
||||
"San", "T", "Ter", "Tom", "Ul", "V", "W", "Y",
|
||||
};
|
||||
|
||||
static char *gnome_syllable2[] = {
|
||||
"a", "aa", "ai", "e", "ei", "i", "o", "uo", "u", "uu",
|
||||
};
|
||||
|
||||
static char *gnome_syllable3[] = {
|
||||
"ron", "re", "la", "ki", "kseli", "ksi", "ku", "ja", "ta", "na", "namari",
|
||||
"neli", "nika", "nikki", "nu", "nukka", "ka", "ko", "li", "kki", "rik",
|
||||
"po", "to", "pekka", "rjaana", "rjatta", "rjukka", "la", "lla", "lli", "mo",
|
||||
"nni",
|
||||
};
|
||||
|
||||
static char *hobbit_syllable1[] = {
|
||||
"B", "Ber", "Br", "D", "Der", "Dr", "F", "Fr", "G", "H", "L", "Ler", "M",
|
||||
"Mer", "N", "P", "Pr", "Per", "R", "S", "T", "W",
|
||||
};
|
||||
|
||||
static char *hobbit_syllable2[] = {
|
||||
"a", "e", "i", "ia", "o", "oi", "u",
|
||||
};
|
||||
|
||||
static char *hobbit_syllable3[] = {
|
||||
"bo", "ck", "decan", "degar", "do", "doc", "go", "grin", "lba", "lbo", "lda",
|
||||
"ldo", "lla", "ll", "lo", "m", "mwise", "nac", "noc", "nwise", "p", "ppin",
|
||||
"pper", "tho", "to",
|
||||
};
|
||||
|
||||
static char *human_syllable1[] = {
|
||||
"Ab", "Ac", "Ad", "Af", "Agr", "Ast", "As", "Al", "Adw", "Adr", "Ar", "B",
|
||||
"Br", "C", "Cr", "Ch", "Cad", "D", "Dr", "Dw", "Ed", "Eth", "Et", "Er",
|
||||
"El", "Eow", "F", "Fr", "G", "Gr", "Gw", "Gal", "Gl", "H", "Ha", "Ib",
|
||||
"Jer", "K", "Ka", "Ked", "L", "Loth", "Lar", "Leg", "M", "Mir", "N", "Nyd",
|
||||
"Ol", "Oc", "On", "P", "Pr", "R", "Rh", "S", "Sev", "T", "Tr", "Th", "V",
|
||||
"Y", "Z", "W", "Wic",
|
||||
};
|
||||
|
||||
static char *human_syllable2[] = {
|
||||
"a", "ae", "au", "ao", "are", "ale", "ali", "ay", "ardo", "e", "ei", "ea",
|
||||
"eri", "era", "ela", "eli", "enda", "erra", "i", "ia", "ie", "ire", "ira",
|
||||
"ila", "ili", "ira", "igo", "o", "oa", "oi", "oe", "ore", "u", "y",
|
||||
};
|
||||
|
||||
static char *human_syllable3[] = {
|
||||
"a", "and", "b", "bwyn", "baen", "bard", "c", "ctred", "cred", "ch", "can",
|
||||
"d", "dan", "don", "der", "dric", "dfrid", "dus", "f", "g", "gord", "gan",
|
||||
"l", "li", "lgrin", "lin", "lith", "lath", "loth", "ld", "ldric", "ldan",
|
||||
"m", "mas", "mos", "mar", "mond", "n", "nydd", "nidd", "nnon", "nwan",
|
||||
"nyth", "nad", "nn", "nnor", "nd", "p", "r", "ron", "rd", "s", "sh", "seth",
|
||||
"sean", "t", "th", "tha", "tlan", "trem", "tram", "v", "vudd", "w", "wan",
|
||||
"win", "wyn", "wyr", "wyr", "wyth",
|
||||
};
|
||||
|
||||
static char *orc_syllable1[] = {
|
||||
"B", "Er", "G", "Gr", "H", "P", "Pr", "R", "V", "Vr", "T", "Tr", "M", "Dr",
|
||||
};
|
||||
|
||||
static char *orc_syllable2[] = {
|
||||
"a", "i", "o", "oo", "u", "ui",
|
||||
};
|
||||
|
||||
static char *orc_syllable3[] = {
|
||||
"dash", "dish", "dush", "gar", "gor", "gdush", "lo", "gdish", "k", "lg",
|
||||
"nak", "rag", "rbag", "rg", "rk", "ng", "nk", "rt", "ol", "urk", "shnak",
|
||||
"mog", "mak", "rak",
|
||||
};
|
||||
|
||||
static char *entish_syllable1[] = {
|
||||
"Baum", "Wurzel", "Rinden", "Ast", "Blatt",
|
||||
};
|
||||
|
||||
static char *entish_syllable2[] = {
|
||||
"-",
|
||||
};
|
||||
|
||||
static char *entish_syllable3[] = {
|
||||
"Hüter", "Pflanzer", "Hirte", "Wächter", "Wachser", "Beschützer",
|
||||
};
|
||||
|
||||
static char *cthuloid_syllable1[] = {
|
||||
"Cth", "Az", "Fth", "Ts", "Xo", "Q'N", "R'L", "Ghata", "L", "Zz", "Fl", "Cl",
|
||||
"S", "Y",
|
||||
};
|
||||
|
||||
static char *cthuloid_syllable2[] = {
|
||||
"nar", "loi", "ul", "lu", "noth", "thon", "ath", "'N", "rhy", "oth", "aza",
|
||||
"agn", "oa", "og",
|
||||
};
|
||||
|
||||
static char *cthuloid_syllable3[] = {
|
||||
"l", "a", "u", "oa", "oggua", "oth", "ath", "aggua", "lu", "lo", "loth",
|
||||
"lotha", "agn", "axl",
|
||||
};
|
||||
|
||||
static char *create_random_name(race_t race)
|
||||
{
|
||||
static char name[64];
|
||||
|
||||
switch (race) {
|
||||
case RC_DWARF:
|
||||
strcpy(name,
|
||||
dwarf_syllable1[rng_int() % (sizeof(dwarf_syllable1) /
|
||||
sizeof(char *))]);
|
||||
strcat(name,
|
||||
dwarf_syllable2[rand() % (sizeof(dwarf_syllable2) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
dwarf_syllable3[rand() % (sizeof(dwarf_syllable3) / sizeof(char *))]);
|
||||
break;
|
||||
case RC_ELF:
|
||||
strcpy(name,
|
||||
elf_syllable1[rand() % (sizeof(elf_syllable1) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
elf_syllable2[rand() % (sizeof(elf_syllable2) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
elf_syllable3[rand() % (sizeof(elf_syllable3) / sizeof(char *))]);
|
||||
break;
|
||||
/*
|
||||
case RACE_GNOME:
|
||||
strcpy(name, gnome_syllable1[rand()%(sizeof(gnome_syllable1) / sizeof(char*))]);
|
||||
strcat(name, gnome_syllable2[rand()%(sizeof(gnome_syllable2) / sizeof(char*))]);
|
||||
strcat(name, gnome_syllable3[rand()%(sizeof(gnome_syllable3) / sizeof(char*))]);
|
||||
break;
|
||||
*/
|
||||
case RC_HALFLING:
|
||||
strcpy(name,
|
||||
hobbit_syllable1[rand() % (sizeof(hobbit_syllable1) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
hobbit_syllable2[rand() % (sizeof(hobbit_syllable2) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
hobbit_syllable3[rand() % (sizeof(hobbit_syllable3) / sizeof(char *))]);
|
||||
break;
|
||||
case RC_HUMAN:
|
||||
case RC_AQUARIAN:
|
||||
case RC_CAT:
|
||||
strcpy(name,
|
||||
human_syllable1[rand() % (sizeof(human_syllable1) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
human_syllable2[rand() % (sizeof(human_syllable2) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
human_syllable3[rand() % (sizeof(human_syllable3) / sizeof(char *))]);
|
||||
break;
|
||||
case RC_ORC:
|
||||
case RC_TROLL:
|
||||
case RC_GOBLIN:
|
||||
strcpy(name,
|
||||
orc_syllable1[rand() % (sizeof(orc_syllable1) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
orc_syllable2[rand() % (sizeof(orc_syllable2) / sizeof(char *))]);
|
||||
strcat(name,
|
||||
orc_syllable3[rand() % (sizeof(orc_syllable3) / sizeof(char *))]);
|
||||
break;
|
||||
/*
|
||||
case RC_TREEMAN:
|
||||
strcpy(name, entish_syllable1[rand()%(sizeof(entish_syllable1) / sizeof(char*))]);
|
||||
strcat(name, entish_syllable2[rand()%(sizeof(entish_syllable2) / sizeof(char*))]);
|
||||
strcat(name, entish_syllable3[rand()%(sizeof(entish_syllable3) / sizeof(char*))]);
|
||||
break;
|
||||
*/
|
||||
case RC_DAEMON:
|
||||
case RC_INSECT:
|
||||
strcpy(name,
|
||||
cthuloid_syllable1[rand() % (sizeof(cthuloid_syllable1) /
|
||||
sizeof(char *))]);
|
||||
strcat(name,
|
||||
cthuloid_syllable2[rand() % (sizeof(cthuloid_syllable2) /
|
||||
sizeof(char *))]);
|
||||
strcat(name,
|
||||
cthuloid_syllable3[rand() % (sizeof(cthuloid_syllable3) /
|
||||
sizeof(char *))]);
|
||||
break;
|
||||
default:
|
||||
name[0] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
race_t race;
|
||||
|
||||
for (race = 0; race < 11; race++) {
|
||||
int i;
|
||||
printf("%d:", (int)race);
|
||||
for (i = 0; i < 20; i++) {
|
||||
printf(" %s", create_random_name(race));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue