Skip to content

Commit

Permalink
Merge branch 'dev' into observer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ipagaxi authored Jul 8, 2024
2 parents 66b2eb7 + 68c24ec commit 07550b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/include/Activities/FightActivity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FightActivity: public Activity {
~FightActivity();

ActivityEnum executeActivity() override;
void runCurrentState(Game &game);
void runCurrentState();

private:
/*
Expand All @@ -37,10 +37,6 @@ class FightActivity: public Activity {
std::unique_ptr<FightState> currentFightState;

Enemy initEnemy();
void runPlayersTurn();
void runEnemiesTurn();
void runDefeat();
void runVictory();
};

#endif
2 changes: 1 addition & 1 deletion src/include/UIElements/UIStats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UIStats: public UIElement, Observer<Actor> {
sf::Vector2f getPosition() override;
void setPosition(float x, float y) override;
sf::FloatRect getSize() override;

void update(Actor newActor) override;

private:
Expand Down
5 changes: 3 additions & 2 deletions src/main/Activities/FightActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ FightActivity::~FightActivity() {
this->fightEnv.backgroundMusic.stop();
}

void FightActivity::runCurrentState(Game &game) {
void FightActivity::runCurrentState() {
FightStateEnum newStateFightEnum = this->currentFightState->run(this->fightEnv);
if (newStateFightEnum != this->currentFightStateEnum) {
switch (newStateFightEnum) {
case FightStateEnum::PLAYER_STATE:
this->currentFightState = std::move(std::make_unique<PlayersTurn>(this->fightEnv));
break;
case FightStateEnum::ENEMY_STATE:
std::cout << "Player health: " << Game::getInstance().player.health << std::endl;
this->currentFightState = std::move(std::make_unique<EnemiesTurn>());
break;
case FightStateEnum::TURN_CHANGE:
Expand All @@ -73,7 +74,7 @@ ActivityEnum FightActivity::executeActivity() {
this->exitButton.draw();
this->fightEnv.textFadingManager.run();

this->runCurrentState(game);
this->runCurrentState();

if (this->exitButton.clickListener()) {

Expand Down
3 changes: 3 additions & 0 deletions src/main/UIElements/UIStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
UIStats::~UIStats() {
}


UIStats::UIStats(std::shared_ptr<Actor> actor): Observer(reinterpret_cast<Subject<Actor> &>(*actor)) {

Game& game = Game::getInstance();
sf::Vector2u windowSize = game.gameWindow.getSize();
this->actor = _actor;
sf::Color statsValueFontColor = sf::Color::Yellow;
sf::Color statsLabelFontColor = sf::Color::White;
this->statsTextHeight = windowSize.y * 0.015;
Expand Down

0 comments on commit 07550b2

Please sign in to comment.