everything starts to connect, still a big mess though !!
This commit is contained in:
33
src/Page.elm
33
src/Page.elm
@@ -5,7 +5,6 @@ import Api.Player
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (..)
|
||||
import Page.Admin as Admin
|
||||
import Page.Dashboard as Dashboard
|
||||
import Page.GroupChest as GroupChest
|
||||
import Page.Shop as Shop
|
||||
@@ -33,7 +32,7 @@ mapMsg toMsg =
|
||||
maybeSession page =
|
||||
case page of
|
||||
Dashboard model ->
|
||||
Just <| Session.getSession model
|
||||
Just <| Dashboard.getSession model
|
||||
|
||||
GroupChest model ->
|
||||
Just <| Session.getSession model
|
||||
@@ -83,7 +82,7 @@ view page =
|
||||
case maybeSession page of
|
||||
Just session ->
|
||||
case Session.user session of
|
||||
Session.Player player _ ->
|
||||
Session.Player player _ _ ->
|
||||
player.name
|
||||
|
||||
Session.Admin ->
|
||||
@@ -96,7 +95,7 @@ view page =
|
||||
case maybeSession page of
|
||||
Just session ->
|
||||
case Session.user session of
|
||||
Session.Player player _ ->
|
||||
Session.Player player _ _ ->
|
||||
let
|
||||
linkWithGem =
|
||||
navLink "fas fa-gem"
|
||||
@@ -131,7 +130,7 @@ viewSessionBar session controls =
|
||||
Nothing ->
|
||||
[ text "" ]
|
||||
|
||||
Just (Session.Player player wealth) ->
|
||||
Just (Session.Player player wealth _) ->
|
||||
let
|
||||
_ =
|
||||
Debug.log "viewSessionBar wealth" player.wealth
|
||||
@@ -179,8 +178,6 @@ navLink icon linkText url =
|
||||
|
||||
-- UPDATE
|
||||
--
|
||||
-- Note : All pages 'update' function
|
||||
-- shall return (subMode, Cmd Api.Msg)
|
||||
|
||||
|
||||
type PageMsg
|
||||
@@ -203,7 +200,7 @@ map func page =
|
||||
Just session ->
|
||||
case page of
|
||||
Dashboard model ->
|
||||
Dashboard { model | session = func session }
|
||||
Dashboard <| Dashboard.updateSession model (func session)
|
||||
|
||||
GroupChest model ->
|
||||
GroupChest { model | session = func session }
|
||||
@@ -224,6 +221,9 @@ update msg page =
|
||||
( GotGroupChestMsg _, _, _ ) ->
|
||||
( page, Cmd.none )
|
||||
|
||||
( GotDashboardMsg (Dashboard.Api apiMsg), Dashboard home, _ ) ->
|
||||
update (ApiMsg apiMsg) page
|
||||
|
||||
( GotDashboardMsg subMsg, Dashboard home, _ ) ->
|
||||
Dashboard.update subMsg home
|
||||
|> updatePage Dashboard GotDashboardMsg
|
||||
@@ -231,6 +231,9 @@ update msg page =
|
||||
( GotDashboardMsg _, _, _ ) ->
|
||||
( page, Cmd.none )
|
||||
|
||||
( GotShopMsg (Shop.Api apiMsg), Shop shop, _ ) ->
|
||||
update (ApiMsg apiMsg) page
|
||||
|
||||
( GotShopMsg subMsg, Shop shop, _ ) ->
|
||||
Shop.update subMsg shop
|
||||
|> updatePage Shop GotShopMsg
|
||||
@@ -244,7 +247,7 @@ update msg page =
|
||||
Session.wealth session
|
||||
in
|
||||
case Session.user session of
|
||||
Session.Player player aModel ->
|
||||
Session.Player player aModel _ ->
|
||||
let
|
||||
( newWealth, maybeEdit ) =
|
||||
Wealth.update wealthMsg aModel
|
||||
@@ -328,15 +331,16 @@ applyUpdate u user =
|
||||
in
|
||||
{- Note: DbUpdates always refer to the active player -}
|
||||
case user of
|
||||
Session.Player player wealthModel ->
|
||||
Session.Player player wealthModel loot ->
|
||||
case u of
|
||||
Api.ItemRemoved item ->
|
||||
--List.filter (\i -> i.id /= item.id) model.state.playerLoot
|
||||
user
|
||||
Session.Player player wealthModel <|
|
||||
List.filter
|
||||
(\i -> i.id /= item.id)
|
||||
loot
|
||||
|
||||
Api.ItemAdded item ->
|
||||
--{ model | state = { state | playerLoot = item :: model.state.playerLoot } }
|
||||
user
|
||||
Session.Player player wealthModel (item :: loot)
|
||||
|
||||
Api.WealthUpdated diff ->
|
||||
let
|
||||
@@ -356,6 +360,7 @@ applyUpdate u user =
|
||||
(wealth.pp + diff.pp)
|
||||
}
|
||||
wealthModel
|
||||
loot
|
||||
|
||||
Api.ClaimAdded claim ->
|
||||
-- { model | claims = claim :: model.claims }
|
||||
|
||||
Reference in New Issue
Block a user