| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Game.Calc
Description
Game calculations and its processing functions
Synopsis
- data PlayerInput = PlayerInput {
- username :: String
- board :: [Combination]
- scoop :: Bool
- withFantasy :: Bool
- data LineResult
- data LineType
- data PlayerCalculations = PlayerCalculations {
- player :: PlayerInput
- top :: LineResult
- middle :: LineResult
- bottom :: LineResult
- isScoop :: Bool
- isNextFantasy :: Bool
- totalDetailed :: (String, [LineCompareResult])
- total :: Int
- comparePlayers :: PlayerInput -> PlayerInput -> LineCompareResult
- calcGame :: [PlayerInput] -> [PlayerCalculations]
Documentation
data PlayerInput Source #
Constructors
| PlayerInput | |
Fields
| |
Instances
data LineResult Source #
Data container for line result for the user.
Contains data about type of line (position - topmiddlebottom), about points for the combination, total values for combo/bonus points after comparison with others.
Instances
Instances
| Show LineType Source # | |
| Generic LineType Source # | |
| FromJSON LineType Source # | |
Defined in Game.Calc | |
| ToJSON LineType Source # | |
Defined in Game.Calc Methods toEncoding :: LineType -> Encoding toJSONList :: [LineType] -> Value toEncodingList :: [LineType] -> Encoding | |
| type Rep LineType Source # | |
Defined in Game.Calc | |
data PlayerCalculations Source #
Container for result of calculations for each player.
Contains data about given player input,
description of each line in form of LineResult,
some utility bool values, such as isScoop, isNextFantasy.
Also has total sum of points for user after comparison.
And a debug detailed version of the total (totalDetailed field).
Constructors
| PlayerCalculations | |
Fields
| |
Instances
| Generic PlayerCalculations Source # | |
Defined in Game.Calc Associated Types type Rep PlayerCalculations :: Type -> Type # Methods from :: PlayerCalculations -> Rep PlayerCalculations x # to :: Rep PlayerCalculations x -> PlayerCalculations # | |
| FromJSON PlayerCalculations Source # | |
Defined in Game.Calc Methods parseJSON :: Value -> Parser PlayerCalculations parseJSONList :: Value -> Parser [PlayerCalculations] | |
| ToJSON PlayerCalculations Source # | |
Defined in Game.Calc Methods toJSON :: PlayerCalculations -> Value toEncoding :: PlayerCalculations -> Encoding toJSONList :: [PlayerCalculations] -> Value toEncodingList :: [PlayerCalculations] -> Encoding | |
| type Rep PlayerCalculations Source # | |
Defined in Game.Calc | |
comparePlayers :: PlayerInput -> PlayerInput -> LineCompareResult Source #
Function to compare PlayerInput records and retrieve calculated points.
Takes two PlayerInput as input. Returns calculated points in form of LineCompareResult
calcGame :: [PlayerInput] -> [PlayerCalculations] Source #
Main function for game calculation.
Takes a list of 'PlayerInput;, which length should be 3.
Return a list of PlayerCalculations.
First of all, function receives all players comparison using collectLinesResults.
Then it checks for input conditions:
length of input and length of comparison results should be equal and should equal 3.
Then for each of player input function creates PlayerCalculations record.