C++代写:CS150 Game of War

代写一个叫Game of War的扑克牌游戏,能实现双人对战。

Requirement

In this problem set you’ll build on the work of recent dailies to write a complete program. There is a flowchart deadline and a draft deadline as well as a final deadline.

Instructions

You will implement the game of War in a C++ program. There are no official rules, so we will follow the 2-player rules outlined below. Visit Wikipedia for more details. If you are not familiar with the standard deck of cards, there is a Wikipedia article for that too. The rules of the game are very simple, so it is really a game for young children.

  • The game is played with a standard 52-card deck (13 ranks, Aces high, 4 suits). Suits are ignored in War.
  • The deck is shuffled and then dealt into 2 equal hands of 26.
  • Players play their hands from top to bottom. Cards are not examined or rearranged.
  • Each player turns over the top card from their hand. The high card wins and collects both cards, which are returned to the bottom of the winner’s hand. In the event of a tie, there is a war, described below.
  • In a war, the tying cards stay out and are followed by one face-down card and one face-up card per player. The face-up cards play in the same way as usual: the high card winds and the player collects all six cards out and returns them to the bottom of their hand.
  • If ties continue, the war continues with another two face-down cards and another two face-up cards. If a player runs out of cards during a war, the player loses immediately.
  • If the war ends, play continues as normal.
  • The game is over when one player collects all 52 cards, or when a war ends due to one player’s inability to continue.

Specifications

Much of the program’s design is up to you, but you must write your code to follow the specifications below.

  • Your code should compile using the command
g++ -std=c++11 -Wall -Werror -pedantic -o war war.c++
  • The deck of cards and each hand, as well as other piles of cards of a temporary nature, should be implemented as vectors.

  • When a player wins a trick, the cards collected must be returned to the bottom of the hand—that is, the opposite side from where cards are played.