While i have coded a card game called speed before (in Delphi 6 no less, which was kind of a nightmare compared to LÖVE and lua), i never coded solitaire, but i can tell you how i'd implement it:
Code: Select all
-- Data:
-- French cards, so we have 52 individual ones, 4 suites of 13 values.
-- 7 "slots" where you "work", 4 where you store the 4 suites, 1 where the deck you pull from is, and another where a card from the deck is revealed.
-- Functionality or Rules:
-- The cards have these increasing values: "A23456789JQK"
-- Drawing a card transfers it from the deck to the slot next to it, this is repeatable (and the deck will be reset when you get to the last card)
-- You can move only the top card in the 7 working slots, or flip it if it's not yet flipped; you can only move cards onto another if the current one is both a different color, and the value difference is one. You can only move a king to an empty space, should you have one.
- You can only incrementally place cards in the 4 upper slots
Do note that you can do it in many more different ways too, like you could forget the slots, and just on-the-fly mess with x,y positions of cards, and whether they are flipped or not, or you could store cards only as tables in the slots, having 3-parameter values of suit,value,flipped or something.
Also, there are variants like when you take 3 cards from the deck at once, or when the deck can't be flipped back after you went through all the cards.
Things like whether you can drag cards or just click them to select them are minute implementation details, though.
All this said, i'd recommend you reading
the PIL, the [wiki]love[/wiki] wiki at least, and try doing it yourself. Money doesn't solve problems you know