Skip to content

Commit

Permalink
feat: losser vanish
Browse files Browse the repository at this point in the history
  • Loading branch information
TiyoSheng committed Oct 22, 2023
1 parent 3632bdf commit 7708592
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/client/src/pages/game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 7708592

Please sign in to comment.