rp_11001/assets/Game/SlotRanking/scripts/SlotRankingDataManager.ts
TJH fb72706ade
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m14s
龙虎榜
2025-12-31 15:20:31 +08:00

159 lines
4.4 KiB
TypeScript

export class SlotRankingDataManager {
static _instance: SlotRankingDataManager = null;
static get instance(): SlotRankingDataManager {
if (!this._instance) {
this._instance = new SlotRankingDataManager();
}
return this._instance;
}
_rankList: any = null;
set rankList(list: any) { this._rankList = list; }
get rankList(): any { return this._rankList; }
/**
*
* {
"List": [
{
"Id": "20251225_day_faketrans-VND",
"Name": "",
"Type": "day",
"StartTime": 1766592000,
"EndTime": 1766689200,
"CloseTime": 1766775600,
"Status": 0,
"Rewards": [
10,
8,
5,
3,
3,
3,
3,
3,
3,
3
],
"SpinLimit": 10,
"BetLimit": 1000000
},
{
"Id": "20251222_week_faketrans-VND",
"Name": "",
"Type": "week",
"StartTime": 1766592000,
"EndTime": 1766678400,
"CloseTime": 1766764800,
"Status": 0,
"Rewards": [
10,
5,
5,
5,
5,
5,
5,
5,
5,
5
],
"SpinLimit": 10,
"BetLimit": 5000000
}
]
}
*/
getRankMaxCloseTimeIsBiggerThanCurTime(): boolean {
if (!this._rankList || !this._rankList.List || this._rankList.List.length === 0) {
// 代表当前没有活动开启,则说明关闭入口按钮
return false;
}
let maxCloseTime = 0;
for (let item of this._rankList.List) {
if (item.CloseTime > maxCloseTime) {
maxCloseTime = item.CloseTime;
}
}
return Date.now() <= (maxCloseTime * 1000);
}
getRankListStatusByType(type: string): number {
if (!this._rankList || !this._rankList.List || this._rankList.List.length === 0) {
return 2;
}
let item = this._rankList.List.find((item: any) => item.Type === type);
return item ? item.Status : 2;
}
getRankListStatus(): number {
if (!this._rankList || !this._rankList.List || this._rankList.List.length === 0) {
return 2;
}
let hasEnabled = false; // 是否有启用的
let hasMaintenance = false; // 是否有维护的
for (let item of this._rankList.List) {
if (item.Status === 0) {
hasEnabled = true;
break;
} else if (item.Status === 1) {
hasMaintenance = true;
}
}
if (hasEnabled) {
return 0;
}
if (hasMaintenance) {
return 1;
}
return 2;
}
getRankListServerId(): string | null {
if (!this._rankList || !this._rankList.List || this._rankList.List.length === 0) {
return null;
}
let id = this._rankList.List[0].Id;
if (!id) {
return null;
}
let parts = id.split('_');
if (parts.length >= 3) {
return parts[2];
}
return null;
}
getRankEndTimeByType(type: string): number | null {
if (!this._rankList || !this._rankList.List || this._rankList.List.length === 0) {
return null;
}
let item = this._rankList.List.find((item: any) => item.Type === type);
return item ? item.EndTime : null;
}
getRankInfoByType(type: string): any | null {
if (!this._rankList || !this._rankList.List || this._rankList.List.length === 0) {
return null;
}
let item = this._rankList.List.find((item: any) => item.Type === type);
return item || null;
}
}