From fa7f875bbd77ec91a72f65a13ce661a033e50b34 Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 21 Oct 2018 22:35:20 +1100 Subject: [PATCH] frontend stuff --- client/src/components/battle.cryp.card.jsx | 40 ++++++ client/src/components/cryp.list.jsx | 2 +- client/src/components/game.jsx | 147 +++++++++++++++------ client/src/components/item.list.jsx | 2 +- 4 files changed, 150 insertions(+), 41 deletions(-) create mode 100644 client/src/components/battle.cryp.card.jsx diff --git a/client/src/components/battle.cryp.card.jsx b/client/src/components/battle.cryp.card.jsx new file mode 100644 index 00000000..99074934 --- /dev/null +++ b/client/src/components/battle.cryp.card.jsx @@ -0,0 +1,40 @@ +const preact = require('preact'); + +function CrypCard(cryp) { + return ( +
sendItemUse(cryp.id)} > +
+
+
+

{cryp.name}

+

Level {cryp.lvl}

+
+
+
+ +
+
+ +
+
{cryp.hp.value} / {cryp.stam.value} HP
+ + +
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
+ + +
+ +
+ ); +} + +module.exports = CrypCard; diff --git a/client/src/components/cryp.list.jsx b/client/src/components/cryp.list.jsx index cb718c45..404ee80b 100755 --- a/client/src/components/cryp.list.jsx +++ b/client/src/components/cryp.list.jsx @@ -8,7 +8,7 @@ function CrypList({ cryps, activeItem, sendGamePve, sendItemUse }) { const crypPanels = cryps.sort(nameSort).map(cryp => (
sendItemUse(cryp.id)} >
diff --git a/client/src/components/game.jsx b/client/src/components/game.jsx index 495fd940..9e02b17d 100644 --- a/client/src/components/game.jsx +++ b/client/src/components/game.jsx @@ -1,5 +1,96 @@ const preact = require('preact'); +function PlayerCrypCard(cryp) { + return ( +
+
+
+
+

{cryp.name}

+

Level {cryp.lvl}

+
+
+
+ +
+
+ +
+
{cryp.hp.value} / {cryp.stam.value} HP
+ + +
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
+ + +
+ +
+ ); +} + +function PlayerTeam(team) { + const cryps = team.cryps.map(PlayerCrypCard); + + return ( +
+ {cryps} +
+ ) +} + +function OpponentCrypCard(cryp) { + return ( +
+
+
+
+

{cryp.name}

+

Level {cryp.lvl}

+
+
+
+ +
+
+ +
+
{cryp.hp.value} / {cryp.stam.value} HP
+ + +
{cryp.xp} / {Math.pow(2,cryp.lvl+1)} XP
+ + +
+
+ ); +} + +function OpponentTeam(team) { + const cryps = team.cryps.map(OpponentCrypCard); + + return ( +
+ {cryps} +
+ ) +} + +function GameState(game) { + return ( +
+
{game.phase}
+
+ ) +} + function GamePanel({ game, sendGameSkill, sendGameTarget, account }) { if (!game) return
...
; @@ -7,52 +98,30 @@ function GamePanel({ game, sendGameSkill, sendGameTarget, account }) { const playerTeam = game.teams.find(t => t.id === account.id); - const targetBtn = playerTeam.incoming.map(i => ( - - )); - - const playerCryps = playerTeam.cryps.map(c => ( -
-
{c.name}
- -
- )); + const gameState = GameState(game); + // const targetBtn = playerTeam.incoming.map(i => ( + // + // )); return ( -
-

{game.phase}

-
-

them

-
{JSON.stringify(otherTeams)}
+
+
+
{otherTeams.map(OpponentTeam)}
+ {gameState} +
{PlayerTeam(playerTeam)}
-
-

us

- {playerCryps} - {targetBtn} +
+
log
) - // return ( - //
- //
{JSON.stringify(game.a)}
- //
{JSON.stringify(game.b)}
- //
- // {game.log.map((l, i) => (

{l}

))} - //
- //
- // ); } module.exports = GamePanel; diff --git a/client/src/components/item.list.jsx b/client/src/components/item.list.jsx index d0cd6199..b003b5b8 100644 --- a/client/src/components/item.list.jsx +++ b/client/src/components/item.list.jsx @@ -5,7 +5,7 @@ function ItemList({ items, setActiveItem }) { if (!items) return
...
; const itemPanels = items.map(item => ( -
+