协议增加:请求排行榜数据
This commit is contained in:
@@ -7,6 +7,7 @@ import { GirlDetailData } from "./GirlDetailData";
|
||||
import { GirlUnlockData } from "./GirlUnlockData";
|
||||
import { GirlChatData } from "./GirlChatData";
|
||||
import { GirlFavorabilityData } from "./GirlFavorabilityData";
|
||||
import { GirlRankData } from "./GirlRankData";
|
||||
import { GirlOtherData } from "./GirlOtherData";
|
||||
import { DataId } from "./DataManager";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
@@ -37,18 +38,29 @@ const DAILY_BUCKET = "__daily__";
|
||||
export class GirlData extends BaseData {
|
||||
// 大分类
|
||||
private _categories = new Map<string, CategoryBucket>();
|
||||
// 排行榜数据
|
||||
private _rankData: GirlRankData;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._rankData = new GirlRankData();
|
||||
this._rankData.init?.(DataId.GirlRank);
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this._categories.clear();
|
||||
this._rankData.clear();
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this._categories.clear();
|
||||
this._rankData.clear();
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
super.destroy();
|
||||
this._categories = null;
|
||||
this._rankData = null;
|
||||
}
|
||||
|
||||
/** 保障 _categories 存在 */
|
||||
@@ -85,10 +97,7 @@ export class GirlData extends BaseData {
|
||||
}
|
||||
|
||||
/** 保存技师列表 */
|
||||
public setGirlList(
|
||||
categoryId: string,
|
||||
data: proto.cs.ICSGetGirlListRes
|
||||
): void {
|
||||
public setGirlList(categoryId: string, data: proto.cs.ICSGetGirlListRes): void {
|
||||
if (!data) return;
|
||||
this.setGirlBrief(categoryId, data.girls);
|
||||
this.setGirlUnlock(categoryId, data.girls);
|
||||
@@ -100,10 +109,7 @@ export class GirlData extends BaseData {
|
||||
}
|
||||
|
||||
/** 保存技师详细数据 */
|
||||
public setGirlDetailData(
|
||||
categoryId: string,
|
||||
data: proto.cs.ICSGetGirlDetailRes
|
||||
): void {
|
||||
public setGirlDetailData(categoryId: string, data: proto.cs.ICSGetGirlDetailRes): void {
|
||||
if (!data) return;
|
||||
let details = [];
|
||||
details.push(data.girl);
|
||||
@@ -183,6 +189,55 @@ export class GirlData extends BaseData {
|
||||
return oneData.getGrilAvatar();
|
||||
}
|
||||
|
||||
/** --------------------------------------------------------- 技师的排行榜数据 --------------------------------------------------------- */
|
||||
|
||||
/** 保存 排行榜数据 */
|
||||
public setGirlRank(rankType: proto.cs.EnmRankType, data: proto.cs.ICSGetRankRes): void {
|
||||
if (!data) return;
|
||||
let arrayData = data.girls;
|
||||
// 遍历
|
||||
for (const oneData of arrayData) {
|
||||
let briefData = oneData.girl;
|
||||
let categoryId = briefData.category;
|
||||
this.mergeOneBrief(categoryId.toString(), briefData);
|
||||
let theArray = [];
|
||||
theArray.push(oneData);
|
||||
this.setGirlUnlock(categoryId.toString(), theArray);
|
||||
this.setGirlFavorability(categoryId.toString(), theArray);
|
||||
this.setGirlOther(categoryId.toString(), theArray);
|
||||
}
|
||||
this._rankData.setRankData(rankType, arrayData);
|
||||
const cats = this.ensureCategories();
|
||||
logger.log("保存排行榜数据后,大分类的数据: ", cats);
|
||||
}
|
||||
|
||||
/** 添加 排行榜数据 */
|
||||
public addRankData(rankType: proto.cs.EnmRankType, data: proto.cs.ICSGetRankRes): void {
|
||||
if (!data) return;
|
||||
let arrayData = data.girls;
|
||||
// 遍历
|
||||
for (const oneData of arrayData) {
|
||||
let briefData = oneData.girl;
|
||||
let categoryId = briefData.category;
|
||||
this.mergeOneBrief(categoryId.toString(), briefData);
|
||||
let theArray = [];
|
||||
theArray.push(oneData);
|
||||
this.setGirlUnlock(categoryId.toString(), theArray);
|
||||
this.setGirlFavorability(categoryId.toString(), theArray);
|
||||
this.setGirlOther(categoryId.toString(), theArray);
|
||||
}
|
||||
this._rankData.addRankData(rankType, arrayData);
|
||||
const cats = this.ensureCategories();
|
||||
logger.log("添加排行榜数据后,大分类的数据: ", cats);
|
||||
}
|
||||
|
||||
/** 获取排行榜技师 id,根据排行榜类型 */
|
||||
public getRankIdsByType(rankType: proto.cs.EnmRankType): number[] {
|
||||
if (!this._rankData) return [];
|
||||
const ids = this._rankData.getRankIdsByType(rankType);
|
||||
return ids;
|
||||
}
|
||||
|
||||
/** --------------------------------------------------------- 技师的简要数据 --------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user