summaryrefslogtreecommitdiff
path: root/Userland/Games
AgeCommit message (Collapse)Author
2021-06-06AK+Everywhere: Disallow constructing Functions from incompatible typesAli Mohammad Pur
Previously, AK::Function would accept _any_ callable type, and try to call it when called, first with the given set of arguments, then with zero arguments, and if all of those failed, it would simply not call the function and **return a value-constructed Out type**. This lead to many, many, many hard to debug situations when someone forgot a `const` in their lambda argument types, and many cases of people taking zero arguments in their lambdas to ignore them. This commit reworks the Function interface to not include any such surprising behaviour, if your function instance is not callable with the declared argument set of the Function, it can simply not be assigned to that Function instance, end of story.
2021-06-04Hearts: Don't destroy the animation handler while running itGunnar Beutner
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-04Solitaire: Fixes undo feature from incorrect merge conflict resolutionMatthew Jones
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-06-02Hearts: Play the first valid card (left-to-right) when pressing spaceMatthew B. Jones
2021-06-02LibChess: Change cursor style when hovering or dragging valid pieceBrandonKi
2021-06-01Hearts: Fix sorting for pick_low_points_high_value_cardGunnar Beutner
Previously the function did not sort the hand at all which means we wouldn't necessarily pick the card with the highest value.
2021-06-01Hearts: Prefer to pass high value cardsGunnar Beutner
Previously we'd prefer to pass high points cards. Instead we should prefer to pass high value cards first.
2021-06-01Hearts: Pick better non-matching cardsGunnar Beutner
When we don't have a matching card for the lead card rather than always preferring to play hearts we should try to get rid of our high value cards first if no other player has hearts cards higher than what we have.
2021-06-01Hearts: Make debugging AI suggestions easierGunnar Beutner
When building Hearts with HEARTS_DEBUG we highlight the card the AI would have picked. This makes comparing AI and human decisions easier.
2021-06-01Hearts: Pick better cards when we're the third playerGunnar Beutner
When we're the third player in a trick and we don't have a lower value card we would previously pick a slightly higher value card. Instead we should pick the highest value card unless there are points in the current trick or the lead card is spades and the higher value card we would've picked is higher than the queen and another player still has the queen. The rationale is that we have to take the trick anyway so we might as well get rid of our highest value card. If the trailing player has a lower value card of the same type we take the trick but don't gain any points. If they don't have a card of the same type it doesn't matter whether we play a high value or low value card.
2021-06-01Hearts: Pick better lead cardsGunnar Beutner
Previously the AI would prefer playing a lead card for which no other player had a card with a higher value even though it also had a card for which a higher value card was still in play.
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-26Hearts: Highlight cards when an invalid play is attemptedGunnar Beutner
This briefly inverts the selected card when the user attempts to make an invalid play.
2021-05-25Solitaire: Persist high score separately per game modeTimothy Flynn
With different scoring rules for one-card vs. three-card draw mode, it makes more sense to separately track their high scores.
2021-05-25Solitaire: Award bonus points based on time elapsedTimothy Flynn
The exact formula used for bonus points seems to vary by implementation. This uses Klondike Solitaire's formula: https://en.wikipedia.org/wiki/Klondike_(solitaire)#Scoring
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: Remove dead call to Game::start_game_over_animationTimothy Flynn
This invocation will exit immediately. There's also no reason to invoke stop_game_over_animation here because that's the first thing that will happen in the call to setup.
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-25Hearts: Don't advance the game's state when an animation is playingGunnar Beutner
Previously we'd end up cancelling an animation that was still playing when the user selects a card.
2021-05-25Hearts: Fix animations that get stuck "mid-flight"Gunnar Beutner
When an animation is stopped the cards should be moved to their final position anyway. Otherwise they might end up getting stuck in the middle of the animation.
2021-05-25Hearts: Add support for playing more than one handGunnar Beutner
This changes the game so that more than one hand can be played. Once one player has 100 or more points the game ends. A score card is shown between each hand. Fixes #7374.
2021-05-25Hearts: Let the AI continuously play gamesGunnar Beutner
When there are no human players (toggled with Shift-F10) the AI will continuously start new games when the current game has finished.
2021-05-25Hearts: Implement passing cards to other playersGunnar Beutner
Fixes #7375.
2021-05-25Hearts: Move card click handler into a separate methodGunnar Beutner
2021-05-25Hearts: Move sorting helper from Player::pick_lead_card into a methodGunnar Beutner
2021-05-25Hearts: Move code to reposition cards into a separate methodGunnar Beutner
2021-05-25Hearts: Move round initialization into a separate methodGunnar Beutner
2021-05-25Hearts: Move hand sorting functionality into a methodGunnar Beutner
2021-05-23Hearts: Allow player to set their nameJosh Perry
Added a new settings dialog to Hearts with a textbox to allow the player to set a name, which is persisted in the Hearts config file.
2021-05-23Hearts: Add key combinations to letting the AI play for youGunnar Beutner
A single card can be played with F10 while Shift-F10 toggles the AI for the current as well as all future tricks.
2021-05-23Hearts: Let the AI prefer lead cards for which other cards are in playGunnar Beutner
When picking a lead card the AI should avoid playing cards where it knows that no other player has a lower value card of the same type.
2021-05-23Hearts: Fix sorting function for lead cardsGunnar Beutner
The pick_lead_card() function sometimes picks the incorrect card because the sorted_hand vector wasn't being sorted properly.
2021-05-22Hearts: Let the AI pick better lead cardsGunnar Beutner
Instead of picking the card with the lowest value we should pick the card with the highest value for which we know no lower value card is in play anymore and that someone else still has an even higher value card.
2021-05-22Hearts: Prefer to play Queen of Spades when we're the trailing playerGunnar Beutner
Previously in a trick like 2S, KS, 5S we'd rather follow up with AS instead of QS. We should prefer to play QS in this case.
2021-05-22Hearts: Fix crash when starting an animation when there already is oneGunnar Beutner
This ensures that the preceding animation is stopped first.
2021-05-22Hearts: Remove dead codeGunnar Beutner
2021-05-22GameOfLife: Add choosable patternsRyan Wilson
2021-05-21Games: Add HeartsGunnar Beutner
2021-05-21Solitaire: Move cards functionality into LibCardsGunnar Beutner
2021-05-21Revert "Userland: static vs non-static constexpr variables"Linus Groh
This reverts commit 800ea8ea969835297dc7e7da345a45b9dc5e751a. Booting the system no longer worked after these changes.
2021-05-21Userland: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-20Solitaire: Fix a spelling mistake in one of the variable namesGunnar Beutner
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()Andreas Kling
Ask for a bold_variant() of the default_fixed_width_font() instead.
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_font()Andreas Kling
Instead use default_font().bold_variant() in cases where we want a bold variant of the default font. :^)
2021-05-18Solitaire: Prevent player dragging entire stack to foundationJesse Buhagiar
Currently, it is possible for the player to drag an entire stack of cards to the foundation stack, provided the top card of the stack (i.e the "root" card) can be dropped onto the foundation stack. This causes an invalid state where, e.g, red cards end up in a black foundation stack, or vice versa.
2021-05-18Pong: Make the game winnableDmitrii Ubskii
- Make the ball chill out a bit by reducing its x velocity by 1. - Make the AI dumber. It now relaxes until the ball is coming towards it and is in its half of the court.
2021-05-18Pong: Fix paddle movement across resets if keys are heldDmitrii Ubskii
The game waited for the next key down event before moving the player paddle. Now the state of the arrow keys is carried over between resets.