ofc-calc-haskell-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Game.Calc

Description

Game calculations and its processing functions

Synopsis

Documentation

data PlayerInput Source #

Constructors

PlayerInput 

Instances

Instances details
Show PlayerInput Source # 
Instance details

Defined in Game.Calc

Generic PlayerInput Source # 
Instance details

Defined in Game.Calc

Associated Types

type Rep PlayerInput :: Type -> Type #

FromJSON PlayerInput Source # 
Instance details

Defined in Game.Calc

Methods

parseJSON :: Value -> Parser PlayerInput

parseJSONList :: Value -> Parser [PlayerInput]

ToJSON PlayerInput Source # 
Instance details

Defined in Game.Calc

Methods

toJSON :: PlayerInput -> Value

toEncoding :: PlayerInput -> Encoding

toJSONList :: [PlayerInput] -> Value

toEncodingList :: [PlayerInput] -> Encoding

type Rep PlayerInput Source # 
Instance details

Defined in Game.Calc

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 details
Show LineResult Source # 
Instance details

Defined in Game.Calc

Generic LineResult Source # 
Instance details

Defined in Game.Calc

Associated Types

type Rep LineResult :: Type -> Type #

FromJSON LineResult Source # 
Instance details

Defined in Game.Calc

Methods

parseJSON :: Value -> Parser LineResult

parseJSONList :: Value -> Parser [LineResult]

ToJSON LineResult Source # 
Instance details

Defined in Game.Calc

Methods

toJSON :: LineResult -> Value

toEncoding :: LineResult -> Encoding

toJSONList :: [LineResult] -> Value

toEncodingList :: [LineResult] -> Encoding

type Rep LineResult Source # 
Instance details

Defined in Game.Calc

data LineType Source #

Constructors

Top 
Middle 
Bottom 

Instances

Instances details
Show LineType Source # 
Instance details

Defined in Game.Calc

Generic LineType Source # 
Instance details

Defined in Game.Calc

Associated Types

type Rep LineType :: Type -> Type #

Methods

from :: LineType -> Rep LineType x #

to :: Rep LineType x -> LineType #

FromJSON LineType Source # 
Instance details

Defined in Game.Calc

Methods

parseJSON :: Value -> Parser LineType

parseJSONList :: Value -> Parser [LineType]

ToJSON LineType Source # 
Instance details

Defined in Game.Calc

Methods

toJSON :: LineType -> Value

toEncoding :: LineType -> Encoding

toJSONList :: [LineType] -> Value

toEncodingList :: [LineType] -> Encoding

type Rep LineType Source # 
Instance details

Defined in Game.Calc

type Rep LineType = D1 ('MetaData "LineType" "Game.Calc" "ofc-calc-haskell-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Top" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Middle" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bottom" 'PrefixI 'False) (U1 :: Type -> Type)))

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 

Instances

Instances details
Generic PlayerCalculations Source # 
Instance details

Defined in Game.Calc

Associated Types

type Rep PlayerCalculations :: Type -> Type #

FromJSON PlayerCalculations Source # 
Instance details

Defined in Game.Calc

Methods

parseJSON :: Value -> Parser PlayerCalculations

parseJSONList :: Value -> Parser [PlayerCalculations]

ToJSON PlayerCalculations Source # 
Instance details

Defined in Game.Calc

type Rep PlayerCalculations Source # 
Instance details

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.