Safe Haskell | None |
---|---|
Language | Haskell2010 |
A game requires the engine provided by the library, perhaps customized, and game content, defined completely afresh for the particular game. The possible kinds of content are fixed in the library and all defined within the library source code directory. On the other hand, game content, is defined in the directory hosting the particular game definition.
Content of a given kind is just a list of content items.
After the list is verified and the data preprocessed, it's held
in the ContentData
datatype.
Synopsis
- newtype ContentId c = ContentId Word16
- data ContentData c
- type Freqs a = [(GroupName a, Int)]
- type Rarity = [(Double, Int)]
- contentIdIndex :: ContentId k -> Int
- validateRarity :: Rarity -> [Text]
- emptyContentData :: ContentData a
- makeContentData :: (NFData c, Show c) => String -> (c -> Text) -> (c -> Freqs c) -> (c -> [Text]) -> ([c] -> ContentData c -> [Text]) -> [c] -> ContentData c
- okind :: ContentData a -> ContentId a -> a
- omemberGroup :: ContentData a -> GroupName a -> Bool
- oisSingletonGroup :: ContentData a -> GroupName a -> Bool
- ouniqGroup :: Show a => ContentData a -> GroupName a -> ContentId a
- opick :: Show a => ContentData a -> GroupName a -> (a -> Bool) -> Rnd (Maybe (ContentId a))
- ofoldrWithKey :: ContentData a -> (ContentId a -> a -> b -> b) -> b -> b
- ofoldlWithKey' :: ContentData a -> (b -> ContentId a -> a -> b) -> b -> b
- ofoldlGroup' :: ContentData a -> GroupName a -> (b -> Int -> ContentId a -> a -> b) -> b -> b
- omapVector :: ContentData a -> (a -> b) -> Vector b
- oimapVector :: ContentData a -> (ContentId a -> a -> b) -> Vector b
- olength :: ContentData a -> Int
Documentation
Content identifiers for the content type c
.
Instances
Enum (ContentId c) Source # | |
Defined in Game.LambdaHack.Common.ContentData succ :: ContentId c -> ContentId c # pred :: ContentId c -> ContentId c # toEnum :: Int -> ContentId c # fromEnum :: ContentId c -> Int # enumFrom :: ContentId c -> [ContentId c] # enumFromThen :: ContentId c -> ContentId c -> [ContentId c] # enumFromTo :: ContentId c -> ContentId c -> [ContentId c] # enumFromThenTo :: ContentId c -> ContentId c -> ContentId c -> [ContentId c] # | |
Eq (ContentId c) Source # | |
Ord (ContentId c) Source # | |
Defined in Game.LambdaHack.Common.ContentData | |
Show (ContentId c) Source # | |
Generic (ContentId c) Source # | |
Binary (ContentId c) Source # | |
NFData (ContentId c) Source # | |
Defined in Game.LambdaHack.Common.ContentData | |
Hashable (ContentId c) Source # | |
Defined in Game.LambdaHack.Common.ContentData | |
UnboxRepClass (ContentId k) Source # | |
type Rep (ContentId c) Source # | |
Defined in Game.LambdaHack.Common.ContentData | |
type UnboxRep (ContentId k) Source # | |
Defined in Game.LambdaHack.Common.ContentData |
data ContentData c Source #
Verified and preprocessed content data of a particular kind.
Instances
Generic (ContentData c) Source # | |
Defined in Game.LambdaHack.Common.ContentData type Rep (ContentData c) :: * -> * # from :: ContentData c -> Rep (ContentData c) x # to :: Rep (ContentData c) x -> ContentData c # | |
NFData c => NFData (ContentData c) Source # | |
Defined in Game.LambdaHack.Common.ContentData rnf :: ContentData c -> () # | |
type Rep (ContentData c) Source # | |
Defined in Game.LambdaHack.Common.ContentData type Rep (ContentData c) = D1 (MetaData "ContentData" "Game.LambdaHack.Common.ContentData" "LambdaHack-0.8.1.2-9Fmfvbfsr9xEInnejydwaW" False) (C1 (MetaCons "ContentData" PrefixI True) (S1 (MetaSel (Just "contentVector") NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 (Vector c)) :*: S1 (MetaSel (Just "groupFreq") NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 (Map (GroupName c) [(Int, (ContentId c, c))])))) |
type Freqs a = [(GroupName a, Int)] Source #
For each group that the kind belongs to, denoted by a GroupName
in the first component of a pair, the second component of a pair shows
how common the kind is within the group.
contentIdIndex :: ContentId k -> Int Source #
validateRarity :: Rarity -> [Text] Source #
:: (NFData c, Show c) | |
=> String | |
-> (c -> Text) | name of the content itme, used for validation |
-> (c -> Freqs c) | frequency in groups, for validation and preprocessing |
-> (c -> [Text]) | validate a content item and list all offences |
-> ([c] -> ContentData c -> [Text]) | validate the whole defined content of this type and list all offence |
-> [c] | all content of this type |
-> ContentData c |
okind :: ContentData a -> ContentId a -> a Source #
Content element at given id.
omemberGroup :: ContentData a -> GroupName a -> Bool Source #
oisSingletonGroup :: ContentData a -> GroupName a -> Bool Source #
ouniqGroup :: Show a => ContentData a -> GroupName a -> ContentId a Source #
The id of the unique member of a singleton content group.
opick :: Show a => ContentData a -> GroupName a -> (a -> Bool) -> Rnd (Maybe (ContentId a)) Source #
Pick a random id belonging to a group and satisfying a predicate.
ofoldrWithKey :: ContentData a -> (ContentId a -> a -> b -> b) -> b -> b Source #
Fold over all content elements of a
.
ofoldlWithKey' :: ContentData a -> (b -> ContentId a -> a -> b) -> b -> b Source #
Fold strictly over all content a
.
ofoldlGroup' :: ContentData a -> GroupName a -> (b -> Int -> ContentId a -> a -> b) -> b -> b Source #
Fold over the given group only.
omapVector :: ContentData a -> (a -> b) -> Vector b Source #
oimapVector :: ContentData a -> (ContentId a -> a -> b) -> Vector b Source #
olength :: ContentData a -> Int Source #
Size of content a
.