70 likes | 181 Views
T ask O riented P rogramming i n using Rinus Plasmeijer – Bas Lijnse - Peter Achten Pieter Koopman - Steffen Michels - Jurriën Stutterheim Jan Martin Jansen (NLDA) - Laszlo Domoszlai (ELTE) LIGRETTO CASE STUDY. Ligretto (slightly simplified version).
E N D
Task Oriented Programming in using Rinus Plasmeijer–Bas Lijnse- Peter Achten Pieter Koopman- Steffen Michels-JurriënStutterheim Jan Martin Jansen (NLDA) - Laszlo Domoszlai (ELTE) LIGRETTO CASE STUDY
Ligretto (slightly simplified version) • A card game for 2 upto 4 players • Card attributes: • numbered (1 .. 10) • front color (red, green, blue, yellow) • back color (red, green, blue, yellow) • Each player has 40 cards: of each color all possible 10 values
Ligretto: initial set-up (4 players) middle 2 - 10 1 3 hand (concealed, discard) ligretto (10 cards) row
Ligretto: play the game middle • only cards from row and discard can be placed in middle • new pile in middle starts with card value 1 • on a middle pile only a card with same front color and value 1 higher can be placed • cards taken from row are immediately replaced by top card from ligretto pile • flip top 3 concealed cards to discard pile • if concealed pile is empty, shuffle discard pile and move to concealed pile • game ends as soon as first ligretto pile is empty 2 - 10 1 3 hand (concealed, discard) ligretto (10 cards) row
Getting started: ligretto.dcl • :: NrOfPlayers :== Int • :: Middle :== [Pile] • :: Pile :== [Card] • :: Card = { back :: Color • , front :: Color • , nr :: Int } • :: SideUp = Front | Back • :: Color = Red | Green | Blue | Yellow • :: Player = { color :: Color • , row :: Row • , ligretto :: Pile • , hand :: Hand } • :: Row :== [Card] • :: Hand = { conceal :: Pile • , discard :: Pile }
Getting started: ligretto.dcl • nr_of_cards_in_row :: NrOfPlayers -> Int • colors :: NrOfPlayers -> [Color] • initial_player :: NrOfPlayers Color Int -> Player • row_card :: Int Player -> Card • move_ligretto_card_to_row :: Int Player -> Player • top_discard :: Player -> Maybe Card • shuffle_hand :: Int Player -> Player • remove_top_of_discard :: Player -> Player • swap_discards :: Player -> Player • card_matches_top_of_pile :: Card Pile -> Bool
Getting started: ligrettoTOP.icl • view_card :: SideUp Card -> HtmlTag • play_ligretto :: Task Color