adds replaceShop from items

This commit is contained in:
2019-11-26 21:15:16 +01:00
parent a81d184af6
commit 89b22bb07d
8 changed files with 731 additions and 140 deletions

View File

@@ -1,9 +1,8 @@
module Page.Chest exposing (..)
module Page.Chest exposing (Model, Msg, init, setContent, update, view)
import Api
exposing
( ActionMode(..)
, Claims
( Claims
, HttpResult
, Item
, Loot
@@ -22,8 +21,132 @@ import Set exposing (Set)
import Utils exposing (..)
setContent : ChestContent -> Model -> Model
setContent content model =
update (SetContent content) model
|> Tuple.first
-- MODEL
{-
type alias ViewConfig =
{ filterText : String
}
type alias Selection data =
{ selection : Set Int -- Set of selected items
, selectionData : Dict Int data -- Data associated by id
}
type alias AddConfig =
{ showModal : Bool
, autoComplete : Loot
, newItem : Maybe Item
, sourceName : Maybe String
, itemList : Maybe (List String)
}
type ChestMsg
= ConfirmAction
| CancelAction
| EnterMode ActionMode
| ViewMsg
| SelectionMsg
| AddMsg
type Content
= PlayerLoot Int
| GroupLoot
| MerchantShop
| Inventory
type Context
= View String
| Sell (Selection Int)
| Buy (Selection Int)
| Grab (Selection ())
| Add AddConfig
type Chest
= Chest Context Loot
type Chest
= View ViewConfig Loot
| Sell Selection Loot
| Buy Selection Loot
| Grab Selection Loot
| Add AddConfig Loot
type alias Cache =
{ playerLoot : ...
, ...
, claims : Claims
}
-- Leading to new model
type alias Model =
{ navKey: Nav.Key
, error : Maybe String
, notification : Maybe String
, player : Player
, wealth : Wealth.Model
, cache : Cache
, chest : Chest
}
-- Hence,
type ViewMsg
= SetContent ChestContent
| SearchTextChanged String
type AddMsg
= NewItemAdded Item
| NewItemNameChanged String
| NewItemPriceChanged String
| SourceNameChanged String
| SetNewItem Item
| OpenModal
| FromListChanged String
| FromListConfirmed
| NewItemsFromList Loot (Maybe String)
type SelectionMsg
= SetSelection (Maybe Selection)
| SwitchSelectionState Int
-- Buy/Sell modes
| PriceModifierChanged Int String
| WealthMsg Wealth.Msg
type Msg
= ApiMsg Api.Msg
| GotLoot Api.ToChest (HttpResult Loot)
| GotClaims (HttpResult Claims)
| GotPlayer (HttpResult Player)
| ClearNotification
| GotChestMsg ChestMsg
-}
type ActionMode
= View
| Sell
| Buy
| Grab
| Add
type alias State =
@@ -31,6 +154,7 @@ type alias State =
, error : Maybe String
, notification : Maybe String
-- Chest state
-- Buy/Sell loot
, priceModifiers : Dict Int Int
@@ -58,9 +182,13 @@ type alias Selection =
type alias Model =
{ navKey : Nav.Key
, state : State
-- Chest
, shown : Route.ChestContent
, selection : Maybe Selection
, searchText : String
-- Others
, wealth : Wealth.Model
, claims : Claims
}