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 ffbf893..1288aee 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 @@ -1,18 +1,35 @@ package it.polimi.ingsw.gc14.Model.Orders; -import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.Player; import java.util.*; public class Order2 extends OrderLogicCard { + + /** + * Creates an Order2 logic card for a two-player game. + * + * @param players the list of players associated with this order card. + * @throws NoSuchElementException if the number of players is not equal to 2. + */ public Order2(ArrayList players)throws NoSuchElementException { if(players.size()!=2) throw new NoSuchElementException(); super(players); } + + /** + * 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, + * 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. + * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 2}. + */ @Override protected void effect(Player player,int index) throws IndexOutOfBoundsException { @@ -29,7 +46,6 @@ public class Order2 extends OrderLogicCard { if(index==1){ if(!player.removeFood(1)){ player.removePrestige(2); - return; } } } 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 f0144fb..fc7f6d2 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 @@ -7,11 +7,29 @@ import java.util.ArrayList; import java.util.NoSuchElementException; public class Order3 extends OrderLogicCard { + + /** + * Creates an Order3 logic card for a three-player game. + * + * @param players the list of players associated with this order card. + * @throws NoSuchElementException if the number of players is not equal to 3. + */ public Order3(ArrayList players) throws NoSuchElementException{ if(players.size()!=3) throw new NoSuchElementException(); super(players); } + + /** + * 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. + * + * @param player the player to whom the effect is applied. + * @param index the position index of the effect to apply. + * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 3}. + */ @Override protected void effect(Player player,int index) throws IndexOutOfBoundsException { @@ -29,7 +47,6 @@ public class Order3 extends OrderLogicCard { if(player.removeFood(1)){ player.removePrestige(2); } - return; } } } \ No newline at end of file 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 afde765..06bb44a 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 @@ -7,11 +7,31 @@ import java.util.ArrayList; import java.util.NoSuchElementException; public class Order4 extends OrderLogicCard { + + /** + * Creates an Order4 logic card for a four-player game. + * + * @param players the list of players associated with this order card. + * @throws NoSuchElementException if the number of players is not equal to 4. + */ public Order4(ArrayList players)throws NoSuchElementException { if(players.size()!=4) throw new NoSuchElementException(); super(players); } + + /** + * 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}, 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, + * 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. + * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 4}. + */ @Override protected void effect(Player player,int index) throws IndexOutOfBoundsException { @@ -35,7 +55,6 @@ public class Order4 extends OrderLogicCard { if(player.removeFood(1)){ player.removePrestige(2); } - return; } } } \ No newline at end of file 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 0f5f5dc..41b7228 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 @@ -7,11 +7,32 @@ import java.util.ArrayList; import java.util.NoSuchElementException; public class Order5 extends OrderLogicCard { + + /** + * Creates an Order5 logic card for a five-player game. + * + * @param players the list of players associated with this order card. + * @throws NoSuchElementException if the number of players is not equal to 5. + */ public Order5(ArrayList players) throws NoSuchElementException{ if(players.size()!=5) throw new NoSuchElementException(); super(players); } + + /** + * Applies the effect associated with the specified position index for the given player. + *

If {@code index == 0}, the player gains 3 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}, no effect is applied. + *

If {@code index == 4}, the player tries to remove 1 Food; if the removal succeeds, + * 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. + * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 5}. + */ @Override protected void effect(Player player,int index) throws IndexOutOfBoundsException { @@ -35,7 +56,6 @@ public class Order5 extends OrderLogicCard { if(player.removeFood(1)){ player.removePrestige(2); } - return; } } }