本帖最后由 温柔的败退 于 2024-11-28 09:52 编辑
请问一下需要的是那一部分,subdata的可以么
export default class PlayerData extends Subdata {
@Decorator.persistence()
skinList: number[];
@Decorator.persistence()
skinItemList: number[];
@Decorator.persistence()
loginDays: number;
@Decorator.persistence()
lastLoginTime: number;
@Decorator.persistence()
lastSevenDayCheckInTime: number;
@Decorator.persistence()
lastHalloweenCheckInTime: number;
@Decorator.persistence()
sevenDayCheckInDays: number;
@Decorator.persistence()
halloweenCheckInDays: number;
@Decorator.persistence()
diamonds: number;
@Decorator.persistence()
isDressingId: string;
// 新增礼物列表变量
@Decorator.persistence()
giftList: number[];
@Decorator.persistence()
winCount: number[];
@Decorator.persistence()
onlineDurationToday: number;
@Decorator.persistence()
lastCheckInTime: number;
protected initDefaultData(): void {
this.skinList = new Array(20).fill(0);
this.skinItemList = new Array(20).fill(0);
this.loginDays = 0;
this.lastLoginTime = 0;
this.lastSevenDayCheckInTime = 0;
this.lastHalloweenCheckInTime = 0;
this.sevenDayCheckInDays = 0;
this.halloweenCheckInDays = 0;
this.diamonds = 500;
this.isDressingId = "";
this.giftList = new Array(20).fill(0);
this.winCount = [0, 0, 0, 0];
this.onlineDurationToday = 0;
}
public resetOnlineDuration(): void {
this.onlineDurationToday = 0;
this.save(true);
}
public setOnlineDuration(duration: number): void {
this.onlineDurationToday = duration;
this.save(true);
}
public getOnlineDurationToday(): number {
return this.onlineDurationToday;
}
public getLastLoginTime(): number {
return this.lastLoginTime;
}
public setLastLoginTime(now: number): void {
this.lastLoginTime = now;
this.save(true);
}
public setIsDressingId(dressId: string): void {
this.isDressingId = dressId;
this.save(true);
}
public getIsDressingId(): string {
return this.isDressingId;
}
public addSevenDayCheckInDays(): void {
this.sevenDayCheckInDays += 1;
this.save(true);
}
public addHalloweenCheckInDays(): void {
this.halloweenCheckInDays += 1;
this.save(true);
}
// 增加钻石数量
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;
}
public setLastHalloweenCheckInTime(now: number): void {
this.lastHalloweenCheckInTime = now;
}
}
|