small refactor for kill route prechecks
This commit is contained in:
+13
-24
@@ -65,36 +65,25 @@ router.post(
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let attacker_loadout: number | undefined
|
|
||||||
let victim_loadout: number | undefined
|
|
||||||
|
|
||||||
// await checkUpdateOrCreatePlayer(
|
// await checkUpdateOrCreatePlayer(
|
||||||
// { id: attacker_id, name: attackerData.name })
|
// { id: attacker_id, name: attackerData.name })
|
||||||
// await checkUpdateOrCreatePlayer(
|
// await checkUpdateOrCreatePlayer(
|
||||||
// { id: victim_id, name: victimData.name }
|
// { id: victim_id, name: victimData.name }
|
||||||
// )
|
// )
|
||||||
if (attackerData.loadout.titan) {
|
|
||||||
await checkOrCreateTitan(attackerData.loadout.titan)
|
|
||||||
}
|
|
||||||
if (victimData.loadout.titan) {
|
|
||||||
await checkOrCreateTitan(victimData.loadout.titan)
|
|
||||||
}
|
|
||||||
await checkOrCreateWeapon(cause_of_death)
|
|
||||||
await checkOrCreateWeapon(attackerData.current_weapon.id)
|
|
||||||
await checkOrCreateWeapon(victimData.current_weapon.id)
|
|
||||||
|
|
||||||
await checkOrCreateLoadout(attackerData.loadout).then(
|
await Promise.all([
|
||||||
(e) => (attacker_loadout = e)
|
checkOrCreateWeapon(cause_of_death),
|
||||||
)
|
checkOrCreateWeapon(attackerData.current_weapon.id),
|
||||||
await checkOrCreateLoadout(victimData.loadout).then(
|
checkOrCreateWeapon(victimData.current_weapon.id),
|
||||||
(e) => (victim_loadout = e)
|
async () => { if (attackerData.loadout.titan) { await checkOrCreateTitan(attackerData.loadout.titan) } },
|
||||||
)
|
async () => { if (victimData.loadout.titan) { await checkOrCreateTitan(victimData.loadout.titan) } }
|
||||||
if (attacker_loadout === undefined) {
|
])
|
||||||
throw new Error('attacker_loadout is undefined')
|
|
||||||
}
|
const [attacker_loadout, victim_loadout] = await Promise.all([
|
||||||
if (victim_loadout === undefined) {
|
checkOrCreateLoadout(attackerData.loadout),
|
||||||
throw new Error('victim_loadout is undefined')
|
checkOrCreateLoadout(victimData.loadout)
|
||||||
}
|
])
|
||||||
|
|
||||||
const insertResult = await db
|
const insertResult = await db
|
||||||
.insertInto('ToneAPI_v3.kill')
|
.insertInto('ToneAPI_v3.kill')
|
||||||
.values({
|
.values({
|
||||||
|
|||||||
Reference in New Issue
Block a user