comp345 / risk-game

Warzone game on console implemented using C++
1 stars 0 forks source link

small deploy fix for human #35

Closed laila-chammaa closed 2 years ago

laila-chammaa commented 2 years ago

validating if the amount entered is available.

laila-chammaa commented 2 years ago

Okk This adds validation to every strategies that calls getAttackableTerritories right? So the Normal and the Human strategies?

no this is just human cuz it asks for more than one, normal always asks for one army at a time, and then on the next turn, it checks if reinforcment input is > 0 before asking for another army, so validation is already there:

if (issuingPlayer->getReinforcementPool() > 0)
    {
..........
        // Create Deploy -> decrease reinforcement
        Deploy *deploy = new Deploy(1, issuingPlayer, territoryTarget);
        issuingPlayer->setReinforcementPool(issuingPlayer->getReinforcementPool() - 1);
eyeshield2110 commented 2 years ago

Okk This adds validation to every strategies that calls getAttackableTerritories right? So the Normal and the Human strategies?

no this is just human cuz it asks for more than one, normal always asks for one army at a time, and then on the next turn, it checks if reinforcment input is > 0 before asking for another army, so validation is already there:

if (issuingPlayer->getReinforcementPool() > 0)
    {
..........
        // Create Deploy -> decrease reinforcement
        Deploy *deploy = new Deploy(1, issuingPlayer, territoryTarget);
        issuingPlayer->setReinforcementPool(issuingPlayer->getReinforcementPool() - 1);

Ok gotchu I'm approving it and merging it into a3_archived