Trouble loading proper sprite resource

I'm trying to get a powerup to load based off the players health. In my current state, it only loads the 'Pill'.
What it should do:
Laser_Fine - ph(20-16)
Cluster - ph(15-11)
Shield - ph(10-6)
Pill - ph(5-0)

This is the current call to load the sprite.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
bool LoadResources(EntityManager &em)
{ 
  ...
   if (PowerUp::PowerToken::Pill)
	{
		if (!em.GetPowerUp().SetSprite("pill_blue"))
		{
			LOG_ERROR("Could not find sprite 'pill_blue'");
			return false;
		}
	}
	else if (PowerUp::PowerToken::Cluster)
	{
		if (!em.GetPowerUp().SetSprite("powerupblue_star"))
		{
			LOG_ERROR("Could not find sprite 'powerupblue_star'");
			return false;
		}
	}
	else if (PowerUp::PowerToken::Laser_Fine)
	{
		if (!em.GetPowerUp().SetSprite("powerupblue_bolt"))
		{
			LOG_ERROR("Could not find sprite 'powerupblue_bolt'");
			return false;
		}
	}
	else if (PowerUp::PowerToken::Shield)
	{
		if (!em.GetPowerUp().SetSprite("powerupblue_shield"))
		{
			LOG_ERROR("Could not find sprite 'powerupblue_shield'");
			return false;
		}
	}
   ...
}


From my PowerUp.h
This is the PowerUp class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class PowerUp : public Entity
{
public:

	enum PowerToken
	{
		Cluster,
		Laser_Fine,
		Shield,
		Pill
	};

	static const char* PowerTokenStrings[];

	static const char* PowerToken2String(PowerToken t)
	{
		return PowerTokenStrings[(int)t];
	}

private:
	PowerToken powerToken;

public:
	PowerUp();
	void Update(float elapsedTime, sf::RenderWindow& target, PlayerShip &player);

	void SetPowerToken(PowerToken t) { powerToken = t; }
	PowerToken GetPowerToken() { return powerToken; }
};

From my PowerUp.cpp
This is where I set the decision basis for which token to use.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void PowerUp::Update(float elapsedTime, sf::RenderWindow& target, PlayerShip &player)
{
	Vector2f position = Entity::GetPosition();
	if (player.GetHealth() <= 5)
	{
		SetPowerToken(PowerUp::PowerToken::Pill);
	}
	else if (player.GetHealth() <= 10 && player.GetHealth() > 5)
	{
		SetPowerToken(PowerUp::PowerToken::Shield);
	}
	else if (player.GetHealth() <= 15 && player.GetHealth() > 10)
	{
		SetPowerToken(PowerUp::PowerToken::Cluster);
	}
	else if (player.GetHealth() <= 20 && player.GetHealth() > 15)
	{
		SetPowerToken(PowerUp::PowerToken::Laser_Fine);
	}
	PowerUp::GetPowerToken();
}


The players health is set to 20 at runtime.

Is there something I've overlooked?

NOTE: I apologize for the length. I tried to crop as much while leaving as much pertinent information as possible. Thanks for the help
if (PowerUp::PowerToken::Pill) is actually if (3). It is always true, so it is always executed and other elses are not even taken into account. You probably wanted if (something.powerToken == PowerUp::PowerToken::Pill)
That makes sense. Thank you for the response.
Topic archived. No new replies allowed.