Fix: Fixed Food / Prestige Removal Logic In Order*.java (Missing "!") + Refactor Of Corresponding Javadoc.

This commit is contained in:
GabrieleRadice
2026-04-30 17:56:30 +02:00
parent c6df350401
commit c9abac6d57
5 changed files with 12 additions and 10 deletions
@@ -26,7 +26,7 @@ public class Order2 extends OrderLogicCard {
/** /**
* Applies the effect associated with the specified position index for the given player. * Applies the effect associated with the specified position index for the given player.
* <p>If {@code index == 0}, the player gains 1 Food and the building effect is applied. * <p>If {@code index == 0}, the player gains 1 Food and the building effect is applied.
* <p>If {@code index == 1}, the player tries to remove 1 Food; if the player cannot remove it, * <p>If {@code index == 1}, the player tries to remove 1 Food; if the player pay it,
* the player loses 2 Prestige. * the player loses 2 Prestige.
* *
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
@@ -27,7 +27,8 @@ public class Order3 extends OrderLogicCard {
* Applies the effect associated with the specified position index for the given player. * Applies the effect associated with the specified position index for the given player.
* <p>If {@code index == 0}, the player gains 2 Food and the building effect is applied. * <p>If {@code index == 0}, the player gains 2 Food and the building effect is applied.
* <p>If {@code index == 1}, no effect is applied. * <p>If {@code index == 1}, no effect is applied.
* <p>If {@code index == 2}, if the player can remove 1 Food, the player loses 2 Prestige. * <p>If {@code index == 2}, the player tries to remove 1 Food; if the player pay it,
* the player loses 2 Prestige.
* *
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
* @param index the position index of the effect to apply. * @param index the position index of the effect to apply.
@@ -47,7 +48,7 @@ public class Order3 extends OrderLogicCard {
return; return;
} }
if(index==2){ if(index==2){
if(player.removeFood(1)){ if(!player.removeFood(1)){
player.removePrestige(2); player.removePrestige(2);
} }
} }
@@ -28,7 +28,7 @@ public class Order4 extends OrderLogicCard {
* <p>If {@code index == 0}, the player gains 2 Food and the building effect is applied. * <p>If {@code index == 0}, the player gains 2 Food and the building effect is applied.
* <p>If {@code index == 1}, the player gains 1 Food and the building effect is applied. * <p>If {@code index == 1}, the player gains 1 Food and the building effect is applied.
* <p>If {@code index == 2}, no effect is applied. * <p>If {@code index == 2}, no effect is applied.
* <p>If {@code index == 3}, the player tries to remove 1 Food; if the removal succeeds, * <p>If {@code index == 3}, the player tries to remove 1 Food; if the player pay it,
* the player loses 2 Prestige. * the player loses 2 Prestige.
* *
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
@@ -55,7 +55,7 @@ public class Order4 extends OrderLogicCard {
return; return;
} }
if(index==3){ if(index==3){
if(player.removeFood(1)){ if(!player.removeFood(1)){
player.removePrestige(2); player.removePrestige(2);
} }
} }
@@ -29,7 +29,7 @@ public class Order5 extends OrderLogicCard {
* <p>If {@code index == 1}, the player gains 1 Food and the building effect is applied. * <p>If {@code index == 1}, the player gains 1 Food and the building effect is applied.
* <p>If {@code index == 2}, no effect is applied. * <p>If {@code index == 2}, no effect is applied.
* <p>If {@code index == 3}, no effect is applied. * <p>If {@code index == 3}, no effect is applied.
* <p>If {@code index == 4}, the player tries to remove 1 Food; if the removal succeeds, * <p>If {@code index == 4}, the player tries to remove 1 Food; if the player pay it,
* the player loses 2 Prestige. * the player loses 2 Prestige.
* *
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
@@ -56,7 +56,7 @@ public class Order5 extends OrderLogicCard {
return; return;
} }
if(index==4){ if(index==4){
if(player.removeFood(1)){ if(!player.removeFood(1)){
player.removePrestige(2); player.removePrestige(2);
} }
} }
@@ -3,9 +3,10 @@ package it.polimi.ingsw.gc14.Model.Orders;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
/** /**
* Abstract base class for all order logic cards. * Abstract base class for all order {@code logic cards}.
* An OrderLogicCard manages a queue of players and defines the effects * An {@code OrderLogicCard} manages a queue of {@code players} and defines the effects
* applied when players are pushed back into the queue. * applied when they are pushed back into the queue.
* @see it.polimi.ingsw.gc14.Model.Player Player
*/ */
public class OrderPlayer{ public class OrderPlayer{
public Player player; public Player player;