Skip to content
Snippets Groups Projects
Verified Commit ba4988a2 authored by TORTEROTOT THOMAS's avatar TORTEROTOT THOMAS
Browse files

Made level items and item values data structures of Terrain class const

parent 7c65a248
Branches
No related merge requests found
......@@ -8,7 +8,7 @@
namespace pm
{
std::array<EItemType, 13> Terrain::level_items{
const std::array<EItemType, 13> Terrain::level_items{
EItemType::Key, // default
EItemType::Cherry, // 1
EItemType::Strawberry, // 2
......@@ -24,7 +24,7 @@ std::array<EItemType, 13> Terrain::level_items{
EItemType::Bell // 12
};
std::unordered_map<EItemType, int> Terrain::item_values = {
const std::unordered_map<EItemType, int> Terrain::item_values = {
{EItemType::Cherry, 100},
{EItemType::Strawberry, 300},
{EItemType::Abricot, 500},
......@@ -124,7 +124,7 @@ void Terrain::eat(const Vector2I& pos)
Engine::get().get_gamemode<PacmanGamemode>().victory();
break;
case ECellType::Item:
points = item_values[cell.get_item()];
points = item_values.find(cell.get_item())->second;
Engine::get().get_gamemode<PacmanGamemode>().add_points(points);
cell.update_type(ECellType::Void);
update_sprite_handles();
......
......@@ -60,8 +60,8 @@ private:
void create_wall_cache_surface();
void free_wall_cache_surface();
static std::array<EItemType, 13> level_items;
static std::unordered_map<EItemType, int> item_values;
static const std::array<EItemType, 13> level_items;
static const std::unordered_map<EItemType, int> item_values;
std::unordered_map<EItemType, SpriteHandle> item_sprite_handles;
int32_t unit_length = 16;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment