package com.alterdekim.game.entity;

import com.alterdekim.flash.decompiler.mapper.FlashClass;
import com.alterdekim.flash.decompiler.mapper.FlashField;
import com.alterdekim.flash.decompiler.mapper.FlashValue;
import com.alterdekim.flash.decompiler.mapper.FlashValueType;
import com.alterdekim.game.component.game.RoleFlags;
import com.alterdekim.game.mapper.Integer2BooleanConverter;
import com.alterdekim.game.mapper.Integer2RoleFlagsConverter;
import com.alterdekim.game.mapper.String2DateConverter;
import com.alterdekim.game.xml.RoleFlagsDeserializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;
import java.util.Date;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="goods")
@ToString
@FlashClass(name = "g")
public class Good {

    @Id
    @FlashValue(type = FlashValueType.Id)
    private Long id;

    @FlashField(name = "MRId")
    @Column(nullable = false)
    private Integer mRId = -1;

    @FlashField(name = "TRId")
    @Column(nullable = false)
    private Integer tRId = -1;

    @FlashField(name = "IconMRId")
    @Column(nullable = false)
    private Integer iconMRId = -1;

    @FlashField(name = "DescTRId")
    @Column(nullable = false)
    private Integer descTRId = -1;

    @FlashField(name = "GoodTypeId")
    @Column(nullable = false)
    private Integer goodTypeId;

    @FlashField(name = "RoleFlags", useCustomConverter = true, converter = Integer2RoleFlagsConverter.class)
    @Enumerated(EnumType.STRING)
    private RoleFlags roleFlags = RoleFlags.NONE;

    @FlashField(name = "UsualTickets")
    @Column(nullable = false)
    private Integer usualTickets = 0;

    @FlashField(name = "MagicTickets")
    @Column(nullable = false)
    private Integer magicTickets = 0;

    @FlashField(name = "DefCurrency")
    @Column(nullable = false)
    private Integer defCurrency;

    @FlashField(name = "LevelThreshold")
    @Column(nullable = false)
    private Integer levelThreshold;

    @FlashField(name = "UnlockCost")
    @Column(nullable = false)
    private Integer unlockCost;

    @FlashField(name = "SortOrder")
    @Column(nullable = false)
    private Integer sortOrder;

    @FlashField(name = "PublishDate", useCustomConverter = true, converter = String2DateConverter.class)
    @Column(nullable = false)
    private LocalDateTime publishDate;

    @FlashField(name = "Tags")
    @Column(nullable = false)
    private String tags;

    @FlashField(name = "LayerId")
    @Column(nullable = false)
    private Integer layerId = 0;

    @FlashField(name = "IsActive", useCustomConverter = true, converter = Integer2BooleanConverter.class)
    @Column(nullable = false)
    private Boolean isActive;

    @FlashField(name = "ItemCount")
    @Column(nullable = false)
    private Integer itemCount = -1;
}
