LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Server.ItemRev

Contents

- Item discovery types
- The `FlavourMap` type
- Important implementation parts, exposed for tests
- Internal operations

Description

Creation of items on the server. Types and operations that don't involve server state nor our custom monads.

Synopsis

- data ItemKnown = ItemKnown ItemIdentity AspectRecord (Maybe FactionId)
- data NewItem
  - = NewItem (GroupName ItemKind) ItemKnown ItemFull ItemQuant
  - | NoNewItem
- type ItemRev = HashMap ItemKnown ItemId
- type UniqueSet = EnumSet (ContentId ItemKind)
- newItemKind :: COps -> UniqueSet -> Freqs ItemKind -> AbsDepth -> AbsDepth -> Int -> Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind)
- newItem :: COps -> Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind) -> FlavourMap -> DiscoveryKindRev -> AbsDepth -> AbsDepth -> Rnd NewItem
- data DiscoveryKindRev
- emptyDiscoveryKindRev :: DiscoveryKindRev
- serverDiscos :: COps -> DiscoveryKindRev -> Rnd (DiscoveryKind, DiscoveryKindRev)
- data FlavourMap
- emptyFlavourMap :: FlavourMap
- dungeonFlavourMap :: COps -> FlavourMap -> Rnd FlavourMap
- rollFlavourMap :: Vector Word16 -> Rnd (EnumMap (ContentId ItemKind) Flavour, EnumMap (ContentSymbol ItemKind) (EnumSet Flavour)) -> ContentId ItemKind -> ItemKind -> Rnd (EnumMap (ContentId ItemKind) Flavour, EnumMap (ContentSymbol ItemKind) (EnumSet Flavour))
- buildItem :: COps -> AspectRecord -> FlavourMap -> DiscoveryKindRev -> ContentId ItemKind -> Item
- keepMetaGameInformation :: ContentData ItemKind -> Vector Word16 -> Vector Word16

# Documentation

data ItemKnown Source #

The essential item properties, used for the `ItemRev` hash table from items to their ids, needed to assign ids to newly generated items. All the other meaningful properties can be derived from them. Note: item seed instead of `AspectRecord` is not enough, becaused different seeds may result in the same `AspectRecord` and we don't want such items to be distinct in UI and elsewhere.

Constructors

ItemKnown ItemIdentity AspectRecord (Maybe FactionId) |

#### Instances

Instances details

Binary ItemKnown Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods put :: ItemKnown -> Put Source # get :: Get ItemKnown Source # putList :: [ItemKnown] -> Put Source #
Generic ItemKnown Source # |

Instance details

Defined in Game.LambdaHack.Server.ItemRev

Associated Types

type Rep ItemKnown |

Instance details

Defined in Game.LambdaHack.Server.ItemRev

type Rep ItemKnown = D1 ('MetaData "ItemKnown" "Game.LambdaHack.Server.ItemRev" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "ItemKnown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemIdentity) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 AspectRecord) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe FactionId)))))

Methods

from :: ItemKnown -> Rep ItemKnown x Source #

to :: Rep ItemKnown x -> ItemKnown Source #

Show ItemKnown Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods showsPrec :: Int -> ItemKnown -> ShowS Source # show :: ItemKnown -> String Source # showList :: [ItemKnown] -> ShowS Source #
Eq ItemKnown Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods (==) :: ItemKnown -> ItemKnown -> Bool Source # (/=) :: ItemKnown -> ItemKnown -> Bool Source #
Hashable ItemKnown Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods hashWithSalt :: Int -> ItemKnown -> Int Source # hash :: ItemKnown -> Int Source #
type Rep ItemKnown Source # |

Instance details

Defined in Game.LambdaHack.Server.ItemRev

type Rep ItemKnown = D1 ('MetaData "ItemKnown" "Game.LambdaHack.Server.ItemRev" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "ItemKnown" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ItemIdentity) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 AspectRecord) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe FactionId)))))

data NewItem Source #

Constructors

NewItem (GroupName ItemKind) ItemKnown ItemFull ItemQuant |
NoNewItem |

type ItemRev = HashMap ItemKnown ItemId Source #

Reverse item map, for item creation, to keep items and item identifiers in bijection.

type UniqueSet = EnumSet (ContentId ItemKind) Source #

newItemKind :: COps -> UniqueSet -> Freqs ItemKind -> AbsDepth -> AbsDepth -> Int -> Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind) Source #

Roll an item kind based on given `Freqs` and kind rarities

newItem :: COps -> Frequency (GroupName ItemKind, ContentId ItemKind, ItemKind) -> FlavourMap -> DiscoveryKindRev -> AbsDepth -> AbsDepth -> Rnd NewItem Source #

Given item kind frequency, roll item kind, generate item aspects based on level and put together the full item data set.

# Item discovery types

data DiscoveryKindRev Source #

The reverse map to `DiscoveryKind`, needed for item creation. This is total and never changes, hence implemented as vector. Morally, it's indexed by `ContentId ItemKind` and elements are `ItemKindIx`.

#### Instances

Instances details

Binary DiscoveryKindRev Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods put :: DiscoveryKindRev -> Put Source # get :: Get DiscoveryKindRev Source # putList :: [DiscoveryKindRev] -> Put Source #
Show DiscoveryKindRev Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods showsPrec :: Int -> DiscoveryKindRev -> ShowS Source # show :: DiscoveryKindRev -> String Source # showList :: [DiscoveryKindRev] -> ShowS Source #

emptyDiscoveryKindRev :: DiscoveryKindRev Source #

serverDiscos :: COps -> DiscoveryKindRev -> Rnd (DiscoveryKind, DiscoveryKindRev) Source #

# The `FlavourMap` type

data FlavourMap Source #

Flavours assigned by the server to item kinds, in this particular game. This is total and never changes, hence implemented as vector. Morally, it's indexed by `ContentId ItemKind` and elements are `Flavour`.

#### Instances

Instances details

Binary FlavourMap Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods put :: FlavourMap -> Put Source # get :: Get FlavourMap Source # putList :: [FlavourMap] -> Put Source #
Show FlavourMap Source # |
Instance details Defined in Game.LambdaHack.Server.ItemRev Methods showsPrec :: Int -> FlavourMap -> ShowS Source # show :: FlavourMap -> String Source # showList :: [FlavourMap] -> ShowS Source #

emptyFlavourMap :: FlavourMap Source #

dungeonFlavourMap :: COps -> FlavourMap -> Rnd FlavourMap Source #

Randomly chooses flavour for all item kinds for this game.

# Important implementation parts, exposed for tests

rollFlavourMap :: Vector Word16 -> Rnd (EnumMap (ContentId ItemKind) Flavour, EnumMap (ContentSymbol ItemKind) (EnumSet Flavour)) -> ContentId ItemKind -> ItemKind -> Rnd (EnumMap (ContentId ItemKind) Flavour, EnumMap (ContentSymbol ItemKind) (EnumSet Flavour)) Source #

Assigns flavours to item kinds. Assures no flavor is repeated for the same symbol, except for items with only one permitted flavour.

# Internal operations

buildItem :: COps -> AspectRecord -> FlavourMap -> DiscoveryKindRev -> ContentId ItemKind -> Item Source #

Build an item with the given kind and aspects.

keepMetaGameInformation :: ContentData ItemKind -> Vector Word16 -> Vector Word16 Source #

Keep in a vector the information that is retained from playthrough to playthrough. The information being, e.g., `ItemKindIx` or `Flavour`. The information is morally indexed by `ContentId ItemKind` and its `Enum` instance fits in `Word16`.