beware: new directory layout, new server

This commit is contained in:
Enno Rehling 2012-06-05 07:36:05 -07:00
parent 6b57791acb
commit 2bf3c840ae
5 changed files with 72 additions and 99 deletions

53
scripts/tests/attrib.lua Normal file
View File

@ -0,0 +1,53 @@
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', {})
write_game('attrib.dat')
free_game()
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)
write_game("attrib.dat")
free_game()
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

View File

@ -1,6 +1,6 @@
require "lunit" require "lunit"
module("tests.bson", package.seeall, lunit.testcase) module("tests.eressea.bson", package.seeall, lunit.testcase)
function setup() function setup()
free_game() free_game()

View File

@ -35,7 +35,7 @@ local function two_factions()
return f1, f2 return f1, f2
end end
module("tests.common", package.seeall, lunit.testcase) module("tests.eressea.common", package.seeall, lunit.testcase)
function setup() function setup()
free_game() free_game()

View File

@ -1,20 +1,23 @@
require "lunit" require "lunit"
module("tests.spells", package.seeall, lunit.testcase) module("tests.eressea.spells", package.seeall, lunit.testcase)
local r, f, u
function setup() function setup()
free_game() free_game()
settings.set("magic.fumble.enable", "0")
settings.set("magic.regeneration.enable", "0") settings.set("magic.regeneration.enable", "0")
settings.set("magic.fumble.enable", "0")
settings.set("rules.economy.food", "4") 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 end
function test_spell_payment() function test_spell_payment()
local r = region.create(0,0, "plain")
local f = faction.create("spell_payment@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:set_skill("magic", 12)
u.magic = "gwyrrd" -- calls create_mage
u:add_spell("create_roi") u:add_spell("create_roi")
local permaura = u:get_pooled("permaura") local permaura = u:get_pooled("permaura")
@ -23,7 +26,7 @@ function test_spell_payment()
u:clear_orders() u:clear_orders()
u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ") u:add_order("ZAUBERE 'Erschaffe einen Ring der Unsichtbarkeit' ")
process_orders() process_orders()
write_reports()
assert_equal(1, u:get_item("roi")) assert_equal(1, u:get_item("roi"))
assert_equal(0, u:get_item("money")) assert_equal(0, u:get_item("money"))
assert_equal(0, u.aura) assert_equal(0, u.aura)
@ -31,12 +34,6 @@ function test_spell_payment()
end end
function test_spell_not_found_no_payment() function test_spell_not_found_no_payment()
local r = region.create(0,0, "plain")
local f = faction.create("spell_fails_no_payment@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 12)
local permaura = u:get_pooled("permaura") local permaura = u:get_pooled("permaura")
u:add_item("money", 3000) u:add_item("money", 3000)
u.aura = 50 u.aura = 50
@ -51,132 +48,49 @@ function test_spell_not_found_no_payment()
assert_equal(permaura, u:get_pooled("permaura")) assert_equal(permaura, u:get_pooled("permaura"))
end end
function test_create_firesword()
local r = region.create(0,0, "plain")
local f = faction.create("create_firesword@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 12)
u:add_spell("create_firesword")
u:cast_spell('create_firesword', 1)
assert_equal(1, u:get_item("firesword"))
end
function test_create_roi() function test_create_roi()
local r = region.create(0,0, "plain")
local f = faction.create("create_roi@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_roi') u:add_spell('create_roi')
u:cast_spell('create_roi') u:cast_spell('create_roi')
assert_equal(1, u:get_item("roi")) assert_equal(1, u:get_item("roi"))
end end
function test_create_roqf() function test_create_roqf()
local r = region.create(0,0, "plain")
local f = faction.create("create_roqf@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_roqf') u:add_spell('create_roqf')
u:cast_spell('create_roqf') u:cast_spell('create_roqf')
assert_equal(1, u:get_item("roqf")) assert_equal(1, u:get_item("roqf"))
end end
function test_create_aots() function test_create_aots()
local r = region.create(0,0, "plain")
local f = faction.create("create_aots@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_aots') u:add_spell('create_aots')
u:cast_spell('create_aots') u:cast_spell('create_aots')
assert_equal(1, u:get_item("aots")) assert_equal(1, u:get_item("aots"))
end end
function test_create_ror() function test_create_ror()
local r = region.create(0,0, "plain")
local f = faction.create("create_ror@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_ror') u:add_spell('create_ror')
u:cast_spell('create_ror') u:cast_spell('create_ror')
assert_equal(1, u:get_item("ror")) assert_equal(1, u:get_item("ror"))
end end
function test_create_magicherbbag()
local r = region.create(0,0, "plain")
local f = faction.create("create_magicherbbag@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_magicherbbag')
u:cast_spell('create_magicherbbag')
assert_equal(1, u:get_item("magicherbbag"))
end
function test_create_trollbelt() function test_create_trollbelt()
local r = region.create(0,0, "plain")
local f = faction.create("create_trollbelt@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_trollbelt') u:add_spell('create_trollbelt')
u:cast_spell('create_trollbelt') u:cast_spell('create_trollbelt')
assert_equal(1, u:get_item("trollbelt")) assert_equal(1, u:get_item("trollbelt"))
end end
function test_create_dreameye() function test_create_dreameye()
local r = region.create(0,0, "plain")
local f = faction.create("create_dreameye@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_dreameye') u:add_spell('create_dreameye')
u:cast_spell('create_dreameye') u:cast_spell('create_dreameye')
assert_equal(1, u:get_item("dreameye")) assert_equal(1, u:get_item("dreameye"))
end end
function test_create_antimagic() function test_create_antimagic()
local r = region.create(0,0, "plain")
local f = faction.create("create_antimagic@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_antimagic') u:add_spell('create_antimagic')
u:cast_spell('create_antimagic') u:cast_spell('create_antimagic')
assert_equal(1, u:get_item("antimagic")) assert_equal(1, u:get_item("antimagic"))
end end
function test_create_runesword()
local r = region.create(0,0, "plain")
local f = faction.create("create_runesword@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.magic = "gwyrrd" -- calls create_mage
u:set_skill("magic", 10)
u:add_spell('create_runesword')
u:cast_spell('create_runesword')
assert_equal(1, u:get_item("runesword"))
end
function test_create_rop() function test_create_rop()
local r = region.create(0,0, "plain")
local f = faction.create("create_rop@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:set_skill("magic", 10)
u:add_spell('create_rop') u:add_spell('create_rop')
u:cast_spell('create_rop') u:cast_spell('create_rop')
assert_equal(1, u:get_item("rop")) assert_equal(1, u:get_item("rop"))

View File

@ -1,6 +1,12 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project (eressea C) project (eressea C)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
ELSE(CMAKE_COMPILER_IS_GNUCC)
MESSAGE(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
set (ERESSEA_LIBRARY ${PROJECT_NAME} CACHE INTERNAL "Eressea Core Library") set (ERESSEA_LIBRARY ${PROJECT_NAME} CACHE INTERNAL "Eressea Core Library")
set (ERESSEA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "Eressea Core headers") set (ERESSEA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "Eressea Core headers")