feat: One step ahead for interactions implementation
This commit is contained in:
@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
@ -24,6 +25,16 @@ public class RoomController {
|
||||
@Autowired
|
||||
private GameService gameService;
|
||||
|
||||
@GetMapping
|
||||
@CheckUser
|
||||
public ResponseEntity<UnifiedResponse<List<Room>, Error>> getAllRooms(@RequestParam("playerKey") String playerKey) {
|
||||
var player = playerRepository.findByPlayerKey(playerKey).get();
|
||||
|
||||
return ResponseEntity.ok(
|
||||
UnifiedResponse.success(player.getGame().getRooms())
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/current_room")
|
||||
@CheckUser
|
||||
public ResponseEntity<UnifiedResponse<Room, Error>> getCurrentRoom(@RequestParam("playerKey") String playerKey) {
|
||||
|
@ -10,8 +10,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/status")
|
||||
public class StatusController {
|
||||
|
||||
// Don't decode this base64, just go to /status endpoint, you'll be surprised
|
||||
@GetMapping
|
||||
public UnifiedResponse<String, Error> getStatus() {
|
||||
return UnifiedResponse.success("working");
|
||||
|
@ -42,6 +42,10 @@ public class Character {
|
||||
@JsonIgnore
|
||||
private List<Player> playersWhoSaw = new ArrayList<>();
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "interaction_data_id", referencedColumnName = "id")
|
||||
private cz.jzitnik.chronos.entities.Interaction interactionData;
|
||||
|
||||
private String dialog;
|
||||
|
||||
public Character(String name, Room room, String dialog) {
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cz.jzitnik.chronos.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class Interaction {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "start_text")
|
||||
private String startText;
|
||||
|
||||
@Column(name = "interacted_with_text")
|
||||
private String interactedWithText;
|
||||
|
||||
@OneToOne(mappedBy = "interactionData")
|
||||
@JsonIgnore
|
||||
private Character character;
|
||||
}
|
Reference in New Issue
Block a user