-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5084360
commit 07a1569
Showing
28 changed files
with
439 additions
and
342 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
59 changes: 0 additions & 59 deletions
59
server/src/main/java/de/pnp/manager/component/IRecipeEntry.java
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
server/src/main/java/de/pnp/manager/component/IResourceUsage.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,62 @@ | ||
package de.pnp.manager.component; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import de.pnp.manager.component.IResourceUsage.CharacterResourceUsage; | ||
import de.pnp.manager.component.IResourceUsage.ItemUsage; | ||
import de.pnp.manager.component.IResourceUsage.MaterialUsage; | ||
import de.pnp.manager.component.attributes.SecondaryAttribute; | ||
import de.pnp.manager.component.item.Item; | ||
import de.pnp.manager.component.item.Material; | ||
import de.pnp.manager.component.upgrade.UpgradeRecipe; | ||
import de.pnp.manager.validation.IsConsumable; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
import org.springframework.data.mongodb.core.mapping.DBRef; | ||
|
||
/** | ||
* The product or an entry in the material list of a {@link CraftingRecipe} or an {@link UpgradeRecipe}. | ||
*/ | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = ItemUsage.class, name = "ItemUsage"), | ||
@JsonSubTypes.Type(value = MaterialUsage.class, name = "MaterialUsage"), | ||
@JsonSubTypes.Type(value = CharacterResourceUsage.class, name = "CharacterResourceUsage") | ||
}) | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME) | ||
public sealed interface IResourceUsage<T> { | ||
|
||
/** | ||
* The amount needed for this {@link IResourceUsage}. | ||
*/ | ||
float amount(); | ||
|
||
/** | ||
* The resource needed for this {@link IResourceUsage}. | ||
*/ | ||
T resource(); | ||
|
||
/** | ||
* An {@link IResourceUsage} which uses a specific {@link Item}. | ||
*/ | ||
record ItemUsage(@Positive float amount, @DBRef @NotNull Item resource) implements | ||
IResourceUsage<Item> { | ||
|
||
} | ||
|
||
/** | ||
* An {@link IResourceUsage} which uses a {@link Material}. | ||
*/ | ||
record MaterialUsage(@Positive float amount, @DBRef @NotNull Material resource) implements | ||
IResourceUsage<Material> { | ||
|
||
} | ||
|
||
/** | ||
* An {@link IResourceUsage} which uses a {@link SecondaryAttribute} of a player. | ||
*/ | ||
record CharacterResourceUsage(@Positive float amount, | ||
@DBRef @NotNull @IsConsumable SecondaryAttribute resource) implements | ||
IResourceUsage<SecondaryAttribute> { | ||
|
||
} | ||
} |
Oops, something went wrong.