Moved to Hibernate
This commit is contained in:
@@ -1,27 +1,58 @@
|
||||
package com.bernard.nodecames.model;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapsId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
public class World {
|
||||
|
||||
@EmbeddedId
|
||||
WorldId id;
|
||||
|
||||
@MapsId("gameId")
|
||||
@ManyToOne
|
||||
Game game;
|
||||
|
||||
String name;
|
||||
|
||||
// Config used when resetting this world
|
||||
GridConfig initialConfig;
|
||||
|
||||
@Nullable
|
||||
@ManyToOne(optional = true)
|
||||
Grid currentGrid;
|
||||
|
||||
boolean won;
|
||||
|
||||
public World(Game g, String name, GridConfig initConfig, Grid currentGrid, boolean won) {
|
||||
this.id = new WorldId(g.getId(), name);
|
||||
this.game = g;
|
||||
this.initialConfig = initConfig;
|
||||
this.currentGrid = currentGrid;
|
||||
this.won = won;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.getId().getName();
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Embeddable
|
||||
public static class WorldId {
|
||||
UUID gameId;
|
||||
String name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user