Skip to content

Commit

Permalink
Fix attackEffects in boardToInPlaceCells.
Browse files Browse the repository at this point in the history
Unfortunately symbols didn't work because of
kcsongor/generic-lens#96. Had to revert to field' has
someome suggests on the issue.
  • Loading branch information
polux committed Jul 2, 2020
1 parent 87ae4d3 commit e1b0d2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/client/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

module View where

Expand All @@ -11,6 +12,7 @@ import Card
import Constants
import Control.Lens
import Data.Generics.Labels
import Data.Generics.Product
import Data.List
import qualified Data.Map.Strict as Map
import Data.Maybe (fromJust, fromMaybe, isJust, isNothing, mapMaybe, maybeToList)
Expand Down Expand Up @@ -73,8 +75,7 @@ boardToInPlaceCells z Model {anims, board, interaction} =
cSpot `elem` emptyPlayingPlayerSpots
&& pSpot == playingPlayerSpot,
let attackEffect =
(anims ^. spotToLens pSpot . #inPlace & unwrap)
Map.!? cSpot & flip fromMaybe mempty,
anims ^. spotToLens pSpot . field' @"inPlace" . #unAttackEffects . ix cSpot,
-- draw border around some cards if:
-- 1/ card in hand is being hovered or dragged -> draw borders around
-- valid drag targets
Expand Down
5 changes: 4 additions & 1 deletion app/shared/Board.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ instance Semigroup AttackEffect where
hitPointsChange = hp1 + hp2
}

newtype AttackEffects = AttackEffects (Map.Map CardSpot AttackEffect)
instance Monoid AttackEffect where
mempty = AttackEffect { death = False, attackBump = False, hitPointsChange = 0 }

newtype AttackEffects = AttackEffects { unAttackEffects :: Map.Map CardSpot AttackEffect }
deriving (Eq, Generic)

instance Semigroup AttackEffects where
Expand Down

0 comments on commit e1b0d2c

Please sign in to comment.