KeeganWoods1/C345---Risk

Order execution implementation

Opened this issue · 0 comments

Provide a group of C++ classes that implements the execution of orders following the official rules of the Warzone
game. The code that implements the execution of the orders must be placed within the execute() method of the
order class/subclasses in the Orders.cpp/Orders.h files. Each specific order kind (listed below) must be a
subclass of an abstract class named Order that has a pure virtual method named execute().

Deploy order: A deploy order tells a certain number of armies taken from the reinforcement pool to deploy to a
target territory owned by the player issuing this order.
• If the target territory does not belong to the player that issued the order, the order is invalid.
• If the target territory belongs to the player that issued the deploy order, the selected number of armies is
added to the number of armies on that territory.

Advance order: An advance order tells a certain number of army units to move from a source territory to a target
adjacent territory.
• If the source territory does not belong to the player that issued the order, the order is invalid.
• If the target territory is not adjacent to the source territory, the order is invalid.
• If the source and target territory both belong to the player that issued the order, the army units are moved
from the source to the target territory.
• If the target territory belongs to another player than the player that issued the advance order, an attack is
simulated when the order is executed. An attack is simulated by the following battle simulation
mechanism:
o Each attacking army unit involved has 60% chances of killing one defending army. At the same time,
each defending army unit has 70% chances of killing one attacking army unit.
o If all the defender's armies are eliminated, the attacker captures the territory. The attacking army units
that survived the battle then occupy the conquered territory.
o A player receives a card at the end of his turn if they successfully conquered at least one territory
during their turn.

Airlift order: An airlift order tells a certain number of armies taken from a source territory to be moved to a target
territory, the source territory being owned by the player issuing the order. The airlift order can only be created by
playing the airlift card.
• If the source or target does not belong to the player that issued the order, the order is invalid.
• If both the source and target territories belong to the player that issue the airlift order, then the selected
number of armies is moved from the source to the target territory.
• If the target territory does not belong to the player that issued the airlift order, the selected number of
armies is attacking that territory (see “advance order”).

Bomb order: A bomb order targets a territory owned by another player than the one issuing the order. Its result is
to remove half of the armies from this territory. The bomb order can only be created by playing the bomb card.
• If the target belongs to the player that issued the order, the order is invalid.
• If the target belongs to an enemy player, half of the armies are removed from this territory.

Blockade order: A blockade order targets a territory that belongs to the player issuing the order. Its effect is to
double the number of armies on the territory and to transfer the ownership of the territory to the Neutral player.
• If the target territory belongs to an enemy player, the order is declared invalid. The blockade order can
only be created by playing the blockade card.
• If the target territory belongs to the player issuing the order, the number of armies on the territory is
doubled and the ownership of the territory is transferred to the Neutral player.

Negotiate order: A negotiate order targets an enemy player. It results in the target player and the player issuing
the order to not be able to successfully attack each others’ territories for the remainder of the turn. The negotiate
order can only be created by playing the diplomacy card.
• If the target is the player issuing the order, then the order is invalid.
• If the target is an enemy player, then the effect is that any attack that may be declared between territories
of the player issuing the negotiate order and the target player will result in an invalid order.