Skip to content

Commit 37b6219

Browse files
committed
Merge branch 'master' of github.com:cash1981/civilization-boardgame-rest
2 parents 0de7a5f + 304c74b commit 37b6219

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/main/java/no/asgari/civilization/server/action/PlayerAction.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,4 +715,21 @@ public void saveNote(String pbfId, String playerId, MessageDTO messageDTO) {
715715
playerhand.setGamenote(messageDTO.getMessage());
716716
pbfCollection.updateById(pbfId, pbf);
717717
}
718+
719+
public void takeTurnButton(String pbfId, String playerId) {
720+
Preconditions.checkNotNull(pbfId);
721+
Preconditions.checkNotNull(playerId);
722+
PBF pbf = pbfCollection.findOneById(pbfId);
723+
724+
pbf.getPlayers().stream()
725+
.filter(p -> p.isYourTurn())
726+
.forEach(p -> p.setYourTurn(false));
727+
728+
Playerhand playerhand = getPlayerhandByPlayerId(playerId, pbf);
729+
playerhand.setYourTurn(true);
730+
731+
pbfCollection.updateById(pbfId, pbf);
732+
733+
super.createCommonPublicLog("took turn button", pbfId, playerId);
734+
}
718735
}

src/main/java/no/asgari/civilization/server/resource/PlayerResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,12 @@ public Response saveNote(@Auth Player player, @NotEmpty @PathParam("pbfId") Stri
345345
return Response.ok().build();
346346
}
347347

348+
@PUT
349+
@Path("/turn/take")
350+
public Response takeTurn(@Auth Player player, @NotEmpty @PathParam("pbfId") String pbfId) {
351+
playerAction.takeTurnButton(pbfId, player.getId());
352+
return Response.ok().build();
353+
}
354+
355+
348356
}

0 commit comments

Comments
 (0)