-
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.
Merge branch 'dev' into feature/item
- Loading branch information
Showing
10 changed files
with
229 additions
and
5 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
16 changes: 16 additions & 0 deletions
16
src/main/java/club/ttg/dnd5/model/spell/component/SpellMaterialComponent.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,16 @@ | ||
package club.ttg.dnd5.model.spell.component; | ||
|
||
import club.ttg.dnd5.model.spell.enums.ComparisonOperator; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
public class SpellMaterialComponent { | ||
private String name; // Название компонента | ||
private Integer price; // Цена (используем Integer вместо int, чтобы допустить null) | ||
private ComparisonOperator comparison; // Оператор сравнения | ||
private boolean consumable; // Расходуемый или нет | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/club/ttg/dnd5/model/spell/enums/ComparisonOperator.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,27 @@ | ||
package club.ttg.dnd5.model.spell.enums; | ||
|
||
public enum ComparisonOperator { | ||
LESS("<"), | ||
GREATER(">"), | ||
EQUAL("="); | ||
|
||
private final String symbol; | ||
|
||
ComparisonOperator(String symbol) { | ||
this.symbol = symbol; | ||
} | ||
|
||
public String getSymbol() { | ||
return symbol; | ||
} | ||
|
||
public static ComparisonOperator fromSymbol(String symbol) { | ||
for (ComparisonOperator op : values()) { | ||
if (op.symbol.equals(symbol)) { | ||
return op; | ||
} | ||
} | ||
throw new IllegalArgumentException("Invalid comparison operator: " + symbol); | ||
} | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
src/main/java/club/ttg/dnd5/model/spell/enums/MagicSchool.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,40 @@ | ||
package club.ttg.dnd5.model.spell.enums; | ||
|
||
import club.ttg.dnd5.exception.ApiException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public enum MagicSchool { | ||
CONJURATION("вызов", 0), | ||
EVOCATION("воплощение", 1), | ||
ILLUSION("иллюзия", 2), | ||
NECROMANCY("некромантия", 3), | ||
ABJURATION("ограждение", 4), | ||
ENCHANTMENT("очарование", 5), | ||
TRANSMUTATION("преобразование", 6), | ||
DIVINATION("прорицание", 7); | ||
|
||
private String name; | ||
private int code; | ||
|
||
MagicSchool(String name, int code) { | ||
this.name = name; | ||
this.code = code; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
|
||
public static MagicSchool getMagicSchool(String name) { | ||
for (MagicSchool school : values()) { | ||
if (school.name.equalsIgnoreCase(name)) { | ||
return school; | ||
} | ||
} | ||
throw new ApiException(HttpStatus.NOT_FOUND, "Неправильное название школы магии"); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/club/ttg/dnd5/model/spell/enums/TimeUnit.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,42 @@ | ||
package club.ttg.dnd5.model.spell.enums; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum TimeUnit { | ||
BONUS("бонусное действие"), | ||
REACTION("реакция"), | ||
ACTION("действие"), | ||
ROUND("ход"), | ||
MINUTE("минута"), | ||
HOUR("час"); | ||
|
||
private final String name; | ||
|
||
public String getName(int number) { | ||
return switch (this) { | ||
case MINUTE -> formatTime(number, "минута", "минуты", "минут"); | ||
case HOUR -> formatTime(number, "час", "часа", "часов"); | ||
default -> name; | ||
}; | ||
} | ||
|
||
private String formatTime(int number, String singular, String dual, String plural) { | ||
int lastDigit = number % 10; | ||
int lastTwoDigits = number % 100; | ||
|
||
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) { | ||
return plural; | ||
} | ||
|
||
if (lastDigit == 1) { | ||
return singular; | ||
} else if (lastDigit >= 2 && lastDigit <= 4) { | ||
return dual; | ||
} else { | ||
return plural; | ||
} | ||
} | ||
} |
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