149 lines
3.6 KiB
TypeScript
149 lines
3.6 KiB
TypeScript
/**
|
||
* 技师的解锁数据
|
||
*/
|
||
import { BaseData } from "./BaseData";
|
||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||
|
||
export class GirlUnlockData extends BaseData {
|
||
// id
|
||
private id: number;
|
||
// 付费技师是否已经解锁
|
||
private isRelease: boolean;
|
||
// 角色解锁时间,时间戳,秒
|
||
private unlockTime: number;
|
||
// 解锁图片 id
|
||
private unlockedImageIds: number[];
|
||
// 解锁视频 id
|
||
private unlockedVideoIds: number[];
|
||
|
||
constructor() {
|
||
super();
|
||
this.id = 0;
|
||
this.isRelease = false;
|
||
this.unlockTime = 0;
|
||
this.unlockedImageIds = [];
|
||
this.unlockedVideoIds = [];
|
||
}
|
||
|
||
public reset(): void {
|
||
this.id = 0;
|
||
this.isRelease = false;
|
||
this.unlockTime = 0;
|
||
this.unlockedImageIds = [];
|
||
this.unlockedVideoIds = [];
|
||
}
|
||
|
||
public clear(): void {
|
||
this.id = 0;
|
||
this.isRelease = false;
|
||
this.unlockTime = 0;
|
||
this.unlockedImageIds = [];
|
||
this.unlockedVideoIds = [];
|
||
}
|
||
|
||
public destroy(): void {
|
||
super.destroy();
|
||
this.id = null;
|
||
this.isRelease = null;
|
||
this.unlockTime = null;
|
||
this.unlockedImageIds = null;
|
||
this.unlockedVideoIds = null;
|
||
}
|
||
|
||
/** 获取 id */
|
||
public getId(): number {
|
||
return this.id;
|
||
}
|
||
|
||
/** 保存 id */
|
||
public setId(value: number): void {
|
||
this.id = value;
|
||
}
|
||
|
||
/** 获取 付费技师是否已经解锁 */
|
||
public getIsRelease(): boolean {
|
||
return this.isRelease;
|
||
}
|
||
|
||
/** 保存 付费技师是否已经解锁 */
|
||
public setIsRelease(value: boolean): void {
|
||
this.isRelease = value;
|
||
}
|
||
|
||
/** 获取 角色解锁时间,时间戳,秒 */
|
||
public getUnlockTime(): number {
|
||
return this.unlockTime;
|
||
}
|
||
|
||
/** 保存 角色解锁时间,时间戳,秒 */
|
||
public setUnlockTime(value: number): void {
|
||
this.unlockTime = value;
|
||
// logger.log("设置角色 ", this.id, " 的解锁时间:", this.unlockTime);
|
||
}
|
||
|
||
/** 判断图片是否解锁,根据 id */
|
||
public isImageUnlock(id: number): boolean {
|
||
for (let i = 0; i < this.unlockedImageIds.length; i++) {
|
||
if (this.unlockedImageIds[i] === id) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/** 解锁图片 */
|
||
public unlockImage(id: number) {
|
||
// 去重
|
||
let exists = this.isImageUnlock(id);
|
||
if (!exists) {
|
||
this.unlockedImageIds.push(id);
|
||
}
|
||
logger.log("技师 ", this.id, " 当前解锁图片的所有id:",this.unlockedImageIds);
|
||
}
|
||
|
||
/** 获取所有解锁图片的 id */
|
||
public getUnlockedImageIds(): number[] {
|
||
return this.unlockedImageIds;
|
||
}
|
||
|
||
/** 保存解锁图片 id */
|
||
public setUnlockedImageIds(value: number[]): void {
|
||
for(let one of value) {
|
||
this.unlockImage(one);
|
||
}
|
||
}
|
||
|
||
/** 判断视频是否解锁,根据 id */
|
||
public isVideoUnlock(id: number): boolean {
|
||
for (let i = 0; i < this.unlockedVideoIds.length; i++) {
|
||
if (this.unlockedVideoIds[i] === id) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/** 解锁视频 */
|
||
public unlockVideo(id: number) {
|
||
// 去重
|
||
let exists = this.isVideoUnlock(id);;
|
||
if (!exists) {
|
||
this.unlockedVideoIds.push(id);
|
||
}
|
||
logger.log("技师 ", this.id, " 当前解锁视频的所有id:",this.unlockedVideoIds);
|
||
}
|
||
|
||
/** 获取所有解锁视频的 id */
|
||
public getUnlockedVideoIds(): number[] {
|
||
return this.unlockedVideoIds;
|
||
}
|
||
|
||
/** 保存解锁视频 id */
|
||
public setUnlockedVideoIds(value: number[]): void {
|
||
for(let one of value) {
|
||
this.unlockVideo(one);
|
||
}
|
||
}
|
||
}
|