|
|
|
@@ -7,6 +7,7 @@ import { GirlDetailData } from "./GirlDetailData";
|
|
|
|
|
import { GirlUnlockData } from "./GirlUnlockData";
|
|
|
|
|
import { GirlChatData } from "./GirlChatData";
|
|
|
|
|
import { GirlFavorabilityData } from "./GirlFavorabilityData";
|
|
|
|
|
import { GirlOtherData } from "./GirlOtherData";
|
|
|
|
|
import { DataId } from "./DataManager";
|
|
|
|
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
|
|
|
|
import { PriceType } from "../../schema/schema";
|
|
|
|
@@ -24,6 +25,8 @@ interface CategoryBucket {
|
|
|
|
|
chats: Map<number, GirlChatData>;
|
|
|
|
|
// 技师的好感度数据
|
|
|
|
|
favorability: Map<number, GirlFavorabilityData>;
|
|
|
|
|
// 技师的其他数据
|
|
|
|
|
other: Map<number, GirlOtherData>;
|
|
|
|
|
// 技师的id
|
|
|
|
|
girlIds: number[];
|
|
|
|
|
}
|
|
|
|
@@ -67,6 +70,7 @@ export class GirlData extends BaseData {
|
|
|
|
|
unlocks: new Map<number, GirlUnlockData>(),
|
|
|
|
|
chats: new Map<number, GirlChatData>(),
|
|
|
|
|
favorability: new Map<number, GirlFavorabilityData>(),
|
|
|
|
|
other: new Map<number, GirlOtherData>(),
|
|
|
|
|
girlIds: [],
|
|
|
|
|
};
|
|
|
|
|
cats.set(categoryId, bucket);
|
|
|
|
@@ -89,6 +93,7 @@ export class GirlData extends BaseData {
|
|
|
|
|
this.setGirlBrief(categoryId, data.girls);
|
|
|
|
|
this.setGirlUnlock(categoryId, data.girls);
|
|
|
|
|
this.setGirlFavorability(categoryId, data.girls);
|
|
|
|
|
this.setGirlOther(categoryId, data.girls);
|
|
|
|
|
|
|
|
|
|
const bucket = this.ensureBucket(categoryId);
|
|
|
|
|
logger.log("保存类别 ", categoryId, " 的技师列表: ", bucket);
|
|
|
|
@@ -107,6 +112,7 @@ export class GirlData extends BaseData {
|
|
|
|
|
this.setGirlUnlock(categoryId, details);
|
|
|
|
|
this.setGirlChat(categoryId, details);
|
|
|
|
|
this.setGirlFavorability(categoryId, details);
|
|
|
|
|
this.setGirlOther(categoryId, details);
|
|
|
|
|
|
|
|
|
|
const bucket = this.ensureBucket(categoryId);
|
|
|
|
|
logger.log("保存类别 ", categoryId, " 的详细数据: ", bucket);
|
|
|
|
@@ -129,6 +135,54 @@ export class GirlData extends BaseData {
|
|
|
|
|
logger.log("保存可聊天的技师数据: ", cats);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------- 每日推荐 --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/** 保存每日推荐:放入特殊分类 DAILY_BUCKET,并维护 id 索引 */
|
|
|
|
|
public setDailyRecommend(data: proto.cs.ICSDailyRecommendRes): void {
|
|
|
|
|
if (!data) return;
|
|
|
|
|
this.mergeOneBrief(DAILY_BUCKET, data.girl);
|
|
|
|
|
const bucket = this.ensureBucket(DAILY_BUCKET);
|
|
|
|
|
logger.log("保存每日推荐: ", bucket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 判断每日推荐是否存在 */
|
|
|
|
|
public isDailyRecommendIn(): boolean {
|
|
|
|
|
const bucket = this.ensureCategories().get(DAILY_BUCKET);
|
|
|
|
|
if (!bucket) return false;
|
|
|
|
|
return bucket.girlIds.length > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取推荐id */
|
|
|
|
|
public getRecommendGirlId(): number {
|
|
|
|
|
const bucket = this.ensureBucket(DAILY_BUCKET);
|
|
|
|
|
const girlIds = bucket.girlIds;
|
|
|
|
|
const length = girlIds.length;
|
|
|
|
|
if (length <= 0) return 0;
|
|
|
|
|
return girlIds[length - 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取每日推荐的简要数据 */
|
|
|
|
|
private getRecommendGrilBrief(): GirlBriefData | null {
|
|
|
|
|
const recId = this.getRecommendGirlId();
|
|
|
|
|
if (recId <= 0) return null;
|
|
|
|
|
const data = this.getGrilBrief(DAILY_BUCKET, recId);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取名字 */
|
|
|
|
|
public getRecommendGrilName(): string {
|
|
|
|
|
let oneData = this.getRecommendGrilBrief();
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.getGrilName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取头像路径 */
|
|
|
|
|
public getRecommendGrilAvatar(): string {
|
|
|
|
|
let oneData = this.getRecommendGrilBrief();
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.getGrilAvatar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------- 技师的简要数据 --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -1155,31 +1209,24 @@ export class GirlData extends BaseData {
|
|
|
|
|
/** --------------------------------------------------------- 技师的好感度数据 --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
// 创建一个技师好感度数据
|
|
|
|
|
private createOneGirlFavorability(
|
|
|
|
|
id: number,
|
|
|
|
|
star: number
|
|
|
|
|
): GirlFavorabilityData {
|
|
|
|
|
private createOneGirlFavorability(id: number, star: number, bookmarkTime: number): GirlFavorabilityData {
|
|
|
|
|
let oneData = new GirlFavorabilityData();
|
|
|
|
|
oneData.init?.(DataId.GirlFavorability);
|
|
|
|
|
oneData.setId(id);
|
|
|
|
|
oneData.setStar(star);
|
|
|
|
|
oneData.setBookmarkTime(bookmarkTime);
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解析技师好感度数据,一个
|
|
|
|
|
private parseOneGirlFavorability(
|
|
|
|
|
data: proto.cs.IGirlData
|
|
|
|
|
): GirlFavorabilityData | null {
|
|
|
|
|
private parseOneGirlFavorability(data: proto.cs.IGirlData): GirlFavorabilityData | null {
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
let oneData = this.createOneGirlFavorability(data.id, data.star);
|
|
|
|
|
let oneData = this.createOneGirlFavorability(data.id, data.star, Number(data.bookmarkTime));
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 保存技师的好感度数据 */
|
|
|
|
|
private setGirlFavorability(
|
|
|
|
|
categoryId: string,
|
|
|
|
|
data: proto.cs.IGirlData[]
|
|
|
|
|
): void {
|
|
|
|
|
private setGirlFavorability(categoryId: string,data: proto.cs.IGirlData[]): void {
|
|
|
|
|
if (!data) return;
|
|
|
|
|
const bucket = this.ensureBucket(categoryId);
|
|
|
|
|
for (const g of data) {
|
|
|
|
@@ -1195,14 +1242,14 @@ export class GirlData extends BaseData {
|
|
|
|
|
let briefData = data.girl;
|
|
|
|
|
let categoryId = briefData.category;
|
|
|
|
|
let girlId = briefData.id;
|
|
|
|
|
let favData = this.getGrilFavorability(categoryId.toString(), girlId);
|
|
|
|
|
let favData = this.getGirlFavorability(categoryId.toString(), girlId);
|
|
|
|
|
if (favData) {
|
|
|
|
|
// 已存在数据,刷新
|
|
|
|
|
favData.setStar(data.star);
|
|
|
|
|
} else {
|
|
|
|
|
// 不存在数据,创建
|
|
|
|
|
const bucket = this.ensureBucket(categoryId.toString());
|
|
|
|
|
let oneData = this.createOneGirlFavorability(data.id, data.star);
|
|
|
|
|
let oneData = this.createOneGirlFavorability(data.id, data.star, 0);
|
|
|
|
|
if (oneData) {
|
|
|
|
|
bucket.favorability.set(data.id, oneData);
|
|
|
|
|
}
|
|
|
|
@@ -1210,10 +1257,7 @@ export class GirlData extends BaseData {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 取某分类 + girlId 的好感度数据 */
|
|
|
|
|
private getGrilFavorability(
|
|
|
|
|
categoryId: string,
|
|
|
|
|
girlId: number
|
|
|
|
|
): GirlFavorabilityData | null {
|
|
|
|
|
private getGirlFavorability(categoryId: string, girlId: number): GirlFavorabilityData | null {
|
|
|
|
|
const b = this.ensureCategories().get(categoryId);
|
|
|
|
|
if (!b) return null;
|
|
|
|
|
return b.favorability.get(girlId) ?? null;
|
|
|
|
@@ -1228,56 +1272,89 @@ export class GirlData extends BaseData {
|
|
|
|
|
|
|
|
|
|
/** 获取星级 */
|
|
|
|
|
public getStar(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGrilFavorability(categoryId, girlId);
|
|
|
|
|
let oneData = this.getGirlFavorability(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.getStar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------- 每日推荐 --------------------------------------------------------- */
|
|
|
|
|
/** 获取收藏时间,时间戳,秒 */
|
|
|
|
|
public getBookmarkTime(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGirlFavorability(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.getBookmarkTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 保存每日推荐:放入特殊分类 DAILY_BUCKET,并维护 id 索引 */
|
|
|
|
|
public setDailyRecommend(data: proto.cs.ICSDailyRecommendRes): void {
|
|
|
|
|
/** 是否已经收藏 */
|
|
|
|
|
public isBookmarkGirl(categoryId: string, girlId: number): boolean {
|
|
|
|
|
let oneData = this.getGirlFavorability(categoryId, girlId);
|
|
|
|
|
if (!oneData) return false;
|
|
|
|
|
return oneData.isBookmarkGirl();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取所有已经收藏技师的 id */
|
|
|
|
|
public getAllBookmarkGirlIds(): number[] {
|
|
|
|
|
const result: number[] = [];
|
|
|
|
|
const seen = new Set<number>(); // 用来去重
|
|
|
|
|
const cats = this.ensureCategories();
|
|
|
|
|
// 遍历
|
|
|
|
|
for (const [categoryId, bucket] of cats.entries()) {
|
|
|
|
|
for (const girlId of bucket.girlIds) {
|
|
|
|
|
if (this.isBookmarkGirl(categoryId, girlId) && !seen.has(girlId)) {
|
|
|
|
|
seen.add(girlId); // 标记已加入
|
|
|
|
|
result.push(girlId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 返回结果
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** --------------------------------------------------------- 技师的其他数据 --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
// 创建一个技师其他数据
|
|
|
|
|
private createOneGirlOther(heatValue: number): GirlOtherData {
|
|
|
|
|
let oneData = new GirlOtherData();
|
|
|
|
|
oneData.init?.(DataId.GirlOther);
|
|
|
|
|
oneData.setHeatValue(heatValue);
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解析技师其他数据,一个
|
|
|
|
|
private parseOneGirlOther(data: proto.cs.IGirlData): GirlOtherData | null {
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
let oneData = this.createOneGirlOther(Number(data.score));
|
|
|
|
|
return oneData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 保存技师的其他数据 */
|
|
|
|
|
private setGirlOther(categoryId: string, data: proto.cs.IGirlData[]): void {
|
|
|
|
|
if (!data) return;
|
|
|
|
|
this.mergeOneBrief(DAILY_BUCKET, data.girl);
|
|
|
|
|
const bucket = this.ensureBucket(DAILY_BUCKET);
|
|
|
|
|
logger.log("保存每日推荐: ", bucket);
|
|
|
|
|
const bucket = this.ensureBucket(categoryId);
|
|
|
|
|
for (const g of data) {
|
|
|
|
|
const one = this.parseOneGirlOther(g);
|
|
|
|
|
if (!one) continue;
|
|
|
|
|
bucket.other.set(g.id, one);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 判断每日推荐是否存在 */
|
|
|
|
|
public isDailyRecommendIn(): boolean {
|
|
|
|
|
const bucket = this.ensureCategories().get(DAILY_BUCKET);
|
|
|
|
|
if (!bucket) return false;
|
|
|
|
|
return bucket.girlIds.length > 0;
|
|
|
|
|
/** 取某分类 + girlId 的其他数据 */
|
|
|
|
|
private getGirlOther(categoryId: string, girlId: number): GirlOtherData | null {
|
|
|
|
|
const b = this.ensureCategories().get(categoryId);
|
|
|
|
|
if (!b) return null;
|
|
|
|
|
return b.other.get(girlId) ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取推荐id */
|
|
|
|
|
public getRecommendGirlId(): number {
|
|
|
|
|
const bucket = this.ensureBucket(DAILY_BUCKET);
|
|
|
|
|
const girlIds = bucket.girlIds;
|
|
|
|
|
const length = girlIds.length;
|
|
|
|
|
if (length <= 0) return 0;
|
|
|
|
|
return girlIds[length - 1];
|
|
|
|
|
}
|
|
|
|
|
/** 技师的其他数据是否存在 */
|
|
|
|
|
public isGirlOtherIn(categoryId: string, girlId: number): boolean {
|
|
|
|
|
const b = this.ensureCategories().get(categoryId);
|
|
|
|
|
if (!b) return false;
|
|
|
|
|
return b.other.has(girlId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取每日推荐的简要数据 */
|
|
|
|
|
private getRecommendGrilBrief(): GirlBriefData | null {
|
|
|
|
|
const recId = this.getRecommendGirlId();
|
|
|
|
|
if (recId <= 0) return null;
|
|
|
|
|
const data = this.getGrilBrief(DAILY_BUCKET, recId);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取名字 */
|
|
|
|
|
public getRecommendGrilName(): string {
|
|
|
|
|
let oneData = this.getRecommendGrilBrief();
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.getGrilName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取头像路径 */
|
|
|
|
|
public getRecommendGrilAvatar(): string {
|
|
|
|
|
let oneData = this.getRecommendGrilBrief();
|
|
|
|
|
if (!oneData) return "";
|
|
|
|
|
return oneData.getGrilAvatar();
|
|
|
|
|
/** 获取热度值 */
|
|
|
|
|
public getHeatValue(categoryId: string, girlId: number): number {
|
|
|
|
|
let oneData = this.getGirlOther(categoryId, girlId);
|
|
|
|
|
if (!oneData) return 0;
|
|
|
|
|
return oneData.getHeatValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|