p7/Main.hs

91 lines
2.7 KiB
Haskell
Raw Normal View History

2018-06-24 21:18:15 -04:00
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings #-}
2018-06-22 00:23:58 -04:00
module Main where
2018-06-21 22:24:42 -04:00
2018-06-22 00:23:58 -04:00
import Data.Time.Clock
import Data.Time.Calendar
2018-06-24 21:18:15 -04:00
import Data.List
2018-06-24 19:21:29 -04:00
import Data.Maybe
2018-06-21 22:24:42 -04:00
import Packs
2018-06-24 17:26:43 -04:00
import State
2018-06-24 19:21:29 -04:00
import Format
import Timestamp
2018-06-24 19:47:53 -04:00
import Preview
2018-06-24 21:18:15 -04:00
import Yesod
import Config
2018-06-22 00:23:58 -04:00
2018-06-24 21:18:15 -04:00
data Chhf = Chhf
io :: MonadIO io => IO a -> io a
io = liftIO
putStrLnIO :: MonadIO io => String -> io ()
putStrLnIO = io . putStrLn
mkYesod "Chhf" [parseRoutes|
/ HomeR GET
|]
instance Yesod Chhf
inBoth :: (Eq a) => [a] -> [a] -> [a]
inBoth x y = filter (\n -> n `elem` y) x
getHomeR :: Handler Html
getHomeR = do
t <- io $ getCurrentTime >>= return . toGregorian . utctDay
2018-06-24 19:47:53 -04:00
let ts = toTS t
2018-06-24 21:18:15 -04:00
let ((i,o),b,r) = currentFormat ts
let bx = (\(Bq x) -> x)
let (_,ib,_) = initialRotation
let bbout = map show $ catMaybes $ inBoth (bx ib) (tail $ bx b)
let dpout = sort $ map show $ map (\(Ir n) -> n) i
let pr = getPreview ts
defaultLayout [whamlet|
<h1>CHHF - A Dunedin Netrunner Format
<h2>About
<p>The Chris Hay Honourary Format, a post-cancellation Netrunner format. #
2018-06-24 21:40:31 -04:00
The format consists of 18 packs at any time, and between 5 and 6 big boxes. #
2018-06-24 21:18:15 -04:00
The following rotation rules are in place:
<ul>
<li> Each month, the two packs that have been in rotation longest are rotated out, and two random packs are rotated in
<li> After a pack rotates out, it cannot rotate in for 3 months
<li> Each month, in release order, one big box (Including Terminal Directive) is banned for the month
<li> On the seventh month, all big boxes are legal
<p> The rotation updates on the first of each month, based on whatever time my server is set to (Probably NZ time but who knows really), and from the 20th of each month onwards, a preview of the upcoming changes will be shown.
<h2>Current Rotation:
<h3>Evergreen:
<ul>
<li>Revised Core Set x3
<h3>Big Boxes:
<ul>
$forall bb <- bbout
<li>#{bb}
<h3>Data-packs:
<ul>
$forall dp <- dpout
<li>#{dp}
<h2>Upcoming Changes:
$maybe (pin, pout, pbin, pbout) <- pr
<h3>In:
<ul>
$maybe pbbin <- pbin
<li>#{show pbbin}
$forall indp <- pin
<li>#{show indp}
<h3>Out:
<ul>
$maybe pbbout <- pbout
<li>#{show pbbout}
$forall outdp <- pout
<li>#{show outdp}
$nothing
<h3>Coming soon!
|]
main :: IO ()
main = warp 80 Chhf
2018-06-24 19:21:29 -04:00
toTS :: (Integer, Int, Int) -> Timestamp
toTS (y,m,d) = Ts (fromIntegral d) (fromIntegral m) y