Android build v1.0.27

This commit is contained in:
Warren H
2026-06-19 21:29:44 -04:00
parent 88874933c3
commit ba6d3b614e
9 changed files with 1240 additions and 760 deletions
+43 -7
View File
@@ -386,6 +386,11 @@ export function CombatScreen({
const nextFloatingTextId = useRef(1)
const combatRef = useRef(initialCombatState)
const selectedIdRef = useRef(partyTemplate[0].id)
const runCombatTickRef = useRef<() => void>(() => {})
const combatClockActiveRef = useRef(false)
const lastCombatTickAtRef = useRef(performance.now())
const statusRef = useRef(status)
const pausedRef = useRef(paused)
const { party, resource, enemyHealth, cooldowns, freeCastReady } = combatState
const encounter = encounters[encounterIndex]
const currentPart = getCurrentPart(encounterIndex)
@@ -415,6 +420,9 @@ export function CombatScreen({
enabled: dualScreenEnabled,
} = useDualScreen()
statusRef.current = status
pausedRef.current = paused
useEffect(() => {
const now = Date.now()
runStartedAtRef.current = now
@@ -846,9 +854,7 @@ export function CombatScreen({
if (spell) castSpell(spell)
})
useEffect(() => {
if (status !== 'playing' || paused) return
const timer = window.setInterval(() => {
const runCombatTick = useCallback(() => {
const current = combatRef.current
const nextElapsedTicks = current.elapsedTicks + 1
const nextCooldowns = Object.fromEntries(
@@ -1042,8 +1048,6 @@ export function CombatScreen({
enemyHealth: nextEncounter.maxHealth,
})
addLog(`${encounter.enemyName} defeated. ${nextEncounter.enemyName} approaches.`, 'system')
}, TICK_MS)
return () => window.clearInterval(timer)
}, [
addLog,
addFloatingHeal,
@@ -1065,11 +1069,43 @@ export function CombatScreen({
profile.character.name,
setCombat,
startPart,
status,
currentPart,
paused,
])
useEffect(() => {
runCombatTickRef.current = runCombatTick
}, [runCombatTick])
useEffect(() => {
if (status === 'playing' && !paused) {
if (!combatClockActiveRef.current) {
lastCombatTickAtRef.current = performance.now()
combatClockActiveRef.current = true
}
return
}
combatClockActiveRef.current = false
}, [paused, status])
useEffect(() => {
const timer = window.setInterval(() => {
if (
!combatClockActiveRef.current
|| statusRef.current !== 'playing'
|| pausedRef.current
) return
const now = performance.now()
const dueTicks = Math.min(4, Math.floor((now - lastCombatTickAtRef.current) / TICK_MS))
if (dueTicks <= 0) return
lastCombatTickAtRef.current += dueTicks * TICK_MS
for (let index = 0; index < dueTicks; index += 1) {
if (statusRef.current !== 'playing' || pausedRef.current) return
runCombatTickRef.current()
}
}, 50)
return () => window.clearInterval(timer)
}, [])
useEffect(() => {
if (
!reward