Bomberman Multiplayer
Authoritative multiplayer networking layer for Bomberman.
Loading...
Searching...
No Matches
PowerupConfig.h
Go to the documentation of this file.
1
6#ifndef BOMBERMAN_SIM_POWERUPCONFIG_H
7#define BOMBERMAN_SIM_POWERUPCONFIG_H
8
9#include <array>
10#include <cstdint>
11#include <string_view>
12
13#include "Sim/SimConfig.h"
14
15namespace bomberman::sim
16{
18 constexpr std::size_t kPowerupTypeCount = 4;
19
21 enum class PowerupType : uint8_t
22 {
23 SpeedBoost = 0,
24 Invincibility = 1,
25 BombRangeBoost = 2,
26 MaxBombsBoost = 3
27 };
28
36 constexpr std::array<PowerupType, 4> kRoundPowerupPlacements{{
37 PowerupType::SpeedBoost,
38 PowerupType::Invincibility,
39 PowerupType::BombRangeBoost,
40 PowerupType::MaxBombsBoost
41 }};
42
44 constexpr uint8_t kPowerupsPerRound = static_cast<uint8_t>(kRoundPowerupPlacements.size());
45
47 constexpr uint32_t kDefaultPowerupDurationTicks = static_cast<uint32_t>(kTickRate) * 10u;
48
51
54
57
60
62 constexpr double kSpeedBoostTilesPerSecond = 5.5;
63
65 constexpr int32_t kSpeedBoostPlayerSpeedQ =
66 static_cast<int32_t>(kSpeedBoostTilesPerSecond * 256.0 / kTickRate + 0.5);
67
69 constexpr uint8_t kBombRangeBoostAmount = 1;
70
72 constexpr uint8_t kBoostedMaxBombs = 2;
73
75 constexpr uint32_t kPowerupPlacementSeedSalt = 0x9E3779B9u;
76
77 static_assert(static_cast<std::size_t>(PowerupType::MaxBombsBoost) + 1u == kPowerupTypeCount,
78 "kPowerupTypeCount must match the defined powerup enum range");
79
81 constexpr bool isValidPowerupType(const uint8_t rawType)
82 {
83 return rawType == static_cast<uint8_t>(PowerupType::SpeedBoost) ||
84 rawType == static_cast<uint8_t>(PowerupType::Invincibility) ||
85 rawType == static_cast<uint8_t>(PowerupType::BombRangeBoost) ||
86 rawType == static_cast<uint8_t>(PowerupType::MaxBombsBoost);
87 }
88
90 constexpr std::string_view powerupTypeName(const PowerupType type)
91 {
92 switch (type)
93 {
94 case PowerupType::SpeedBoost:
95 return "SpeedBoost";
96 case PowerupType::Invincibility:
97 return "Invincibility";
98 case PowerupType::BombRangeBoost:
99 return "BombRangeBoost";
100 case PowerupType::MaxBombsBoost:
101 return "MaxBombsBoost";
102 }
103
104 return "Unknown";
105 }
106
108 constexpr std::size_t powerupTypeIndex(const PowerupType type)
109 {
110 return static_cast<std::size_t>(type);
111 }
112
114 constexpr uint32_t powerupEffectDurationTicks(const PowerupType type)
115 {
116 switch (type)
117 {
118 case PowerupType::SpeedBoost:
120 case PowerupType::Invincibility:
122 case PowerupType::BombRangeBoost:
124 case PowerupType::MaxBombsBoost:
126 }
127
128 return 0;
129 }
130} // namespace bomberman::sim
131
132#endif // BOMBERMAN_SIM_POWERUPCONFIG_H
Shared simulation tuning constants used by client and server gameplay code.
Shared simulation primitives and constants used by both the client and the authoritative server.
Definition Movement.h:21
constexpr uint8_t kPowerupsPerRound
Number of hidden powerups seeded into each round when enabled.
Definition PowerupConfig.h:44
constexpr std::array< PowerupType, 4 > kRoundPowerupPlacements
Stable per-round hidden placements seeded under random bricks.
Definition PowerupConfig.h:36
constexpr uint32_t kDefaultPowerupDurationTicks
Default temporary powerup lifetime in simulation ticks.
Definition PowerupConfig.h:47
constexpr uint32_t kPowerupPlacementSeedSalt
Deterministic salt mixed into round placement RNG so repeated map seeds can still vary by round.
Definition PowerupConfig.h:75
constexpr uint32_t kInvincibilityDurationTicks
Invincibility lifetime in simulation ticks.
Definition PowerupConfig.h:50
PowerupType
Supported temporary multiplayer powerup effects.
Definition PowerupConfig.h:22
constexpr uint32_t powerupEffectDurationTicks(const PowerupType type)
Returns the configured lifetime for one powerup effect.
Definition PowerupConfig.h:114
constexpr std::string_view powerupTypeName(const PowerupType type)
Returns a human-readable name for one powerup type.
Definition PowerupConfig.h:90
constexpr bool isValidPowerupType(const uint8_t rawType)
Returns true when a raw byte encodes one of the defined powerup types.
Definition PowerupConfig.h:81
constexpr std::size_t powerupTypeIndex(const PowerupType type)
Returns the stable array index used for per-type powerup stats.
Definition PowerupConfig.h:108
constexpr uint32_t kBombRangeBoostDurationTicks
Bomb-range boost lifetime in simulation ticks.
Definition PowerupConfig.h:56
constexpr int16_t kTickRate
Simulation tick rate in Hz.
Definition SimConfig.h:14
constexpr uint32_t kMaxBombsBoostDurationTicks
Max-bombs boost lifetime in simulation ticks.
Definition PowerupConfig.h:59
constexpr uint32_t kSpeedBoostDurationTicks
Speed boost lifetime in simulation ticks.
Definition PowerupConfig.h:53
constexpr uint8_t kBombRangeBoostAmount
Additional blast radius applied to bombs placed during the range boost.
Definition PowerupConfig.h:69
constexpr int32_t kSpeedBoostPlayerSpeedQ
Movement speed in tile-Q8 units per simulation tick while the speed boost is active.
Definition PowerupConfig.h:65
constexpr uint8_t kBoostedMaxBombs
Bomb-cap target while the max-bombs boost is active.
Definition PowerupConfig.h:72
constexpr double kSpeedBoostTilesPerSecond
Future movement-speed target while the speed boost is active.
Definition PowerupConfig.h:62
constexpr std::size_t kPowerupTypeCount
Number of defined multiplayer powerup types.
Definition PowerupConfig.h:18