Lot more tests!
- Tests for converting legacy terrain types - Tests for initialization to sane values Fixes: - cCreature no longer initializes spec1 and spec2 to 0. This probably didn't cause bugs, but who knows... - In fact, cCreature no longer explicitly initializes anything in its cTownperson superclass. That's what the superclass constructor is for after all. - Relatedly, cTownperson now defaults to a facial graphic of -1. Also a docile attitude. - iLiving defaults to ap 0, direction here. - Fix Change When Step terrains to properly support not having a sound while still allowing an arbitrary number of custom sounds. - Add support for a lack of sound to Change When Used terrains, including at conversion time (original game supported it but OBoE was forcing the sound to a door sound). - Fix conversion of crumbling terrain types (old conversion was allowing quickfire to destroy them) Other: - New addAttack method in cMonster. - Change snd_num_t to signed, because it's been getting annoying that I can't easily use -1 to mean "no sound".
This commit is contained in:
@@ -136,7 +136,7 @@ different properties but the same appearance.)</li>
|
||||
<li><b>Change When Walk -</b> The terrain type changes to another when the party tries to
|
||||
walk into it. This happens even if the terrain is blocked to travel. Extra 1 is the number
|
||||
of the terrain type the terrain changes into. Extra 2 is the number of the sound that
|
||||
plays when this happens. If Extra 2 is left at 0, no sound plays.</li>
|
||||
plays when this happens. If Extra 2 is left at -1, no sound plays.</li>
|
||||
<li><b>Does Damage -</b> When someone walks on this space, some type of damage is
|
||||
inflicted. Damaged inflicted is inflicted using a dice roll, with the number of dice in
|
||||
Extra 2 and the sides per die in Extra 1. The type of damage to inflict is in Extra 3.
|
||||
|
@@ -262,6 +262,8 @@
|
||||
91CC173E1B421CA0003D9A69 /* scen_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CC173B1B421CA0003D9A69 /* scen_write.cpp */; };
|
||||
91CC17491B422D5C003D9A69 /* scen_read.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91CC173A1B421CA0003D9A69 /* scen_read.cpp */; };
|
||||
91D634560F8FD77800674AB3 /* BoE.icns in Resources */ = {isa = PBXBuildFile; fileRef = 2B8F435C0C0973680012E4A8 /* BoE.icns */; };
|
||||
91E128E41BC1624700C8BE1D /* ter_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E128E31BC1624700C8BE1D /* ter_legacy.cpp */; };
|
||||
91E128E61BC19DA400C8BE1D /* init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E128E51BC19DA400C8BE1D /* init.cpp */; };
|
||||
91E381461B97673700F69B81 /* town_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E381451B97671E00F69B81 /* town_write.cpp */; };
|
||||
91E381481B97677900F69B81 /* talk_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E381471B97675900F69B81 /* talk_write.cpp */; };
|
||||
91E3814A1B97679800F69B81 /* out_write.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E381491B97678D00F69B81 /* out_write.cpp */; };
|
||||
@@ -750,6 +752,8 @@
|
||||
91D635AD0F90E7B500674AB3 /* valleydy.meg */ = {isa = PBXFileReference; lastKnownFileType = file; path = valleydy.meg; sourceTree = "<group>"; };
|
||||
91D635AE0F90E7B500674AB3 /* zakhazi.exs */ = {isa = PBXFileReference; lastKnownFileType = file; path = zakhazi.exs; sourceTree = "<group>"; };
|
||||
91D635AF0F90E7B500674AB3 /* zakhazi.meg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zakhazi.meg; sourceTree = "<group>"; };
|
||||
91E128E31BC1624700C8BE1D /* ter_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ter_legacy.cpp; sourceTree = "<group>"; };
|
||||
91E128E51BC19DA400C8BE1D /* init.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = init.cpp; sourceTree = "<group>"; };
|
||||
91E1862B1B2B2AC0006A99EA /* estreams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = estreams.cpp; sourceTree = "<group>"; };
|
||||
91E30F2A1A74819B0057C54A /* fileio_party.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fileio_party.cpp; sourceTree = "<group>"; };
|
||||
91E30F2D1A7481C20057C54A /* fileio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fileio.cpp; sourceTree = "<group>"; };
|
||||
@@ -1324,6 +1328,7 @@
|
||||
children = (
|
||||
91CC17391B421CA0003D9A69 /* catch.cpp */,
|
||||
91C763D81B4C4BB30086D879 /* enums.cpp */,
|
||||
91E128E51BC19DA400C8BE1D /* init.cpp */,
|
||||
919B13A31BBD8849009905A4 /* item_legacy.cpp */,
|
||||
91EF27761B693D5500666469 /* item_read.cpp */,
|
||||
91EF27781B693D5F00666469 /* item_write.cpp */,
|
||||
@@ -1339,6 +1344,7 @@
|
||||
919B13A51BBDE985009905A4 /* spec_legacy.cpp */,
|
||||
91C2A6EE1B8FAA8E00346948 /* talk_read.cpp */,
|
||||
91E381471B97675900F69B81 /* talk_write.cpp */,
|
||||
91E128E31BC1624700C8BE1D /* ter_legacy.cpp */,
|
||||
91EF27721B693D3800666469 /* ter_read.cpp */,
|
||||
91EF27741B693D4800666469 /* ter_write.cpp */,
|
||||
91C2A6EC1B8FA91400346948 /* town_read.cpp */,
|
||||
@@ -1868,6 +1874,8 @@
|
||||
919B13A21BBCDF14009905A4 /* monst_legacy.cpp in Sources */,
|
||||
919B13A41BBD8854009905A4 /* item_legacy.cpp in Sources */,
|
||||
919B13A61BBDE986009905A4 /* spec_legacy.cpp in Sources */,
|
||||
91E128E41BC1624700C8BE1D /* ter_legacy.cpp in Sources */,
|
||||
91E128E61BC19DA400C8BE1D /* init.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@@ -293,7 +293,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
break;
|
||||
case eTerSpec::CHANGE_WHEN_STEP_ON:
|
||||
alter_space(where_check.x,where_check.y,ter_flag1);
|
||||
if(ter_flag2 < 200) {
|
||||
if(ter_flag2 >= 0) {
|
||||
play_sound(-1 * ter_flag2);
|
||||
}
|
||||
give_help(47,65);
|
||||
@@ -1256,7 +1256,8 @@ bool use_space(location where) {
|
||||
}
|
||||
add_string_to_buf(" OK.");
|
||||
alter_space(where.x,where.y,univ.scenario.ter_types[ter].flag1);
|
||||
play_sound(univ.scenario.ter_types[ter].flag2);
|
||||
if(univ.scenario.ter_types[ter].flag2 >= 0)
|
||||
play_sound(univ.scenario.ter_types[ter].flag2);
|
||||
return true;
|
||||
} else if(univ.scenario.ter_types[ter].special == eTerSpec::CALL_SPECIAL_WHEN_USED) {
|
||||
short spec_type = 0;
|
||||
|
@@ -17,15 +17,11 @@
|
||||
|
||||
const short cCreature::charm_odds[21] = {90,90,85,80,78, 75,73,60,40,30, 20,10,4,1,0, 0,0,0,0,0, 0};
|
||||
|
||||
cCreature::cCreature(){
|
||||
number = active = 0;
|
||||
attitude = start_attitude = eAttitude::DOCILE;
|
||||
start_loc.x = start_loc.y = cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
|
||||
mobility = 1;
|
||||
summon_time = 0;
|
||||
time_flag = eMonstTime::ALWAYS;
|
||||
spec1 = spec2 = spec_enc_code = time_code = monster_time = 0;
|
||||
personality = special_on_kill = facial_pic = -1;
|
||||
cCreature::cCreature() {
|
||||
active = 0;
|
||||
attitude = eAttitude::DOCILE;
|
||||
cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
|
||||
summon_time = 0;
|
||||
target = 6;
|
||||
}
|
||||
|
||||
|
@@ -19,8 +19,8 @@ class iLiving {
|
||||
public:
|
||||
// HACK: This is only really marked mutable so that I can use operator[] from const methods
|
||||
mutable std::map<eStatus,short> status;
|
||||
short ap;
|
||||
eDirection direction;
|
||||
short ap = 0;
|
||||
eDirection direction = DIR_HERE;
|
||||
short marked_damage = 0; // for use during animations
|
||||
|
||||
virtual bool is_alive() const = 0;
|
||||
|
@@ -138,6 +138,17 @@ void cMonster::append(legacy::monster_record_type& old){
|
||||
see_spec = -1;
|
||||
}
|
||||
|
||||
int cMonster::addAttack(unsigned short dice, unsigned short sides, eMonstMelee type) {
|
||||
int which = 0;
|
||||
while(which < 3 && a[which].dice > 0 && a[which].sides > 0)
|
||||
which++;
|
||||
if(which >= 3) return -1;
|
||||
a[which].dice = dice;
|
||||
a[which].sides = sides;
|
||||
a[which].type = type;
|
||||
return which;
|
||||
}
|
||||
|
||||
std::map<eMonstAbil,uAbility>::iterator cMonster::addAbil(eMonstAbilTemplate what, int param) {
|
||||
switch(what) {
|
||||
// Missiles: {true, type, missile pic, dice, sides, skill, range, odds}
|
||||
@@ -415,6 +426,8 @@ cTownperson::cTownperson() {
|
||||
personality = -1;
|
||||
special_on_kill = -1;
|
||||
special_on_talk = -1;
|
||||
facial_pic = -1;
|
||||
start_attitude = eAttitude::DOCILE;
|
||||
}
|
||||
|
||||
cTownperson::cTownperson(location loc, mon_num_t num, const cMonster& monst) : cTownperson() {
|
||||
|
@@ -120,6 +120,7 @@ public:
|
||||
spec_num_t see_spec;
|
||||
|
||||
std::map<eMonstAbil,uAbility>::iterator addAbil(eMonstAbilTemplate what, int param = 0);
|
||||
int addAttack(unsigned short dice, unsigned short sides, eMonstMelee type = eMonstMelee::SWING);
|
||||
|
||||
void append(legacy::monster_record_type& old);
|
||||
cMonster();
|
||||
|
@@ -162,6 +162,7 @@ void cTerrain::append(legacy::terrain_type_type& old){
|
||||
break;
|
||||
case 1:
|
||||
special = eTerSpec::CHANGE_WHEN_STEP_ON;
|
||||
if(flag2 == 200) flag2 = -1;
|
||||
flag3 = 0;
|
||||
break;
|
||||
case 2:
|
||||
@@ -186,7 +187,7 @@ void cTerrain::append(legacy::terrain_type_type& old){
|
||||
break;
|
||||
case 7:
|
||||
special = eTerSpec::CRUMBLING;
|
||||
flag2 = 1; // destroyed by Move Mountains but not by quickfire; 0 = both, 2 = quickfire only
|
||||
flag2 = 0; // destroyed by Move Mountains but not by quickfire; 1 = both, 2 = quickfire only
|
||||
break;
|
||||
case 8:
|
||||
special = eTerSpec::LOCKABLE;
|
||||
@@ -254,7 +255,6 @@ void cTerrain::append(legacy::terrain_type_type& old){
|
||||
break;
|
||||
case 22:
|
||||
special = eTerSpec::CHANGE_WHEN_USED;
|
||||
flag2 = 59;
|
||||
flag3 = 0;
|
||||
break;
|
||||
case 23:
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
typedef unsigned short snd_num_t;
|
||||
typedef signed int snd_num_t;
|
||||
void init_snd_tool();
|
||||
bool sound_going(snd_num_t which_s);
|
||||
void play_sound(short which, short how_many_times = 1);
|
||||
|
223
test/init.cpp
Normal file
223
test/init.cpp
Normal file
@@ -0,0 +1,223 @@
|
||||
//
|
||||
// init.cpp
|
||||
// BoE
|
||||
//
|
||||
// Created by Celtic Minstrel on 15-10-04.
|
||||
//
|
||||
//
|
||||
|
||||
#include <catch.hpp>
|
||||
#include "scenario.hpp"
|
||||
#include "creature.hpp"
|
||||
#include "creatlist.hpp"
|
||||
|
||||
TEST_CASE("Initialization sanity test for terrain") {
|
||||
cTerrain ter;
|
||||
CHECK(ter.name.empty());
|
||||
CHECK(ter.picture == 0);
|
||||
CHECK(ter.blockage == eTerObstruct::CLEAR);
|
||||
CHECK(ter.flag1 == -1);
|
||||
CHECK(ter.flag2 == 0);
|
||||
CHECK(ter.flag3 == 0);
|
||||
CHECK(ter.special == eTerSpec::NONE);
|
||||
CHECK(ter.trans_to_what == 0);
|
||||
CHECK_FALSE(ter.fly_over);
|
||||
CHECK_FALSE(ter.boat_over);
|
||||
CHECK_FALSE(ter.block_horse);
|
||||
CHECK_FALSE(ter.is_archetype);
|
||||
CHECK(ter.light_radius == 0);
|
||||
CHECK(ter.step_sound == eStepSnd::STEP);
|
||||
CHECK(ter.shortcut_key == 0);
|
||||
CHECK(ter.obj_num == 0);
|
||||
CHECK(ter.ground_type == 0);
|
||||
CHECK(ter.trim_type == eTrimType::NONE);
|
||||
CHECK(ter.trim_ter == 0);
|
||||
CHECK(ter.frill_for == -1);
|
||||
CHECK(ter.frill_chance == 0);
|
||||
CHECK(ter.combat_arena == 0);
|
||||
CHECK(ter.obj_pos == loc(0,0));
|
||||
CHECK(ter.obj_size == loc(0,0));
|
||||
CHECK(ter.map_pic == -1);
|
||||
}
|
||||
|
||||
TEST_CASE("Initialization sanity test for monster") {
|
||||
cCreature who;
|
||||
SECTION("Monster base class") {
|
||||
cMonster& monst = who;
|
||||
CHECK(monst.level == 0);
|
||||
CHECK(monst.m_name.empty());
|
||||
CHECK(monst.m_health == 0);
|
||||
CHECK(monst.armor == 0);
|
||||
CHECK(monst.skill == 0);
|
||||
CHECK(monst.a[0].dice == 0);
|
||||
CHECK(monst.a[0].sides == 0);
|
||||
CHECK(monst.a[0].type == eMonstMelee::SWING);
|
||||
CHECK(monst.a[1].dice == 0);
|
||||
CHECK(monst.a[1].sides == 0);
|
||||
CHECK(monst.a[1].type == eMonstMelee::SWING);
|
||||
CHECK(monst.a[2].dice == 0);
|
||||
CHECK(monst.a[2].sides == 0);
|
||||
CHECK(monst.a[2].type == eMonstMelee::SWING);
|
||||
CHECK(monst.m_type == eRace::HUMAN);
|
||||
CHECK(monst.speed == 4);
|
||||
CHECK(monst.mu == 0);
|
||||
CHECK(monst.cl == 0);
|
||||
CHECK(monst.treasure == 0);
|
||||
CHECK(monst.abil.empty());
|
||||
CHECK(monst.corpse_item == 0);
|
||||
CHECK(monst.corpse_item_chance == 0);
|
||||
CHECK(monst.resist.size() == 10);
|
||||
CHECK(monst.resist[eDamageType::WEAPON] == 100);
|
||||
CHECK(monst.resist[eDamageType::FIRE] == 100);
|
||||
CHECK(monst.resist[eDamageType::POISON] == 100);
|
||||
CHECK(monst.resist[eDamageType::COLD] == 100);
|
||||
CHECK(monst.resist[eDamageType::MAGIC] == 100);
|
||||
CHECK(monst.resist[eDamageType::UNBLOCKABLE] == 100);
|
||||
CHECK(monst.resist[eDamageType::UNDEAD] == 100);
|
||||
CHECK(monst.resist[eDamageType::DEMON] == 100);
|
||||
CHECK(monst.resist[eDamageType::MARKED] == 100);
|
||||
CHECK_FALSE(monst.mindless);
|
||||
CHECK_FALSE(monst.invuln);
|
||||
CHECK_FALSE(monst.invisible);
|
||||
CHECK_FALSE(monst.guard);
|
||||
CHECK_FALSE(monst.amorphous);
|
||||
CHECK(monst.x_width == 1);
|
||||
CHECK(monst.y_width == 1);
|
||||
CHECK(monst.default_attitude == eAttitude::DOCILE);
|
||||
CHECK(monst.summon_type == 0);
|
||||
CHECK(monst.default_facial_pic == 0);
|
||||
CHECK(monst.picture_num == 149);
|
||||
CHECK(monst.ambient_sound == -1);
|
||||
CHECK(monst.see_spec == -1);
|
||||
}
|
||||
SECTION("Townsperson base class") {
|
||||
cTownperson& dude = who;
|
||||
CHECK(dude.number == 0);
|
||||
CHECK(dude.start_attitude == eAttitude::DOCILE);
|
||||
CHECK(dude.start_loc == loc(80,80));
|
||||
CHECK(dude.mobility == 1);
|
||||
CHECK(dude.time_flag == eMonstTime::ALWAYS);
|
||||
CHECK(dude.spec1 == -1);
|
||||
CHECK(dude.spec2 == -1);
|
||||
CHECK(dude.spec_enc_code == 0);
|
||||
CHECK(dude.time_code == 0);
|
||||
CHECK(dude.monster_time == 0);
|
||||
CHECK(dude.personality == -1);
|
||||
CHECK(dude.special_on_kill == -1);
|
||||
CHECK(dude.special_on_talk == -1);
|
||||
CHECK(dude.facial_pic == -1);
|
||||
}
|
||||
SECTION("Living base class") {
|
||||
iLiving& base = who;
|
||||
CHECK(base.status.empty());
|
||||
CHECK(base.ap == 0);
|
||||
CHECK(base.direction == DIR_HERE);
|
||||
CHECK(base.marked_damage == 0);
|
||||
}
|
||||
SECTION("Main creature class") {
|
||||
CHECK(who.active == 0);
|
||||
CHECK(who.attitude == eAttitude::DOCILE);
|
||||
CHECK(who.cur_loc == loc(80,80));
|
||||
CHECK(who.summon_time == 0);
|
||||
CHECK(who.target == 6);
|
||||
CHECK(who.targ_loc == loc(80,80));
|
||||
CHECK(who.health == 0);
|
||||
CHECK(who.mp == 0);
|
||||
CHECK(who.max_mp == 0);
|
||||
CHECK(who.morale == 0);
|
||||
CHECK(who.m_morale == 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Construction sanity test for monster") {
|
||||
// First, build a base monster.
|
||||
cMonster monst;
|
||||
monst.default_facial_pic = 12;
|
||||
monst.default_attitude = eAttitude::HOSTILE_A;
|
||||
|
||||
cTownperson dude({10,10}, 7, monst); // This is here because the population sections also need it
|
||||
SECTION("Into townsperson") {
|
||||
CHECK(dude.number == 7);
|
||||
CHECK(dude.start_loc == loc(10,10));
|
||||
CHECK(dude.facial_pic == 12);
|
||||
CHECK(dude.start_attitude == eAttitude::HOSTILE_A);
|
||||
return; // Don't need to bother adding the extra monster/townperson attributes for this test
|
||||
}
|
||||
|
||||
cPopulation pop;
|
||||
SECTION("Population init sanity test") {
|
||||
CHECK(pop.size() == 0);
|
||||
CHECK(pop.which_town == 200);
|
||||
CHECK_FALSE(pop.hostile);
|
||||
return; // Don't need to bother adding the extra monster/townperson attributes for this test
|
||||
}
|
||||
|
||||
monst.addAbil(eMonstAbilTemplate::TOUCH_STEAL_GOLD);
|
||||
monst.addAttack(2, 8, eMonstMelee::STAB);
|
||||
monst.resist[eDamageType::FIRE] = 25;
|
||||
monst.level = 5;
|
||||
monst.m_name = "The Grinch";
|
||||
monst.m_health = 32;
|
||||
monst.armor = 9;
|
||||
monst.skill = 1;
|
||||
monst.m_type = eRace::GOBLIN;
|
||||
monst.invisible = true;
|
||||
monst.mu = 1;
|
||||
|
||||
dude.time_flag = eMonstTime::APPEAR_AFTER_CHOP;
|
||||
dude.personality = 8;
|
||||
dude.start_attitude = eAttitude::HOSTILE_B;
|
||||
|
||||
SECTION("Into population (normal mode)") {
|
||||
pop.assign(0, dude, monst, false, 1);
|
||||
REQUIRE(pop.size() == 1);
|
||||
CHECK(pop[0].active == 1);
|
||||
CHECK(pop[0].picture_num == 0);
|
||||
CHECK(pop[0].m_health == 32);
|
||||
CHECK(pop[0].health == 32);
|
||||
CHECK(pop[0].max_mp == 60);
|
||||
CHECK(pop[0].mp == 60);
|
||||
CHECK(pop[0].m_morale == 50);
|
||||
CHECK(pop[0].morale == 50);
|
||||
CHECK(pop[0].ap == 0);
|
||||
CHECK(pop[0].direction == DIR_HERE);
|
||||
CHECK(pop[0].status.size() == 0);
|
||||
CHECK(pop[0].attitude == eAttitude::HOSTILE_B);
|
||||
CHECK(pop[0].cur_loc == loc(10,10));
|
||||
// Townsperson stuff
|
||||
CHECK(pop[0].time_flag == eMonstTime::APPEAR_AFTER_CHOP);
|
||||
CHECK(pop[0].personality == 8);
|
||||
// Monster stuff
|
||||
CHECK(pop[0].m_name == "The Grinch");
|
||||
CHECK(pop[0].level == 5);
|
||||
CHECK(pop[0].armor == 9);
|
||||
CHECK(pop[0].skill == 1);
|
||||
CHECK(pop[0].speed == 4);
|
||||
CHECK(pop[0].m_type == eRace::GOBLIN);
|
||||
CHECK(pop[0].resist[eDamageType::FIRE] == 25);
|
||||
CHECK(pop[0].invisible);
|
||||
CHECK(pop[0].mu == 1);
|
||||
REQUIRE(pop[0].abil.size() == 1);
|
||||
CHECK(pop[0].abil[eMonstAbil::STEAL_GOLD].active);
|
||||
// No need to bother checking the attributes of the ability, just make sure it's there
|
||||
}
|
||||
SECTION("Into population (easy mode)") {
|
||||
pop.assign(0, dude, monst, true, 1);
|
||||
REQUIRE(pop.size() == 1);
|
||||
CHECK(pop[0].m_health == 16);
|
||||
CHECK(pop[0].health == 16);
|
||||
}
|
||||
SECTION("Into population (with difficulty adjust") {
|
||||
pop.assign(0, dude, monst, false, 10);
|
||||
REQUIRE(pop.size() == 1);
|
||||
CHECK(pop[0].m_health == 320);
|
||||
CHECK(pop[0].health == 320);
|
||||
}
|
||||
SECTION("Into population (high-level monster)") {
|
||||
monst.level = 50;
|
||||
pop.assign(0, dude, monst, false, 1);
|
||||
REQUIRE(pop.size() == 1);
|
||||
CHECK(pop[0].m_morale == 800);
|
||||
CHECK(pop[0].morale == 800);
|
||||
}
|
||||
}
|
@@ -146,14 +146,9 @@ TEST_CASE("Saving monster types") {
|
||||
CHECK(scen.scen_monsters[1].resist[eDamageType::SPECIAL] == 100);
|
||||
}
|
||||
SECTION("With attacks") {
|
||||
scen.scen_monsters[1].a[0].dice = 1;
|
||||
scen.scen_monsters[1].a[0].sides = 4;
|
||||
scen.scen_monsters[1].a[1].dice = 2;
|
||||
scen.scen_monsters[1].a[1].sides = 6;
|
||||
scen.scen_monsters[1].a[1].type = eMonstMelee::STAB;
|
||||
scen.scen_monsters[1].a[2].sides = 3;
|
||||
scen.scen_monsters[1].a[2].dice = 8;
|
||||
scen.scen_monsters[1].a[2].type = eMonstMelee::SLIME;
|
||||
scen.scen_monsters[1].addAttack(1, 4);
|
||||
scen.scen_monsters[1].addAttack(2, 6, eMonstMelee::STAB);
|
||||
scen.scen_monsters[1].addAttack(3, 8, eMonstMelee::SLIME);
|
||||
in_and_out("attacks", scen);
|
||||
CHECK(scen.scen_monsters[1].a[0].dice == 1);
|
||||
CHECK(scen.scen_monsters[1].a[0].sides == 4);
|
||||
@@ -161,8 +156,8 @@ TEST_CASE("Saving monster types") {
|
||||
CHECK(scen.scen_monsters[1].a[1].dice == 2);
|
||||
CHECK(scen.scen_monsters[1].a[1].sides == 6);
|
||||
CHECK(scen.scen_monsters[1].a[1].type == eMonstMelee::STAB);
|
||||
CHECK(scen.scen_monsters[1].a[2].sides == 3);
|
||||
CHECK(scen.scen_monsters[1].a[2].dice == 8);
|
||||
CHECK(scen.scen_monsters[1].a[2].dice == 3);
|
||||
CHECK(scen.scen_monsters[1].a[2].sides == 8);
|
||||
CHECK(scen.scen_monsters[1].a[2].type == eMonstMelee::SLIME);
|
||||
}
|
||||
SECTION("With an ability of every type") {
|
||||
|
225
test/ter_legacy.cpp
Normal file
225
test/ter_legacy.cpp
Normal file
@@ -0,0 +1,225 @@
|
||||
//
|
||||
// ter_legacy.cpp
|
||||
// BoE
|
||||
//
|
||||
// Created by Celtic Minstrel on 15-10-04.
|
||||
//
|
||||
//
|
||||
|
||||
#include <catch.hpp>
|
||||
#include "terrain.hpp"
|
||||
#include "oldstructs.hpp"
|
||||
|
||||
TEST_CASE("Converting terrain types from legacy scenarios") {
|
||||
cTerrain new_ter;
|
||||
legacy::terrain_type_type old_ter = {
|
||||
26,
|
||||
2, 0, 0, 0, 12, true, true,
|
||||
true, 17, 3, 'c', 0, 0, 0,
|
||||
};
|
||||
SECTION("Basic information") {
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.picture == 26);
|
||||
CHECK(new_ter.blockage == eTerObstruct::BLOCK_MONSTERS);
|
||||
CHECK(new_ter.trans_to_what == 12);
|
||||
CHECK(new_ter.fly_over);
|
||||
CHECK(new_ter.boat_over);
|
||||
CHECK(new_ter.block_horse);
|
||||
CHECK_FALSE(new_ter.is_archetype);
|
||||
CHECK(new_ter.light_radius == 17);
|
||||
CHECK(new_ter.step_sound == eStepSnd::NONE);
|
||||
CHECK(new_ter.shortcut_key == 'c');
|
||||
// Some details from translation
|
||||
CHECK(new_ter.combat_arena == 2);
|
||||
CHECK(new_ter.trim_type == eTrimType::W);
|
||||
CHECK(new_ter.trim_ter == 4);
|
||||
CHECK(new_ter.ground_type == 3);
|
||||
CHECK(new_ter.special == eTerSpec::NONE);
|
||||
CHECK(new_ter.flag1 == -1);
|
||||
CHECK(new_ter.flag2 == 0);
|
||||
CHECK(new_ter.flag3 == 0);
|
||||
}
|
||||
SECTION("With special properties") {
|
||||
SECTION("Change when walk") {
|
||||
old_ter.special = 1;
|
||||
old_ter.flag1 = 20;
|
||||
old_ter.flag2 = 200;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CHANGE_WHEN_STEP_ON);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
CHECK(new_ter.flag2 == -1);
|
||||
}
|
||||
SECTION("Fire damage") {
|
||||
old_ter.special = 2;
|
||||
old_ter.flag1 = 3;
|
||||
old_ter.flag2 = 6;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::DAMAGING);
|
||||
CHECK(new_ter.flag1 == 3);
|
||||
CHECK(new_ter.flag2 == 6);
|
||||
CHECK(new_ter.flag3 == int(eDamageType::FIRE));
|
||||
}
|
||||
SECTION("Cold damage") {
|
||||
old_ter.special = 3;
|
||||
old_ter.flag1 = 3;
|
||||
old_ter.flag2 = 6;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::DAMAGING);
|
||||
CHECK(new_ter.flag1 == 3);
|
||||
CHECK(new_ter.flag2 == 6);
|
||||
CHECK(new_ter.flag3 == int(eDamageType::COLD));
|
||||
}
|
||||
SECTION("Magic damage") {
|
||||
old_ter.special = 4;
|
||||
old_ter.flag1 = 3;
|
||||
old_ter.flag2 = 6;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::DAMAGING);
|
||||
CHECK(new_ter.flag1 == 3);
|
||||
CHECK(new_ter.flag2 == 6);
|
||||
CHECK(new_ter.flag3 == int(eDamageType::MAGIC));
|
||||
}
|
||||
SECTION("Poison land") {
|
||||
old_ter.special = 5;
|
||||
old_ter.flag1 = 8;
|
||||
old_ter.flag2 = 75;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::DANGEROUS);
|
||||
CHECK(new_ter.flag1 == 8);
|
||||
CHECK(new_ter.flag2 == 75);
|
||||
CHECK(new_ter.flag3 == int(eStatus::POISON));
|
||||
}
|
||||
SECTION("Disease land") {
|
||||
old_ter.special = 6;
|
||||
old_ter.flag1 = 8;
|
||||
old_ter.flag2 = 75;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::DANGEROUS);
|
||||
CHECK(new_ter.flag1 == 8);
|
||||
CHECK(new_ter.flag2 == 75);
|
||||
CHECK(new_ter.flag3 == int(eStatus::DISEASE));
|
||||
}
|
||||
SECTION("Crumbling") {
|
||||
old_ter.special = 7;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CRUMBLING);
|
||||
CHECK(new_ter.flag1 == 0);
|
||||
CHECK(new_ter.flag2 == 0);
|
||||
}
|
||||
SECTION("Lockable") {
|
||||
old_ter.special = 8;
|
||||
old_ter.flag1 = 20;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::LOCKABLE);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
}
|
||||
SECTION("Unlockable") {
|
||||
old_ter.special = 9;
|
||||
old_ter.flag1 = 20;
|
||||
old_ter.flag2 = 10;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::UNLOCKABLE);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
CHECK(new_ter.flag2 == 10);
|
||||
CHECK(new_ter.flag3 == 0);
|
||||
}
|
||||
SECTION("Unlockable/bashable") {
|
||||
old_ter.special = 10;
|
||||
old_ter.flag1 = 20;
|
||||
old_ter.flag2 = 10;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::UNLOCKABLE);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
CHECK(new_ter.flag2 == 10);
|
||||
CHECK(new_ter.flag3 == 1);
|
||||
}
|
||||
SECTION("Sign") {
|
||||
old_ter.special = 11;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::IS_A_SIGN);
|
||||
}
|
||||
SECTION("Call local special") {
|
||||
old_ter.special = 12;
|
||||
old_ter.flag1 = 20;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CALL_SPECIAL);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
CHECK(new_ter.flag2 == 1);
|
||||
}
|
||||
SECTION("Call global special") {
|
||||
old_ter.special = 13;
|
||||
old_ter.flag1 = 20;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CALL_SPECIAL);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
CHECK(new_ter.flag2 == 0);
|
||||
}
|
||||
SECTION("Container") {
|
||||
old_ter.special = 14;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::IS_A_CONTAINER);
|
||||
}
|
||||
SECTION("Waterfall") {
|
||||
old_ter.special = 15;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::WATERFALL_CAVE);
|
||||
CHECK(new_ter.flag1 == DIR_S);
|
||||
CHECK(new_ter.flag2 == 5);
|
||||
CHECK(new_ter.flag3 == 90);
|
||||
}
|
||||
SECTION("Conveyor belt (north)") {
|
||||
old_ter.special = 16;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CONVEYOR);
|
||||
CHECK(new_ter.flag1 == DIR_N);
|
||||
}
|
||||
SECTION("Conveyor belt (east)") {
|
||||
old_ter.special = 17;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CONVEYOR);
|
||||
CHECK(new_ter.flag1 == DIR_E);
|
||||
}
|
||||
SECTION("Conveyor belt (south)") {
|
||||
old_ter.special = 18;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CONVEYOR);
|
||||
CHECK(new_ter.flag1 == DIR_S);
|
||||
}
|
||||
SECTION("Conveyor belt (west)") {
|
||||
old_ter.special = 19;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CONVEYOR);
|
||||
CHECK(new_ter.flag1 == DIR_W);
|
||||
}
|
||||
SECTION("Blocked to monsters") {
|
||||
old_ter.special = 20;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::BLOCKED_TO_MONSTERS);
|
||||
}
|
||||
SECTION("Town entrance") {
|
||||
old_ter.special = 21;
|
||||
old_ter.flag1 = 20;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::TOWN_ENTRANCE);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
}
|
||||
SECTION("Change when used") {
|
||||
old_ter.special = 22;
|
||||
old_ter.flag1 = 20;
|
||||
old_ter.flag2 = 200;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CHANGE_WHEN_USED);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
// Unlike change when step, this didn't originally have special allowance for no sound
|
||||
CHECK(new_ter.flag2 == 200);
|
||||
}
|
||||
SECTION("Call scenario special when used") {
|
||||
old_ter.special = 23;
|
||||
old_ter.flag1 = 20;
|
||||
new_ter.append(old_ter);
|
||||
CHECK(new_ter.special == eTerSpec::CALL_SPECIAL_WHEN_USED);
|
||||
CHECK(new_ter.flag1 == 20);
|
||||
CHECK(new_ter.flag2 == 0);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user