oups... bah beaucoup de choses
This commit is contained in:
parent
8dca2f10c6
commit
e6dfbfbe03
55 changed files with 943 additions and 72 deletions
|
|
@ -0,0 +1,78 @@
|
||||||
|
package fr.epita.assistants.yakamon.converter;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.GameEntity;
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.YakadexEntryEntity;
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.YakamonEntity;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.YakadexEntry;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.YakamonAction;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.request.StartGameRequest;
|
||||||
|
import fr.epita.assistants.yakamon.utils.ElementType;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public final class DtoToEntityConverter {
|
||||||
|
|
||||||
|
public static YakamonEntity toYakamonEntity(YakamonAction dto) {
|
||||||
|
if (dto == null) return null;
|
||||||
|
|
||||||
|
YakamonEntity entity = new YakamonEntity();
|
||||||
|
// may be null / invalid
|
||||||
|
if (dto.uuid != null) {
|
||||||
|
try {
|
||||||
|
entity.uuid = UUID.fromString(dto.uuid);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
entity.uuid = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entity.uuid = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.nickname = dto.nickname;
|
||||||
|
entity.yakadexId = dto.yakadexId;
|
||||||
|
entity.energyPoints = dto.energyPoints;
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YakadexEntryEntity toYakadexEntryEntity(YakadexEntry dto) {
|
||||||
|
if (dto == null) return null;
|
||||||
|
|
||||||
|
YakadexEntryEntity e = new YakadexEntryEntity();
|
||||||
|
e.id = dto.id;
|
||||||
|
e.name = dto.name;
|
||||||
|
e.description = dto.description;
|
||||||
|
e.evolveThreshold = dto.evolveThreshold;
|
||||||
|
e.evolutionId = dto.evolutionId;
|
||||||
|
e.caught = dto.caught;
|
||||||
|
|
||||||
|
// map element type strings to enum
|
||||||
|
if (dto.firstType != null) {
|
||||||
|
try {
|
||||||
|
e.firstType = ElementType.valueOf(dto.firstType);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
e.firstType = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e.firstType = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dto.secondType != null) {
|
||||||
|
try {
|
||||||
|
e.secondType = ElementType.valueOf(dto.secondType);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
e.secondType = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e.secondType = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameEntity toGameEntity(StartGameRequest request) {
|
||||||
|
if (request == null) return null;
|
||||||
|
GameEntity g = new GameEntity();
|
||||||
|
g.mapPath = request.mapPath;
|
||||||
|
g.start(LocalDateTime.now());
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
package fr.epita.assistants.yakamon.converter;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.YakadexEntryEntity;
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.YakamonEntity;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.YakadexEntry;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.YakamonAction;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class EntityToDtoConverter {
|
||||||
|
|
||||||
|
public static YakamonAction toYakamonAction(YakamonEntity e) {
|
||||||
|
if (e == null) return null;
|
||||||
|
String uuid = null;
|
||||||
|
if (e.uuid != null) {
|
||||||
|
uuid = e.uuid.toString();
|
||||||
|
}
|
||||||
|
return new YakamonAction(uuid, e.nickname, e.yakadexId, e.energyPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YakadexEntry toYakadexEntry(YakadexEntryEntity e) {
|
||||||
|
if (e == null) return null;
|
||||||
|
|
||||||
|
String firstType = null;
|
||||||
|
if (e.firstType != null) {
|
||||||
|
firstType = e.firstType.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
String secondType = null;
|
||||||
|
if (e.secondType != null) {
|
||||||
|
secondType = e.secondType.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer evolutionId = e.evolutionId;
|
||||||
|
|
||||||
|
return new YakadexEntry(
|
||||||
|
e.id,
|
||||||
|
e.name,
|
||||||
|
firstType,
|
||||||
|
secondType,
|
||||||
|
e.evolveThreshold,
|
||||||
|
evolutionId,
|
||||||
|
e.caught,
|
||||||
|
e.description
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<YakadexEntry> toYakadexEntries(
|
||||||
|
List<YakadexEntryEntity> entries
|
||||||
|
) {
|
||||||
|
List<YakadexEntry> out = new ArrayList<>();
|
||||||
|
if (entries == null || entries.isEmpty()) return out;
|
||||||
|
for (YakadexEntryEntity e : entries) {
|
||||||
|
YakadexEntry dto = toYakadexEntry(e);
|
||||||
|
if (dto != null) out.add(dto);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<YakamonAction> toYakamonActions(
|
||||||
|
List<YakamonEntity> yakamons
|
||||||
|
) {
|
||||||
|
List<YakamonAction> out = new ArrayList<>();
|
||||||
|
if (yakamons == null || yakamons.isEmpty()) return out;
|
||||||
|
for (YakamonEntity y : yakamons) {
|
||||||
|
YakamonAction a = toYakamonAction(y);
|
||||||
|
if (a != null) out.add(a);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
package fr.epita.assistants.yakamon.converter;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.data.model.GameModel;
|
||||||
|
import fr.epita.assistants.yakamon.data.model.PlayerModel;
|
||||||
|
import fr.epita.assistants.yakamon.data.model.YakadexEntryModel;
|
||||||
|
import fr.epita.assistants.yakamon.data.model.YakamonModel;
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.GameEntity;
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.PlayerEntity;
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.YakadexEntryEntity;
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.YakamonEntity;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public final class EntityToModelConverter {
|
||||||
|
|
||||||
|
public static GameModel toGameModel(GameEntity e) {
|
||||||
|
if (e == null) return null;
|
||||||
|
GameModel m = new GameModel();
|
||||||
|
m.map = e.mapPath;
|
||||||
|
m.started = e.started;
|
||||||
|
m.startTime = e.startTime;
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerModel toPlayerModel(PlayerEntity e) {
|
||||||
|
if (e == null) return null;
|
||||||
|
PlayerModel m = new PlayerModel();
|
||||||
|
m.name = e.name;
|
||||||
|
m.posX = e.posX;
|
||||||
|
m.posY = e.posY;
|
||||||
|
m.lastMove = e.lastMove;
|
||||||
|
m.lastCatch = e.lastCatch;
|
||||||
|
m.lastCollect = e.lastCollect;
|
||||||
|
m.lastFeed = e.lastFeed;
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YakamonModel toYakamonModel(YakamonEntity e) {
|
||||||
|
if (e == null) return null;
|
||||||
|
YakamonModel m = new YakamonModel();
|
||||||
|
m.nickname = e.nickname;
|
||||||
|
m.energyPoints = e.energyPoints;
|
||||||
|
if (e.yakadexId != null) {
|
||||||
|
YakadexEntryModel yakadex = new YakadexEntryModel();
|
||||||
|
yakadex.name = null;
|
||||||
|
yakadex.caught = null;
|
||||||
|
yakadex.firstType = null;
|
||||||
|
yakadex.secondType = null;
|
||||||
|
yakadex.description = null;
|
||||||
|
yakadex.evolveThreshold = null;
|
||||||
|
m.yakadexEntryId = yakadex;
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static YakadexEntryModel toYakadexEntryModel(YakadexEntryEntity e) {
|
||||||
|
if (e == null) return null;
|
||||||
|
YakadexEntryModel m = new YakadexEntryModel();
|
||||||
|
m.name = e.name;
|
||||||
|
m.caught = e.caught;
|
||||||
|
m.firstType = e.firstType;
|
||||||
|
m.secondType = e.secondType;
|
||||||
|
m.description = e.description;
|
||||||
|
m.evolveThreshold = e.evolveThreshold;
|
||||||
|
m.evolutionId = null; // don't know yet
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
package fr.epita.assistants.yakamon.data.model;
|
package fr.epita.assistants.yakamon.data.model;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Entity @Table(name="game")
|
@Entity
|
||||||
|
@Table(name = "game")
|
||||||
public class GameModel {
|
public class GameModel {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY) protected Long id;
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
public Long id;
|
||||||
|
|
||||||
public String map;
|
public String map;
|
||||||
|
public boolean started;
|
||||||
|
public LocalDateTime startTime;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,22 @@
|
||||||
package fr.epita.assistants.yakamon.data.model;
|
package fr.epita.assistants.yakamon.data.model;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "player")
|
@Table(name = "player")
|
||||||
public class PlayerModel {
|
public class PlayerModel {
|
||||||
@Id @GeneratedValue(strategy = GenerationType.UUID) protected UUID id;
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.UUID)
|
||||||
|
public UUID id;
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public Integer posX;
|
public Integer posX;
|
||||||
public Integer posY;
|
public Integer posY;
|
||||||
public Timestamp lastMove;
|
public LocalDateTime lastMove;
|
||||||
public Timestamp lastCatch;
|
public LocalDateTime lastCatch;
|
||||||
public Timestamp lastCollect;
|
public LocalDateTime lastCollect;
|
||||||
public Timestamp lastFeed;
|
public LocalDateTime lastFeed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,25 @@
|
||||||
package fr.epita.assistants.yakamon.data.model;
|
package fr.epita.assistants.yakamon.data.model;
|
||||||
|
|
||||||
|
|
||||||
import fr.epita.assistants.yakamon.utils.ElementType;
|
import fr.epita.assistants.yakamon.utils.ElementType;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "yakadex_entry")
|
@Table(name = "yakadex_entry")
|
||||||
public class YakadexEntryModel {
|
public class YakadexEntryModel {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY) protected Integer id;
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
public Integer id;
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public Boolean caught;
|
public Boolean caught;
|
||||||
public ElementType firstType;
|
public ElementType firstType;
|
||||||
public ElementType secondType;
|
public ElementType secondType;
|
||||||
public String description;
|
public String description;
|
||||||
@OneToOne @JoinColumn(name="evolution_id") public YakadexEntryModel evolutionId;
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "evolution_id")
|
||||||
|
public YakadexEntryModel evolutionId;
|
||||||
|
|
||||||
public Integer evolveThreshold;
|
public Integer evolveThreshold;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package fr.epita.assistants.yakamon.data.repository;
|
||||||
|
|
||||||
|
public class GameRepository {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package fr.epita.assistants.yakamon.data.repository;
|
||||||
|
|
||||||
|
public class PlayerRepository {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package fr.epita.assistants.yakamon.data.repository;
|
||||||
|
|
||||||
|
public class TeamRepository {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package fr.epita.assistants.yakamon.data.repository;
|
||||||
|
|
||||||
|
public class YakadexRepository {}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.entity;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public class GameEntity {
|
||||||
|
|
||||||
|
public Long id;
|
||||||
|
public String mapPath;
|
||||||
|
public boolean started;
|
||||||
|
public LocalDateTime startTime;
|
||||||
|
|
||||||
|
public GameEntity() {}
|
||||||
|
|
||||||
|
public GameEntity(
|
||||||
|
Long id,
|
||||||
|
String mapPath,
|
||||||
|
boolean started,
|
||||||
|
LocalDateTime startTime
|
||||||
|
) {
|
||||||
|
this.id = id;
|
||||||
|
this.mapPath = mapPath;
|
||||||
|
this.started = started;
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameEntity start(LocalDateTime startTime) {
|
||||||
|
// TODO
|
||||||
|
startTime = startTime == null ? LocalDateTime.now() : startTime;
|
||||||
|
started = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameEntity stop() {
|
||||||
|
this.started = false;
|
||||||
|
this.startTime = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.entity;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.utils.tile.ItemType;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ItemEntity {
|
||||||
|
|
||||||
|
public Integer id;
|
||||||
|
public ItemType type;
|
||||||
|
public Integer quantity;
|
||||||
|
|
||||||
|
public ItemEntity(Integer id, ItemType type, Integer quantity) {
|
||||||
|
this.id = id;
|
||||||
|
if (type == null) {
|
||||||
|
System.err.println(
|
||||||
|
"Warning: attempted to pass null item type, using default 'NONE'"
|
||||||
|
);
|
||||||
|
type = ItemType.NONE;
|
||||||
|
}
|
||||||
|
this.type = Objects.requireNonNull(type, "type must not be null");
|
||||||
|
this.quantity = quantity != null ? quantity : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public ItemEntity addQuantity(int amount) {
|
||||||
|
// int current = this.quantity != null ? this.quantity : 0;
|
||||||
|
// this.quantity = current + amount;
|
||||||
|
// return this;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.entity;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.utils.ElementType;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class YakadexEntryEntity {
|
||||||
|
|
||||||
|
public Integer id;
|
||||||
|
public String name;
|
||||||
|
public ElementType firstType;
|
||||||
|
public ElementType secondType;
|
||||||
|
public Integer evolveThreshold;
|
||||||
|
public Integer evolutionId;
|
||||||
|
public Boolean caught;
|
||||||
|
public String description;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.entity;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class YakamonEntity {
|
||||||
|
|
||||||
|
public UUID uuid;
|
||||||
|
public String nickname;
|
||||||
|
public Integer yakadexId;
|
||||||
|
public Integer energyPoints;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.service;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.GameEntity;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GameService {
|
||||||
|
|
||||||
|
public static GameEntity game = new GameEntity();
|
||||||
|
public static final GameService INSTANCE = new GameService(); // TODO ?
|
||||||
|
|
||||||
|
public GameEntity startGame(String mapPath) {
|
||||||
|
if (mapPath == null) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Could not start game with null mapPath"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (game == null) {
|
||||||
|
game = new GameEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
game.start(LocalDateTime.now());
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStarted() {
|
||||||
|
return game != null && game.started;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopGame() {
|
||||||
|
if (game == null) {
|
||||||
|
game = new GameEntity();
|
||||||
|
}
|
||||||
|
game.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.service;
|
||||||
|
|
||||||
|
public class PlayerService {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.service;
|
||||||
|
|
||||||
|
public class TeamService {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package fr.epita.assistants.yakamon.domain.service;
|
||||||
|
|
||||||
|
public class YakadexService {}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.api;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class YakadexEntry {
|
||||||
|
|
||||||
|
public Integer id;
|
||||||
|
public String name;
|
||||||
|
public String firstType;
|
||||||
|
public String secondType;
|
||||||
|
public Integer evolveThreshold;
|
||||||
|
public Integer evolutionId;
|
||||||
|
public Boolean caught;
|
||||||
|
public String description;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.api;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class YakamonAction {
|
||||||
|
|
||||||
|
public String uuid;
|
||||||
|
public String nickname;
|
||||||
|
public Integer yakadexId;
|
||||||
|
public Integer energyPoints;
|
||||||
|
}
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GetInventoryRequest {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
public class PlayerCatchRequest {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
import fr.epita.assistants.yakamon.utils.tile.ItemType;
|
|
||||||
import fr.epita.assistants.yakamon.utils.tile.TerrainType;
|
|
||||||
|
|
||||||
public class PlayerCollectRequest {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
public class PlayerInfosRequest {
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
package fr.epita.assistants.yakamon.presentation.api.request;
|
||||||
|
|
||||||
import fr.epita.assistants.yakamon.utils.Direction;
|
import fr.epita.assistants.yakamon.utils.Direction;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class PlayerMoveRequest {
|
public class PlayerMoveRequest {
|
||||||
|
|
||||||
Direction direction;
|
Direction direction;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
package fr.epita.assistants.yakamon.presentation.api.request;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class StartGameRequest {
|
public class StartGameRequest {
|
||||||
|
|
||||||
public String mapPath;
|
public String mapPath;
|
||||||
public String playerName;
|
public String playerName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
public class TeamEvolveRequest {
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
package fr.epita.assistants.yakamon.presentation.api.request;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class TeamFeedRequest {
|
public class TeamFeedRequest {
|
||||||
|
|
||||||
public Integer quantity;
|
public Integer quantity;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
public class TeamInfosRequest {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
public class TeamReleaseRequest {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
package fr.epita.assistants.yakamon.presentation.api.request;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class TeamRenameRequest {
|
public class TeamRenameRequest {
|
||||||
|
|
||||||
|
public String newNickname;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
public class YakadexAllInfosRequest {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.request;
|
|
||||||
|
|
||||||
public class YakadexInfosRequest {
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ErrorResponse {
|
||||||
|
|
||||||
|
public String message;
|
||||||
|
}
|
||||||
|
|
@ -1,15 +1,19 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class GetInventoryResponse {
|
public class GetInventoryResponse {
|
||||||
|
|
||||||
public class ItemType {
|
public class ItemType {
|
||||||
|
|
||||||
public String type;
|
public String type;
|
||||||
public String value;
|
public String value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Items {
|
public class Items {
|
||||||
|
|
||||||
public ItemType itemType;
|
public ItemType itemType;
|
||||||
public Integer quantity;
|
public Integer quantity;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,15 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
public class PlayerCatchResponse {
|
import fr.epita.assistants.yakamon.presentation.api.YakamonAction;
|
||||||
public String uuid;
|
|
||||||
public String nickname;
|
public class PlayerCatchResponse extends YakamonAction {
|
||||||
public Integer yakadexId;
|
|
||||||
public Integer energyPoints;
|
public PlayerCatchResponse(
|
||||||
|
String uuid,
|
||||||
|
String nickname,
|
||||||
|
Integer yakadexId,
|
||||||
|
Integer energyPoints
|
||||||
|
) {
|
||||||
|
super(uuid, nickname, yakadexId, energyPoints);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,15 @@ package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
import fr.epita.assistants.yakamon.utils.tile.ItemType;
|
import fr.epita.assistants.yakamon.utils.tile.ItemType;
|
||||||
import fr.epita.assistants.yakamon.utils.tile.TerrainType;
|
import fr.epita.assistants.yakamon.utils.tile.TerrainType;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class PlayerCollectResponse {
|
public class PlayerCollectResponse {
|
||||||
|
|
||||||
public class TileType {
|
public class TileType {
|
||||||
|
|
||||||
public class Collectible {
|
public class Collectible {
|
||||||
|
|
||||||
ItemType type;
|
ItemType type;
|
||||||
String value;
|
String value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class PlayerInfosResponse {
|
public class PlayerInfosResponse {
|
||||||
//TODO
|
|
||||||
// Player model
|
public String uuid;
|
||||||
|
public String name;
|
||||||
|
public Integer posX;
|
||||||
|
public Integer posY;
|
||||||
|
public String lastMove;
|
||||||
|
public String lastCatch;
|
||||||
|
public String lastCollect;
|
||||||
|
public String lastFeed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class PlayerMoveResponse {
|
public class PlayerMoveResponse {
|
||||||
|
|
||||||
public Integer posX;
|
public Integer posX;
|
||||||
public Integer posY;
|
public Integer posY;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,21 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class StartGameResponse {
|
public class StartGameResponse {
|
||||||
|
|
||||||
|
public class Collectible {
|
||||||
|
|
||||||
|
public String item;
|
||||||
|
public String value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Tile {
|
||||||
|
|
||||||
|
String terrainType;
|
||||||
|
Collectible collectible;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tile[][] tiles;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
public class TeamEvolveResponse {
|
import fr.epita.assistants.yakamon.presentation.api.YakamonAction;
|
||||||
|
|
||||||
|
public class TeamEvolveResponse extends YakamonAction {
|
||||||
|
|
||||||
|
public TeamEvolveResponse(
|
||||||
|
String uuid,
|
||||||
|
String nickname,
|
||||||
|
Integer yakadexId,
|
||||||
|
Integer energyPoints
|
||||||
|
) {
|
||||||
|
super(uuid, nickname, yakadexId, energyPoints);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
public class TeamFeedResponse {
|
import fr.epita.assistants.yakamon.presentation.api.YakamonAction;
|
||||||
|
|
||||||
|
public class TeamFeedResponse extends YakamonAction {
|
||||||
|
|
||||||
|
public TeamFeedResponse(
|
||||||
|
String uuid,
|
||||||
|
String nickname,
|
||||||
|
Integer yakadexId,
|
||||||
|
Integer energyPoints
|
||||||
|
) {
|
||||||
|
super(uuid, nickname, yakadexId, energyPoints);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.YakamonAction;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class TeamInfosResponse {
|
public class TeamInfosResponse {
|
||||||
|
|
||||||
|
YakamonAction[] yakamons;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
|
||||||
|
|
||||||
public class TeamReleaseResponse {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
public class TeamRenameResponse {
|
import fr.epita.assistants.yakamon.presentation.api.YakamonAction;
|
||||||
|
|
||||||
|
public class TeamRenameResponse extends YakamonAction {
|
||||||
|
|
||||||
|
public TeamRenameResponse(
|
||||||
|
String uuid,
|
||||||
|
String nickname,
|
||||||
|
Integer yakadexId,
|
||||||
|
Integer energyPoints
|
||||||
|
) {
|
||||||
|
super(uuid, nickname, yakadexId, energyPoints);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,10 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.YakadexEntry;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class YakadexAllInfosResponse {
|
public class YakadexAllInfosResponse {
|
||||||
|
|
||||||
|
YakadexEntry[] entries;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,28 @@
|
||||||
package fr.epita.assistants.yakamon.presentation.api.response;
|
package fr.epita.assistants.yakamon.presentation.api.response;
|
||||||
|
|
||||||
public class YakadexInfosResponse {
|
import fr.epita.assistants.yakamon.presentation.api.YakadexEntry;
|
||||||
|
|
||||||
|
public class YakadexInfosResponse extends YakadexEntry {
|
||||||
|
|
||||||
|
public YakadexInfosResponse(
|
||||||
|
Integer id,
|
||||||
|
String name,
|
||||||
|
String firstType,
|
||||||
|
String secondType,
|
||||||
|
Integer evolveThreshold,
|
||||||
|
Integer evolutionId,
|
||||||
|
Boolean caught,
|
||||||
|
String description
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
firstType,
|
||||||
|
secondType,
|
||||||
|
evolveThreshold,
|
||||||
|
evolutionId,
|
||||||
|
caught,
|
||||||
|
description
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.rest;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.domain.entity.GameEntity;
|
||||||
|
import fr.epita.assistants.yakamon.domain.service.GameService;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.request.StartGameRequest;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.StartGameResponse;
|
||||||
|
import jakarta.ws.rs.Consumes;
|
||||||
|
import jakarta.ws.rs.POST;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@Path("/start")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public class GameResource {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(
|
||||||
|
GameResource.class.getName()
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/")
|
||||||
|
public Response start(StartGameRequest request) {
|
||||||
|
if (
|
||||||
|
request == null ||
|
||||||
|
request.mapPath == null ||
|
||||||
|
request.mapPath.isBlank() ||
|
||||||
|
request.playerName == null ||
|
||||||
|
request.playerName.isBlank()
|
||||||
|
) {
|
||||||
|
LOGGER.warning(
|
||||||
|
"Invalid start request: missing mapPath or playerName"
|
||||||
|
);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Invalid mapPath or playerName")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info(
|
||||||
|
"Starting game for player='" +
|
||||||
|
request.playerName +
|
||||||
|
"' with map='" +
|
||||||
|
request.mapPath +
|
||||||
|
"'"
|
||||||
|
);
|
||||||
|
|
||||||
|
GameService gameService = new GameService();
|
||||||
|
GameEntity startedGame = gameService.startGame(request.mapPath);
|
||||||
|
|
||||||
|
LOGGER.info(
|
||||||
|
"Game started at: " +
|
||||||
|
(startedGame != null ? startedGame.startTime : "unknown")
|
||||||
|
);
|
||||||
|
|
||||||
|
// StartGameResponse response = new StartGameResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.rest;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.GetInventoryResponse;
|
||||||
|
import jakarta.ws.rs.Consumes;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("/inventory")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public class InventoryResource {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
public Response getInventory() {
|
||||||
|
// GetInventoryResponse response = new GetInventoryResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.rest;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.domain.service.GameService;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.request.PlayerMoveRequest;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.GetInventoryResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.PlayerCatchResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.PlayerCollectResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.PlayerInfosResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.PlayerMoveResponse;
|
||||||
|
import jakarta.ws.rs.*;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("/")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public class PlayerResource {
|
||||||
|
|
||||||
|
private final GameService gameService = new GameService();
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/catch")
|
||||||
|
public Response catchYakamon() {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
// TODO service
|
||||||
|
return Response.status(Response.Status.NOT_IMPLEMENTED).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/collect")
|
||||||
|
public Response collect() {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
// TODO service
|
||||||
|
return Response.status(Response.Status.NOT_IMPLEMENTED).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/inventory")
|
||||||
|
public Response getInventory() {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
// TODO service
|
||||||
|
// GetInventoryResponse response = inventoryService.getInventory();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.status(Response.Status.NOT_IMPLEMENTED).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/move")
|
||||||
|
public Response move(PlayerMoveRequest request) {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
if (request == null) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Request body is required")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (request.direction == null) {
|
||||||
|
// return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
// .entity("Direction is required")
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
// TODO service
|
||||||
|
return Response.status(Response.Status.NOT_IMPLEMENTED).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/player")
|
||||||
|
public Response getPlayerInfos() {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO service
|
||||||
|
// PlayerInfosResponse response = playerService.getInfos(...);
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.status(Response.Status.NOT_IMPLEMENTED).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.rest;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.domain.service.GameService;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.request.TeamFeedRequest;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.request.TeamRenameRequest;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.TeamEvolveResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.TeamFeedResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.TeamInfosResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.TeamRenameResponse;
|
||||||
|
import jakarta.ws.rs.*;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("/team")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public class TeamResource {
|
||||||
|
|
||||||
|
private final GameService gameService = new GameService();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
public Response getTeam() {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
// TODO service
|
||||||
|
// TeamInfosResponse response = new TeamInfosResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/{uuid}/evolve")
|
||||||
|
public Response evolve(@PathParam("uuid") String uuid) {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
if (uuid == null || uuid.isBlank()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Missing or invalid uuid")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO service
|
||||||
|
// TeamEvolveResponse response = new TeamEvolveResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/{uuid}/feed")
|
||||||
|
public Response feed(
|
||||||
|
@PathParam("uuid") String uuid,
|
||||||
|
TeamFeedRequest request
|
||||||
|
) {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
if (uuid == null || uuid.isBlank()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Missing or invalid uuid")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
request == null || request.quantity == null || request.quantity <= 0
|
||||||
|
) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Invalid quantity")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO service
|
||||||
|
// TeamFeedResponse response = new TeamFeedResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("/{uuid}/release")
|
||||||
|
public Response release(@PathParam("uuid") String uuid) {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
if (uuid == null || uuid.isBlank()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Missing or invalid uuid")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO service
|
||||||
|
// return 204 (No Content) to match the subject
|
||||||
|
return Response.noContent().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PATCH
|
||||||
|
@Path("/{uuid}/rename")
|
||||||
|
public Response rename(
|
||||||
|
@PathParam("uuid") String uuid,
|
||||||
|
TeamRenameRequest request
|
||||||
|
) {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game not started")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
if (uuid == null || uuid.isBlank()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Missing or invalid uuid")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
if (request == null) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Missing request body")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO service
|
||||||
|
// TeamRenameResponse response = new TeamRenameResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package fr.epita.assistants.yakamon.presentation.rest;
|
||||||
|
|
||||||
|
import fr.epita.assistants.yakamon.domain.service.GameService;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.YakadexAllInfosResponse;
|
||||||
|
import fr.epita.assistants.yakamon.presentation.api.response.YakadexInfosResponse;
|
||||||
|
import jakarta.ws.rs.*;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@Path("/yakadex")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public class YakadexResource {
|
||||||
|
|
||||||
|
private final GameService gameService = new GameService();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
public Response getYakadex(
|
||||||
|
@QueryParam("only_missing") Boolean onlyMissing
|
||||||
|
) {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game is not running")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// YakadexAllInfosResponse response = new YakadexAllInfosResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{id}")
|
||||||
|
public Response getYakadexById(@PathParam("id") Integer id) {
|
||||||
|
if (!gameService.isStarted()) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("Game is not running")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == null || id < 0) {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// YakadexInfosResponse response = new YakadexInfosResponse();
|
||||||
|
// return Response.ok(response).build();
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue