fix(stats): handle eidolon capture (#1190)
Reviewed-on: #1190 Reviewed-by: Sainan <sainan@calamity.inc> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
This commit is contained in:
parent
2891e2fef5
commit
ae9a98ca8b
@ -104,14 +104,16 @@ export const updateStats = async (playerStats: TStatsDatabaseDocument, payload:
|
|||||||
case "FIRE_WEAPON":
|
case "FIRE_WEAPON":
|
||||||
case "HIT_ENTITY_ITEM":
|
case "HIT_ENTITY_ITEM":
|
||||||
case "HEADSHOT_ITEM":
|
case "HEADSHOT_ITEM":
|
||||||
case "KILL_ENEMY_ITEM": {
|
case "KILL_ENEMY_ITEM":
|
||||||
|
case "KILL_ASSIST_ITEM": {
|
||||||
playerStats.Weapons ??= [];
|
playerStats.Weapons ??= [];
|
||||||
const statKey = {
|
const statKey = {
|
||||||
FIRE_WEAPON: "fired",
|
FIRE_WEAPON: "fired",
|
||||||
HIT_ENTITY_ITEM: "hits",
|
HIT_ENTITY_ITEM: "hits",
|
||||||
HEADSHOT_ITEM: "headshots",
|
HEADSHOT_ITEM: "headshots",
|
||||||
KILL_ENEMY_ITEM: "kills"
|
KILL_ENEMY_ITEM: "kills",
|
||||||
}[category] as "fired" | "hits" | "headshots" | "kills";
|
KILL_ASSIST_ITEM: "assists"
|
||||||
|
}[category] as "fired" | "hits" | "headshots" | "kills" | "assists";
|
||||||
|
|
||||||
for (const [type, count] of Object.entries(data as IUploadEntry)) {
|
for (const [type, count] of Object.entries(data as IUploadEntry)) {
|
||||||
const weapon = playerStats.Weapons.find(element => element.type === type);
|
const weapon = playerStats.Weapons.find(element => element.type === type);
|
||||||
@ -129,19 +131,33 @@ export const updateStats = async (playerStats: TStatsDatabaseDocument, payload:
|
|||||||
|
|
||||||
case "KILL_ENEMY":
|
case "KILL_ENEMY":
|
||||||
case "EXECUTE_ENEMY":
|
case "EXECUTE_ENEMY":
|
||||||
case "HEADSHOT": {
|
case "HEADSHOT":
|
||||||
|
case "KILL_ASSIST": {
|
||||||
playerStats.Enemies ??= [];
|
playerStats.Enemies ??= [];
|
||||||
const enemyStatKey = {
|
const enemyStatKey = {
|
||||||
KILL_ENEMY: "kills",
|
KILL_ENEMY: "kills",
|
||||||
EXECUTE_ENEMY: "executions",
|
EXECUTE_ENEMY: "executions",
|
||||||
HEADSHOT: "headshots"
|
HEADSHOT: "headshots",
|
||||||
}[category] as "kills" | "executions" | "headshots";
|
KILL_ASSIST: "assists"
|
||||||
|
}[category] as "kills" | "executions" | "headshots" | "assists";
|
||||||
|
|
||||||
for (const [type, count] of Object.entries(data as IUploadEntry)) {
|
for (const [type, count] of Object.entries(data as IUploadEntry)) {
|
||||||
const enemy = playerStats.Enemies.find(element => element.type === type);
|
const enemy = playerStats.Enemies.find(element => element.type === type);
|
||||||
if (enemy) {
|
if (enemy) {
|
||||||
|
if (category === "KILL_ENEMY") {
|
||||||
|
enemy.kills ??= 0;
|
||||||
|
const captureCount = (actionData["CAPTURE_ENEMY"] as IUploadEntry)?.[type];
|
||||||
|
if (captureCount) {
|
||||||
|
enemy.kills += Math.max(count - captureCount, 0);
|
||||||
|
enemy.captures ??= 0;
|
||||||
|
enemy.captures += captureCount;
|
||||||
|
} else {
|
||||||
|
enemy.kills += count;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
enemy[enemyStatKey] ??= 0;
|
enemy[enemyStatKey] ??= 0;
|
||||||
enemy[enemyStatKey] += count;
|
enemy[enemyStatKey] += count;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const newEnemy: IEnemy = { type: type };
|
const newEnemy: IEnemy = { type: type };
|
||||||
newEnemy[enemyStatKey] = count;
|
newEnemy[enemyStatKey] = count;
|
||||||
@ -394,6 +410,7 @@ const ignoredCategories = [
|
|||||||
"PRE_DIE_ITEM",
|
"PRE_DIE_ITEM",
|
||||||
"GEAR_USED",
|
"GEAR_USED",
|
||||||
"DIE_ITEM",
|
"DIE_ITEM",
|
||||||
|
"CAPTURE_ENEMY", // handled in KILL_ENEMY
|
||||||
|
|
||||||
// timers action
|
// timers action
|
||||||
"IN_SHIP_TIME",
|
"IN_SHIP_TIME",
|
||||||
|
@ -44,6 +44,7 @@ export interface IEnemy {
|
|||||||
kills?: number;
|
kills?: number;
|
||||||
assists?: number;
|
assists?: number;
|
||||||
deaths?: number;
|
deaths?: number;
|
||||||
|
captures?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMission {
|
export interface IMission {
|
||||||
@ -126,6 +127,8 @@ export interface IStatsAdd {
|
|||||||
DIE_ITEM?: IUploadEntry;
|
DIE_ITEM?: IUploadEntry;
|
||||||
EXECUTE_ENEMY?: IUploadEntry;
|
EXECUTE_ENEMY?: IUploadEntry;
|
||||||
EXECUTE_ENEMY_ITEM?: IUploadEntry;
|
EXECUTE_ENEMY_ITEM?: IUploadEntry;
|
||||||
|
KILL_ASSIST?: IUploadEntry;
|
||||||
|
KILL_ASSIST_ITEM?: IUploadEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUploadEntry {
|
export interface IUploadEntry {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user