Commit bdf3a24
authored
* feat(scoring): implement Zeit-Bracket scoring strategy for Race Mode (#168)
Replaces the old ScoringService/ScoringServiceImpl with a sealed
ScoringStrategy hierarchy. RaceScoringStrategy applies time-bracket
points (DIAMOND=60, GOLD=45, SILVER=30, BRONZE=15, FINISH=5) on
map completion, then position bonuses (1st=10, 2nd=6, 3rd=3, 4th+=1)
at end-phase. PracticeScoringStrategy classifies medal tiers only
with no competitive points. Strategy is chosen by ScoringStrategyFactory
based on GameMode and stored as ScoringStrategyComponent on the game entity.
MapDefinition gains referenceDurationMs (default 3 min) used as the
bracket classification anchor. PlayerScore and ScoreComponent gain
completionTimeMs and medalTier fields. Flyway V1 baseline + V2
migration add completion_time_ms to game_results; database module
switches to Flyway for all future schema changes per ADR-0011.
* refactor(scoring): migrate to pure ECS — remove ScoringStrategy hierarchy
Replaces the hybrid ScoringStrategy service pattern with pure ECS:
- NEW: ElapsedTimeComponent (game entity, refreshed per tick by phase)
- NEW: BracketConfigComponent (game entity, set per map by orchestrator)
- NEW: CompletionDetectionSystem — detects when a player passes all rings,
writes completionTimeMs + medalTier + bracket points (RACE: 60/45/30/15/5)
directly into ScoreComponent; idempotent, degrades gracefully on missing config
- ScoreComponent.addPositionBonus(int) added for layered bonus application
- MinestomGamePhase: updateElapsedTime() runs before entityManager.update()
so all systems see a consistent elapsed-time value on every tick;
recordCompletions() removed (now CompletionDetectionSystem's job)
- MinestomEndPhase.rankAndApplyBonuses() is now pure ECS — reads
GameModeComponent, applies 10/6/3/1 position bonuses for RACE, no-op for PRACTICE
- GameOrchestrator registers CompletionDetectionSystem in the system chain
and attaches BracketConfigComponent to the game entity on each map load
- GameSession: ScoringStrategy field removed, constructor simplified to 3 args
- DELETED: ScoringStrategy, BaseScoringStrategy, RaceScoringStrategy,
PracticeScoringStrategy, ScoringStrategyFactory, ScoringStrategyComponent
- Tests: ScoringServiceTest rewritten as CompletionDetectionSystem @envtest
covering all bracket tiers, PRACTICE mode, idempotency, and DNF handling
* test(phase): fix MinestomEndPhaseRankingTest — update position bonuses to 10/6/3/1 and use @envtest with real players
* fix(database): V3 migration — convert UUID columns from BINARY(16) to native uuid type
Hibernate ORM 7 maps java.util.UUID to MariaDB's native uuid type, but the
V1 baseline created elytra_players.playerId and game_results.player_id as
BINARY(16). This caused two runtime errors:
- hbm2ddl=update tried to ALTER the columns but MariaDB refused due to FK
- INSERT failed with 'Data too long' because Hibernate sends UUID as a
36-char string, not 16-byte binary
V3 drops fk_game_results_player, converts both columns to uuid NOT NULL,
and re-adds the FK. Safe on fresh installs too (no-op if already uuid).
* feat(hud): replace speed+points display with speed, ring progress, elapsed time and bracket pace
- Actionbar during race: '{speed} m/s · {passed}/{total} · {mm:ss.t} [BRACKET]'
where bracket is colored (aqua=DIAMOND, gold=GOLD, gray=SILVER, bronze=BRONZE, red=FINISH)
and projected from current pace (elapsedMs / passed * total)
- After finish: '{speed} m/s · MEDAL · {finish time}'
- Ring pass feedback: 'Ring X/N!' instead of '+1 pts' — ring points no longer
meaningful to show per-ring since bracket score is awarded at finish
- ScoreDisplaySystem now injects EntityManager to read ElapsedTimeComponent,
BracketConfigComponent and ActiveMapComponent from the game entity
- Updated translation keys: hud.actionbar (4 args), hud.actionbar.finished,
hud.ring_passed (ring count instead of points)
* fix(game): reset rings and score on landing, sync isFlying from player.isGliding()
- ElytraPhysicsSystem now syncs flight.setFlying(player.isGliding()) every tick
so landing is detected correctly (previously setFlying(false) was never called)
- New LandingResetSystem: on flying→notFlying transition for unfinished players,
resets RingTrackerComponent + ScoreComponent and clears the actionbar
(runs after ElytraPhysicsSystem, before ScoreDisplaySystem)
- ScoreDisplaySystem clears its tick/hash cache when not flying so the next
takeoff renders the HUD immediately without a stale-hash delay
- HudComponent.clearActionbar() sends Component.empty() to dismiss the last message
* feat(scoring): dynamic DB record-based bracket scoring for race mode
Replace static per-map reference durations with a live record sourced from
the database. The first player to finish any (cup, map) combination sets the
record and receives DIAMOND; every subsequent finisher is classified relative
to the current in-session best via MedalBrackets.classify(). A faster finish
breaks the record and also earns DIAMOND.
- Add V4 Flyway migration and MapRecordEntity for the map_records table
- Add MapRecordRepository (getRecordTime / saveOrUpdateRecord UPSERT)
- Expose MapRecordRepository through DatabaseService / DatabaseServiceImpl
- Introduce MapRecordComponent (ECS component on game entity, holds recordTimeMs)
- Remove referenceDurationMs from MapDefinition; update BracketConfigComponent
to hold only brackets (reference now comes from MapRecordComponent)
- Rewrite CompletionDetectionSystem with optional MapRecordRepository injection:
sets/updates MapRecordComponent on game entity and fires async DB UPSERT
- GameOrchestrator.loadNextMap() seeds MapRecordComponent from DB async;
passes MapRecordRepository to CompletionDetectionSystem
- ScoreDisplaySystem.computePace() reads MapRecordComponent for the pace
projection; returns DIAMOND when no record exists yet
- Update ScoringServiceTest to seed MapRecordComponent instead of using
the removed BracketConfigComponent reference field
* fix(server): resolve two compile errors blocking CI
- GameOrchestrator: remove duplicate local 'cupName' declaration inside
loadNextMap() lambda (variable already declared at top of block)
- ElytraPhysicsSystem: replace player.isGliding() (not available in
Minestom) with player.isOnGround() as the landing detection proxy;
when the server confirms ground contact, flight.setFlying(false) is set
so LandingResetSystem can detect the flying→landed transition
1 parent 7da668b commit bdf3a24
41 files changed
Lines changed: 1652 additions & 364 deletions
File tree
- server/src
- main
- java/net/elytrarace/server
- cup
- ecs
- component
- system
- game
- persistence
- phase
- scoring
- resources
- test/java/net/elytrarace/server
- game
- perf
- phase
- scoring
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | | - | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 70 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| 29 | + | |
| 30 | + | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| |||
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
34 | | - | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | | - | |
37 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
38 | 47 | | |
39 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
40 | 51 | | |
41 | 52 | | |
42 | 53 | | |
43 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
44 | 75 | | |
45 | 76 | | |
46 | 77 | | |
47 | 78 | | |
48 | 79 | | |
49 | | - | |
| 80 | + | |
50 | 81 | | |
51 | 82 | | |
52 | 83 | | |
| |||
109 | 140 | | |
110 | 141 | | |
111 | 142 | | |
112 | | - | |
| 143 | + | |
113 | 144 | | |
114 | | - | |
| 145 | + | |
| 146 | + | |
115 | 147 | | |
116 | | - | |
| 148 | + | |
117 | 149 | | |
118 | 150 | | |
119 | | - | |
| 151 | + | |
| 152 | + | |
120 | 153 | | |
121 | 154 | | |
122 | 155 | | |
123 | 156 | | |
124 | 157 | | |
125 | 158 | | |
126 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
127 | 165 | | |
128 | 166 | | |
129 | 167 | | |
130 | 168 | | |
131 | 169 | | |
132 | 170 | | |
133 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
134 | 194 | | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 59 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
7 | 21 | | |
8 | 22 | | |
9 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
10 | 27 | | |
11 | 28 | | |
| 29 | + | |
| 30 | + | |
12 | 31 | | |
13 | 32 | | |
14 | 33 | | |
| |||
33 | 52 | | |
34 | 53 | | |
35 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
36 | 90 | | |
37 | | - | |
| 91 | + | |
| 92 | + | |
38 | 93 | | |
39 | 94 | | |
40 | 95 | | |
41 | 96 | | |
| 97 | + | |
| 98 | + | |
42 | 99 | | |
43 | 100 | | |
0 commit comments