package com.alterdekim.game.component.game.avatar;

import com.alterdekim.game.message.amf.AMFKey;
import com.alterdekim.game.xml.BodyPartTypeSerializer;
import com.alterdekim.game.xml.LayerIdSerializer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

@ToString
@Getter
@AllArgsConstructor
public class BodyAvatarItem {
    @AMFKey(name = "BodyPartTypeId")
    private Integer bodyPartTypeId;

    @AMFKey(name = "Id")
    private Long id;

    @AMFKey(name = "Color")
    private Integer color;

    @AMFKey(name = "IsBodyPart")
    private Boolean isBodyPart;

    @AMFKey(name = "BodyPartId")
    private Integer bodyPartId;

    @AMFKey(name = "GoodID")
    private Long goodId;

    @AMFKey(name = "MediaResourceID")
    private Integer mediaResourceId;

    @AMFKey(name = "LayerID")
    private Integer layerId;

    @AMFKey(name = "GoodTypeID")
    private Integer goodTypeId;

    public static BodyAvatarItem fromInterface(IBodyAvatarItem i) {
        return new BodyAvatarItem(
                BodyPartTypeSerializer.parse(i.getBodyPartTypeId()),
                i.getId(),
                i.getColor(),
                i.getIsBodyPart() == 1,
                i.getBodyPartId(),
                i.getGoodId(),
                i.getMediaResourceId(),
                LayerIdSerializer.parse(i.getLayerId()),
                i.getGoodTypeId()
        );
    }
}
