80 lines
1.8 KiB
TypeScript
80 lines
1.8 KiB
TypeScript
/**
|
|
* 技师的聊天数据
|
|
*/
|
|
import { BaseData } from "./BaseData";
|
|
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
|
|
|
export class GirlChatData extends BaseData {
|
|
// id
|
|
private id: number;
|
|
// 总聊天次数
|
|
private chatTotalCount: number;
|
|
// 剩余聊天次数, < 0: 不限制; = 0 聊天次数已经用完; > 0 还剩余多少次聊天次数
|
|
private chatRemainCount: number;
|
|
|
|
constructor() {
|
|
super();
|
|
this.id = 0;
|
|
this.chatTotalCount = 0;
|
|
this.chatRemainCount = 0;
|
|
}
|
|
|
|
public reset(): void {
|
|
this.id = 0;
|
|
this.chatTotalCount = 0;
|
|
this.chatRemainCount = 0;
|
|
}
|
|
|
|
public clear(): void {
|
|
this.id = 0;
|
|
this.chatTotalCount = 0;
|
|
this.chatRemainCount = 0;
|
|
}
|
|
|
|
public destroy(): void {
|
|
super.destroy();
|
|
this.id = null;
|
|
this.chatTotalCount = null;
|
|
this.chatRemainCount = null;
|
|
}
|
|
|
|
/** 获取 id */
|
|
public getId(): number {
|
|
return this.id;
|
|
}
|
|
|
|
/** 保存 id */
|
|
public setId(value: number): void {
|
|
this.id = value;
|
|
}
|
|
|
|
/** 获取总聊天次数 */
|
|
public getChatTotalCount(): number {
|
|
return this.chatTotalCount;
|
|
}
|
|
|
|
/** 保存总聊天次数 */
|
|
public setChatTotalCount(value: number): void {
|
|
this.chatTotalCount = value;
|
|
console.log("当前总聊天次数:", this.chatTotalCount);
|
|
}
|
|
|
|
/** 获取剩余聊天次数 */
|
|
public getChatRemainCount(): number {
|
|
return this.chatRemainCount;
|
|
}
|
|
|
|
/** 保存剩余聊天次数 */
|
|
public setChatRemainCount(value: number): void {
|
|
this.chatRemainCount = value;
|
|
console.log("当前剩余聊天次数:", this.chatRemainCount);
|
|
}
|
|
|
|
/** 更新剩余聊天次数 */
|
|
public useChat(times: number = 1) {
|
|
if (this.chatRemainCount > 0) {
|
|
this.setChatRemainCount(Math.max(0, this.chatRemainCount - times));
|
|
}
|
|
}
|
|
}
|