335 |
namespace |
namespace |
336 |
{ |
{ |
337 |
class SwapStone : public Stone, public TimeHandler { |
class SwapStone : public Stone, public TimeHandler { |
|
CLONEOBJ(SwapStone); |
|
|
|
|
338 |
public: |
public: |
339 |
SwapStone() |
SwapStone() |
340 |
: Stone("st-swap") |
: Stone("st-swap") |
345 |
|
|
346 |
private: |
private: |
347 |
|
|
348 |
|
// Object interface |
349 |
|
SwapStone *clone(); |
350 |
|
void dispose(); |
351 |
|
|
352 |
// GridObject interface |
// GridObject interface |
353 |
void init_model(); |
void init_model(); |
354 |
void on_removal(); |
void on_removal(); |
368 |
|
|
369 |
}; |
}; |
370 |
|
|
371 |
|
SwapStone *SwapStone::clone() { |
372 |
|
SwapStone *other = new SwapStone(*this); |
373 |
|
other->in_exchange_with = 0; |
374 |
|
return other; |
375 |
|
} |
376 |
|
|
377 |
|
void SwapStone::dispose() { |
378 |
|
if (state == COME && in_exchange_with != 0) { |
379 |
|
in_exchange_with->dispose(); |
380 |
|
delete in_exchange_with; |
381 |
|
} |
382 |
|
delete this; |
383 |
|
} |
384 |
|
|
385 |
void SwapStone::on_removal() { |
void SwapStone::on_removal() { |
386 |
if (state == COME) { |
if (state == COME) { |
387 |
g_timer.remove_alarm(this); |
g_timer.remove_alarm(this); |