From c9abac6d5783d397b64da01a4aaeb4aead07920a Mon Sep 17 00:00:00 2001 From: GabrieleRadice <265572328+GabrieleRadice@users.noreply.github.com> Date: Thu, 30 Apr 2026 17:56:30 +0200 Subject: [PATCH] Fix: Fixed Food / Prestige Removal Logic In Order*.java (Missing "!") + Refactor Of Corresponding Javadoc. --- .../java/it/polimi/ingsw/gc14/Model/Orders/Order2.java | 2 +- .../java/it/polimi/ingsw/gc14/Model/Orders/Order3.java | 5 +++-- .../java/it/polimi/ingsw/gc14/Model/Orders/Order4.java | 4 ++-- .../java/it/polimi/ingsw/gc14/Model/Orders/Order5.java | 4 ++-- .../it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java | 7 ++++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java index 6d926c4..548f483 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java @@ -26,7 +26,7 @@ public class Order2 extends OrderLogicCard { /** * Applies the effect associated with the specified position index for the given player. *

If {@code index == 0}, the player gains 1 Food and the building effect is applied. - *

If {@code index == 1}, the player tries to remove 1 Food; if the player cannot remove it, + *

If {@code index == 1}, 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. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java index fb4c71a..14bc2db 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java @@ -27,7 +27,8 @@ public class Order3 extends OrderLogicCard { * Applies the effect associated with the specified position index for the given player. *

If {@code index == 0}, the player gains 2 Food and the building effect is applied. *

If {@code index == 1}, no effect is applied. - *

If {@code index == 2}, if the player can remove 1 Food, the player loses 2 Prestige. + *

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 index the position index of the effect to apply. @@ -47,7 +48,7 @@ public class Order3 extends OrderLogicCard { return; } if(index==2){ - if(player.removeFood(1)){ + if(!player.removeFood(1)){ player.removePrestige(2); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java index 966f15a..1fc229c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java @@ -28,7 +28,7 @@ public class Order4 extends OrderLogicCard { *

If {@code index == 0}, the player gains 2 Food and the building effect is applied. *

If {@code index == 1}, the player gains 1 Food and the building effect is applied. *

If {@code index == 2}, no effect is applied. - *

If {@code index == 3}, the player tries to remove 1 Food; if the removal succeeds, + *

If {@code index == 3}, 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. @@ -55,7 +55,7 @@ public class Order4 extends OrderLogicCard { return; } if(index==3){ - if(player.removeFood(1)){ + if(!player.removeFood(1)){ player.removePrestige(2); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java index 468c626..d184bcc 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java @@ -29,7 +29,7 @@ public class Order5 extends OrderLogicCard { *

If {@code index == 1}, the player gains 1 Food and the building effect is applied. *

If {@code index == 2}, no effect is applied. *

If {@code index == 3}, no effect is applied. - *

If {@code index == 4}, the player tries to remove 1 Food; if the removal succeeds, + *

If {@code index == 4}, 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. @@ -56,7 +56,7 @@ public class Order5 extends OrderLogicCard { return; } if(index==4){ - if(player.removeFood(1)){ + if(!player.removeFood(1)){ player.removePrestige(2); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java index 360bebc..56ac136 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/OrderPlayer.java @@ -3,9 +3,10 @@ package it.polimi.ingsw.gc14.Model.Orders; import it.polimi.ingsw.gc14.Model.Player; /** - * Abstract base class for all order logic cards. - * An OrderLogicCard manages a queue of players and defines the effects - * applied when players are pushed back into the queue. + * Abstract base class for all order {@code logic cards}. + * An {@code OrderLogicCard} manages a queue of {@code players} and defines the effects + * applied when they are pushed back into the queue. + * @see it.polimi.ingsw.gc14.Model.Player Player */ public class OrderPlayer{ public Player player;