Skip to content

Commit

Permalink
Reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
rcMarty committed Feb 11, 2024
1 parent e61fd5c commit 89c8c4a
Show file tree
Hide file tree
Showing 32 changed files with 112 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target/
!**/src/test/**/target/
/logs/
/.config/.env
/src/main/resources/static

### IntelliJ IDEA ###
.idea
Expand All @@ -14,3 +15,4 @@ target/

### VS Code ###
.vscode/

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class Dice {
new Roll(Roll.Type.SPECIAL, 1),
new Roll(Roll.Type.SPECIAL, 2)
));

public final List<Roll> rolls;

public Dice(List<Roll> pairs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@AllArgsConstructor
public class Roll {
private final Type type;

private final int value;

public Roll(Type type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ public class TestApp {

@Autowired
LocationRepo locationRepo;

@Autowired
CharacterRepo characterRepo;

@Autowired
EnemyRepo enemyRepo;

@Autowired
SummonRepo summonRepo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,46 @@
public class ValidationConfig {

private final HexGrid hexGrid;

private final Description description;

private final Title title;

private final Tag tag;

@Data
public static class HexGrid {
private int minHexes;

private int maxHexes;

private int maxWidth;
}

@Data
public static class Description {
private int maxLen;

private String allowedChars;
}

@Data
public static class Title {
private int minLen;

private int maxLen;

private String allowedChars;
}

@Data
public static class Tag {
private int minLen;

private int maxLen;

private String allowedChars;

private String prefix;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,30 @@ public class ValidationController {

//region Schema

@Autowired
PartRepo partRepo;

@Autowired
EnemyRepo enemyRepo;

@Autowired
SummonRepo summonRepo;

@Autowired
ActionRepo actionRepo;

//endregion

//region Encounter

@Autowired
EffectRepo effectRepo;

@PostMapping("/part")
public ResponseEntity<RestResponse> validatePart(@RequestBody PartDTO part) {
return validate(part);
}

@Autowired
PartRepo partRepo;
@PostMapping("/part/{id}")
public ResponseEntity<RestResponse> validatePartById(@PathVariable int id) {
return validate(partRepo.findById(id));
Expand All @@ -51,44 +68,34 @@ public ResponseEntity<RestResponse> validateHex(@RequestBody HexDTO hex) {
return validate(hex);
}

//endregion

//region Encounter

@PostMapping("/enemy")
public ResponseEntity<RestResponse> validateEnemy(@RequestBody EnemyDTO enemy) {
return validate(enemy);
}

@Autowired
EnemyRepo enemyRepo;
@PostMapping("/enemy/{id}")
public ResponseEntity<RestResponse> validateEnemyById(@PathVariable int id) {
return validate(enemyRepo.findById(id));
}

//endregion

@PostMapping("/summon")
public ResponseEntity<RestResponse> validateSummon(@RequestBody Summon summon) {
return validate(summon);
}

@Autowired
SummonRepo summonRepo;
@PostMapping("/summon/{id}")
public ResponseEntity<RestResponse> validateSummonById(@PathVariable int id) {
return validate(summonRepo.findById(id));
}

//endregion

//region Combat
@PostMapping("/action")
public ResponseEntity<RestResponse> validateAction(@RequestBody ActionDTO action) {
return validate(action);
}

@Autowired
ActionRepo actionRepo;
@PostMapping("/action/{id}")
public ResponseEntity<RestResponse> validateActionById(@PathVariable int id) {
return validate(actionRepo.findById(id));
Expand All @@ -99,8 +106,6 @@ public ResponseEntity<RestResponse> validateEffect(@RequestBody EffectDTO effect
return validate(effect);
}

@Autowired
EffectRepo effectRepo;
@PostMapping("/effect/{id}")
public ResponseEntity<RestResponse> validateEffectById(@PathVariable int id) {
return validate(effectRepo.findById(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
public class Pagination {

private int count;

private boolean hasMoreEntries;

private int totalEntries;

private int page;

private int limit;

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class RestPaginatedResult<T> {

private final Pagination pagination;

private final List<T> entries;

public static <T> RestPaginatedResult<T> of(Pagination pagination, List<T> entries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@Data
public class RestResponse {
private final HttpStatus status;

private final String message;

public RestResponse(HttpStatus status, String message, Object... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
@Data
public class RestError {
private final HttpStatus status;

private final String message;

private final List<RestSubError> errors = new ArrayList<>();

private LocalDateTime timestamp = LocalDateTime.now();

public RestError(HttpStatus status, String message, Object... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class CompositeError extends MessageError {

private String object;

private List<RestSubError> errors;

public CompositeError(String object, List<RestSubError> errors, String message, Object... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import cz.trailsthroughshadows.algorithm.util.Sanitized;
import cz.trailsthroughshadows.api.rest.model.error.RestSubError;
import lombok.*;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
@Setter
public class ValidationError extends MessageError {
private String object;

private String field;

private Object rejectedValue;

public ValidationError(String object, String field, Object rejectedValue, String message, Object... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class Achievement {

@Column(nullable = false, length = 128)
private String title;

@Column(nullable = false)
private String description;

@Column(nullable = false)
private int xpReward;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ActionController {

@Autowired
private ActionRepo actionRepo;

@Autowired
private MovementRepo movementRepo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class Summon extends Validable implements Cloneable {
@ManyToOne()
@JoinColumn(name = "idAction")
private ActionDTO action;

@OneToMany(mappedBy = "idSummon")
@ToString.Exclude
private Collection<SummonEffect> effects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import cz.trailsthroughshadows.api.rest.json.LazyFieldsFilter;
import cz.trailsthroughshadows.algorithm.validation.Validable;
import cz.trailsthroughshadows.algorithm.validation.ValidationConfig;
import cz.trailsthroughshadows.api.rest.json.LazyFieldsFilter;
import cz.trailsthroughshadows.api.rest.model.error.type.ValidationError;
import jakarta.annotation.Nullable;
import jakarta.persistence.*;
Expand Down Expand Up @@ -36,17 +36,6 @@ public class SummonAction extends Validable {
@Column
private Integer range;

@Embeddable
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class SummonActionId implements Serializable {
@Column(name = "idSummon")
private Integer idSummon;
@Column(name = "idAction")
private Integer idAction;
}

//region Validation
@Override
protected void validateInner(@Nullable ValidationConfig validationConfig) {
Expand All @@ -69,6 +58,18 @@ protected void validateInner(@Nullable ValidationConfig validationConfig) {
public String getValidableValue() {
return summon.getTitle() + " for " + range + " hexes.";
}

@Embeddable
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class SummonActionId implements Serializable {
@Column(name = "idSummon")
private Integer idSummon;

@Column(name = "idAction")
private Integer idAction;
}
//endregion
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class BackgroundController {

@Autowired
private ClazzRepo clazzRepo;

@Autowired
private RaceRepo raceRepo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public class Clazz {

@Column(nullable = false, length = 128)
private String title;

@Column(length = 32)
private String tag;

@Column(nullable = true)
private String description;

@Column(nullable = false)
private int baseHealth;

@Column(nullable = false)
private int baseDefence;

@Column(nullable = false)
private int baseInitiative;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ public class Race {

@Column(nullable = false, length = 128)
public String title;

@Column(nullable = false)
public int baseInitiative;

@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = LazyFieldsFilter.class)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "idRace")
public Collection<RaceEffect> effects;

@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = LazyFieldsFilter.class)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "idRace")
@ToString.Exclude
public Collection<RaceAction> actions;

@Column(length = 32)
private String tag;

@Column
private String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class CampaignAchievements {
public static class CampaignAchievementsId implements Serializable {
@Column(nullable = false)
private Integer idCampaign;

@Column(nullable = false)
private Integer idAchievement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public class MarketController {
@Autowired
private ItemRepo itemRepo;

@Autowired
private MarketRepo marketRepo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Item {
@OneToMany
@JoinColumn(name = "idItem")
private Collection<ItemEffect> effects;

@ManyToOne
@JoinColumn(name = "idAction")
private ActionDTO action;
Expand Down
Loading

0 comments on commit 89c8c4a

Please sign in to comment.