package premium_store.controller.DTO;

import com.fasterxml.jackson.annotation.JsonProperty;
import premium_store.model.GameClient;

import java.util.List;

//класс, который соединяет танки клиента в одну строчку (нам так захотелось)
public class ClientDTO {
    private long id;
    private String nickName;
    private String email;
    private Integer balance;
    private List<TankDTO> tanks;

    public ClientDTO(){ }

    public ClientDTO(GameClient gameClient){
        this.id = gameClient.getId();
        this.nickName = gameClient.getNickName();
        this.email = gameClient.getEmail();
        this.balance = gameClient.getBalance();
        this.tanks = gameClient.getTanks().stream()
                .map(TankDTO::new)
                .toList();
    }

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    public long getId(){
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getNickName(){
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getEmail(){
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getBalance(){
        return balance;
    }

    public void setBalance(Integer balance) {
        this.balance = balance;
    }

    public List<TankDTO> getTanks(){
        return tanks;
    }

    public Long getIdLastTanks(){
        return tanks.get(tanks.size() - 1).getId();
    }

    public void setTanks(List<TankDTO> tanks) {
        this.tanks = tanks;
    }
}
