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

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Common.HighScore

Contents

- Internal operations

Description

High score table operations.

Synopsis

- data ScoreTable
- type ScoreDict = EnumMap (ContentId ModeKind) ScoreTable
- empty :: ScoreDict
- register :: ScoreTable -> Int -> Int -> Time -> Status -> POSIXTime -> Challenge -> Text -> EnumMap (ContentId ItemKind) Int -> EnumMap (ContentId ItemKind) Int -> HiCondPoly -> (Bool, (ScoreTable, Int))
- showScore :: TimeZone -> Int -> ScoreRecord -> [Text]
- showAward :: Int -> ScoreTable -> Int -> Text -> Text
- getTable :: ContentId ModeKind -> ScoreDict -> ScoreTable
- unTable :: ScoreTable -> [ScoreRecord]
- getRecord :: Int -> ScoreTable -> ScoreRecord
- getStatus :: ScoreRecord -> Status
- getDate :: ScoreRecord -> POSIXTime
- data ScoreRecord
- insertPos :: ScoreRecord -> ScoreTable -> (ScoreTable, Int)

# Documentation

data ScoreTable Source #

The list of scores, in decreasing order.

#### Instances

Instances details

Binary ScoreTable Source # |
Instance details Defined in Game.LambdaHack.Common.HighScore Methods put :: ScoreTable -> Put Source # get :: Get ScoreTable Source # putList :: [ScoreTable] -> Put Source #
Show ScoreTable Source # |
Instance details Defined in Game.LambdaHack.Common.HighScore Methods showsPrec :: Int -> ScoreTable -> ShowS Source # show :: ScoreTable -> String Source # showList :: [ScoreTable] -> ShowS Source #
Eq ScoreTable Source # |
Instance details Defined in Game.LambdaHack.Common.HighScore Methods (==) :: ScoreTable -> ScoreTable -> Bool Source # (/=) :: ScoreTable -> ScoreTable -> Bool Source #

type ScoreDict = EnumMap (ContentId ModeKind) ScoreTable Source #

A dictionary from game mode IDs to scores tables.

empty :: ScoreDict Source #

Empty score table

register Source #

Arguments

:: ScoreTable | old table
-> Int | the total value of faction items
-> Int | the total value of dungeon items
-> Time | game time spent
-> Status | reason of the game interruption
-> POSIXTime | current date
-> Challenge | challenge setup
-> Text | name of the faction's gkind
-> EnumMap (ContentId ItemKind) Int | allies lost
-> EnumMap (ContentId ItemKind) Int | foes killed
-> HiCondPoly |
-> (Bool, (ScoreTable, Int)) |

Register a new score in a score table.

showScore :: TimeZone -> Int -> ScoreRecord -> [Text] Source #

Show a single high score, from the given ranking in the high score table.

showAward Source #

Arguments

:: Int | number of (3-line) scores to be shown
-> ScoreTable | current score table
-> Int | position of the current score in the table
-> Text | the name of the game mode
-> Text |

getTable :: ContentId ModeKind -> ScoreDict -> ScoreTable Source #

unTable :: ScoreTable -> [ScoreRecord] Source #

getRecord :: Int -> ScoreTable -> ScoreRecord Source #

getStatus :: ScoreRecord -> Status Source #

getDate :: ScoreRecord -> POSIXTime Source #

# Internal operations

data ScoreRecord Source #

A single score record. Records are ordered in the highscore table, from the best to the worst, in lexicographic ordering wrt the fields below.

#### Instances

Instances details

Binary ScoreRecord Source # |
Instance details Defined in Game.LambdaHack.Common.HighScore Methods put :: ScoreRecord -> Put Source # get :: Get ScoreRecord Source # putList :: [ScoreRecord] -> Put Source #
Generic ScoreRecord Source # |

Instance details

Defined in Game.LambdaHack.Common.HighScore

Associated Types

type Rep ScoreRecord |

Instance details

Defined in Game.LambdaHack.Common.HighScore

type Rep ScoreRecord = D1 ('MetaData "ScoreRecord" "Game.LambdaHack.Common.HighScore" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "ScoreRecord" 'PrefixI 'True) (((S1 ('MetaSel ('Just "points") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "negTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Time)) :*: (S1 ('MetaSel ('Just "date") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 POSIXTime) :*: S1 ('MetaSel ('Just "status") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Status))) :*: ((S1 ('MetaSel ('Just "challenge") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Challenge) :*: S1 ('MetaSel ('Just "gkindName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "ourVictims") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (EnumMap (ContentId ItemKind) Int)) :*: S1 ('MetaSel ('Just "theirVictims") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (EnumMap (ContentId ItemKind) Int))))))

Methods

from :: ScoreRecord -> Rep ScoreRecord x Source #

to :: Rep ScoreRecord x -> ScoreRecord Source #

Eq ScoreRecord Source # |
Instance details Defined in Game.LambdaHack.Common.HighScore Methods (==) :: ScoreRecord -> ScoreRecord -> Bool Source # (/=) :: ScoreRecord -> ScoreRecord -> Bool Source #
Ord ScoreRecord Source # |

Instance details

Defined in Game.LambdaHack.Common.HighScore

Methods

compare :: ScoreRecord -> ScoreRecord -> Ordering Source #

(<) :: ScoreRecord -> ScoreRecord -> Bool Source #

(<=) :: ScoreRecord -> ScoreRecord -> Bool Source #

(>) :: ScoreRecord -> ScoreRecord -> Bool Source #

(>=) :: ScoreRecord -> ScoreRecord -> Bool Source #

max :: ScoreRecord -> ScoreRecord -> ScoreRecord Source #

min :: ScoreRecord -> ScoreRecord -> ScoreRecord Source #

type Rep ScoreRecord Source # |

Instance details

Defined in Game.LambdaHack.Common.HighScore

type Rep ScoreRecord = D1 ('MetaData "ScoreRecord" "Game.LambdaHack.Common.HighScore" "LambdaHack-0.11.0.1-BLuOaw8nuizISmzkanqI8h" 'False) (C1 ('MetaCons "ScoreRecord" 'PrefixI 'True) (((S1 ('MetaSel ('Just "points") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "negTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Time)) :*: (S1 ('MetaSel ('Just "date") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 POSIXTime) :*: S1 ('MetaSel ('Just "status") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Status))) :*: ((S1 ('MetaSel ('Just "challenge") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Challenge) :*: S1 ('MetaSel ('Just "gkindName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "ourVictims") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (EnumMap (ContentId ItemKind) Int)) :*: S1 ('MetaSel ('Just "theirVictims") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (EnumMap (ContentId ItemKind) Int))))))

insertPos :: ScoreRecord -> ScoreTable -> (ScoreTable, Int) Source #

Insert a new score into the table, Return new table and the ranking. Make sure the table doesn't grow too large.