Skip to content

Commit

Permalink
City deck filter
Browse files Browse the repository at this point in the history
  • Loading branch information
lsocrate committed Jul 20, 2022
1 parent 7a24ef5 commit d6be23c
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 34 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed assets/svg/icon-city-conc.svg.br
Binary file not shown.
Binary file removed assets/svg/icon-city-core.svg.br
Binary file not shown.
Binary file removed assets/svg/icon-city-hoe.svg.br
Binary file not shown.
2 changes: 1 addition & 1 deletion client/src/Data/Pack.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Data.Pack exposing (Pack, decoder, list, toString)
module Data.Pack exposing (Pack(..), decoder, list, toString)

import Enum exposing (Enum)
import Json.Decode as Decode exposing (Decoder)
Expand Down
70 changes: 50 additions & 20 deletions client/src/Pages/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type alias Model =
{ matches : List Card
, collection : Collection
, stackFilters : Filter.Model Cards.CardStack Never
, cityFilters : Filter.Model Filter.City Never
, primaryFilters : Filter.Model Filter.PrimaryTrait Never
, secondaryFilters : Filter.Model Filter.SecondaryTrait Never
, attackTypeFilters : Filter.Model Cards.AttackType Never
Expand All @@ -53,6 +54,7 @@ init shared =
( { collection = shared.collection
, matches = matchesForQuery shared.collection shared.headerSearch
, stackFilters = Filter.allStacks
, cityFilters = Filter.city
, primaryFilters = Filter.primaryTraits
, secondaryFilters = Filter.secondaryTraits
, attackTypeFilters = Filter.attackTypes
Expand Down Expand Up @@ -91,6 +93,7 @@ fuzzySort query items =
type Msg
= FromShared Shared.Msg
| FromStacksFilter (Filter.Msg Cards.CardStack)
| FromCityFilter (Filter.Msg Filter.City)
| FromPrimaryFilter (Filter.Msg Filter.PrimaryTrait)
| FromSecondaryFilter (Filter.Msg Filter.SecondaryTrait)
| FromAttackTypesFilter (Filter.Msg Cards.AttackType)
Expand Down Expand Up @@ -125,6 +128,9 @@ update msg model =
FromStacksFilter subMsg ->
( { model | stackFilters = Filter.update subMsg model.stackFilters }, Effect.none )

FromCityFilter subMsg ->
( { model | cityFilters = Filter.update subMsg model.cityFilters }, Effect.none )

FromPrimaryFilter subMsg ->
( { model | primaryFilters = Filter.update subMsg model.primaryFilters }, Effect.none )

Expand Down Expand Up @@ -165,25 +171,48 @@ view shared model =
[ div [ class "searchpage__filters" ]
[ UI.Text.header [ text "Filters" ]
, div [ class "filter-group" ]
[ div [ class "filter-group__flags" ]
[ Html.map FromStacksFilter <| Filter.view model.stackFilters
]
, div [ class "filter-group__flags" ]
[ Html.map FromPrimaryFilter <| Filter.view model.primaryFilters
]
, div [ class "filter-group__flags" ]
[ Html.map FromSecondaryFilter <| Filter.view model.secondaryFilters
]
, div [ class "filter-group__flags" ]
[ Html.map FromAttackTypesFilter <| Filter.view model.attackTypeFilters
]
, div [ class "filter-group__flags" ]
[ Html.map FromClansFilter <| Filter.view model.clansFilters
]
, div [ class "filter-group__flags" ]
[ Html.map FromDisciplinesFilter <| Filter.view model.disciplineFilters
]
]
([ Just
(div [ class "filter-group__flags" ]
[ Html.map FromStacksFilter <| Filter.view model.stackFilters
]
)
, if Filter.isCityEnabled model.stackFilters then
Just
(div [ class "filter-group__flags" ]
[ Html.map FromCityFilter <| Filter.view model.cityFilters
]
)

else
Nothing
, Just
(div [ class "filter-group__flags" ]
[ Html.map FromPrimaryFilter <| Filter.view model.primaryFilters
]
)
, Just
(div [ class "filter-group__flags" ]
[ Html.map FromSecondaryFilter <| Filter.view model.secondaryFilters
]
)
, Just
(div [ class "filter-group__flags" ]
[ Html.map FromAttackTypesFilter <| Filter.view model.attackTypeFilters
]
)
, Just
(div [ class "filter-group__flags" ]
[ Html.map FromClansFilter <| Filter.view model.clansFilters
]
)
, Just
(div [ class "filter-group__flags" ]
[ Html.map FromDisciplinesFilter <| Filter.view model.disciplineFilters
]
)
]
|> List.filterMap identity
)
, div [ class "filter-group" ]
[ label []
[ text "Card pack: "
Expand Down Expand Up @@ -228,7 +257,8 @@ matchTextFilter model card =

matchFilterSelections : Model -> Card -> Bool
matchFilterSelections model card =
Filter.isAllowedWide Filter.pickSecondaryTraits model.secondaryFilters card
Filter.isAllowedWide Filter.pickCity model.cityFilters card
&& Filter.isAllowedWide Filter.pickSecondaryTraits model.secondaryFilters card
&& Filter.isAllowedWide (Cards.stack >> List.singleton) model.stackFilters card
&& Filter.isAllowedWide Cards.discipline model.disciplineFilters card
&& Filter.isAllowedWide Filter.pickPrimaryTraits model.primaryFilters card
Expand Down
53 changes: 52 additions & 1 deletion client/src/UI/FilterSelection.elm
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
module UI.FilterSelection exposing
( Model
( City
, Model
, Msg
, PrimaryTrait
, SecondaryTrait
, allStacks
, attackTypes
, city
, clans
, disciplines
, isAllowedStrict
, isAllowedWide
, isCityEnabled
, pickCity
, pickPrimaryTraits
, pickSecondaryTraits
, playerStacks
Expand All @@ -21,6 +25,7 @@ module UI.FilterSelection exposing
import Cards exposing (Card)
import Data.Clan as Clan
import Data.Discipline as Discipline exposing (Discipline)
import Data.Pack as Pack
import Html exposing (Html, div, input, label)
import Html.Attributes exposing (class, classList, type_)
import Html.Events exposing (onCheck)
Expand Down Expand Up @@ -105,6 +110,52 @@ playerStacks =
]


isCityEnabled : Model Cards.CardStack never -> Bool
isCityEnabled model =
case extractWhitelist model of
[] ->
True

stacks ->
List.member Cards.CityStack stacks


type City
= Core
| HeartOfEurope
| Conclave22


pickCity : Card -> List City
pickCity c =
case c of
Cards.CityCard { traits, set } ->
if traits.event then
case set of
Pack.Conclave22 ->
[ Conclave22 ]

Pack.HeartOfEurope ->
[ HeartOfEurope ]

_ ->
[ Core ]

else
[ Core, HeartOfEurope, Conclave22 ]

_ ->
[ Core, HeartOfEurope, Conclave22 ]


city : Model City never
city =
[ { value = Core, selected = False, icon = Icon.icon ( Icon.CityCore, Icon.Standard ) }
, { value = HeartOfEurope, selected = False, icon = Icon.icon ( Icon.CityHoE, Icon.Standard ) }
, { value = Conclave22, selected = False, icon = Icon.icon ( Icon.CityConclave, Icon.Standard ) }
]


type PrimaryTrait
= Action
| Attack
Expand Down
12 changes: 12 additions & 0 deletions client/src/UI/Icon.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type IconImage
| BloodPotencReq
| BloodPotency
| City
| CityConclave
| CityHoE
| CityCore
| Conspiracy
| Damage
| Delete
Expand Down Expand Up @@ -148,6 +151,15 @@ imageOpts image =
City ->
( class "ui-icon_city", "City" )

CityConclave ->
( class "ui-icon_city-conclave", "City - Conclave" )

CityCore ->
( class "ui-icon_city-core", "City - San Francisco" )

CityHoE ->
( class "ui-icon_city-hoe", "City - Prague" )

Conspiracy ->
( class "ui-icon_conspiracy", "Conspiracy" )

Expand Down
2 changes: 1 addition & 1 deletion client/src/UI/Icon.sass
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
span
visibility: hidden

$other_icons: action agenda alchemy animal attack blood bloodpotencyrequirement city conspiracy crown damage delete edit faction hand_of_cards haven influence influence_modifier leader library mental menu ongoing physical ranged reaction ritual save scheme shield skull social special title unhosted_action
$other_icons: action agenda alchemy animal attack blood bloodpotencyrequirement city city-conclave city-core city-hoe conspiracy crown damage delete edit faction hand_of_cards haven influence influence_modifier leader library mental menu ongoing physical ranged reaction ritual save scheme shield skull social special title unhosted_action
@each $icon in $other_icons
.ui-icon_#{$icon}
--svg-ui-icon: url("data-url:../../assets/icons/icon-#{$icon}.svg")
Expand Down
13 changes: 2 additions & 11 deletions server/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const tempCardImagesFolder = path.join(
"card-temp"
);
const logoFolder = path.join(dirname, "..", "..", "..", "..", "assets", "logo");
const svgFolder = path.join(dirname, "..", "..", "..", "..", "assets", "svg");

const clientDistFolder = path.join(
dirname,
Expand Down Expand Up @@ -74,7 +73,7 @@ export async function createServer(): Promise<Service> {
fastify.register(fastifyStatic, {
root: cardImagesFolder,
wildcard: false,
preCompressed: true,
preCompressed: false,
prefix: "/card",
decorateReply: false,
maxAge: "14d",
Expand All @@ -83,7 +82,7 @@ export async function createServer(): Promise<Service> {
fastify.register(fastifyStatic, {
root: tempCardImagesFolder,
wildcard: false,
preCompressed: true,
preCompressed: false,
prefix: "/card",
decorateReply: false,
maxAge: "2d",
Expand All @@ -97,14 +96,6 @@ export async function createServer(): Promise<Service> {
maxAge: "14d",
decorateReply: false,
});
fastify.register(fastifyStatic, {
root: svgFolder,
wildcard: false,
preCompressed: true,
prefix: "/svg",
maxAge: "14d",
decorateReply: false,
});
fastify.register(fastifyStatic, {
root: clientDistFolder,
wildcard: false,
Expand Down

0 comments on commit d6be23c

Please sign in to comment.