This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into develop
- Loading branch information
Showing
15 changed files
with
286 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/fr/sae/terraria/modele/entities/player/craft/recipes/TorchRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fr.sae.terraria.modele.entities.player.craft.recipes; | ||
|
||
import fr.sae.terraria.modele.entities.player.inventory.Inventory; | ||
import fr.sae.terraria.modele.entities.player.inventory.Stack; | ||
|
||
|
||
public class TorchRecipe | ||
{ | ||
private static final int NB_INGREDIENTS = 2; | ||
public static final int NB_COALS = 1; | ||
public static final int NB_STICKS = 1; | ||
|
||
|
||
public static Ingredient apply(final Inventory inventory) | ||
{ | ||
Ingredient ingredient = new Ingredient(TorchRecipe.NB_INGREDIENTS); | ||
boolean haveEnoughCoal = false; | ||
boolean haveEnoughSticks = false; | ||
|
||
int i = 0; | ||
do { | ||
Stack stack = inventory.get().get(i); | ||
|
||
if (!haveEnoughCoal) | ||
haveEnoughCoal = IngredientSet.coals(ingredient, stack, TorchRecipe.NB_COALS); | ||
if (!haveEnoughSticks) | ||
haveEnoughSticks = IngredientSet.sticks(ingredient, stack, TorchRecipe.NB_COALS); | ||
i++; | ||
} while (i < inventory.get().size() && (!haveEnoughCoal || !haveEnoughSticks)); | ||
|
||
return (haveEnoughCoal && haveEnoughSticks) ? ingredient : null; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/fr/sae/terraria/modele/entities/player/inventory/Inventory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.