Philippe229/risk

Main game loop: attack phase

Closed this issue · 0 comments

benrs commented

Provide a group of C++ classes that implement the attack phase following the official rules of the game of Risk. In
this phase, the player is allowed to declare a series of attacks to try to gain control of additional countries, and
eventually control the entire map. The attack phase follows the following loop:
 The player decides if it will attack or not. If not, the attack phase is over.
 The player selects one of its countries to attack from, and one of the neighbors of this country to attack
(i.e. the attacked country belongs to another player). The attacking country must have at least 2 armies
on it.
 The attacker and defender players choose the number of dice to roll for their attack/defense. The attacker
is allowed 1 to 3 dice, with the maximum number of dice being the number of armies on the attacking
country, minus one. The defender is allowed 1 to 2 dice, with the maximum number of dice being the
number of armies on the defending country.
 The dice are rolled for each player and sorted, then compared pair-wise. For each pair, the player with
the lowest roll loses one army. If the pair is equal, the attacker loses an army.
 If the attacked country runs out of armies, it has been defeated. The defending country now belongs to
the attacking player. The attacker is allowed to move a number of armies from the attacking country to the
attacked country, in the range [1 to (number of armies on attacking country -1)].
 The player is allowed to initiate any number of attacks per turn, including 0.
You must deliver a driver that demonstrates that 1) only valid attacks can be declared (i.e. valid attacker/attacked
country); 2) only valid number of dice can be chosen by the attacker/defender; 3) given known dice values, that
the right number of armies are deducted on the attacker/defender; 4) the attacker is allowed to initiate multiple
attacks, until it declares that it does not want to attack anymore.