Android build v1.1.22
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { asIwt2HealerId, type Iwt2HealerId } from '../content/healerAbilities'
|
||||
import { IWT2_BOSS_PET_DROP_RATE, iwt2BossMaterialRewardFor, iwt2BossPetRewardFor } from '../content/bossRewards'
|
||||
import type { Iwt2BossId } from '../content/bosses'
|
||||
|
||||
export type Iwt2InventoryItem = {
|
||||
id: string
|
||||
@@ -11,6 +13,7 @@ export type Iwt2ArmorPaletteId = 'guild_green' | 'sun_gold' | 'ember_red' | 'moo
|
||||
|
||||
export type Iwt2CollectionLog = {
|
||||
bossKills: Record<string, number>
|
||||
bossPets: Record<string, number>
|
||||
dropsFound: Record<string, number>
|
||||
}
|
||||
|
||||
@@ -29,6 +32,20 @@ export type Iwt2CloudSlot = {
|
||||
collectionLog: Iwt2CollectionLog
|
||||
}
|
||||
|
||||
export type Iwt2BossPetAward = {
|
||||
bossId: Iwt2BossId
|
||||
petId: string
|
||||
petName: string
|
||||
quantity: number
|
||||
duplicate: boolean
|
||||
quantityAfter: number
|
||||
}
|
||||
|
||||
export type Iwt2BossKillReward = {
|
||||
save: Iwt2Save
|
||||
petAwarded: Iwt2BossPetAward | null
|
||||
}
|
||||
|
||||
export type Iwt2Save = {
|
||||
version: 1
|
||||
updatedAt: number
|
||||
@@ -54,6 +71,7 @@ export function createDefaultIwt2Save(): Iwt2Save {
|
||||
inventory: [],
|
||||
collectionLog: {
|
||||
bossKills: {},
|
||||
bossPets: {},
|
||||
dropsFound: {},
|
||||
},
|
||||
}
|
||||
@@ -76,6 +94,7 @@ function normalizeSave(value: unknown): Iwt2Save {
|
||||
inventory: Array.isArray(candidate.inventory) ? candidate.inventory : [],
|
||||
collectionLog: {
|
||||
bossKills: candidate.collectionLog?.bossKills ?? {},
|
||||
bossPets: candidate.collectionLog?.bossPets ?? {},
|
||||
dropsFound: candidate.collectionLog?.dropsFound ?? {},
|
||||
},
|
||||
cloudSlot: normalizeCloudSlot(candidate.cloudSlot),
|
||||
@@ -97,9 +116,16 @@ export function writeIwt2Save(save: Iwt2Save) {
|
||||
}))
|
||||
}
|
||||
|
||||
export function recordIwt2BossKill(save: Iwt2Save, bossId: string): Iwt2Save {
|
||||
const drop = bossDropFor(bossId)
|
||||
return {
|
||||
export function recordIwt2BossKill(save: Iwt2Save, bossId: Iwt2BossId): Iwt2Save {
|
||||
return recordIwt2BossKillReward(save, bossId).save
|
||||
}
|
||||
|
||||
export function recordIwt2BossKillReward(save: Iwt2Save, bossId: Iwt2BossId): Iwt2BossKillReward {
|
||||
const drop = iwt2BossMaterialRewardFor(bossId)
|
||||
const pet = iwt2BossPetRewardFor(bossId)
|
||||
const awardedPet = Math.random() < IWT2_BOSS_PET_DROP_RATE
|
||||
const previousPetQuantity = save.collectionLog.bossPets[pet.id] ?? 0
|
||||
const updatedSave: Iwt2Save = {
|
||||
...save,
|
||||
updatedAt: Date.now(),
|
||||
character: {
|
||||
@@ -122,12 +148,31 @@ export function recordIwt2BossKill(save: Iwt2Save, bossId: string): Iwt2Save {
|
||||
...save.collectionLog.bossKills,
|
||||
[bossId]: (save.collectionLog.bossKills[bossId] ?? 0) + 1,
|
||||
},
|
||||
bossPets: awardedPet
|
||||
? {
|
||||
...save.collectionLog.bossPets,
|
||||
[pet.id]: (save.collectionLog.bossPets[pet.id] ?? 0) + 1,
|
||||
}
|
||||
: save.collectionLog.bossPets,
|
||||
dropsFound: {
|
||||
...save.collectionLog.dropsFound,
|
||||
[drop.id]: (save.collectionLog.dropsFound[drop.id] ?? 0) + 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
return {
|
||||
save: updatedSave,
|
||||
petAwarded: awardedPet
|
||||
? {
|
||||
bossId,
|
||||
duplicate: previousPetQuantity > 0,
|
||||
petId: pet.id,
|
||||
petName: pet.name,
|
||||
quantity: 1,
|
||||
quantityAfter: previousPetQuantity + 1,
|
||||
}
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
export function updateIwt2CharacterSettings(
|
||||
@@ -157,6 +202,7 @@ export function snapshotIwt2CloudSlot(save: Iwt2Save): Iwt2Save {
|
||||
inventory: save.inventory.map((item) => ({ ...item })),
|
||||
collectionLog: {
|
||||
bossKills: { ...save.collectionLog.bossKills },
|
||||
bossPets: { ...save.collectionLog.bossPets },
|
||||
dropsFound: { ...save.collectionLog.dropsFound },
|
||||
},
|
||||
},
|
||||
@@ -172,18 +218,12 @@ export function restoreIwt2CloudSlot(save: Iwt2Save): Iwt2Save {
|
||||
inventory: save.cloudSlot.inventory.map((item) => ({ ...item })),
|
||||
collectionLog: {
|
||||
bossKills: { ...save.cloudSlot.collectionLog.bossKills },
|
||||
bossPets: { ...save.cloudSlot.collectionLog.bossPets },
|
||||
dropsFound: { ...save.cloudSlot.collectionLog.dropsFound },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function bossDropFor(bossId: string): { id: string, name: string } {
|
||||
if (bossId === 'yian-kut-ku') return { id: 'yian-kut-ku-scale', name: 'Yian Kut Ku Scale' }
|
||||
if (bossId === 'great-jaggi') return { id: 'great-jaggi-hide', name: 'Great Jaggi Hide' }
|
||||
if (bossId === 'khezu') return { id: 'khezu-pearl', name: 'Khezu Pearl' }
|
||||
return { id: 'raw-bulldrome-coin', name: 'Raw Bulldrome Coin' }
|
||||
}
|
||||
|
||||
function asIwt2ArmorPaletteId(value: unknown): Iwt2ArmorPaletteId {
|
||||
return value === 'sun_gold'
|
||||
|| value === 'ember_red'
|
||||
@@ -214,6 +254,7 @@ function normalizeCloudSlot(value: unknown): Iwt2CloudSlot | undefined {
|
||||
inventory: Array.isArray(candidate.inventory) ? candidate.inventory : [],
|
||||
collectionLog: {
|
||||
bossKills: candidate.collectionLog.bossKills ?? {},
|
||||
bossPets: candidate.collectionLog.bossPets ?? {},
|
||||
dropsFound: candidate.collectionLog.dropsFound ?? {},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user