forked from github/server
BUG 2322: Test and bugfix for castle names.
This commit is contained in:
parent
e530543022
commit
34d51d9e6c
|
@ -1032,3 +1032,48 @@ function test_recruit()
|
|||
assert_equal(6, u.number)
|
||||
end
|
||||
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()
|
||||
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
|
||||
|
|
|
@ -406,9 +406,6 @@ building *new_building(const struct building_type * btype, region * r,
|
|||
*bptr = b;
|
||||
|
||||
update_lighthouse(b);
|
||||
if (b->type->name) {
|
||||
bname = LOC(lang, buildingtype(btype, b, 0));
|
||||
}
|
||||
if (!bname) {
|
||||
bname = LOC(lang, btype->_name);
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ extern "C" {
|
|||
|
||||
extern struct selist *buildingtypes;
|
||||
extern struct attrib_type at_building_action;
|
||||
extern struct attrib_type at_building_generic_type;
|
||||
|
||||
int cmp_castle_size(const struct building *b, const struct building *a);
|
||||
int building_protection(const struct building_type *btype, int stage);
|
||||
|
@ -117,13 +118,13 @@ extern "C" {
|
|||
int flags;
|
||||
} building;
|
||||
|
||||
extern struct attrib_type at_building_generic_type;
|
||||
extern const char *buildingtype(const building_type * btype,
|
||||
|
||||
const char *buildingtype(const building_type * btype,
|
||||
const struct building *b, int bsize);
|
||||
extern const char *write_buildingname(const building * b, char *ibuf,
|
||||
const char *write_buildingname(const building * b, char *ibuf,
|
||||
size_t size);
|
||||
extern int buildingcapacity(const struct building *b);
|
||||
extern struct building *new_building(const struct building_type *typ,
|
||||
int buildingcapacity(const struct building *b);
|
||||
struct building *new_building(const struct building_type *typ,
|
||||
struct region *r, const struct locale *lang);
|
||||
int build_building(struct unit *u, const struct building_type *typ,
|
||||
int id, int size, struct order *ord);
|
||||
|
@ -147,9 +148,9 @@ extern "C" {
|
|||
void bunhash(struct building *b);
|
||||
int buildingcapacity(const struct building *b);
|
||||
|
||||
extern void remove_building(struct building **blist, struct building *b);
|
||||
extern void free_building(struct building *b);
|
||||
extern void free_buildings(void);
|
||||
void remove_building(struct building **blist, struct building *b);
|
||||
void free_building(struct building *b);
|
||||
void free_buildings(void);
|
||||
|
||||
const struct building_type *findbuildingtype(const char *name,
|
||||
const struct locale *lang);
|
||||
|
@ -157,16 +158,16 @@ extern "C" {
|
|||
#include "build.h"
|
||||
#define NOBUILDING NULL
|
||||
|
||||
extern int resolve_building(variant data, void *address);
|
||||
extern void write_building_reference(const struct building *b,
|
||||
int resolve_building(variant data, void *address);
|
||||
void write_building_reference(const struct building *b,
|
||||
struct storage *store);
|
||||
extern variant read_building_reference(struct gamedata *data);
|
||||
variant read_building_reference(struct gamedata *data);
|
||||
|
||||
extern struct building *findbuilding(int n);
|
||||
struct building *findbuilding(int n);
|
||||
|
||||
extern struct unit *building_owner(const struct building *b);
|
||||
extern void building_set_owner(struct unit * u);
|
||||
extern void building_update_owner(struct building * bld);
|
||||
struct unit *building_owner(const struct building *b);
|
||||
void building_set_owner(struct unit * u);
|
||||
void building_update_owner(struct building * bld);
|
||||
|
||||
bool buildingtype_exists(const struct region *r,
|
||||
const struct building_type *bt, bool working);
|
||||
|
@ -174,10 +175,10 @@ extern "C" {
|
|||
bool is_building_type(const struct building_type *btype, const char *name);
|
||||
struct building *active_building(const struct unit *u, const struct building_type *btype);
|
||||
|
||||
extern const char *buildingname(const struct building *b);
|
||||
const char *buildingname(const struct building *b);
|
||||
|
||||
extern const char *building_getname(const struct building *b);
|
||||
extern void building_setname(struct building *self, const char *name);
|
||||
const char *building_getname(const struct building *b);
|
||||
void building_setname(struct building *self, const char *name);
|
||||
|
||||
struct region *building_getregion(const struct building *b);
|
||||
void building_setregion(struct building *bld, struct region *r);
|
||||
|
|
Loading…
Reference in New Issue