Player Stats Display - UQcsse3200/2026-studio-4 GitHub Wiki
PlayerStatsDisplay is a UI component attached directly to the player entity. It renders the player's live combat stats: health (as both a bar and a label), max health, strength (effective attack updates), movement speed, attack speed, and the shared shield display. It keeps combat stats in sync through CombatStatsComponent events. The current main/items implementation no longer has a Strength Charm count control.
Strength Charm behaviour
In remote items 9eb2186, each distinct StrengthCharm object picked up adds 10 to raw baseAttack. Charm.pickUp guards repeat application of the same object; it does not prevent different StrengthCharm objects from adding separate bonuses. With no other effects and baseAttack 10, two distinct pickups produce 20 then 30.
Charm.drop calls removeEffect to subtract that object's 10-point bonus and then removes it from inventory. Calling InventoryComponent.removeCharm directly only updates storage/events; it does not itself undo the bonus. No player-facing Charm drop button is supplied by the checked inventory book.
Strength Potion multiplies effective attack separately. Its expiry preserves raw Charm changes. The old global non-stacking rule and CharmEffectComponent references in Sprint 1 records do not describe the current implementation. The current HUD does not display the stored Charm count.
For the complete item flow and evidence, see Item Drop, Pickup and Strength Charm — Sprint 1.
Historical usage example and screenshots
The following example and screenshots describe the earlier Sprint 1 HUD, including its removed Charm-count control. They are not instructions for the current component. Production PlayerFactory attaches PlayerStatsDisplay to the player with its CombatStatsComponent; there is no implicit linked-entity lookup. See current Team 5 HUD for Gold/consumables and verification for current limits.
Original usage example
How to use:
// Attach to a UI entity alongside the components it reads from
Entity playerUI = new Entity()
.addComponent(new PlayerStatsDisplay());
// PlayerStatsDisplay expects the entity (or a linked entity) to already have:
// a CombatStatsComponent (for health, maxHealth, baseAttack, movementSpeed, attackSpeed)
// and an InventoryComponent (for charm count)
// Elsewhere, when combat stats change...
combatStats.setHealth(80); // fires "updateHealth" event which update healthLabel and healthBar
combatStats.setBaseAttack(25); // fires "updateBaseAttack" update strengthLabel
combatStats.setMaxHealth(150); // fires "updateMaxHealth"update healthBar range
// When a charm is added/removed from inventory...
inventory.addCharm(charm); // fires "charmAdded" then update charmCountLabel
Testing
Manual Testing:
- Start the game with the player at full health: confirm the health bar and
-
When enemy attack or damage the player: confirm the health bar animates down smoothly and the label updates.
-
When the player picks up the first Strength Charm after an enemy dies and presses 'E', confirm that "Strength Charms" changes from 0 to 1 and "Strength" changes from 10 to 20. Pick up another Strength Charm and confirm that the count increases again while Strength remains 20, demonstrating the intentional non-stacking behaviour.
- Change base attack, movement speed, and attack speed using player.json for now, confirm each corresponding label updates independently without affecting the others.