Skip to content

Commit

Permalink
moved observer destructor calles to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Ipagaxi committed May 26, 2024
1 parent 515b1e8 commit 2d093cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/include/Activities/FightActivity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class FightActivity: public Activity {
private:
FightEnv fightEnv;
FightStateEnum currentFightStateEnum = FightStateEnum::TURN_CHANGE;
std::shared_ptr<Enemy> enemy;

std::unique_ptr<FightState> currentFightState;

Expand Down
4 changes: 2 additions & 2 deletions src/main/Activities/FightActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

FightActivity::FightActivity() : Activity(), fightEnv(), currentFightState(std::make_unique<TurnChangeState>(fightEnv)) {
Game& game = Game::getInstance();
Enemy enemy = this->initEnemy();
this->fightEnv.enemyOverview = std::make_unique<UIEnemyOverview>(enemy);
this->enemy = std::make_shared<Enemy>(this->initEnemy());
this->fightEnv.enemyOverview = std::make_unique<UIEnemyOverview>(*this->enemy);
this->fightEnv.playerOverview.init();

this->fightEnv.backgroundTX.loadFromFile(RESOURCE_PATH "backgrounds/background_fight.png");
Expand Down
2 changes: 1 addition & 1 deletion src/main/ObserverPattern/Observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Observer::Observer() {

Observer::~Observer() {
std::cout << "~Observer" << std::endl;
//this->subject->detachObserver(*this);
this->subject->detachObserver(*this);
}

void Observer::onNotify(int newValue) {}
Expand Down

0 comments on commit 2d093cd

Please sign in to comment.