Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| abdf4cc654 | |||
| 5449276521 | |||
| 787e2bbae9 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "com.warren.iwanttoheal"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 72
|
||||
versionName "1.0.53"
|
||||
versionCode 75
|
||||
versionName "1.0.56"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
+72
-23
@@ -2307,7 +2307,10 @@ function completeRoguelike(database, characterId, accountId, runMetrics) {
|
||||
const bossesCleared = Number(runMetrics?.bossesCleared ?? Math.floor(encountersCleared / 3))
|
||||
const experienceMode = runMetrics?.experienceMode === 'pvp-boss-quarter-level'
|
||||
? 'pvp-boss-quarter-level'
|
||||
: 'default'
|
||||
: runMetrics?.experienceMode === 'pvp-fight-twelfth-level'
|
||||
? 'pvp-fight-twelfth-level'
|
||||
: 'default'
|
||||
const fightsCleared = Number(runMetrics?.fightsCleared ?? encountersCleared)
|
||||
const resourceSpent = Number(runMetrics?.resourceSpent)
|
||||
const durationSeconds = Number(runMetrics?.durationSeconds)
|
||||
if (!Number.isInteger(dungeonId) || dungeonId < 1) {
|
||||
@@ -2322,6 +2325,9 @@ function completeRoguelike(database, characterId, accountId, runMetrics) {
|
||||
if (!Number.isInteger(bossesCleared) || bossesCleared < 0 || bossesCleared > 100000) {
|
||||
throw new Error('The roguelike boss total is invalid.')
|
||||
}
|
||||
if (!Number.isInteger(fightsCleared) || fightsCleared < 0 || fightsCleared > 100000) {
|
||||
throw new Error('The roguelike fight total is invalid.')
|
||||
}
|
||||
if (!Number.isInteger(resourceSpent) || resourceSpent < 0 || resourceSpent > 100000) {
|
||||
throw new Error('The run resource total is invalid.')
|
||||
}
|
||||
@@ -2374,14 +2380,15 @@ function completeRoguelike(database, characterId, accountId, runMetrics) {
|
||||
`).get(maxLevel).experienceRequired
|
||||
let newExperience = character.experience
|
||||
let newLevel = character.level
|
||||
if (experienceMode === 'pvp-boss-quarter-level') {
|
||||
if (experienceMode === 'pvp-boss-quarter-level' || experienceMode === 'pvp-fight-twelfth-level') {
|
||||
const catchUpTargetLevel = database.prepare(`
|
||||
SELECT COALESCE(MAX(level), 0) AS level
|
||||
FROM characters
|
||||
WHERE account_id = ?
|
||||
AND id != ?
|
||||
`).get(accountId, characterId).level
|
||||
for (let bossIndex = 0; bossIndex < bossesCleared && newExperience < maxExperience; bossIndex += 1) {
|
||||
const rewardUnits = experienceMode === 'pvp-boss-quarter-level' ? bossesCleared : fightsCleared
|
||||
for (let rewardIndex = 0; rewardIndex < rewardUnits && newExperience < maxExperience; rewardIndex += 1) {
|
||||
const currentLevelFloor = database.prepare(`
|
||||
SELECT experience_required AS experienceRequired
|
||||
FROM level_progression
|
||||
@@ -2395,7 +2402,9 @@ function completeRoguelike(database, characterId, accountId, runMetrics) {
|
||||
WHERE level = ?
|
||||
`).get(newLevel + 1).experienceRequired
|
||||
const levelBand = Math.max(1, nextLevelExperience - currentLevelFloor)
|
||||
const rewardRate = catchUpTargetLevel > newLevel ? 0.5 : 0.25
|
||||
const rewardRate = experienceMode === 'pvp-boss-quarter-level'
|
||||
? (catchUpTargetLevel > newLevel ? 0.5 : 0.25)
|
||||
: (catchUpTargetLevel > newLevel ? 1 / 6 : 1 / 12)
|
||||
newExperience = Math.min(maxExperience, newExperience + Math.round(levelBand * rewardRate))
|
||||
newLevel = database.prepare(`
|
||||
SELECT MAX(level) AS level
|
||||
@@ -2589,10 +2598,30 @@ function pvpSnapshot(match) {
|
||||
statuses: match.statuses,
|
||||
progress: match.progress,
|
||||
upgradeChoices: match.upgradeChoices,
|
||||
rematchRequests: match.rematchRequests,
|
||||
updatedAt: match.updatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
function createPvpMatch(contentType, startStage, players, now = Date.now()) {
|
||||
const matchId = randomBytes(12).toString('base64url')
|
||||
const match = {
|
||||
id: matchId,
|
||||
contentType,
|
||||
startStage,
|
||||
createdAt: now,
|
||||
players,
|
||||
states: {},
|
||||
statuses: {},
|
||||
progress: {},
|
||||
upgradeChoices: {},
|
||||
rematchRequests: {},
|
||||
updatedAt: now,
|
||||
}
|
||||
pvpMatches.set(matchId, match)
|
||||
return match
|
||||
}
|
||||
|
||||
function joinPvpQueue(session, payload) {
|
||||
const now = Date.now()
|
||||
cleanupPvpMemory(now)
|
||||
@@ -2622,24 +2651,11 @@ function joinPvpQueue(session, payload) {
|
||||
.sort((left, right) => left.createdAt - right.createdAt)[0]
|
||||
const player = pvpPlayerInfo(session)
|
||||
if (opponent) {
|
||||
const matchId = randomBytes(12).toString('base64url')
|
||||
const match = {
|
||||
id: matchId,
|
||||
contentType,
|
||||
startStage,
|
||||
createdAt: now,
|
||||
players: {
|
||||
a: { side: 'a', ...opponent.player },
|
||||
b: { side: 'b', ...player },
|
||||
},
|
||||
states: {},
|
||||
statuses: {},
|
||||
progress: {},
|
||||
upgradeChoices: {},
|
||||
updatedAt: now,
|
||||
}
|
||||
pvpMatches.set(matchId, match)
|
||||
opponent.matchId = matchId
|
||||
const match = createPvpMatch(contentType, startStage, {
|
||||
a: { side: 'a', ...opponent.player },
|
||||
b: { side: 'b', ...player },
|
||||
}, now)
|
||||
opponent.matchId = match.id
|
||||
opponent.updatedAt = now
|
||||
const ticketId = randomBytes(12).toString('base64url')
|
||||
pvpQueue.set(ticketId, {
|
||||
@@ -2649,7 +2665,7 @@ function joinPvpQueue(session, payload) {
|
||||
contentType,
|
||||
startStage,
|
||||
player,
|
||||
matchId,
|
||||
matchId: match.id,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
})
|
||||
@@ -2751,6 +2767,33 @@ function submitPvpUpgradeChoice(session, matchId, payload) {
|
||||
return pvpSnapshot(match)
|
||||
}
|
||||
|
||||
function requestPvpRematch(session, matchId) {
|
||||
const { match, side } = requirePvpMatchForSession(session, matchId)
|
||||
if (match.nextMatchId) {
|
||||
const nextMatch = pvpMatches.get(match.nextMatchId)
|
||||
if (nextMatch) return { status: 'matched', side, match: pvpSnapshot(nextMatch) }
|
||||
}
|
||||
match.rematchRequests = match.rematchRequests ?? {}
|
||||
match.rematchRequests[side] = true
|
||||
match.updatedAt = Date.now()
|
||||
const opponentSide = side === 'a' ? 'b' : 'a'
|
||||
if (!match.rematchRequests[opponentSide]) {
|
||||
return { status: 'waiting', match: pvpSnapshot(match), side }
|
||||
}
|
||||
const nextMatch = createPvpMatch(
|
||||
match.contentType,
|
||||
match.startStage,
|
||||
{
|
||||
a: match.players.a,
|
||||
b: match.players.b,
|
||||
},
|
||||
Date.now(),
|
||||
)
|
||||
match.nextMatchId = nextMatch.id
|
||||
match.updatedAt = Date.now()
|
||||
return { status: 'matched', side, match: pvpSnapshot(nextMatch) }
|
||||
}
|
||||
|
||||
export function gameApiPlugin() {
|
||||
return {
|
||||
name: 'ashen-halls-game-api',
|
||||
@@ -2971,6 +3014,12 @@ export async function handleApiRequest(request, response, next) {
|
||||
return
|
||||
}
|
||||
|
||||
const pvpRematch = request.url.match(/^\/api\/pvp\/matches\/([A-Za-z0-9_-]+)\/rematch$/)
|
||||
if (pvpRematch && request.method === 'POST') {
|
||||
sendJson(response, 200, requestPvpRematch(session, pvpRematch[1]))
|
||||
return
|
||||
}
|
||||
|
||||
const pvpMatch = request.url.match(/^\/api\/pvp\/matches\/([A-Za-z0-9_-]+)$/)
|
||||
if (pvpMatch && request.method === 'GET') {
|
||||
sendJson(response, 200, pvpSnapshot(requirePvpMatchForSession(session, pvpMatch[1]).match))
|
||||
|
||||
+96
-25
@@ -6087,27 +6087,17 @@ h2 {
|
||||
.pvp-board {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(210px, 0.68fr) minmax(0, 1fr);
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.pvp-side,
|
||||
.pvp-middle-panel {
|
||||
.pvp-side {
|
||||
gap: 8px;
|
||||
min-height: 0;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.pvp-vertical-spell-bar,
|
||||
.pvp-vertical-spell-bar.six-slots {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.pvp-vertical-spell-bar .spell {
|
||||
min-height: 58px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.pvp-screen-tools {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
@@ -6118,18 +6108,41 @@ h2 {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pvp-resource-wrap {
|
||||
color: #82bfff;
|
||||
min-width: 150px;
|
||||
text-align: right;
|
||||
width: min(170px, 100%);
|
||||
.pvp-side-bars {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
min-width: min(320px, 45%);
|
||||
width: min(360px, 48%);
|
||||
}
|
||||
|
||||
.pvp-clear-wrap,
|
||||
.pvp-resource-wrap {
|
||||
color: var(--muted);
|
||||
font-family: 'Press Start 2P', monospace;
|
||||
font-size: 7px;
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pvp-clear-wrap > span,
|
||||
.pvp-resource-wrap > span {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.pvp-clear-wrap .bar,
|
||||
.pvp-resource-wrap .bar {
|
||||
height: 13px;
|
||||
}
|
||||
|
||||
.pvp-clear-wrap {
|
||||
color: #ff8d9a;
|
||||
}
|
||||
|
||||
.pvp-resource-wrap {
|
||||
color: #82bfff;
|
||||
}
|
||||
|
||||
.pvp-side .party-member,
|
||||
.pvp-side .party-member > div,
|
||||
.pvp-side .party-member > small {
|
||||
@@ -6147,7 +6160,7 @@ h2 {
|
||||
}
|
||||
|
||||
.pvp-side .pvp-party-grid.raid .party-member {
|
||||
min-height: 62px;
|
||||
min-height: 96px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
@@ -6184,6 +6197,29 @@ h2 {
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.pvp-side .member-health {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pvp-side .member-health .health-text {
|
||||
align-items: center;
|
||||
color: #fff3c7;
|
||||
display: flex;
|
||||
font-family: 'Press Start 2P', monospace;
|
||||
font-size: 7px;
|
||||
font-style: normal;
|
||||
inset: 0;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
text-shadow: 1px 1px 0 #08090c, -1px -1px 0 #08090c;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.pvp-side .party-member .member-header small {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pvp-side .member-effects {
|
||||
margin-top: 4px;
|
||||
}
|
||||
@@ -6202,22 +6238,57 @@ h2 {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pvp-middle-panel .encounter-header h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.pvp-middle-panel .encounter-header small,
|
||||
.pvp-enemy-race small {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.pvp-middle-panel .roguelike-upgrade-list,
|
||||
.pvp-side .roguelike-upgrade-list {
|
||||
font-size: 12px;
|
||||
line-height: 1.1;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.pvp-bottom-spell-bar {
|
||||
background: var(--panel);
|
||||
border: 3px solid #0c0d11;
|
||||
box-shadow: 4px 4px 0 #08090c;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
grid-column: 1 / -1;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
outline: 2px solid var(--edge);
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.pvp-bottom-spell-bar .spell {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
||||
min-height: 58px;
|
||||
padding: 7px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.pvp-bottom-spell-bar .spell-icon {
|
||||
height: 34px;
|
||||
margin: 0;
|
||||
width: 34px;
|
||||
}
|
||||
|
||||
.pvp-bottom-spell-bar .spell strong {
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pvp-bottom-spell-bar .spell small {
|
||||
font-size: 13px;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pvp-choice-columns {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
joinPvpQueue,
|
||||
loadPvpMatch,
|
||||
publishPvpMatchState,
|
||||
requestPvpRematch,
|
||||
randomCpuDifficulty,
|
||||
recordCpuPvpLeaderboard,
|
||||
recordPvpRoguelikeCheckpoint,
|
||||
@@ -35,6 +36,7 @@ import {
|
||||
type CpuDifficulty,
|
||||
type PvpMatchSnapshot,
|
||||
type PvpMatchSide,
|
||||
type PvpRematchResponse,
|
||||
type PvpContentType,
|
||||
type PvpUpgradeChoicePayload,
|
||||
} from '../pvpRoguelike'
|
||||
@@ -55,24 +57,17 @@ type PvpEncounter = DungeonEncounter & {
|
||||
}
|
||||
|
||||
type SlotKey = '1' | '2' | '3' | '4' | '5' | '6'
|
||||
type DraftSlotKey = Exclude<SlotKey, '6'>
|
||||
type AbilityLabelMode = 'ability' | 'slot'
|
||||
|
||||
type SelfBuffId =
|
||||
| `slot${SlotKey}-extra-target`
|
||||
| `slot${SlotKey}-cost-down`
|
||||
| `slot${SlotKey}-cooldown-down`
|
||||
| 'fifth-cast-free'
|
||||
| 'group-heal-boost'
|
||||
| 'shield-boost'
|
||||
| `slot${DraftSlotKey}-extra-target`
|
||||
| `slot${DraftSlotKey}-cost-down`
|
||||
| `slot${DraftSlotKey}-cooldown-down`
|
||||
|
||||
type OpponentDebuffId =
|
||||
| `opp-slot${SlotKey}-cost-up`
|
||||
| `opp-slot${SlotKey}-cooldown-up`
|
||||
| 'opp-takes-more-damage'
|
||||
| 'opp-healing-reduced'
|
||||
| 'opp-resource-regen-down'
|
||||
| 'opp-cleanse-cooldown-up'
|
||||
| 'opp-purge-random-buff'
|
||||
| `opp-slot${DraftSlotKey}-cost-up`
|
||||
| `opp-slot${DraftSlotKey}-cooldown-up`
|
||||
|
||||
type Choice<T extends string> = {
|
||||
id: T
|
||||
@@ -182,7 +177,7 @@ function slotLabel(slot: SlotKey, spells: Spell[], labelMode: AbilityLabelMode)
|
||||
}
|
||||
|
||||
function buildSelfBuffChoices(spells: Spell[], labelMode: AbilityLabelMode): Array<Choice<SelfBuffId>> {
|
||||
const slotChoices = (['1', '2', '3', '4', '5', '6'] as SlotKey[]).flatMap((slot) => {
|
||||
return (['1', '2', '3', '4', '5'] as DraftSlotKey[]).flatMap((slot) => {
|
||||
const label = slotLabel(slot, spells, labelMode)
|
||||
return [
|
||||
{
|
||||
@@ -202,16 +197,10 @@ function buildSelfBuffChoices(spells: Spell[], labelMode: AbilityLabelMode): Arr
|
||||
},
|
||||
]
|
||||
})
|
||||
return [
|
||||
...slotChoices,
|
||||
{ id: 'fifth-cast-free', name: 'Stored Momentum', description: 'After 5 casts, the next cast is free.' },
|
||||
{ id: 'group-heal-boost', name: 'Wide Radiance', description: 'Party healing is 25% stronger.' },
|
||||
{ id: 'shield-boost', name: 'Dense Shields', description: 'Shield absorbs are 25% stronger.' },
|
||||
]
|
||||
}
|
||||
|
||||
function buildOpponentDebuffChoices(spells: Spell[], labelMode: AbilityLabelMode): Array<Choice<OpponentDebuffId>> {
|
||||
const slotChoices = (['1', '2', '3', '4', '5', '6'] as SlotKey[]).flatMap((slot) => {
|
||||
return (['1', '2', '3', '4', '5'] as DraftSlotKey[]).flatMap((slot) => {
|
||||
const label = slotLabel(slot, spells, labelMode)
|
||||
return [
|
||||
{
|
||||
@@ -226,14 +215,6 @@ function buildOpponentDebuffChoices(spells: Spell[], labelMode: AbilityLabelMode
|
||||
},
|
||||
]
|
||||
})
|
||||
return [
|
||||
...slotChoices,
|
||||
{ id: 'opp-takes-more-damage', name: 'Expose Weakness', description: 'Opponent takes 10% more damage.' },
|
||||
{ id: 'opp-healing-reduced', name: 'Blunted Recovery', description: 'Opponent healing is 15% weaker.' },
|
||||
{ id: 'opp-resource-regen-down', name: 'Mana Squeeze', description: 'Opponent resource regeneration is reduced by 25%.' },
|
||||
{ id: 'opp-cleanse-cooldown-up', name: 'Lingering Toxins', description: 'Opponent cleanse cooldown is 25% longer.' },
|
||||
{ id: 'opp-purge-random-buff', name: 'Strip Momentum', description: 'Remove 1 random buff from the opponent immediately.' },
|
||||
]
|
||||
}
|
||||
|
||||
function toCombatSpell(ability: Ability, key: string): Spell {
|
||||
@@ -261,17 +242,10 @@ function effectiveMaxHealth(member: PartyMember) {
|
||||
return Math.max(1, Math.round(member.maxHealth * (member.maxHealthPenaltyTicks && member.maxHealthPenaltyTicks > 0 ? 0.75 : 1)))
|
||||
}
|
||||
|
||||
function incomingDamageMultiplier(debuffs: OpponentDebuffId[]) {
|
||||
return 1.1 ** buffStacks(debuffs, 'opp-takes-more-damage')
|
||||
}
|
||||
|
||||
function outgoingHealMultiplier(debuffs: OpponentDebuffId[]) {
|
||||
return 0.85 ** buffStacks(debuffs, 'opp-healing-reduced')
|
||||
}
|
||||
|
||||
function healAmount(member: PartyMember, amount: number, debuffs: OpponentDebuffId[], multiplier = 1) {
|
||||
const healingReduction = member.healingReductionTicks && member.healingReductionTicks > 0 ? 0.75 : 1
|
||||
return Math.round(amount * healingReduction * outgoingHealMultiplier(debuffs) * multiplier)
|
||||
void debuffs
|
||||
return Math.round(amount * healingReduction * multiplier)
|
||||
}
|
||||
|
||||
function healMember(member: PartyMember, amount: number, debuffs: OpponentDebuffId[], multiplier = 1) {
|
||||
@@ -282,8 +256,7 @@ function cooldownMultiplier(spell: Spell, buffs: SelfBuffId[], debuffs: Opponent
|
||||
const slot = spell.key as SlotKey
|
||||
const downStacks = buffStacks(buffs, `slot${slot}-cooldown-down` as SelfBuffId)
|
||||
const upStacks = buffStacks(debuffs, `opp-slot${slot}-cooldown-up` as OpponentDebuffId)
|
||||
const cleansePenalty = spell.kind === 'cleanse' ? buffStacks(debuffs, 'opp-cleanse-cooldown-up') : 0
|
||||
return (0.75 ** downStacks) * (1.25 ** (upStacks + cleansePenalty))
|
||||
return (0.75 ** downStacks) * (1.25 ** upStacks)
|
||||
}
|
||||
|
||||
function spellResourceCost(spell: Spell, buffs: SelfBuffId[], debuffs: OpponentDebuffId[], freeCastReady: boolean) {
|
||||
@@ -291,7 +264,8 @@ function spellResourceCost(spell: Spell, buffs: SelfBuffId[], debuffs: OpponentD
|
||||
const downStacks = buffStacks(buffs, `slot${slot}-cost-down` as SelfBuffId)
|
||||
const upStacks = buffStacks(debuffs, `opp-slot${slot}-cost-up` as OpponentDebuffId)
|
||||
const adjustedCost = Math.ceil(spell.cost * (0.75 ** downStacks) * (1.25 ** upStacks))
|
||||
return freeCastReady && buffStacks(buffs, 'fifth-cast-free') > 0 ? 0 : adjustedCost
|
||||
void freeCastReady
|
||||
return adjustedCost
|
||||
}
|
||||
|
||||
function buildEncounterSegment(pool: DungeonEncounter[], stage: number, kind: PvpContentType): PvpEncounter[] {
|
||||
@@ -349,9 +323,6 @@ function starterSide(partyTemplate: PartyMember[], maxResource: number): SideSta
|
||||
}
|
||||
|
||||
function scoreSelfBuff(buff: Choice<SelfBuffId>, spells: Spell[]) {
|
||||
if (buff.id === 'fifth-cast-free') return 8
|
||||
if (buff.id === 'group-heal-boost') return 8
|
||||
if (buff.id === 'shield-boost') return 6
|
||||
const slot = buff.id.match(/slot([1-6])/i)?.[1] as SlotKey | undefined
|
||||
const spell = spells.find((candidate) => candidate.key === slot)
|
||||
if (!spell) return 5
|
||||
@@ -365,11 +336,7 @@ function scoreSelfBuff(buff: Choice<SelfBuffId>, spells: Spell[]) {
|
||||
}
|
||||
|
||||
function scoreDebuff(debuff: Choice<OpponentDebuffId>, opponentBuffCount: number) {
|
||||
if (debuff.id === 'opp-takes-more-damage') return 9
|
||||
if (debuff.id === 'opp-healing-reduced') return 8
|
||||
if (debuff.id === 'opp-resource-regen-down') return 7
|
||||
if (debuff.id === 'opp-cleanse-cooldown-up') return 5
|
||||
if (debuff.id === 'opp-purge-random-buff') return opponentBuffCount > 0 ? 8 : 2
|
||||
void opponentBuffCount
|
||||
if (debuff.id.endsWith('cost-up')) return 7
|
||||
return 6
|
||||
}
|
||||
@@ -386,13 +353,6 @@ function selectCpuChoice<T extends string>(
|
||||
return ranked[0]
|
||||
}
|
||||
|
||||
function removeRandomBuff(side: SideState) {
|
||||
if (side.buffs.length === 0) return side
|
||||
const nextBuffs = [...side.buffs]
|
||||
nextBuffs.splice(Math.floor(Math.random() * nextBuffs.length), 1)
|
||||
return { ...side, buffs: nextBuffs }
|
||||
}
|
||||
|
||||
function createLogEntry(nextLogId: { current: number }, text: string, tone: CombatLogEntry['tone']) {
|
||||
return { id: nextLogId.current++, text, tone }
|
||||
}
|
||||
@@ -469,6 +429,8 @@ export function PvPRoguelikeScreen({
|
||||
const [cpuDifficulty, setCpuDifficulty] = useState<CpuDifficulty | null>(null)
|
||||
const [liveMatch, setLiveMatch] = useState<LivePvpMatch | null>(null)
|
||||
const [liveUpgradePending, setLiveUpgradePending] = useState(false)
|
||||
const [rematchRequested, setRematchRequested] = useState(false)
|
||||
const [rematchMessage, setRematchMessage] = useState('')
|
||||
const [queueMessage, setQueueMessage] = useState('')
|
||||
const [log, setLog] = useState<CombatLogEntry[]>([{ id: 1, text: 'Queueing opponent...', tone: 'system' }])
|
||||
const [reward, setReward] = useState<DungeonReward | null>(null)
|
||||
@@ -567,10 +529,11 @@ export function PvPRoguelikeScreen({
|
||||
encounterPoolRef.current = encounterPool
|
||||
}, [encounterPool])
|
||||
|
||||
const awardBossReward = useCallback((encounterIndexValue: number) => {
|
||||
const awardEncounterReward = useCallback((encounterIndexValue: number) => {
|
||||
if (bossRewardClaimedRef.current.has(encounterIndexValue)) return
|
||||
bossRewardClaimedRef.current.add(encounterIndexValue)
|
||||
const rewardEncounter = encounters[encounterIndexValue]
|
||||
const isBossReward = Boolean(rewardEncounter?.isBoss)
|
||||
completeRoguelike(
|
||||
rewardDungeon.id,
|
||||
rewardDifficulty.id,
|
||||
@@ -578,10 +541,11 @@ export function PvPRoguelikeScreen({
|
||||
0,
|
||||
Math.max(1, Math.round((elapsedTicks * TICK_MS) / 1000)),
|
||||
{
|
||||
bossesCleared: 1,
|
||||
experienceMode: 'pvp-boss-quarter-level',
|
||||
lootSourceEncounterId: rewardEncounter?.sourceEncounterId,
|
||||
roguelikeStage: stage,
|
||||
bossesCleared: isBossReward ? 1 : 0,
|
||||
fightsCleared: 1,
|
||||
experienceMode: isBossReward ? 'pvp-boss-quarter-level' : 'pvp-fight-twelfth-level',
|
||||
lootSourceEncounterId: isBossReward ? rewardEncounter?.sourceEncounterId : undefined,
|
||||
roguelikeStage: isBossReward ? stage : undefined,
|
||||
},
|
||||
)
|
||||
.then((result) => {
|
||||
@@ -590,7 +554,7 @@ export function PvPRoguelikeScreen({
|
||||
const unlockedById = new Map(current.unlockedAbilities.map((ability) => [ability.id, ability]))
|
||||
result.unlockedAbilities.forEach((ability) => unlockedById.set(ability.id, ability))
|
||||
return {
|
||||
bossesKilled: current.bossesKilled + 1,
|
||||
bossesKilled: current.bossesKilled + (isBossReward ? 1 : 0),
|
||||
experienceGained: current.experienceGained + result.experienceGained,
|
||||
previousLevel: current.previousLevel ?? result.previousLevel,
|
||||
newLevel: result.newLevel,
|
||||
@@ -601,6 +565,9 @@ export function PvPRoguelikeScreen({
|
||||
}
|
||||
})
|
||||
onProfileUpdated(result.profile)
|
||||
if (!isBossReward && result.experienceGained > 0) {
|
||||
addLog(`+${result.experienceGained} XP awarded.`, 'loot')
|
||||
}
|
||||
if (result.bonusItem) {
|
||||
addLog(
|
||||
`${result.bonusItem.name} x${result.bonusItem.quantity} awarded.`,
|
||||
@@ -635,6 +602,80 @@ export function PvPRoguelikeScreen({
|
||||
: null)
|
||||
}, [opponentDebuffChoicesCatalog, selfBuffChoicesCatalog])
|
||||
|
||||
const startLiveMatch = useCallback((
|
||||
match: PvpMatchSnapshot<SideState>,
|
||||
side: PvpMatchSide,
|
||||
message?: string,
|
||||
) => {
|
||||
const matchStartStage = match.startStage
|
||||
const firstSegment = buildEncounterSegment(encounterPoolRef.current, matchStartStage, contentType)
|
||||
const firstEncounter = firstSegment[0]
|
||||
const basePlayer = starterSide(partyTemplate, maxResource)
|
||||
const opponentSide: PvpMatchSide = side === 'a' ? 'b' : 'a'
|
||||
const opponent = match.players[opponentSide]
|
||||
const baseOpponent = starterSide(
|
||||
cpuPartyTemplate.map((member) => ({
|
||||
...member,
|
||||
name: member.id === 'mira' ? opponent.characterName : member.name,
|
||||
})),
|
||||
maxResource,
|
||||
)
|
||||
basePlayer.enemyHealth = firstEncounter.maxHealth
|
||||
baseOpponent.enemyHealth = firstEncounter.maxHealth
|
||||
const nextLiveMatch: LivePvpMatch = {
|
||||
id: match.id,
|
||||
side,
|
||||
opponentSide,
|
||||
opponentName: opponent.characterName,
|
||||
opponentClassName: opponent.className,
|
||||
}
|
||||
playerRef.current = basePlayer
|
||||
cpuRef.current = baseOpponent
|
||||
liveMatchRef.current = nextLiveMatch
|
||||
nextLogId.current = 2
|
||||
playerClearedEncounterRef.current = -1
|
||||
queuedMatchRef.current = true
|
||||
bossRewardClaimedRef.current = new Set()
|
||||
setEncounters(firstSegment)
|
||||
setEncounterIndex(0)
|
||||
setCheckpointStage(matchStartStage)
|
||||
setStartStage(matchStartStage)
|
||||
setStage(matchStartStage)
|
||||
setElapsedTicks(0)
|
||||
setStatus('playing')
|
||||
setPlayerSide(basePlayer)
|
||||
setCpuSide(baseOpponent)
|
||||
setSelectedTargetId(partyTemplate[0].id)
|
||||
setPlayerBuffChoices([])
|
||||
setPlayerDebuffChoices([])
|
||||
setSelectedBuff(null)
|
||||
setSelectedDebuff(null)
|
||||
setUpgradeTimeLeft(UPGRADE_CHOICE_SECONDS)
|
||||
upgradeChoiceEndsAtRef.current = 0
|
||||
autoSubmittedUpgradeRef.current = false
|
||||
setEncountersCleared(0)
|
||||
setPaused(false)
|
||||
setTargetGroup(0)
|
||||
setReward(null)
|
||||
setRunSummary(createEmptyPvpRunSummary())
|
||||
setRewardError('')
|
||||
setShowEndLog(false)
|
||||
setFloatingTexts([])
|
||||
setCpuDifficulty(null)
|
||||
setLiveMatch(nextLiveMatch)
|
||||
setLiveUpgradePending(false)
|
||||
pendingLiveUpgradeRef.current = null
|
||||
loggedOpponentDoneRef.current = false
|
||||
recordedRunRef.current = false
|
||||
rewardClaimedRef.current = false
|
||||
cpuDefeatedRef.current = false
|
||||
setRematchRequested(false)
|
||||
setRematchMessage('')
|
||||
const logText = message ?? `${opponent.characterName} found. Stage ${matchStartStage} begins.`
|
||||
setQueueMessage(logText)
|
||||
setLog([{ id: 1, text: logText, tone: 'system' }])
|
||||
}, [contentType, cpuPartyTemplate, maxResource, partyTemplate, setSelectedTargetId])
|
||||
|
||||
const startMatch = useCallback((nextStartStage?: number) => {
|
||||
const matchStartStage = nextStartStage ?? loadPvpRoguelikeCheckpoint(profile.character.id, contentType)
|
||||
const firstSegment = buildEncounterSegment(encounterPoolRef.current, matchStartStage, contentType)
|
||||
@@ -680,6 +721,8 @@ export function PvPRoguelikeScreen({
|
||||
setLiveUpgradePending(false)
|
||||
pendingLiveUpgradeRef.current = null
|
||||
loggedOpponentDoneRef.current = false
|
||||
setRematchRequested(false)
|
||||
setRematchMessage('')
|
||||
recordedRunRef.current = false
|
||||
rewardClaimedRef.current = false
|
||||
cpuDefeatedRef.current = false
|
||||
@@ -709,29 +752,7 @@ export function PvPRoguelikeScreen({
|
||||
if (cancelled) return
|
||||
const opponentSide: PvpMatchSide = side === 'a' ? 'b' : 'a'
|
||||
const opponent = match.players[opponentSide]
|
||||
const nextLiveMatch = {
|
||||
id: match.id,
|
||||
side,
|
||||
opponentSide,
|
||||
opponentName: opponent.characterName,
|
||||
opponentClassName: opponent.className,
|
||||
}
|
||||
liveMatchRef.current = nextLiveMatch
|
||||
setLiveMatch(nextLiveMatch)
|
||||
setCpuDifficulty(null)
|
||||
const opponentBase = starterSide(
|
||||
cpuPartyTemplate.map((member) => ({
|
||||
...member,
|
||||
name: member.id === 'mira' ? opponent.characterName : member.name,
|
||||
})),
|
||||
maxResource,
|
||||
)
|
||||
opponentBase.enemyHealth = firstEncounter.maxHealth
|
||||
cpuRef.current = opponentBase
|
||||
setCpuSide(opponentBase)
|
||||
setQueueMessage(`${opponent.characterName} found. Match begins.`)
|
||||
setLog([{ id: 1, text: `${opponent.characterName} found. Stage ${matchStartStage} begins.`, tone: 'system' }])
|
||||
setStatus('playing')
|
||||
startLiveMatch(match, side, `${opponent.characterName} found. Stage ${match.startStage} begins.`)
|
||||
}
|
||||
const fallbackTimer = window.setTimeout(() => {
|
||||
if (cancelled || liveMatchRef.current) return
|
||||
@@ -781,7 +802,7 @@ export function PvPRoguelikeScreen({
|
||||
if (pollTimer) window.clearTimeout(pollTimer)
|
||||
if (ticketId && !liveMatchRef.current) cancelPvpQueue(ticketId).catch(() => undefined)
|
||||
}
|
||||
}, [addLog, contentType, cpuPartyTemplate, gameMode, maxResource, partyTemplate, profile.character.id, setSelectedTargetId])
|
||||
}, [addLog, contentType, cpuPartyTemplate, gameMode, maxResource, partyTemplate, profile.character.id, setSelectedTargetId, startLiveMatch])
|
||||
|
||||
useEffect(() => startMatch(), [startMatch])
|
||||
|
||||
@@ -807,10 +828,13 @@ export function PvPRoguelikeScreen({
|
||||
setCpuSide(opponentState)
|
||||
}
|
||||
const opponentStatus = snapshot.statuses[liveMatch.opponentSide]
|
||||
if (opponentStatus === 'lost' && !loggedOpponentDoneRef.current) {
|
||||
const opponentAlive = snapshot.progress[liveMatch.opponentSide]?.alive
|
||||
if ((opponentStatus === 'lost' || opponentAlive === false) && !loggedOpponentDoneRef.current && status !== 'won' && status !== 'lost') {
|
||||
loggedOpponentDoneRef.current = true
|
||||
cpuDefeatedRef.current = true
|
||||
addLog(`${liveMatch.opponentName} fell. Finish the boss for XP.`, 'loot')
|
||||
finishRoguelikeRun()
|
||||
setStatus('won')
|
||||
addLog(`${liveMatch.opponentName} fell. Match complete.`, 'loot')
|
||||
}
|
||||
if (opponentStatus === 'won' && status !== 'won' && status !== 'lost') {
|
||||
finishRoguelikeRun()
|
||||
@@ -888,7 +912,7 @@ export function PvPRoguelikeScreen({
|
||||
if (member.health <= 0) return member
|
||||
if (spell.kind === 'group') {
|
||||
if (!groupTargets.has(member.id)) return member
|
||||
const groupPower = Math.round(spell.power * (1.25 ** buffStacks(buffs, 'group-heal-boost')))
|
||||
const groupPower = spell.power
|
||||
const nextHealth = healMember(member, groupPower, debuffs, healingMultiplier(member))
|
||||
addFloatingHeal(sideName, member.id, Math.max(0, nextHealth - member.health))
|
||||
const nextShield = hasSpellEffect('radiance_applies_shield')
|
||||
@@ -905,7 +929,7 @@ export function PvPRoguelikeScreen({
|
||||
}
|
||||
if (!directTargets.has(member.id) && !hotTargets.has(member.id) && !shieldTargets.has(member.id)) return member
|
||||
if (spell.kind === 'shield') {
|
||||
const shieldPower = Math.round(spell.power * (1.25 ** buffStacks(buffs, 'shield-boost')))
|
||||
const shieldPower = spell.power
|
||||
return {
|
||||
...member,
|
||||
shield: Math.max(member.shield, shieldPower),
|
||||
@@ -939,16 +963,6 @@ export function PvPRoguelikeScreen({
|
||||
hotTicks: hotTargets.has(member.id) ? 5 : member.hotTicks,
|
||||
}
|
||||
})
|
||||
const freeCastStacks = buffStacks(buffs, 'fifth-cast-free')
|
||||
const nextFreeCastReady = freeCastStacks > 0 && current.freeCastReady ? false : current.freeCastReady
|
||||
const nextCastsTowardFree = freeCastStacks > 0
|
||||
? current.freeCastReady
|
||||
? 0
|
||||
: current.castsTowardFree + 1 >= 5
|
||||
? 0
|
||||
: current.castsTowardFree + 1
|
||||
: current.castsTowardFree
|
||||
const gainedFreeCast = freeCastStacks > 0 && !current.freeCastReady && current.castsTowardFree + 1 >= 5
|
||||
const nextCooldowns = {
|
||||
...current.cooldowns,
|
||||
}
|
||||
@@ -961,8 +975,8 @@ export function PvPRoguelikeScreen({
|
||||
party: nextParty,
|
||||
resource: current.resource - effectiveCost,
|
||||
cooldowns: nextCooldowns,
|
||||
castsTowardFree: nextCastsTowardFree,
|
||||
freeCastReady: gainedFreeCast || nextFreeCastReady,
|
||||
castsTowardFree: current.castsTowardFree,
|
||||
freeCastReady: false,
|
||||
}
|
||||
setCurrent(nextState)
|
||||
return true
|
||||
@@ -1073,7 +1087,6 @@ export function PvPRoguelikeScreen({
|
||||
const appliesMaxHealthCut = encounterValue.isBoss && elapsedTicks > 0 && elapsedTicks % 13 === 0 && mechanics.includes('max-health-cut')
|
||||
const appliesHealingReduction = encounterValue.isBoss && elapsedTicks > 0 && elapsedTicks % 9 === 0 && mechanics.includes('healing-reduction')
|
||||
const appliesPoison = encounterValue.isBoss && elapsedTicks > 0 && elapsedTicks % 12 === 0 && mechanics.includes('ramping-poison')
|
||||
const damageMultiplier = incomingDamageMultiplier(side.debuffs)
|
||||
const hasSpellEffect = (effectType: string) => sideName === 'player' && activeSpellEffects.has(effectType)
|
||||
const tankPressure = tankPressureTargets(side.party)
|
||||
const tankPressureIds = new Set(tankPressure.targets.map((member) => member.id))
|
||||
@@ -1089,7 +1102,6 @@ export function PvPRoguelikeScreen({
|
||||
? Math.max(1, (member.poisonStacks ?? 0) + 1)
|
||||
: member.poisonStacks ?? 0
|
||||
if (nextPoisonStacks > 0) damage += 3 + nextPoisonStacks * 3
|
||||
damage = Math.round(damage * damageMultiplier)
|
||||
if (member.shield > 0 && hasSpellEffect('shielded_damage_reduction')) {
|
||||
damage = Math.round(damage * 0.8)
|
||||
}
|
||||
@@ -1128,7 +1140,7 @@ export function PvPRoguelikeScreen({
|
||||
...side,
|
||||
party: nextParty,
|
||||
resource: clamp(
|
||||
side.resource + 2.4 * (0.75 ** buffStacks(side.debuffs, 'opp-resource-regen-down')),
|
||||
side.resource + 2.4,
|
||||
0,
|
||||
maxResource,
|
||||
),
|
||||
@@ -1160,8 +1172,8 @@ export function PvPRoguelikeScreen({
|
||||
if (nextPlayer.enemyHealth <= 0 && playerClearedEncounterRef.current !== encounterIndex) {
|
||||
playerClearedEncounterRef.current = encounterIndex
|
||||
setEncountersCleared((value) => value + 1)
|
||||
awardEncounterReward(encounterIndex)
|
||||
if (encounter.isBoss) {
|
||||
awardBossReward(encounterIndex)
|
||||
const nextCheckpoint = recordPvpRoguelikeCheckpoint(
|
||||
profile.character.id,
|
||||
contentType,
|
||||
@@ -1188,7 +1200,10 @@ export function PvPRoguelikeScreen({
|
||||
}
|
||||
if (!liveMatch && !nextCpuAlive && !cpuDefeatedRef.current) {
|
||||
cpuDefeatedRef.current = true
|
||||
addLog(`CPU ${cpuDifficulty ?? 1} fell. Finish the boss for XP.`, 'loot')
|
||||
finishRoguelikeRun()
|
||||
setStatus('won')
|
||||
addLog(`CPU ${cpuDifficulty ?? 1} fell. Match complete.`, 'loot')
|
||||
return
|
||||
}
|
||||
if (nextPlayer.enemyHealth <= 0) {
|
||||
if (encounter.isBoss && cpuDefeatedRef.current) {
|
||||
@@ -1202,7 +1217,7 @@ export function PvPRoguelikeScreen({
|
||||
}
|
||||
}, TICK_MS / speedMultiplier)
|
||||
return () => window.clearInterval(timer)
|
||||
}, [addLog, advanceSide, awardBossReward, beginUpgradePhase, checkpointStage, contentType, cpuDifficulty, cpuTakeTurn, encounter, encounterIndex, encountersCleared, finishRoguelikeRun, liveMatch, paused, profile.character.id, speedMultiplier, stage, status])
|
||||
}, [addLog, advanceSide, awardEncounterReward, beginUpgradePhase, checkpointStage, contentType, cpuDifficulty, cpuTakeTurn, encounter, encounterIndex, encountersCleared, finishRoguelikeRun, liveMatch, paused, profile.character.id, speedMultiplier, stage, status])
|
||||
|
||||
useEffect(() => {
|
||||
if ((status !== 'won' && status !== 'lost') || recordedRunRef.current || !cpuDifficulty) return
|
||||
@@ -1218,6 +1233,46 @@ export function PvPRoguelikeScreen({
|
||||
})
|
||||
}, [contentType, cpuDifficulty, finalEncountersCleared, profile.character.className, profile.character.name, status])
|
||||
|
||||
const handleRematch = useCallback(() => {
|
||||
if (!liveMatch || rematchRequested) return
|
||||
let cancelled = false
|
||||
let attempts = 0
|
||||
setRematchRequested(true)
|
||||
setRematchMessage(`Waiting for ${liveMatch.opponentName} to rematch...`)
|
||||
const handleResponse = (result: PvpRematchResponse<SideState>) => {
|
||||
if (cancelled) return
|
||||
if (result.status === 'matched' && result.match && result.side) {
|
||||
startLiveMatch(result.match, result.side, `Rematch against ${liveMatch.opponentName} begins.`)
|
||||
return
|
||||
}
|
||||
attempts += 1
|
||||
if (attempts >= 180) {
|
||||
setRematchRequested(false)
|
||||
setRematchMessage('Rematch expired.')
|
||||
return
|
||||
}
|
||||
window.setTimeout(pollRematch, 700)
|
||||
}
|
||||
const pollRematch = () => {
|
||||
requestPvpRematch<SideState>(liveMatch.id)
|
||||
.then(handleResponse)
|
||||
.catch((reason: unknown) => {
|
||||
if (cancelled) return
|
||||
attempts += 1
|
||||
if (attempts >= 10) {
|
||||
setRematchRequested(false)
|
||||
setRematchMessage(reason instanceof Error ? reason.message : 'Unable to request rematch.')
|
||||
return
|
||||
}
|
||||
window.setTimeout(pollRematch, 900)
|
||||
})
|
||||
}
|
||||
pollRematch()
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [liveMatch, rematchRequested, startLiveMatch])
|
||||
|
||||
useEffect(() => {
|
||||
if (status !== 'upgrade-choice') return
|
||||
window.requestAnimationFrame(() => focusFirstControl())
|
||||
@@ -1244,9 +1299,7 @@ export function PvPRoguelikeScreen({
|
||||
...playerRef.current,
|
||||
buffs: [...playerRef.current.buffs, submittedBuff.id],
|
||||
}
|
||||
if (opponentChoice.debuffId === 'opp-purge-random-buff') {
|
||||
nextPlayer = removeRandomBuff(nextPlayer)
|
||||
} else if (opponentDebuffChoicesCatalog.some((choice) => choice.id === opponentChoice.debuffId)) {
|
||||
if (opponentDebuffChoicesCatalog.some((choice) => choice.id === opponentChoice.debuffId)) {
|
||||
nextPlayer = { ...nextPlayer, debuffs: [...nextPlayer.debuffs, opponentChoice.debuffId as OpponentDebuffId] }
|
||||
}
|
||||
|
||||
@@ -1353,17 +1406,9 @@ export function PvPRoguelikeScreen({
|
||||
buffs: [...cpuRef.current.buffs, cpuBuff.id],
|
||||
}
|
||||
|
||||
if (chosenDebuff.id === 'opp-purge-random-buff') {
|
||||
nextCpu = removeRandomBuff(nextCpu)
|
||||
} else {
|
||||
nextCpu = { ...nextCpu, debuffs: [...nextCpu.debuffs, chosenDebuff.id] }
|
||||
}
|
||||
nextCpu = { ...nextCpu, debuffs: [...nextCpu.debuffs, chosenDebuff.id] }
|
||||
|
||||
if (cpuDebuff.id === 'opp-purge-random-buff') {
|
||||
nextPlayer = removeRandomBuff(nextPlayer)
|
||||
} else {
|
||||
nextPlayer = { ...nextPlayer, debuffs: [...nextPlayer.debuffs, cpuDebuff.id] }
|
||||
}
|
||||
nextPlayer = { ...nextPlayer, debuffs: [...nextPlayer.debuffs, cpuDebuff.id] }
|
||||
|
||||
const clearedBoss = encounter.isBoss
|
||||
if (clearedBoss && cpuDefeatedRef.current) {
|
||||
@@ -1618,8 +1663,15 @@ export function PvPRoguelikeScreen({
|
||||
<div>
|
||||
<p className="eyebrow">You</p>
|
||||
<h2>{profile.character.name}</h2>
|
||||
<small>{encounter.enemyName} | Stage {stage}{encounter.isBoss ? ' Boss' : ''}</small>
|
||||
</div>
|
||||
<div className="resource-row pvp-resource-row">
|
||||
<div className="pvp-side-bars">
|
||||
<div className="pvp-clear-wrap">
|
||||
<span>Your clear {Math.max(0, Math.floor(playerSide.enemyHealth))} / {encounter.maxHealth}</span>
|
||||
<div className="bar enemy-health boss-bar">
|
||||
<span style={{ width: `${(playerSide.enemyHealth / encounter.maxHealth) * 100}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="pvp-resource-wrap">
|
||||
<span>{gameClass.resourceName} {Math.floor(playerSide.resource)} / {maxResource}</span>
|
||||
{speedMultiplier === 2 && <strong className="speed-badge">2x speed</strong>}
|
||||
@@ -1643,6 +1695,7 @@ export function PvPRoguelikeScreen({
|
||||
<div className="bar member-health">
|
||||
<span style={{ width: `${(member.health / effectiveMaxHealth(member)) * 100}%` }} />
|
||||
{member.shield > 0 && <i style={{ width: `${(member.shield / effectiveMaxHealth(member)) * 100}%` }} />}
|
||||
<em className="health-text">{Math.floor(member.health)} / {effectiveMaxHealth(member)}</em>
|
||||
</div>
|
||||
<div className="floating-combat-texts" aria-hidden="true">
|
||||
{floatingTexts
|
||||
@@ -1665,69 +1718,20 @@ export function PvPRoguelikeScreen({
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="combat-panel pvp-middle-panel">
|
||||
<div className="encounter-header">
|
||||
<div>
|
||||
<p className="eyebrow">Encounter {encounterIndex + 1}</p>
|
||||
<h2>{encounter.enemyName}</h2>
|
||||
<small>Stage {stage}{encounter.isBoss ? ' Boss' : ''}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div className="pvp-enemy-race">
|
||||
<div>
|
||||
<strong>Your clear</strong>
|
||||
<div className="bar enemy-health boss-bar">
|
||||
<span style={{ width: `${(playerSide.enemyHealth / encounter.maxHealth) * 100}%` }} />
|
||||
</div>
|
||||
<small>{Math.max(0, Math.floor(playerSide.enemyHealth))} / {encounter.maxHealth}</small>
|
||||
</div>
|
||||
<div>
|
||||
<strong>{liveMatch ? `${liveMatch.opponentName} clear` : 'CPU clear'}</strong>
|
||||
<div className="bar enemy-health boss-bar">
|
||||
<span style={{ width: `${(cpuSide.enemyHealth / encounter.maxHealth) * 100}%` }} />
|
||||
</div>
|
||||
<small>{Math.max(0, Math.floor(cpuSide.enemyHealth))} / {encounter.maxHealth}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div className="spell-bar six-slots vertical-spell-bar pvp-vertical-spell-bar">
|
||||
{starterSpells.map((spell) => {
|
||||
const remaining = playerSide.cooldowns[spell.id] ?? 0
|
||||
const cost = spellResourceCost(spell, playerSide.buffs, playerSide.debuffs, playerSide.freeCastReady)
|
||||
return (
|
||||
<button
|
||||
className="spell"
|
||||
disabled={status !== 'playing' || playerDone || !playerAlive || remaining > 0 || playerSide.resource < cost}
|
||||
key={`middle-${spell.id}`}
|
||||
onClick={() => castPlayerSpell(spell)}
|
||||
type="button"
|
||||
>
|
||||
<kbd>
|
||||
<ControllerBindingLabel
|
||||
binding={bindings[lastDevice][`ability${Number(spell.key)}` as InputAction]}
|
||||
compact
|
||||
iconStyle={controllerIconStyle}
|
||||
/>
|
||||
</kbd>
|
||||
<span className={`spell-icon spell-${spell.kind}`}>{spell.glyph}</span>
|
||||
<strong>{spell.name}</strong>
|
||||
<small>{cost} {gameClass.resourceName}</small>
|
||||
{remaining > 0 && <i>{remaining.toFixed(1)}</i>}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<p className="roguelike-upgrade-list">
|
||||
{liveMatch ? `${liveMatch.opponentName} (${liveMatch.opponentClassName})` : `CPU ${cpuDifficulty}`} | Encounters cleared: {encountersCleared}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="combat-panel pvp-side">
|
||||
<div className="encounter-header">
|
||||
<div>
|
||||
<p className="eyebrow">Opponent</p>
|
||||
<h2>{opponentLabel}</h2>
|
||||
<small>{liveMatch ? liveMatch.opponentClassName : `CPU ${cpuDifficulty}`} | Encounters cleared: {encountersCleared}</small>
|
||||
</div>
|
||||
<div className="resource-row pvp-resource-row">
|
||||
<div className="pvp-side-bars">
|
||||
<div className="pvp-clear-wrap">
|
||||
<span>{liveMatch ? `${liveMatch.opponentName} clear` : 'CPU clear'} {Math.max(0, Math.floor(cpuSide.enemyHealth))} / {encounter.maxHealth}</span>
|
||||
<div className="bar enemy-health boss-bar">
|
||||
<span style={{ width: `${(cpuSide.enemyHealth / encounter.maxHealth) * 100}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="pvp-resource-wrap">
|
||||
<span>{gameClass.resourceName} {Math.floor(cpuSide.resource)} / {maxResource}</span>
|
||||
<div className="bar mana-bar"><span style={{ width: `${(cpuSide.resource / maxResource) * 100}%` }} /></div>
|
||||
@@ -1745,6 +1749,7 @@ export function PvPRoguelikeScreen({
|
||||
<div className="bar member-health">
|
||||
<span style={{ width: `${(member.health / effectiveMaxHealth(member)) * 100}%` }} />
|
||||
{member.shield > 0 && <i style={{ width: `${(member.shield / effectiveMaxHealth(member)) * 100}%` }} />}
|
||||
<em className="health-text">{Math.floor(member.health)} / {effectiveMaxHealth(member)}</em>
|
||||
</div>
|
||||
<div className="floating-combat-texts" aria-hidden="true">
|
||||
{floatingTexts
|
||||
@@ -1766,6 +1771,34 @@ export function PvPRoguelikeScreen({
|
||||
Buffs: {cpuSide.buffs.length > 0 ? summarizeStacks(cpuSide.buffs, selfBuffChoicesCatalog) : 'none'} | Debuffs: {cpuSide.debuffs.length > 0 ? summarizeStacks(cpuSide.debuffs, opponentDebuffChoicesCatalog) : 'none'}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="pvp-bottom-spell-bar" aria-label="Player abilities">
|
||||
{starterSpells.map((spell) => {
|
||||
const remaining = playerSide.cooldowns[spell.id] ?? 0
|
||||
const cost = spellResourceCost(spell, playerSide.buffs, playerSide.debuffs, playerSide.freeCastReady)
|
||||
return (
|
||||
<button
|
||||
className="spell"
|
||||
disabled={status !== 'playing' || playerDone || !playerAlive || remaining > 0 || playerSide.resource < cost}
|
||||
key={`bottom-${spell.id}`}
|
||||
onClick={() => castPlayerSpell(spell)}
|
||||
type="button"
|
||||
>
|
||||
<kbd>
|
||||
<ControllerBindingLabel
|
||||
binding={bindings[lastDevice][`ability${Number(spell.key)}` as InputAction]}
|
||||
compact
|
||||
iconStyle={controllerIconStyle}
|
||||
/>
|
||||
</kbd>
|
||||
<span className={`spell-icon spell-${spell.kind}`}>{spell.glyph}</span>
|
||||
<strong>{spell.name}</strong>
|
||||
<small>{cost} {gameClass.resourceName}</small>
|
||||
{remaining > 0 && <i>{remaining.toFixed(1)}</i>}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</section>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1910,6 +1943,14 @@ export function PvPRoguelikeScreen({
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{liveMatch && (
|
||||
<>
|
||||
<button disabled={rematchRequested} onClick={handleRematch} type="button">
|
||||
{rematchRequested ? 'Waiting for Rematch' : 'Rematch'}
|
||||
</button>
|
||||
{rematchMessage && <p>{rematchMessage}</p>}
|
||||
</>
|
||||
)}
|
||||
<button onClick={() => startMatch()} type="button">Queue Next Match</button>
|
||||
<button className="secondary-result-button" onClick={onExit} type="button">Back to Roguelike</button>
|
||||
</div>
|
||||
|
||||
+36
-2
@@ -37,7 +37,8 @@ export interface GameRepository {
|
||||
durationSeconds: number,
|
||||
options?: {
|
||||
bossesCleared?: number
|
||||
experienceMode?: 'default' | 'pvp-boss-quarter-level'
|
||||
experienceMode?: 'default' | 'pvp-boss-quarter-level' | 'pvp-fight-twelfth-level'
|
||||
fightsCleared?: number
|
||||
lootSourceEncounterId?: number
|
||||
roguelikeStage?: number
|
||||
},
|
||||
@@ -503,6 +504,31 @@ function scaledPvpBossExperience(
|
||||
return { experience, level }
|
||||
}
|
||||
|
||||
function scaledPvpFightExperience(
|
||||
startingExperience: number,
|
||||
startingLevel: number,
|
||||
fightsCleared: number,
|
||||
maxLevel: number,
|
||||
targetLevel = startingLevel,
|
||||
) {
|
||||
let experience = startingExperience
|
||||
let level = startingLevel
|
||||
const maxExperience = experienceForLevel(maxLevel)
|
||||
for (let fightIndex = 0; fightIndex < fightsCleared && experience < maxExperience; fightIndex += 1) {
|
||||
const currentLevelFloor = experienceForLevel(level)
|
||||
const nextLevelExperience = level >= maxLevel
|
||||
? maxExperience
|
||||
: experienceForLevel(level + 1)
|
||||
const levelBand = Math.max(1, nextLevelExperience - currentLevelFloor)
|
||||
const rewardRate = targetLevel > level ? 1 / 6 : 1 / 12
|
||||
experience = Math.min(maxExperience, experience + Math.round(levelBand * rewardRate))
|
||||
while (level < maxLevel && experienceForLevel(level + 1) <= experience) {
|
||||
level += 1
|
||||
}
|
||||
}
|
||||
return { experience, level }
|
||||
}
|
||||
|
||||
function talentEffectCapacity(level: number) {
|
||||
return Math.min(4, Math.max(0, Math.floor(level / 5)))
|
||||
}
|
||||
@@ -1142,7 +1168,15 @@ function createLocalRepository(store: LocalSaveStore): GameRepository {
|
||||
const bossesCleared = Math.max(0, Math.floor(options?.bossesCleared ?? encountersCleared / 3))
|
||||
const scaledReward = options?.experienceMode === 'pvp-boss-quarter-level'
|
||||
? scaledPvpBossExperience(previousExperience, previousLevel, bossesCleared, profile.maxLevel, highestOtherClassLevel(save))
|
||||
: null
|
||||
: options?.experienceMode === 'pvp-fight-twelfth-level'
|
||||
? scaledPvpFightExperience(
|
||||
previousExperience,
|
||||
previousLevel,
|
||||
Math.max(0, Math.floor(options.fightsCleared ?? encountersCleared)),
|
||||
profile.maxLevel,
|
||||
highestOtherClassLevel(save),
|
||||
)
|
||||
: null
|
||||
const baseRoguelikeReward = Math.round(dungeon.experienceReward * difficulty.experienceMultiplier * (encountersCleared / 3))
|
||||
const newExperience = scaledReward
|
||||
? scaledReward.experience
|
||||
|
||||
+2
-1
@@ -349,7 +349,8 @@ export async function completeRoguelike(
|
||||
durationSeconds: number,
|
||||
options?: {
|
||||
bossesCleared?: number
|
||||
experienceMode?: 'default' | 'pvp-boss-quarter-level'
|
||||
experienceMode?: 'default' | 'pvp-boss-quarter-level' | 'pvp-fight-twelfth-level'
|
||||
fightsCleared?: number
|
||||
lootSourceEncounterId?: number
|
||||
roguelikeStage?: number
|
||||
},
|
||||
|
||||
@@ -35,6 +35,7 @@ export type PvpMatchSnapshot<TSideState = unknown> = {
|
||||
elapsedTicks: number
|
||||
}>>
|
||||
upgradeChoices: Partial<Record<PvpMatchSide, Record<string, PvpUpgradeChoicePayload>>>
|
||||
rematchRequests?: Partial<Record<PvpMatchSide, boolean>>
|
||||
updatedAt: number
|
||||
}
|
||||
|
||||
@@ -45,6 +46,12 @@ export type PvpQueueResponse<TSideState = unknown> = {
|
||||
side?: PvpMatchSide
|
||||
}
|
||||
|
||||
export type PvpRematchResponse<TSideState = unknown> = {
|
||||
status: 'waiting' | 'matched'
|
||||
match?: PvpMatchSnapshot<TSideState>
|
||||
side?: PvpMatchSide
|
||||
}
|
||||
|
||||
export type CpuPvpLeaderboardEntry = {
|
||||
characterName: string
|
||||
className: string
|
||||
@@ -166,3 +173,9 @@ export function submitPvpUpgradeChoice(
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export function requestPvpRematch<TSideState>(matchId: string): Promise<PvpRematchResponse<TSideState>> {
|
||||
return requestGameApiJson(`/api/pvp/matches/${encodeURIComponent(matchId)}/rematch`, {
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user