import {GetDataByPath, PutDataByPath, ResponseData} from './api.ts';


export class Messages {
    Sender: string;
    BoughtItem: string;
    BoughtDino: string;
    BoughtBeacon: string;
    BoughtExp: string;
    ReceivedPoints: string;
    HavePoints: string;
    NoPoints: string;
    WrongId: string;
    NoPermissionsKit: string;
    CantBuyKit: string;
    BoughtKit: string;
    AvailableKits: string;
    NoKits: string;
    KitsLeft: string;
    NoKitsLeft: string;
    CantGivePoints: string;
    RidingDino: string;
    SentPoints: string;
    GotPoints: string;
    NoPlayer: string;
    FoundMorePlayers: string;
    BuyUsage: string;
    ShopUsage: string;
    KitUsage: string;
    BuyKitUsage: string;
    TradeUsage: string;
    PointsCmd: string;
    TradeCmd: string;
    BuyCmd: string;
    ShopCmd: string;
    KitCmd: string;
    BuyKitCmd: string;
    SellCmd: string;
    ShopSellCmd: string;
    SellUsage: string;
    NotEnoughItems: string;
    SoldItems: string;
    BadLevel: string;
    KitsListPrice: string;
    KitsListFormat: string;
    StoreListDino: string;
    StoreListItem: string;
    StoreListFormat: string;
    OnlyOnSpawnKit: string;
    HelpCmd: string;
    ShopMessage: string;
    HelpMessage: string;
    RefundError: string;
    ShopFindCmd: string;
    ShopFindUsage: string;
    ShopFindNotFound: string;
    ShopFindTooManyResults: string;
    NoPermissionsStore: string;

    constructor() {
        this.Sender = "";
        this.BoughtItem = "";
        this.BoughtDino = "";
        this.BoughtBeacon = "";
        this.BoughtExp = "";
        this.ReceivedPoints = "";
        this.HavePoints = "";
        this.NoPoints = "";
        this.WrongId = "";
        this.NoPermissionsKit = "";
        this.CantBuyKit = "";
        this.BoughtKit = "";
        this.AvailableKits = "";
        this.NoKits = "";
        this.KitsLeft = "";
        this.NoKitsLeft = "";
        this.CantGivePoints = "";
        this.RidingDino = "";
        this.SentPoints = "";
        this.GotPoints = "";
        this.NoPlayer = "";
        this.FoundMorePlayers = "";
        this.BuyUsage = "";
        this.ShopUsage = "";
        this.KitUsage = "";
        this.BuyKitUsage = "";
        this.TradeUsage = "";
        this.PointsCmd = "";
        this.TradeCmd = "";
        this.BuyCmd = "";
        this.ShopCmd = "";
        this.KitCmd = "";
        this.BuyKitCmd = "";
        this.SellCmd = "";
        this.ShopSellCmd = "";
        this.SellUsage = "";
        this.NotEnoughItems = "";
        this.SoldItems = "";
        this.BadLevel = "";
        this.KitsListPrice = "";
        this.KitsListFormat = "";
        this.StoreListDino = "";
        this.StoreListItem = "";
        this.StoreListFormat = "";
        this.OnlyOnSpawnKit = "";
        this.HelpCmd = "";
        this.ShopMessage = "";
        this.HelpMessage = "";
        this.RefundError = "";
        this.ShopFindCmd = "";
        this.ShopFindUsage = "";
        this.ShopFindNotFound = "";
        this.ShopFindTooManyResults = "";
        this.NoPermissionsStore = "";
    }
}

//获取配置文件
export function GetArkConfig(): Promise<ResponseData<Messages>> {
    return GetDataByPath("/ark/messages", {}, true) as Promise<ResponseData<Messages>>;
}

export class TimedPointsReward {
    Enabled: boolean
    Interval: number
    StackRewards: boolean
    Groups: Map<string, TimedPointsRewardAmount>

    constructor(Enabled: boolean, Interval: number, StackRewards: boolean, Groups: Map<string, TimedPointsRewardAmount>) {
        this.Enabled = Enabled;
        this.Interval = Interval;
        this.StackRewards = StackRewards;
        this.Groups = Groups;
    }
}

export class TimedPointsRewardAmount {
    Amount: number

    constructor(amount: number) {
        this.Amount = amount;
    }
}

export class Group {
    name: string;
    amount: number;

    constructor(name: string, amount: number) {
        this.name = name;
        this.amount = amount;
    }
}

export function GetTimedPointsReward(): Promise<ResponseData<TimedPointsReward>> {
    return GetDataByPath("/ark/timedPointsReward", {}, true) as Promise<ResponseData<TimedPointsReward>>;
}

export function SaveGroup(group: Group) {
    return PutDataByPath("/ark/timedPointsReward/group", group, true)
}

export function UpdateGroup(oldGroup: Group, newGroup: Group) {
    return PutDataByPath("/ark/timedPointsReward/group", {
        oldGroup: oldGroup, newGroup: newGroup
    }, true)
}
