summaryrefslogtreecommitdiff
path: root/Userland/Games/Solitaire/Game.h
AgeCommit message (Collapse)Author
2021-09-06Solitaire: Add Auto-Collect gameplay optionThitat Auareesuksakul
Add the option for players to enable automatic collection of eligible cards to their foundation pile with a single click of that card.
2021-09-03Everywhere: Use my shiny new serenityos.org email :^)Sam Atkins
2021-06-13Solitaire: Disable filling with background color during end animationSam Atkins
This fixes #7792. The visual glitches with card corners, and the screen-clear when opening a menu, were both caused by the widgets having `fill_with_background_color` set. We need that set most of the time, so we just disable it for the duration of the game-over animation. Also resove a FIXME that no longer applies. :^)
2021-06-13Solitaire: Allow automatic moves to end the game and animateSam Atkins
Previously, if a tab-move moved all the remaining cards to the foundations, the game would not notice until you moved a card away and then back again. I had to add a 1-frame delay to starting the animation, so that it would have time to re-paint the foundation in that case.
2021-06-11Solitaire: Iterate the foundation stacks and inline move_card()Sam Atkins
Keeping this as a separate commit as I'm not certain whether this is a good change or not. The repeated if-else for each Foundation stack bothered me a bit, though more so before I reduced the code in the {}. But maybe the ifs are clearer than the loop? Doing that also meant I could inline the move_card() code instead of needing to make it a lambda. Again, maybe it would be better as a lambda? I'm still figuring out the style Serenity uses, and I know Andreas is big on expressiveness, and move_card() is more expressive than just having the code in the loop.
2021-06-11Solitaire: Combine duplicate tab/double-click logicSam Atkins
The two paths did the same thing, in two different ways. Now they are the same. :^) Can't quite put all of the logic into attempt_to_move_card_to_foundations() because the double-click has to check that you clicked on the top card.
2021-06-11Solitaire: Subtract points when undoing a card-flipSam Atkins
Solitaire: Correct default arg definition location
2021-06-04Solitaire+LibCards: Draw card stacks with rounded cornersTimothy Flynn
Now that the cards have rounded corners, draw the stack box behind the cards with rounded corners as well. This way, the corner of the stack box doesn't peek out from behind the cards. The caveat here is that the "play" card stack now needs to hold a reference to the "waste" stack beneath it so it knows when not to draw its background on top of the waste stack. To faciliate that, the array of card stacks is now a NonnullRefPtrVector so the play stack can store a smart pointer to the waste stack (instead of a raw pointer or reference).
2021-06-03Solitaire: Add keys for drawing and moving cards to foundation stacksMatthew B. Jones
Also shifts logic of starting game length timer into function `start_timer_if_necessary`, so it can be called from original mouse event handler and new `auto_move_eligible_cards_to_stacks`
2021-06-03Solitaire: Add undo functionalityMatthew B. Jones
2021-05-27Solitaire: Start timer when first card is movedMarcus Nilsson
Starts the game timer when the first card is clicked or moved instead of when a new game is started. Fixes #7489
2021-05-25Solitaire: Tweak scoring for three-card draw modeTimothy Flynn
Currently, the player loses 100 points each time the waste stack is recycled. In three-card draw mode, it's standard to only lose 20 points after the third recycle event.
2021-05-25Solitaire: Only update high score after a victorious gameTimothy Flynn
Doesn't make much sense to update the high score on a lost game.
2021-05-21Solitaire: Move cards functionality into LibCardsGunnar Beutner
2021-05-18Solitaire: Persist game mode to config fileTimothy Flynn
2021-05-16Solitaire: Add key combo to dump the state of the layoutTimothy Flynn
Useful for chasing down bugs.
2021-05-16Solitaire: Add setting for number of cards to be drawnTimothy Flynn
Klondike Solitaire has a couple more modes, but this adds modes for 1- and 3-card draws.
2021-05-16Solitaire: Add stack for the playable cards on top of the waste stackTimothy Flynn
While the waste stack and the playable card on top of the waste stack are collectively referred to as the "waste", it's programatically nice to separate them to enable 3-card-draw mode. In that mode, the playable stack will contain 3 cards with a slight x-axis shift, while the waste stack underneath will remain unshifted. So rather than introducing some ugly logic to CardStack to handle this, it's more convenient to have a separate stack on top of the waste stack.
2021-05-05Solitaire: Add statusbar segment to display elapsed timeTimothy Flynn
The timer begins after the new-game animation ends, and stops when either the game-over animation begins or the new-game animation is started again.
2021-05-05Solitaire: Refactor painting logic to accomodate to-be-added widgetsTimothy Flynn
A series of events led to this change: The goal is to add more widgets to the Solitaire GML, such as a GUI::Statusbar. To do so without this change, the window ends up with some black artifacts between the main Solitaire frame and the added elements, because the GML specifies the main widget to have fill_with_background_color=false. However, setting that property to true results in the background color of the widget interferring with the Solitaire frame trying to manually paint its background green. This results in flickering and some elements in the Solitaire frame being painted over by the main background color. To avoid all of that behavior, this sets fill_with_background_color=true and the Solitaire frame's background color to green in the GML. Further, the frame now only queues a paint update on the specific Gfx::Rect areas that need to be updated. This also means we no longer need to track if a stack of cards is dirty, because we only trigger a paint event for dirty stacks.
2021-05-05Solitaire: Convert Solitaire GUI to a frameTimothy Flynn
Looks a bit nicer as a frame with inset edges.
2021-05-05Solitaire: Convert Solitaire window to be created from GMLTimothy Flynn
No functionial change here, but this more easily allows for adding GUI elements to the Solitaire window. This nests the SolitaireWidget as a child of the main window's widget so that the SolitaireWidget does not color the entire window green when it paints its background.
2021-05-05Solitaire: Place files in Solitaire namespace and rename main widgetTimothy Flynn
The purpose is to allow the Solitaire widget to be used in GML. The macro to register a widget requires a namespace, so this moves all files in the application to the Solitaire namespace. This also renames the SolitaireWidget class to Game - this is to avoid the redundancy / verbosity of typing "Solitaire::SolitaireWidget", and matches many other games in Serenity (Breakout, 2048, etc.).