91 |
SimpleStone(const string &knd, const string & snd, bool hollow, bool is_glass) |
SimpleStone(const string &knd, const string & snd, bool hollow, bool is_glass) |
92 |
: Stone(knd.c_str()) |
: Stone(knd.c_str()) |
93 |
, traits(SimpleStoneTraits::Register(snd, hollow, is_glass)) |
, traits(SimpleStoneTraits::Register(snd, hollow, is_glass)) |
94 |
|
, sunglas(false) |
95 |
{} |
{} |
96 |
private: |
private: |
97 |
|
bool sunglas; // seen through glasses |
98 |
|
|
99 |
SimpleStone(const SimpleStone& other) |
SimpleStone(const SimpleStone& other) |
100 |
: Stone(other.get_kind()) |
: Stone(other.get_kind()) |
101 |
, traits(other.traits) |
, traits(other.traits) |
118 |
return traits->is_hollow() || traits->is_glass(); |
return traits->is_hollow() || traits->is_glass(); |
119 |
} |
} |
120 |
|
|
121 |
|
void message(const string& msg, const Value &val) { |
122 |
|
if (traits->is_hollow() && msg == "glasses") { |
123 |
|
if (to_int(val)) { |
124 |
|
if (!sunglas) { |
125 |
|
sunglas = true; |
126 |
|
set_model( "invisible"); |
127 |
|
} |
128 |
|
} |
129 |
|
else { |
130 |
|
if (sunglas) { |
131 |
|
sunglas = false; |
132 |
|
set_model( this->get_kind()); |
133 |
|
} |
134 |
|
} |
135 |
|
} |
136 |
|
} |
137 |
|
|
138 |
const SimpleStoneTraits *traits; // owned by simple_stone_traits |
const SimpleStoneTraits *traits; // owned by simple_stone_traits |
139 |
}; |
}; |
140 |
} |
} |