package com.alterdekim.game.entity;

import com.alterdekim.game.controller.result.api.ApiResult;
import com.alterdekim.game.controller.result.api.LocationResult;
import com.alterdekim.game.controller.result.api.PreloaderResult;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Entity
@Table(name = "locations")
public class Location implements ApiResult {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false)
    private Long locationId;

    @Column(nullable = false)
    private Long mediaResourceId;

    @Column(nullable = false)
    private Double x;

    @Column(nullable = false)
    private Double y;

    @Column(nullable = false, length = 65555)
    private String name;

    @Column(nullable = false)
    private Boolean isDefault;

    @Column(nullable = false)
    private Boolean isEnabled;

    public Location(Long locationId, Long mediaResourceId, Double x, Double y, String name, Boolean isDefault, Boolean isEnabled) {
        this.locationId = locationId;
        this.mediaResourceId = mediaResourceId;
        this.x = x;
        this.y = y;
        this.name = name;
        this.isDefault = isDefault;
        this.isEnabled = isEnabled;
    }

    @Override
    public LocationResult toAPIResult() {
        return new LocationResult(this.id, this.locationId, this.mediaResourceId, this.x, this.y, this.name, this.isDefault, this.isEnabled);
    }
}
