Skip to content

Commit

Permalink
small step towards displaying animations of Board UI
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Jul 1, 2020
1 parent ab81902 commit 87ae4d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app/client/View.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

Expand All @@ -8,12 +9,14 @@ module View where
import Board
import Card
import Constants
import Control.Lens
import Data.Generics.Labels
import Data.List
import qualified Data.Map.Strict as Map
import Data.Maybe (fromJust, fromMaybe, isJust, isNothing, mapMaybe, maybeToList)
import Event
import Game (enemySpots)
import Miso
import Miso hiding (at)
import Miso.String
import Model
import Update
Expand Down Expand Up @@ -43,7 +46,7 @@ boardToInPlaceCells ::
Int ->
Model ->
[View Action]
boardToInPlaceCells z Model {board, interaction} =
boardToInPlaceCells z Model {anims, board, interaction} =
-- draw cards on table
[ div_
( [ cardPositionStyle x y,
Expand All @@ -69,6 +72,9 @@ boardToInPlaceCells z Model {board, interaction} =
let emptyPlayingPlayerSpot =
cSpot `elem` emptyPlayingPlayerSpots
&& pSpot == playingPlayerSpot,
let attackEffect =
(anims ^. spotToLens pSpot . #inPlace & unwrap)
Map.!? cSpot & flip fromMaybe mempty,

This comment has been minimized.

Copy link
@polux

polux Jul 2, 2020

Collaborator

flip fromMaybe mempty is probably not doing what you think it does: it is equivalent to \maybeEffect -> fromMaybe maybeEffect Nothing which is equivalent to maybeEffect. I guess you wanted to have the "neutral attack effect" instead. It is not declared (yet): AttackEffect is only a semigroup, not a monoid. I'll add it and try to fix it.

This comment has been minimized.

Copy link
@smelc

smelc Jul 3, 2020

Author Owner

Good catch, indeed I wanted to use the neutral element, not Nothing.

-- draw border around some cards if:
-- 1/ card in hand is being hovered or dragged -> draw borders around
-- valid drag targets
Expand Down Expand Up @@ -102,6 +108,7 @@ boardToInPlaceCells z Model {board, interaction} =
allCardsSpots \\ playingPlayerCardsSpots
yellow = (255, 255, 0)
green = (0, 255, 0)
unwrap (AttackEffects m) = m -- TODO use some lens magic

boardToInHandCells ::
-- | The z index
Expand Down
2 changes: 1 addition & 1 deletion app/shared/Board.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ otherPlayerSpot :: PlayerSpot -> PlayerSpot
otherPlayerSpot PlayerBottom = PlayerTop
otherPlayerSpot PlayerTop = PlayerBottom

spotToLens :: PlayerSpot -> Lens' (Board Core) (PlayerPart Core)
spotToLens :: PlayerSpot -> Lens' (Board p) (PlayerPart p)
spotToLens =
\case
PlayerBottom -> #playerBottom
Expand Down

0 comments on commit 87ae4d3

Please sign in to comment.