From 2a458450b50606488adce4484a66e33fb5655c8b Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Wed, 10 Dec 2014 19:55:23 -0500 Subject: [PATCH] Expand if race/trait to allow for richer comparisons (Adapted from Windows code) --- osx/boe.party.cpp | 8 ++++++++ osx/boe.party.h | 1 + osx/boe.specials.cpp | 34 +++++++++++++++++++--------------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index 0c55f346..d6d6ee98 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -3214,6 +3214,14 @@ short trait_present(short which_trait) { return ret; } +short race_present(eRace which_race) { + short i,ret = 0; + for (i = 0; i < 6; i++) + if(univ.party[i].main_status == eMainStatus::ALIVE && univ.party[i].race == which_race) + ret += 1; + return ret; +} + short wilderness_lore_present() { // TODO: Add contional statement to choose between these // (Probably requires something added to terrain types to specify that it's cave/surface wilderness.) diff --git a/osx/boe.party.h b/osx/boe.party.h index 7983c0f4..6cb5e93c 100644 --- a/osx/boe.party.h +++ b/osx/boe.party.h @@ -56,6 +56,7 @@ void kill_pc(short which_pc,eMainStatus type); void set_pc_moves(); void take_ap(short num); short trait_present(short which_trait); +short race_present(eRace which_race); short wilderness_lore_present(); void print_spell_cast(short spell_num,short which); void put_party_in_scen(std::string scen_name); diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index 28a0a10d..6a13ac2c 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -3044,28 +3044,32 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type, *next_spec = spec.ex2b; break; case eSpecType::IF_SPECIES: - if(spec.ex1a < 0 || spec.ex1a > 2) break; // TODO: Should we allow monster races too? + if(spec.ex1a < 0 || spec.ex1a > 2) { + giveError("Species out of range (0-human, 1-nephilim, 2-slith)"); + break; // TODO: Should we allow monster races too? + } i = 0; - j = min(spec.ex2a,party_size(0)); + j = min(spec.ex2a,party_size(true)); if (j < 1) j = 1; - for (i = 0; i < 6; i++) { - if ((univ.party[i].main_status == eMainStatus::ALIVE) && (univ.party[i].race == eRace(spec.ex1a))) - i++; - } - if (i >= j) - *next_spec = spec.ex1b; + i = race_present(eRace(spec.ex1a)); + if(spec.ex2b == -2 && i <= j) *next_spec = spec.ex1b; + if(spec.ex2b == -1 && i < j) *next_spec = spec.ex1b; + if(spec.ex2b == 0 && i == j) *next_spec = spec.ex1b; + if(spec.ex2b == 1 && i > j) *next_spec = spec.ex1b; + if(spec.ex2b == 2 && i >= j) *next_spec = spec.ex1b; break; case eSpecType::IF_TRAIT: - j = min(spec.ex2a,party_size(0)); + // TODO: Bound-check the trait. + j = min(spec.ex2a,party_size(true)); if (j < 1) j = 1; - for (i = 0; i < 6; i++) { - if(univ.party[i].main_status == eMainStatus::ALIVE && univ.party[i].traits[spec.ex1a] > 0) - i++; - } - if (trait_present(spec.ex1a) >= j) - *next_spec = spec.ex1b; + i = trait_present(spec.ex1a); + if(spec.ex2b == -2 && i <= j) *next_spec = spec.ex1b; + if(spec.ex2b == -1 && i < j) *next_spec = spec.ex1b; + if(spec.ex2b == 0 && i == j) *next_spec = spec.ex1b; + if(spec.ex2b == 1 && i > j) *next_spec = spec.ex1b; + if(spec.ex2b == 2 && i >= j) *next_spec = spec.ex1b; break; case eSpecType::IF_STATISTIC: if(spec.ex2a < 0 || spec.ex2a > 25) {