summaryrefslogtreecommitdiff
path: root/Userland/Games/Hearts/Game.cpp
AgeCommit message (Collapse)Author
2022-02-16Games: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2021-10-27Everywhere: Rename left/right-click to primary/secondaryFiliph Sandström
This resolves #10641.
2021-08-18Userland+LibGUI: Add shorthand versions of the Margins constructorsin-ack
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same margin on all edges, for example. The constructors follow CSS' style of specifying margins. The added constructors are: - Margins(int all): Sets the same margin on all edges. - Margins(int vertical, int horizontal): Sets the first argument to top and bottom margins, and the second argument to left and right margins. - Margins(int top, int vertical, int bottom): Sets the first argument to the top margin, the second argument to the left and right margins, and the third argument to the bottom margin.
2021-07-24Hearts: Avoid reallocations for Vectors when possibleGunnar Beutner
2021-07-24Hearts: Use AK::get_random_uniform() instead of rand()/srand()Gunnar Beutner
2021-07-23Hearts: Avoid redrawing the UI unnecessarilyGunnar Beutner
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-02Hearts: Play the first valid card (left-to-right) when pressing spaceMatthew B. Jones
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-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-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 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-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-21Games: Add HeartsGunnar Beutner