From d93a2f5ffec92a9baf9e5a81543ba747198c661d Mon Sep 17 00:00:00 2001 From: Cheelax Date: Wed, 27 Sep 2023 09:12:19 +0200 Subject: [PATCH] turn status --- client/src/dojo/createSystemCalls.ts | 32 ++++++++++++++-------------- client/src/ui/Canvas.tsx | 11 +++++++--- client/src/ui/PassTurnButton.tsx | 4 ++-- client/src/ui/TurnStatus.tsx | 9 ++++++++ client/src/utils/animation.ts | 26 +++++++++++----------- 5 files changed, 48 insertions(+), 34 deletions(-) create mode 100644 client/src/ui/TurnStatus.tsx diff --git a/client/src/dojo/createSystemCalls.ts b/client/src/dojo/createSystemCalls.ts index 9bf6b61..b3e509e 100644 --- a/client/src/dojo/createSystemCalls.ts +++ b/client/src/dojo/createSystemCalls.ts @@ -29,7 +29,7 @@ export function createSystemCalls( try { const tx = await execute(signer, 'Create', [ip, seed, pseudo]); - console.log(tx); + // console.log(tx); const receipt = (await signer.waitForTransaction(tx.transaction_hash, { retryInterval: 100, })) as InvokeTransactionReceiptResponse; @@ -61,7 +61,7 @@ export function createSystemCalls( try { const tx = await execute(signer, 'Play', [ip, x, y]); - console.log(tx); + // console.log(tx); const receipt = (await signer.waitForTransaction(tx.transaction_hash, { retryInterval: 100, })) as InvokeTransactionReceiptResponse; @@ -91,14 +91,14 @@ export function createSystemCalls( try { const tx = await execute(signer, 'Spawn', [ip]); - console.log(tx); + // console.log(tx); const receipt = (await signer.waitForTransaction(tx.transaction_hash, { retryInterval: 100, })) as InvokeTransactionReceiptResponse; const events = receipt.events; - console.log(events); + // console.log(events); if (events) { const eventsTransformed = await setComponentsFromEvents(contractComponents, events); await executeEvents(eventsTransformed, add_hole, set_size, reset_holes, set_hit_mob, set_turn); @@ -154,7 +154,7 @@ export async function executeEvents( } const characterEvents = events.filter((e): e is CharacterEvent & ComponentData => e.type === 'Character'); - console.log('characterEvents', characterEvents); + // console.log('characterEvents', characterEvents); for (const e of characterEvents) { if (e.hitter !== 0) { set_turn(e.hitter); @@ -163,7 +163,7 @@ export async function executeEvents( if (e._type === TileType.Barbarian) hit_mob = 'barbarian'; else if (e._type === TileType.Bowman) hit_mob = 'bowman'; else if (e._type === TileType.Wizard) hit_mob = 'wizard'; - console.log('set_hit_mob', hit_mob); + // console.log('set_hit_mob', hit_mob); set_hit_mob(hit_mob); } else { set_turn(e._type); @@ -279,11 +279,11 @@ function handleCharacterEvent( ): Omit { const [game_id, _type] = keys.map((k) => Number(k)); const [health, index, hitter, hit] = values.map((v) => Number(v)); - console.log( - `[Character: KEYS: (game_id: ${game_id}, _type: ${_type}) - VALUES: (health: ${Number(health)}, index: ${Number( - index - )}, hitter: ${Number(hitter)}, hit: ${Number(hit)})]` - ); + // console.log( + // `[Character: KEYS: (game_id: ${game_id}, _type: ${_type}) - VALUES: (health: ${Number(health)}, index: ${Number( + // index + // )}, hitter: ${Number(hitter)}, hit: ${Number(hit)})]` + // ); return { type: 'Character', game_id, @@ -311,11 +311,11 @@ function handleTileEvent( ): Omit { const [game_id, map_id, index] = keys.map((k) => Number(k)); const [_type, x, y] = values.map((v) => Number(v)); - console.log( - `[Tile: KEYS: (game_id: ${game_id}, map_id: ${map_id}, index: ${index}) - VALUES: (_type: ${Number( - _type - )}, (x: ${Number(x)}, y: ${Number(y)}))]` - ); + // console.log( + // `[Tile: KEYS: (game_id: ${game_id}, map_id: ${map_id}, index: ${index}) - VALUES: (_type: ${Number( + // _type + // )}, (x: ${Number(x)}, y: ${Number(y)}))]` + // ); return { type: 'Tile', game_id, diff --git a/client/src/ui/Canvas.tsx b/client/src/ui/Canvas.tsx index a34e95d..09a30ba 100644 --- a/client/src/ui/Canvas.tsx +++ b/client/src/ui/Canvas.tsx @@ -20,6 +20,7 @@ import NewGame from './NewGame'; import PassTurnButton from './PassTurnButton'; import ResetButton from './ResetButton'; import Sword from './Sword'; +import TurnStatus from './TurnStatus'; interface CanvasProps { setMusicPlaying: (bool: boolean) => void; @@ -339,9 +340,13 @@ const Canvas: React.FC = ({ setMusicPlaying }) => { {map.size !== 0 && } - - {map.size !== 0 && } - {map.size !== 0 && } + {map.size !== 0 && ( +
+ + + +
+ )} {map.size === 0 && } setIsGameOver(false)} /> diff --git a/client/src/ui/PassTurnButton.tsx b/client/src/ui/PassTurnButton.tsx index 42ab658..42452ae 100644 --- a/client/src/ui/PassTurnButton.tsx +++ b/client/src/ui/PassTurnButton.tsx @@ -7,8 +7,8 @@ interface NewGameButtonProps { const PassTurnButton: React.FC = ({ onClick }) => { return (