From cad06586751c2302758f125629a1ffed5741f798 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 7 Dec 2025 19:32:11 +0100 Subject: [PATCH] ru:: unified potioon/jewelry flavors with cat colors under the common type name 'flavor' --- rogueviz/ru/classes.cpp | 9 ++++---- rogueviz/ru/flavors.cpp | 44 +++++++++++++++++++++++++++++++++++++ rogueviz/ru/namedcolors.cpp | 22 ------------------- rogueviz/ru/powers.cpp | 34 +++++++--------------------- rogueviz/ru/randeff.cpp | 2 +- rogueviz/ru/ru.cpp | 2 +- 6 files changed, 59 insertions(+), 54 deletions(-) create mode 100644 rogueviz/ru/flavors.cpp delete mode 100644 rogueviz/ru/namedcolors.cpp diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index 7958e2f1..88dee6db 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -34,13 +34,14 @@ struct power { string name; string desc; string glyph; + flavor fl; color_t color; powerfun pf; int id_status; int qty_filled; int qty_owned; flagtype flags; - int random_flavor; + int random_value; vector randeffs; void init(); vector> mods; @@ -358,7 +359,7 @@ struct man : public entity { int experience; stat profession; string backstory; - namedcolor hair, eye; + flavor hair, eye; statarray base_stats; statdata current, next; @@ -512,10 +513,10 @@ struct vtrap : public located_entity { string get_help() override { return "A deadly but invisible trap."; } }; -void sact(stater& s, string t, namedcolor co) { s.act(t+".name", co.name, "black").act(t+".col", co.col, 0xFFFFFFFF); } +void sact(stater& s, string t, flavor co) { s.act(t+".name", co.name, "black").act(t+".col", co.col, 0xFFFFFFFF); } struct cat : public enemy { - namedcolor col; + flavor col; cat(); xy siz() override { return {5, 5}; } string glyph() override { return "f"; } diff --git a/rogueviz/ru/flavors.cpp b/rogueviz/ru/flavors.cpp new file mode 100644 index 00000000..4cdeadaa --- /dev/null +++ b/rogueviz/ru/flavors.cpp @@ -0,0 +1,44 @@ +namespace rogue_unlike { + +struct flavor { + string name; + color_t col; + }; + +flavor + // cat colors + cc_red{"red", 0xC04040FF}, + cc_black{"black", 0x505060FF}, + cc_white{"white", 0xF0F0F0FF}, + // hair colors + hc_blonde{"blonde", 0xF0F0D0FF}, + hc_brownhair{"brown", 0x706030FF}, + hc_red{"red", 0xC04040FF}, + // eye colors + ec_green{"green", 0x40F040FF}, + ec_blue{"green", 0x40F040FF}, + ec_browneye{"brown", 0xA07030FF}, + + // potion colors + pc_bubbling{"bubbling", 0xC0C0C0FF}, + pc_golden{"golden", 0xFFD500FF}, + pc_red{"red", 0xC00000FF}, + pc_blue{"blue", 0x0000C0FF}, + pc_green{"green", 0x00C000FF}, + pc_white{"white", 0xFFFFFFFF}, + pc_black{"black", 0x303030FF}, + + // jewelry flavors + jc_steel{"steel", 0xA0A0C0FF}, + jc_amethyst{"amethyst", 0xC060C0FF}, + jc_ruby{"ruby", 0xC06060FF}, + jc_sapphire{"sapphire", 0x6060C0FF}, + jc_emerald{"emerald", 0x60C060FF}; + +vector cat_colors = { cc_red, cc_black, cc_white }; + +vector potion_colors = { pc_bubbling, pc_golden, pc_red, pc_blue, pc_green, pc_white, pc_black }; + +vector jewelry_colors = { jc_steel, jc_amethyst, jc_ruby, jc_sapphire, jc_emerald }; + +} diff --git a/rogueviz/ru/namedcolors.cpp b/rogueviz/ru/namedcolors.cpp deleted file mode 100644 index b3a7d9ff..00000000 --- a/rogueviz/ru/namedcolors.cpp +++ /dev/null @@ -1,22 +0,0 @@ -namespace rogue_unlike { - -struct namedcolor { - string name; - color_t col; - }; - -namedcolor - // cat colors - nc_red{"red", 0xC04040FF}, - nc_black{"red", 0x505060FF}, - nc_white{"white", 0xF0F0F0FF}, - // hair colors - nc_blonde{"blonde", 0xF0F0D0FF}, - nc_brownhair{"brown", 0x706030FF}, - // eye colors - nc_green{"green", 0x40F040FF}, - nc_browneye{"brown", 0xA07030FF}; - -vector cat_colors = { nc_red, nc_black, nc_white }; - -} diff --git a/rogueviz/ru/powers.cpp b/rogueviz/ru/powers.cpp index acc2cdb2..643a6c4a 100644 --- a/rogueviz/ru/powers.cpp +++ b/rogueviz/ru/powers.cpp @@ -52,33 +52,15 @@ power& power::be_resource(string s) { return self; } -using flavor = pair; int next_potion, next_jewelry; -vector jewelry_colors = { - {"steel", 0xA0A0C0FF}, - {"amethyst", 0xC060C0FF}, - {"ruby", 0xC06060FF}, - {"sapphire", 0x6060C0FF}, - {"emerald", 0x60C060FF}, - }; - -vector potion_colors = { - {"bubbling", 0xC0C0C0FF}, - {"golden", 0xFFD500FF}, - {"red", 0xC00000FF}, - {"blue", 0x0000C0FF}, - {"green", 0x00C000FF}, - {"white", 0xFFFFFFFF}, - {"black", 0x303030FF}, - }; - power& power::be_jewelry(string jtype, string xdesc) { int nj = next_jewelry++; + reshuffle = [this, nj] { fl = jewelry_colors[nj]; }; picked_up = [this] (int x) { qty_owned += x; qty_filled = max(qty_filled, x); }; - get_color = [nj] { return jewelry_colors[nj].second; }; - get_name = [nj, this, jtype] { - string fname = jewelry_colors[nj].first + " " + jtype; + get_color = [this] { return fl.col; }; + get_name = [this, jtype] { + string fname = fl.name + " " + jtype; if(flags & IDENTIFIED) fname = fname + " of " + name; fname = addqof(fname, this); return fname; @@ -120,11 +102,11 @@ string replace_weapon(string s, power *wpn) { power& power::be_potion() { int np = next_potion++; picked_up = [this] (int x) { qty_owned += x; qty_filled = max(qty_filled, x); }; - get_color = [np] { return potion_colors[np].second; }; + get_color = [this] { return fl.col; }; refill = [this] { qty_filled = qty_owned; }; - reshuffle = [this] { random_flavor = rand() % 5040; flags &=~ IDENTIFIED; }; - get_name = [np, this] { - string fname = potion_colors[np].first + " potion"; + reshuffle = [this, np] { fl = potion_colors[np]; flags &=~ IDENTIFIED; }; + get_name = [this] { + string fname = fl.name + " potion"; if(flags & (PARTIAL | IDENTIFIED)) fname = fname + " of " + name; int insq = 0; if(flags & IDENTIFIED) diff --git a/rogueviz/ru/randeff.cpp b/rogueviz/ru/randeff.cpp index a2330e32..cb9d81e0 100644 --- a/rogueviz/ru/randeff.cpp +++ b/rogueviz/ru/randeff.cpp @@ -122,7 +122,7 @@ randeff fire_weapon("Fiery Weapon", "Attacks with your [weapon] set things on fi m.next.mods.emplace_back(d.re->which_weapon, mod::burning, 2 * m.current.stats[stat::wis] + 1e-6); }); -namedcolor morph_cat_color; +flavor morph_cat_color; // morph powers randeff morph_cat("Cat", "Turns you into a cat.", "You turn into a cat!", [] (data &d) { diff --git a/rogueviz/ru/ru.cpp b/rogueviz/ru/ru.cpp index 22064e66..4425857f 100644 --- a/rogueviz/ru/ru.cpp +++ b/rogueviz/ru/ru.cpp @@ -24,7 +24,7 @@ Have fun! */ #include "globals.cpp" -#include "namedcolors.cpp" +#include "flavors.cpp" #include "classes.cpp" #include "staters.cpp" #include "geometry.cpp"