forked from OpenWF/SpaceNinjaServer
		
	fix(stats): captures not being tracked for a new enemy (#1728)
Reviewed-on: OpenWF/SpaceNinjaServer#1728 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									5eecf11b1a
								
							
						
					
					
						commit
						8afb515231
					
				@ -1,6 +1,5 @@
 | 
			
		||||
import { Stats, TStatsDatabaseDocument } from "@/src/models/statsModel";
 | 
			
		||||
import {
 | 
			
		||||
    IEnemy,
 | 
			
		||||
    IStatsAdd,
 | 
			
		||||
    IStatsMax,
 | 
			
		||||
    IStatsSet,
 | 
			
		||||
@ -137,16 +136,21 @@ export const updateStats = async (accountOwnerId: string, payload: IStatsUpdate)
 | 
			
		||||
                        case "HEADSHOT":
 | 
			
		||||
                        case "KILL_ASSIST": {
 | 
			
		||||
                            playerStats.Enemies ??= [];
 | 
			
		||||
                            const enemyStatKey = {
 | 
			
		||||
                            const enemyStatKey = (
 | 
			
		||||
                                {
 | 
			
		||||
                                    KILL_ENEMY: "kills",
 | 
			
		||||
                                    EXECUTE_ENEMY: "executions",
 | 
			
		||||
                                    HEADSHOT: "headshots",
 | 
			
		||||
                                    KILL_ASSIST: "assists"
 | 
			
		||||
                            }[category] as "kills" | "executions" | "headshots" | "assists";
 | 
			
		||||
                                } as const
 | 
			
		||||
                            )[category];
 | 
			
		||||
 | 
			
		||||
                            for (const [type, count] of Object.entries(data as IUploadEntry)) {
 | 
			
		||||
                                const enemy = playerStats.Enemies.find(element => element.type === type);
 | 
			
		||||
                                if (enemy) {
 | 
			
		||||
                                let enemy = playerStats.Enemies.find(element => element.type === type);
 | 
			
		||||
                                if (!enemy) {
 | 
			
		||||
                                    enemy = { type: type };
 | 
			
		||||
                                    playerStats.Enemies.push(enemy);
 | 
			
		||||
                                }
 | 
			
		||||
                                if (category === "KILL_ENEMY") {
 | 
			
		||||
                                    enemy.kills ??= 0;
 | 
			
		||||
                                    const captureCount = (actionData as IStatsAdd)["CAPTURE_ENEMY"]?.[type];
 | 
			
		||||
@ -161,11 +165,6 @@ export const updateStats = async (accountOwnerId: string, payload: IStatsUpdate)
 | 
			
		||||
                                    enemy[enemyStatKey] ??= 0;
 | 
			
		||||
                                    enemy[enemyStatKey] += count;
 | 
			
		||||
                                }
 | 
			
		||||
                                } else {
 | 
			
		||||
                                    const newEnemy: IEnemy = { type: type };
 | 
			
		||||
                                    newEnemy[enemyStatKey] = count;
 | 
			
		||||
                                    playerStats.Enemies.push(newEnemy);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user