feat(dungeons): instanced underworld dungeon portal and keystone attunement engine - #201
Conversation
…attunement engine
| if (action === "LOCK_CHAMBER") { | ||
| instance.isBossChamberLocked = true; | ||
| return { success: true, instanceCompleted: false }; | ||
| } | ||
|
|
||
| if (action === "UNLOCK_CHAMBER") { | ||
| instance.isBossChamberLocked = false; | ||
| return { success: true, instanceCompleted: false }; | ||
| } | ||
|
|
||
| if (action === "DEFEAT_BOSS") { | ||
| instance.defeatedBosses = Math.min(instance.totalBosses, instance.defeatedBosses + 1); | ||
| instance.isBossChamberLocked = false; | ||
|
|
||
| if (instance.defeatedBosses >= instance.totalBosses) { |
There was a problem hiding this comment.
⚠️ Bug: Boss chamber lockout is never enforced on DEFEAT_BOSS
LOCK_CHAMBER sets isBossChamberLocked = true, but DEFEAT_BOSS never checks that flag and immediately resets it to false, so a locked chamber does nothing to block boss defeats. The advertised 'boss chamber lockout' feature is effectively decorative. Guard DEFEAT_BOSS by returning a failure when instance.isBossChamberLocked is true.
Reject boss defeats while the chamber is locked.:
if (action === "DEFEAT_BOSS") {
if (instance.isBossChamberLocked) {
return { success: false, instanceCompleted: false, reason: "Boss chamber is locked." };
}
instance.defeatedBosses = Math.min(instance.totalBosses, instance.defeatedBosses + 1);
instance.isBossChamberLocked = false;
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
| const allMembers = [leader, ...party.filter((p) => p.playerId !== leader.playerId)]; | ||
| if (allMembers.length > dungeon.maxPartySize) { | ||
| return { success: false, reason: `Party exceeds maximum capacity of ${dungeon.maxPartySize} players.` }; | ||
| } |
There was a problem hiding this comment.
💡 Edge Case: Duplicate party members are not deduplicated
openPortal only filters the leader out of the party; duplicate entries with the same playerId among the remaining party members pass through unchanged, inflating partyMembers and the effective party count (and potentially bypassing the maxPartySize check for real distinct players). Deduplicate by playerId before the capacity check.
Deduplicate all members (including leader) by playerId.:
const seen = new Set<string>();
const allMembers = [leader, ...party].filter((p) => {
if (seen.has(p.playerId)) return false;
seen.add(p.playerId);
return true;
});
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
|
|
||
| const durationMs = dungeon.baseDurationMinutes * 60 * 1000; | ||
| const instance: ActiveDungeonInstance = { | ||
| instanceId: `inst_${keystone.dungeonId}_${currentEpochMs}`, |
There was a problem hiding this comment.
💡 Bug: instanceId can collide for portals opened in the same ms
instanceId is built only from keystone.dungeonId and currentEpochMs, so two portals for the same dungeon opened in the same millisecond (or with the same caller-supplied timestamp) generate identical ids, which can corrupt downstream tracking keyed by instance id. Append a random/UUID suffix or a monotonic counter to guarantee uniqueness.
Add a random suffix so concurrent opens don't collide.:
instanceId: `inst_${keystone.dungeonId}_${currentEpochMs}_${Math.random().toString(36).slice(2, 8)}`,
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review
|
| Auto-apply | Compact |
|
|
Important
Your trial ends in 5 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more.
Was this helpful? React with 👍 / 👎 | Gitar
Summary
Implements an instanced underworld dungeon portal and keystone attunement engine for OpenAO MMORPG.
Features