Software Modelling and Design
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
SWEN30006 Software Modelling and Design
Project 2: Lucky Thirteen
- Project Specification -
1 Background
The JQK Computer Game Company (JQK) observes a steep increase in a popularity of card games. The
company foresees a bright future of digital card games and aims at exploring this opportunity. While there
exist many card games already, the company decides to create yet another card game called Lucky
Thirteen.
A software team at JQK has started to develop a framework for this new digital card game. The code does
work to some extent. However, it was implemented in a rush and was not properly designed. JQK has
recruited you and your team to revise the existing design and codebase as well as extending the
framework to also include additional logic and features to make the game even more exciting.
Figure 1: The GUI of LT game
2 Rules for the Lucky Thirteen Games
The Lucky Thirteen (LT) game play is briefly described below. The current program developed by JQK
already supports this behaviour.
• The game is played with a standard 52-card deck with four suits, each having thirteen ranks.
• Each rank is associated with a numerable value where
◦ For summing during the game: Number cards represent as is (i.e., 2 is two). For picture cards,
‘A’ can represent either zero or one, while ‘J’, ‘Q’, ‘K’ can be 10, 11, 12, or 13.
◦ For scoring after the game: Number cards score according to its numerable value (i.e., 2 is
worth two points). For picture cards, ‘A’, ‘J’, ‘Q’, ‘K’ score 1, 11, 12, 13 points respectively.
(See Table 1 for a summary)
• The goal of a player is to have the sum of the value of the cards to thirteen (see below for more
details about the summation).
• The game involves four players who play independently.
• All cards are dealt face down. Note that the software version deals the cards face up to make it
easy for developers to see what is going on. However, computer players should not be able to
“see” the cards of the other players.
• At the start of the game, all 52 cards are shuffled. Two cards are dealt from the pile and put face
up (every player can see these cards). These two cards are referred to as public cards. Then, two
cards are distributed to each player (players cannot see each other cards), these cards are called
private cards. A total of ten cards are dealt from the pile at this step.
• The game consists of four rounds. Each round, each player deals one card from the pile and
discards one card of their choice. Note that a player can choose to discard any of the three private
cards in their hand, and every player can see the discarded card.
• Player 0 always starts first. The game then proceeds clockwise.
• At the end of the fourth round, each player sums the value of the private cards (regardless of the
suit) in their hand or combines with the public card(s) dealt at the beginning of the game to
achieve the summation of thirteen. The summation can only be one of the following two scoring
options (see also Table 2):
◦ Option1: Two private cards in their hand.
◦ Option2: One private card in their hand and one card from the two public cards.
Note that the game automatically checks these two options.
• There are three cases to assign scores to a player. Note that each case considers both scoring
options mentioned above.
◦ Case1: If there is only one player who achieves the sum of exactly thirteen, that player wins
the game and gain a score of 100 points. In other words, only one player receives a score. The
other three players’ score remains zero.
◦ Case2: If no player has the sum of thirteen, each player receives a score of the sum of the two
private cards in their hand according to the following calculation:
▪ Each suit corresponds to a multiplication factor as follows: spade (♠) x 4, heart (♥) x 3,
diamond (♦) x 2, club (♣) x 1.
▪ A number card score as is. Picture cards score as follows: A = 1, J = 11, Q = 12, K = 13.
▪ Example 1: A player with 8-heart and 5-club would receive a score of 8x3 + 5x1 = 29 points.
Note that in this case, all players receive a score.
◦ Case3: If more than one player achieves the sum of thirteen, those players receive a score
from the cards that add up to thirteen according to the score calculation above. If the public
card is used, the multiplication factor is always 2 regardless of the suit. If a player can sum the
cards in different ways to thirteen, the calculation should maximize the score (see Example
3a below).
▪ Example 2: The score of 7-club (in hand) together with 6-club (from public cards) is 7x1 +
6x2 = 19.
▪ Example 3a: A player has J-diamond and A-heart. The public cards are 5-spade and 2-
diamond.
• [Option1] Two cards in hand:
◦ Summing: J as 12 and A as 1 -> 12 + 1 = 13
◦ Scoring: J is 11 and A is 1 -> 11x2 + 1x3 = 25
• [Option2] One card in hand and one public card:
◦ Summing: J as 11 -> 11 + 2 = 13
◦ Scoring: J is 11 -> 11x2 + 2x2 = 26
• The player earns the score of 26 since it is the highest.
Note that in this case only the player(s) whose sum is thirteen may receive scores. The score of
the other players remains zero.
• The winner and the score obtained are displayed on the screen.
The LT program currently supports two types of players: human interactive player who selects the card to
play through a double-left-mouse-click, and random computer player who selects a card to discard at
random. The current configuration is always one human at position 0 and three random players at the
other positions.