1 #pragma once
2 
3 #include "tag-version.h"
4 
5 struct monster_info;
6 
7 // various elemental colour schemes... used for abstracting random
8 // short lists. When adding colours, please also add their names in
9 // str_to_colour!
10 enum element_type
11 {
12     ETC_FIRE = 32,      // fiery colours (must be first and > highest colour)
13     ETC_FIRST = ETC_FIRE,
14     ETC_ICE,            // icy colours
15     ETC_EARTH,          // earthy colours
16     ETC_ELECTRICITY,    // electrical side of air
17     ETC_AIR,            // non-electric and general air magic
18     ETC_POISON,         // used only for venom mage and stalker stuff
19     ETC_WATER,          // used only for the elemental
20     ETC_MAGIC,          // general magical effect
21     ETC_MUTAGENIC,      // transmute, poly, radiation effects
22     ETC_WARP,           // teleportation and anything similar
23     ETC_ENCHANT,        // magical enhancements
24     ETC_HEAL,           // holy healing (not necromantic stuff)
25     ETC_HOLY,           // general "good" god effects
26     ETC_DARK,           // darkness
27     ETC_DEATH,          // assassin/necromancy stuff
28     ETC_UNHOLY,         // demonology stuff
29     ETC_VEHUMET,        // vehumet's oddball colours
30     ETC_BEOGH,          // Beogh altar colours
31     ETC_CRYSTAL,        // colours of crystal
32     ETC_BLOOD,          // colours of blood
33     ETC_SMOKE,          // colours of smoke
34     ETC_SLIME,          // colours of slime
35     ETC_JEWEL,          // colourful
36     ETC_ELVEN,          // used for colouring elf fabric items
37     ETC_DWARVEN,        // used for colouring dwarf fabric items
38     ETC_ORCISH,         // used for colouring orc fabric items
39     ETC_FLASH,          // flashy colours
40     ETC_FLOOR,          // colour of the area's floor
41     ETC_ROCK,           // colour of the area's rock
42     ETC_MIST,           // colour of mist
43     ETC_SHIMMER_BLUE,   // shimmering colours of blue
44     ETC_DECAY,          // colour of decay/swamp
45     ETC_SILVER,         // colour of silver
46     ETC_GOLD,           // colour of gold
47     ETC_IRON,           // colour of iron
48     ETC_BONE,           // colour of bone
49     ETC_ELVEN_BRICK,    // colour of the walls in the Elven Halls
50     ETC_WAVES,          // cyan, with regularly occurring lightcyan waves
51     ETC_TREE,           // colour of trees on land
52     ETC_RANDOM,         // any colour (except BLACK)
53     ETC_VORTEX,        // twisting swirls of grey
54     ETC_LIQUEFIED,      // ripples of yellow and brown.
55     ETC_MANGROVE,       // colour of trees on water
56     ETC_ORB_GLOW,       // halo coming from the Orb of Zot
57     ETC_DISJUNCTION,    // halo from Disjunction
58     ETC_DITHMENOS,      // Dithmenos altar colours
59     ETC_ELEMENTAL,      // Cycling elemental colours
60     ETC_INCARNADINE,    // Draining clouds coloured like raw flesh
61 #if TAG_MAJOR_VERSION == 34
62     ETC_SHINING,        // shining gold (Gozag)
63     ETC_PAKELLAS,       // Pakellas altar colours
64 #endif
65     ETC_WU_JIAN,        // Wu Jian Chinese-inspired colours
66     ETC_AWOKEN_FOREST,  // Angry trees.
67     ETC_DISCO = 96,
68     ETC_FIRST_LUA = ETC_DISCO, // colour indices have to be <128
69 
70     NUM_COLOURS
71 };
72 
73 typedef int (*element_colour_calculator)(int, const coord_def&);
74 
75 struct base_colour_calc
76 {
base_colour_calcbase_colour_calc77     base_colour_calc(element_type _type, string _name)
78         : type(_type), name(_name) {}
~base_colour_calcbase_colour_calc79     virtual ~base_colour_calc() {}
80 
81     element_type type;
82     string name;
83 
84     virtual int get(const coord_def& loc = coord_def(),
85                     bool non_random = false) = 0;
86 
87 protected:
88     int rand_max {120}; // 0-119 is the range of randomness promised to
89                         // Lua colour functions.
90     int rand(bool non_random);
91 };
92 
93 
94 struct element_colour_calc : public base_colour_calc
95 {
element_colour_calcelement_colour_calc96     element_colour_calc(element_type _type, string _name,
97                         element_colour_calculator _calc)
98         : base_colour_calc(_type, _name), calc(_calc) {}
~element_colour_calcelement_colour_calc99     virtual ~element_colour_calc() {}
100 
101     int get(const coord_def& loc = coord_def(),
102             bool non_random = false) override;
103 
104 protected:
105     element_colour_calculator calc;
106 };
107 
108 int str_to_colour(const string &str, int default_colour = -1,
109                   bool accept_number = true, bool accept_elemental = false);
110 const string colour_to_str(colour_t colour);
111 
112 void init_element_colours();
113 void add_element_colour(base_colour_calc *colour);
114 colour_t random_colour(bool ui_rand = false);
115 colour_t random_uncommon_colour();
116 bool is_low_colour(colour_t colour) IMMUTABLE;
117 bool is_high_colour(colour_t colour) IMMUTABLE;
118 colour_t make_low_colour(colour_t colour) IMMUTABLE;
119 colour_t make_high_colour(colour_t colour) IMMUTABLE;
120 int  element_colour(int element, bool no_random = false,
121                     const coord_def& loc = coord_def());
122 int get_disjunct_phase(const coord_def& loc);
123 bool get_vortex_phase(const coord_def& loc);
124 bool get_orb_phase(const coord_def& loc);
125 int dam_colour(const monster_info&);
126 colour_t rune_colour(int type);
127 
128 // Applies ETC_ colour substitutions
129 unsigned real_colour(unsigned raw_colour, const coord_def& loc = coord_def());
130