Skip to content

Commit

Permalink
update for latest GHS, drop objective migration, drop revision migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkars committed Mar 11, 2024
1 parent 26777fe commit 816afe0
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 406 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<revision>0.90.3</revision>
<revision>0.91.0</revision>
</properties>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,12 @@ public String updateGame(@RequestHeader(name = HttpHeaders.AUTHORIZATION) String
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "invalid game payload");
}

// Migration: check if revision is set
if (gameUpdate.getRevision() != null && game.getRevision() != null) {
if (gameUpdate.getRevision() == game.getRevision()) {
game.setPlaySeconds(gameUpdate.getPlaySeconds());
gameUpdate = game;
} else if (gameUpdate.getRevision() <= game.getRevision()) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
"invalid revision: " + gameUpdate.getRevision());
}
if (gameUpdate.getRevision() == game.getRevision()) {
game.setPlaySeconds(gameUpdate.getPlaySeconds());
gameUpdate = game;
} else if (gameUpdate.getRevision() < game.getRevision()) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
"invalid revision: " + gameUpdate.getRevision());
}

if (permissions != null) {
Expand Down
22 changes: 1 addition & 21 deletions src/main/java/de/champonthis/ghs/server/model/GameModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public class GameModel {

// @Required // Migration
@Required
private Long revision;
private int revisionOffset = 0;
private String edition;
Expand All @@ -30,8 +30,6 @@ public class GameModel {
private LinkedList<GameCharacterModel> characters = new LinkedList<>();
@Required
private LinkedList<GameMonsterModel> monsters = new LinkedList<>();
@Required
private LinkedList<GameObjectiveModel> objectives = new LinkedList<>();
private LinkedList<GameObjectiveContainerModel> objectiveContainers = new LinkedList<>();
@Required
private GameState state = GameState.DRAW;
Expand Down Expand Up @@ -272,24 +270,6 @@ public void setMonsters(LinkedList<GameMonsterModel> monsters) {
this.monsters = monsters;
}

/**
* Gets the objectives.
*
* @return the objectives
*/
public LinkedList<GameObjectiveModel> getObjectives() {
return objectives;
}

/**
* Sets the objectives.
*
* @param objectives the new objectives
*/
public void setObjectives(LinkedList<GameObjectiveModel> objectives) {
this.objectives = objectives;
}

/**
* Gets the objective containers.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class GameObjectiveContainerModel {
private int health;
private Integer initiative;
private ScenarioObjectiveIdentifier objectiveId;
private AdditionalIdentifier additionalObjectiveId;

/**
* Gets the uuid.
Expand Down Expand Up @@ -243,5 +244,22 @@ public ScenarioObjectiveIdentifier getObjectiveId() {
public void setObjectiveId(ScenarioObjectiveIdentifier objectiveId) {
this.objectiveId = objectiveId;
}
/**
* Gets the additional objective id.
*
* @return the additional objective id
*/
public AdditionalIdentifier getAdditionalObjectiveId() {
return additionalObjectiveId;
}

/**
* Sets the additional objective id.
*
* @param additionalObjectiveId the new additional objective id
*/
public void setAdditionalObjectiveId(AdditionalIdentifier additionalObjectiveId) {
this.additionalObjectiveId = additionalObjectiveId;
}

}
Loading

0 comments on commit 816afe0

Please sign in to comment.