void PokeProxy::adaptTo(const PokeBattle *pokemon) { PokeBattle *trans = dynamic_cast<PokeBattle*>(pokeData); for (int i = 0; i < 4; i++) { move(i)->adaptTo(&pokemon->move(i)); } if (trans) { *trans = *pokemon; } else { if (*pokeData == *(static_cast<const ShallowBattlePoke*>(pokemon))) { return; } *pokeData = *pokemon; } /* Could be more granular, change if it matters */ emitReset(); }
void PokeProxy::adaptTo(const ShallowBattlePoke *pokemon, bool soft) { const PokeBattle *trans = dynamic_cast<const PokeBattle*>(pokemon); if (trans) { adaptTo(trans); } if (*pokemon == *pokeData) { return; } if (soft) { pokeData->changeStatus(pokemon->status()); return; } /* Could be more granular, change if it matters */ *pokeData = *pokemon; if (pokeData->lifePercent() != pokemon->lifePercent()) { pokeData->setLifePercent(pokemon->lifePercent()); } emitReset(); }
void SlidePuzzleModel::reset() { _status = SlidePuzzleStatus::INIT; _scheduleManager->clear(); _pieces.resize(_width, _height); for (int x = 0; x < _width; x++) { for (int y = 0; y < _height; y++) { Position pos(x, y); _pieces.get(pos) = Position(pos); } } _emptyPos = Position(_width-1, 0); _pieces.get(_emptyPos) = EMPTY_PIECE; emitReset(); _scheduleManager->clear(); shuffle(); }