export default class PlayerData extends Subdata {
@Decorator.persistence()
skinList: number[] = new Array(20).fill(0);
@Decorator.persistence()
skinItemList: number[] = new Array(20).fill(0);
@Decorator.persistence()
loginDays: number = 0;
@Decorator.persistence()
lastLoginTime: number = 0;
@Decorator.persistence()
lastSevenDayCheckInTime: number = 0;
@Decorator.persistence()
lastHalloweenCheckInTime: number = 0;
@Decorator.persistence()
sevenDayCheckInDays: number = 0;
@Decorator.persistence()
halloweenCheckInDays: number = 0;
@Decorator.persistence()
diamonds: number = 500;
@Decorator.persistence()
isDressingId: string = "";
// 新增礼物列表变量
@Decorator.persistence()
giftList: number[] = new Array(20).fill(0);
public setIsDressingId(dressId: string): void {
this.isDressingId = dressId;
this.save(true);
}
public getIsDressingId(): string {
return this.isDressingId;
}
// 增加钻石数量
public addDiamonds(amount: number): void {
this.diamonds += amount;
this.save(true);
}
// 减少钻石数量
public subtractDiamonds(amount: number): void {
if (this.diamonds >= amount) {
this.diamonds -= amount;
this.save(true);
} else {
console.error("Not enough diamonds to subtract");
}
}
// 获取当前钻石数量
public getDiamonds(): number {
return this.diamonds;
}
public addOwnSkin(skinId: number): void {
console.log(this.skinList);
this.skinList[skinId - 1] = 1;
this.save(true);
console.log(this.skinList);
}
public addOwnSkinItem(skinItemId: number): void {
this.skinItemList[skinItemId - 1] = 1;
this.save(true);
}
// 增加礼物
public addGift(giftId: number): void {
this.giftList[giftId] += 1;
this.save(true);
}
public useGift(giftId: number): void {
this.giftList[giftId] -= 1;
this.save(true);
}
// 获取礼物列表
public getGiftList(): number[] {
return this.giftList;
}
}
|