From 77085925500483957a7e6847ee9b0e769807ecba Mon Sep 17 00:00:00 2001 From: Tiyo Date: Sun, 22 Oct 2023 14:59:26 +0800 Subject: [PATCH] feat: losser vanish --- packages/client/src/pages/game/index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index 31e628af..e75212c5 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -64,7 +64,20 @@ const Game = () => { setStartBattleData(false); if (e == 1) { console.log('win'); - getWinTreasureChest(targetPlayer.gem) + let treasureChestData = treasureChest + console.log(treasureChestData, treasureChestData[treasureChestData.length - 1]); + let item = { + id: treasureChestData.length ? treasureChestData[treasureChestData.length - 1].id + 1 : 1, + x: targetPlayer.x, + y: targetPlayer.y, + gem: targetPlayer.gem + } + treasureChestData.push(item) + let targetPlayerIndex = players.findIndex((item) => item.x === targetPlayer.x && item.y === targetPlayer.y); + players.splice(targetPlayerIndex, 1); + setTreasureChest([...treasureChestData]); + setPlayers([...players]); + // getWinTreasureChest(targetPlayer.gem) setTargetPlayer(null); } else if (e == 2) { console.log('lose');