• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JackAshwell11 / Hades / 18802797612

25 Oct 2025 12:04PM UTC coverage: 73.178% (+1.8%) from 71.41%
18802797612

push

github

JackAshwell11
Descoped the project by changing a few things:
- Removed melee and special attacks. These will be replaced with ranged attacks and a charged ranged attack.
- Merged the game options and load game scene into one so the game can be controlled before a new game is started instead of before each run.
- Removed saving functionality as this was unnecessary for the core idea of the game.
- Removed the lobby and integrated the shop directly into the game view.
- Removed many parts of the shop system so we can just focus on component unlocks. Component upgrades may be brought back at a later point, but they will need to be done via separate components.

This will allow me to focus on delivering the core parts of the game without scope creep.

1572 of 2821 branches covered (55.72%)

Branch coverage included in aggregate %.

90 of 93 new or added lines in 16 files covered. (96.77%)

52 existing lines in 6 files now uncovered.

2365 of 2559 relevant lines covered (92.42%)

15573.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.84
/src/hades_engine/src/ecs/systems/inventory.cpp
1
// Related header
2
#include "ecs/systems/inventory.hpp"
3

4
// Std headers
5
#include <utility>
6

7
// Local headers
8
#include "ecs/registry.hpp"
9
#include "ecs/systems/effects.hpp"
10
#include "events.hpp"
11

12
namespace {
13
/// The game objects that can be added to the inventory.
14
constexpr std::array COLLECTIBLE_TYPES{GameObjectType::HealthPotion};
15

16
/// The inventory size.
17
constexpr auto INVENTORY_SIZE{30};
18
}  // namespace
19

20
auto InventorySystem::has_item_in_inventory(const GameObjectID game_object_id, const GameObjectID item_id) const
11✔
21
    -> bool {
22
  // Check if the item is a valid game object or not
23
  if (!get_registry()->has_game_object(item_id)) {
11!
24
    return false;
2✔
25
  }
26

27
  // Check if the item is in the inventory or not
28
  const auto inventory{get_registry()->get_component<Inventory>(game_object_id)};
9✔
29
  return std::ranges::find(inventory->items.begin(), inventory->items.end(), item_id) != inventory->items.end();
8✔
30
}
8✔
31

32
void InventorySystem::add_item_to_inventory(const GameObjectID game_object_id, const GameObjectID item) const {
13✔
33
  // Check if the item is a valid game object or not
34
  if (!get_registry()->has_game_object(item)) {
13!
35
    return;
1✔
36
  }
37

38
  // Check if the item is a collectible item or not
39
  if (const auto item_type{get_registry()->get_game_object_type(item)};
12!
40
      std::ranges::find(COLLECTIBLE_TYPES, item_type) == COLLECTIBLE_TYPES.end()) {
12!
41
    return;
1✔
42
  }
43

44
  // Check if the inventory is full or not
45
  const auto inventory{get_registry()->get_component<Inventory>(game_object_id)};
11!
46
  if (std::cmp_equal(inventory->items.size(), INVENTORY_SIZE)) {
11!
UNCOV
47
    throw std::runtime_error("The inventory is full.");
×
48
  }
49

50
  // Add the item to the inventory, set the collected flag to prevent collision detection, and notify the callbacks
51
  inventory->items.push_back(item);
11!
52
  if (get_registry()->has_component<KinematicComponent>(item)) {
11!
53
    const auto kinematic_component{get_registry()->get_component<KinematicComponent>(item)};
3!
54
    cpSpaceRemoveShape(get_registry()->get_space(), *kinematic_component->shape);
3!
55
    cpSpaceRemoveBody(get_registry()->get_space(), *kinematic_component->body);
3!
56
  }
3✔
57
  notify<EventType::InventoryUpdate>(inventory->items);
11!
58
  notify<EventType::SpriteRemoval>(item);
11!
59
}
11✔
60

61
void InventorySystem::remove_item_from_inventory(const GameObjectID game_object_id, const GameObjectID item_id) const {
6✔
62
  // Check if the item is a valid game object or not
63
  if (!get_registry()->has_game_object(item_id)) {
6!
64
    return;
1✔
65
  }
66

67
  // Check if the inventory is empty or not
68
  const auto inventory{get_registry()->get_component<Inventory>(game_object_id)};
5✔
69
  const auto index{std::ranges::find(inventory->items.begin(), inventory->items.end(), item_id) -
3✔
70
                   inventory->items.begin()};
6✔
71
  if (index < 0 || index >= static_cast<int>(inventory->items.size())) {
3!
72
    return;
1✔
73
  }
74

75
  // Remove the item from the inventory, delete the game object, and notify the callbacks
76
  inventory->items.erase(inventory->items.begin() + index);
2!
77
  get_registry()->delete_game_object(item_id);
2!
78
  notify<EventType::InventoryUpdate>(inventory->items);
2!
79
}
3✔
80

81
void InventorySystem::use_item(const GameObjectID target_id, const GameObjectID item_id) const {
7✔
82
  // Check if the item is a valid game object or not
83
  if (!get_registry()->has_game_object(target_id) || !get_registry()->has_game_object(item_id)) {
7✔
84
    return;
3✔
85
  }
86

87
  // Use the item if it can be used
88
  bool used{false};
4✔
89
  if (get_registry()->has_component<EffectApplier>(item_id)) {
4✔
90
    used = get_registry()->get_system<EffectSystem>()->apply_effects(item_id, target_id);
3!
91
  }
92

93
  // If the item has been used, remove it from the inventory or the dungeon
94
  if (used) {
4✔
95
    if (has_item_in_inventory(target_id, item_id)) {
3✔
96
      remove_item_from_inventory(target_id, item_id);
1✔
97
    } else {
98
      get_registry()->delete_game_object(item_id);
2✔
99
    }
100
  }
101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc