|
|
|
|
@@ -18,6 +18,8 @@ export class BJ_Casino_Data {
|
|
|
|
|
|
|
|
|
|
public Client: any;
|
|
|
|
|
|
|
|
|
|
public Current: any[] = [];
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region private
|
|
|
|
|
@@ -46,6 +48,8 @@ export class BJ_Casino_Data {
|
|
|
|
|
|
|
|
|
|
private _nowContestEnd: string = "";
|
|
|
|
|
|
|
|
|
|
private _isIDupup: boolean = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 0 _rankMagnificationData
|
|
|
|
|
* 1 _rankWinMoneyData
|
|
|
|
|
@@ -73,8 +77,20 @@ export class BJ_Casino_Data {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async onLoad(): Promise<void> {
|
|
|
|
|
// CoroutineV2.Single(this.aaa()).Start();
|
|
|
|
|
let self: this = this;
|
|
|
|
|
await this.ConnectServer();
|
|
|
|
|
await this.SendRankData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SetCurrent(current: any): void {
|
|
|
|
|
this.Current.push(current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region 網路相關
|
|
|
|
|
|
|
|
|
|
/** 連線 */
|
|
|
|
|
public async ConnectServer(): Promise<void> {
|
|
|
|
|
const URL: string = "https://game.online-bj.com";
|
|
|
|
|
const Port: string = "9005";
|
|
|
|
|
await this.ConnectAsync(URL, +Port);
|
|
|
|
|
@@ -86,15 +102,7 @@ export class BJ_Casino_Data {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Login Account Error!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await this.SendRankData();
|
|
|
|
|
}
|
|
|
|
|
public *aaa(): IterableIterator<any> {
|
|
|
|
|
console.log("aaa");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region 網路相關
|
|
|
|
|
|
|
|
|
|
/** 連線(目前沒有重連機制) */
|
|
|
|
|
public async ConnectAsync(host: string, port: number): Promise<void> {
|
|
|
|
|
@@ -150,12 +158,15 @@ export class BJ_Casino_Data {
|
|
|
|
|
if (!resp.IsValid) {
|
|
|
|
|
if (resp.Status === 11) {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Rank 無資料");
|
|
|
|
|
this.OrganizeRankMagnificationData(this._rankMagnificationData);
|
|
|
|
|
this.SetRankMagnificationDataOK();
|
|
|
|
|
} else {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Get RankInfo Fail");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await this.RankMagnificationDataCallBack(resp.Data);
|
|
|
|
|
this.SetRankMagnificationSearchData(resp.Data);
|
|
|
|
|
this.ParseRankMagnificationData(resp.Data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async SendRankWinMoneyData(): Promise<void> {
|
|
|
|
|
@@ -166,15 +177,18 @@ export class BJ_Casino_Data {
|
|
|
|
|
if (!resp.IsValid) {
|
|
|
|
|
if (resp.Status === 11) {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Rank 無資料");
|
|
|
|
|
this.OrganizeRankMagnificationData(this._rankMagnificationData);
|
|
|
|
|
this.SetRankMagnificationDataOK();
|
|
|
|
|
} else {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Get RankInfo Fail");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await this.RankWinMoneyDataCallBack(resp.Data);
|
|
|
|
|
this.SetRankWinMoneySearchData(resp.Data);
|
|
|
|
|
this.ParseRankWinMoneyData(resp.Data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async RankMagnificationDataCallBack(data: any) {
|
|
|
|
|
public SetRankMagnificationSearchData(data: any): void {
|
|
|
|
|
let id: number = +data["id"];
|
|
|
|
|
this._nowSearchMagnificationID = id;
|
|
|
|
|
this._nowContestID = id;
|
|
|
|
|
@@ -196,23 +210,30 @@ export class BJ_Casino_Data {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.Title = `${this._nowContestStart}~${this._nowContestEnd}`;
|
|
|
|
|
this.ParseRankMagnificationData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async ParseRankMagnificationData(data: any) {
|
|
|
|
|
let id = this._nowSearchMagnificationID;
|
|
|
|
|
this.RankDataAddDate(id, data["rank"]);
|
|
|
|
|
this._rankMagnificationData = this._rankMagnificationData.concat(data["rank"]);
|
|
|
|
|
if (id !== this._nowContestStartIndex) {
|
|
|
|
|
this._nowSearchMagnificationID = id - 1;
|
|
|
|
|
// this.SendData("rank.history", { "id": this._nowSearchContestID, "t": 12, "p": 2 });
|
|
|
|
|
let req: any = null;
|
|
|
|
|
req = new AppRankHistory(12, 2, this._nowSearchMagnificationID);
|
|
|
|
|
await req.SendAsync(true);
|
|
|
|
|
public async ParseRankMagnificationData(data: any = null): Promise<void> {
|
|
|
|
|
let id: number = this._nowSearchMagnificationID;
|
|
|
|
|
if (data) {
|
|
|
|
|
this.RankDataAddDate(id, data["rank"]);
|
|
|
|
|
this._rankMagnificationData = this._rankMagnificationData.concat(data["rank"]);
|
|
|
|
|
}
|
|
|
|
|
let targetIndex: number = this._nowContestStartIndex;
|
|
|
|
|
if (this._isIDupup) {
|
|
|
|
|
targetIndex = this._nowContestEndIndex;
|
|
|
|
|
}
|
|
|
|
|
if (id !== targetIndex) {
|
|
|
|
|
if (this._isIDupup) {
|
|
|
|
|
this._nowSearchMagnificationID = id + 1;
|
|
|
|
|
} else {
|
|
|
|
|
this._nowSearchMagnificationID = id - 1;
|
|
|
|
|
}
|
|
|
|
|
let req: any = await this.GetRankData(12, this._nowSearchMagnificationID);
|
|
|
|
|
let resp: INetResponse<any> = req.Result;
|
|
|
|
|
if (!resp.IsValid) {
|
|
|
|
|
if (resp.Status == 11) {
|
|
|
|
|
if (resp.Status === 11) {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Rank 無資料");
|
|
|
|
|
this.ParseRankMagnificationData(resp.Data);
|
|
|
|
|
} else {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Get RankInfo Fail");
|
|
|
|
|
}
|
|
|
|
|
@@ -222,47 +243,65 @@ export class BJ_Casino_Data {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
this.OrganizeRankMagnificationData(this._rankMagnificationData);
|
|
|
|
|
this.SetRankMagnificationData(this._rankMagnificationData);
|
|
|
|
|
this.SetRankMagnificationDataOK();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OrganizeRankMagnificationData(rankdata: any) {
|
|
|
|
|
public async GetRankData(type: number, dayIdid: number): Promise<any> {
|
|
|
|
|
let req: any = null;
|
|
|
|
|
req = new AppRankHistory(type, 2, dayIdid);
|
|
|
|
|
if (dayIdid === this._nowContestID) {
|
|
|
|
|
req = new AppRankInfo(type, 2);
|
|
|
|
|
}
|
|
|
|
|
await req.SendAsync(true);
|
|
|
|
|
return req;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OrganizeRankMagnificationData(rankdata: any): void {
|
|
|
|
|
rankdata.sort((a: any, b: any) => {
|
|
|
|
|
return b[1] - a[1];
|
|
|
|
|
});
|
|
|
|
|
rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => {
|
|
|
|
|
return arr.findIndex((s: any) => rankdata[2][1] === s[2][1]) === index;
|
|
|
|
|
});
|
|
|
|
|
for (let i = 0; i < rankdata.length; i++) {
|
|
|
|
|
for (let i: number = 0; i < rankdata.length; i++) {
|
|
|
|
|
rankdata[i][0] = i + 1;
|
|
|
|
|
}
|
|
|
|
|
this._rankMagnificationData = rankdata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SetRankMagnificationData(rankdata: any) {
|
|
|
|
|
public SetRankMagnificationDataOK(): void {
|
|
|
|
|
this._isOK[0] = true;
|
|
|
|
|
this._checkOK();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async RankWinMoneyDataCallBack(data: any) {
|
|
|
|
|
let id = +data["id"];
|
|
|
|
|
public SetRankWinMoneySearchData(data: any): void {
|
|
|
|
|
let id: number = +data["id"];
|
|
|
|
|
this._nowSearchWinMoneyID = id;
|
|
|
|
|
this.ParseRankWinMoneyData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async ParseRankWinMoneyData(data: any) {
|
|
|
|
|
let id = this._nowSearchWinMoneyID;
|
|
|
|
|
this.RankDataAddDate(id, data["rank"]);
|
|
|
|
|
this._rankWinMoneyData = this._rankWinMoneyData.concat(data["rank"]);
|
|
|
|
|
if (id !== this._nowContestStartIndex) {
|
|
|
|
|
this._nowSearchWinMoneyID = id - 1;
|
|
|
|
|
let req: any = null;
|
|
|
|
|
req = new AppRankHistory(11, 2, this._nowSearchWinMoneyID);
|
|
|
|
|
await req.SendAsync(true);
|
|
|
|
|
public async ParseRankWinMoneyData(data: any = null): Promise<void> {
|
|
|
|
|
let id: number = this._nowSearchWinMoneyID;
|
|
|
|
|
if (data) {
|
|
|
|
|
this.RankDataAddDate(id, data["rank"]);
|
|
|
|
|
this._rankWinMoneyData = this._rankWinMoneyData.concat(data["rank"]);
|
|
|
|
|
}
|
|
|
|
|
let targetIndex: number = this._nowContestStartIndex;
|
|
|
|
|
if (this._isIDupup) {
|
|
|
|
|
targetIndex = this._nowContestEndIndex;
|
|
|
|
|
}
|
|
|
|
|
if (id !== targetIndex) {
|
|
|
|
|
if (this._isIDupup) {
|
|
|
|
|
this._nowSearchWinMoneyID = id + 1;
|
|
|
|
|
} else {
|
|
|
|
|
this._nowSearchWinMoneyID = id - 1;
|
|
|
|
|
}
|
|
|
|
|
let req: any = await this.GetRankData(11, this._nowSearchWinMoneyID);
|
|
|
|
|
let resp: INetResponse<any> = req.Result;
|
|
|
|
|
if (!resp.IsValid) {
|
|
|
|
|
if (resp.Status == 11) {
|
|
|
|
|
if (resp.Status === 11) {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Rank 無資料");
|
|
|
|
|
this.ParseRankWinMoneyData();
|
|
|
|
|
} else {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Get RankInfo Fail");
|
|
|
|
|
}
|
|
|
|
|
@@ -272,53 +311,171 @@ export class BJ_Casino_Data {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
this.OrganizeRankWinMoneyData(this._rankWinMoneyData);
|
|
|
|
|
this.SetRankWinMoneyData(this._rankWinMoneyData);
|
|
|
|
|
this.SetRankWinMoneyDataOK();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OrganizeRankWinMoneyData(rankdata: any) {
|
|
|
|
|
public OrganizeRankWinMoneyData(rankdata: any): void {
|
|
|
|
|
rankdata.sort((a: any, b: any) => {
|
|
|
|
|
return b[1] - a[1];
|
|
|
|
|
});
|
|
|
|
|
rankdata = rankdata.filter((rankdata: any, index: any, arr: any) => {
|
|
|
|
|
return arr.findIndex((s: any) => rankdata[2][1] === s[2][1]) === index;
|
|
|
|
|
});
|
|
|
|
|
for (let i = 0; i < rankdata.length; i++) {
|
|
|
|
|
for (let i: number = 0; i < rankdata.length; i++) {
|
|
|
|
|
rankdata[i][0] = i + 1;
|
|
|
|
|
}
|
|
|
|
|
this._rankWinMoneyData = rankdata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SetRankWinMoneyData(rankdata: any) {
|
|
|
|
|
public SetRankWinMoneyDataOK(): void {
|
|
|
|
|
this._isOK[1] = true;
|
|
|
|
|
this._checkOK();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RankDataAddDate(id: number, rankdata: any) {
|
|
|
|
|
public RankDataAddDate(id: number, rankdata: any): any {
|
|
|
|
|
let date: string = this._contestDateFormID(id);
|
|
|
|
|
for (let i = 0; i < rankdata.length; i++) {
|
|
|
|
|
for (let i: number = 0; i < rankdata.length; i++) {
|
|
|
|
|
rankdata[i].push(date);
|
|
|
|
|
}
|
|
|
|
|
return rankdata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _checkOK() {
|
|
|
|
|
private _checkOK(): void {
|
|
|
|
|
if (this._isOK.includes(false)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
NetManager.Disconnect();
|
|
|
|
|
for (let i: number = 0; i < this.Current.length; i++) {
|
|
|
|
|
const current: any = this.Current[i];
|
|
|
|
|
current.SetInit();
|
|
|
|
|
}
|
|
|
|
|
this.Client.isLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async PrevWeek(): Promise<void> {
|
|
|
|
|
let nowContestIndex: number = this._nowContestIndex;
|
|
|
|
|
if (nowContestIndex - 1 >= 0) {
|
|
|
|
|
nowContestIndex--;
|
|
|
|
|
} else {
|
|
|
|
|
alert(`到底了`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._isIDupup = false;
|
|
|
|
|
await this.RunSetWeek(nowContestIndex);
|
|
|
|
|
// const contest: string = this.ContestData[nowContestIndex];
|
|
|
|
|
// let str: string[] = contest.split("~");
|
|
|
|
|
// let my: moment.Moment = this._getMomentFormString(this._nowContestDate);
|
|
|
|
|
// let start: moment.Moment = this._getMomentFormString(str[0]);
|
|
|
|
|
// let end: moment.Moment = this._getMomentFormString(str[1]);
|
|
|
|
|
// let diff: number = my.diff(start, "day");
|
|
|
|
|
// if (diff < 0) {
|
|
|
|
|
// alert(`還沒開放`);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// this.Client.isLoading.value = true;
|
|
|
|
|
// this._isOK[0] = false;
|
|
|
|
|
// this._isOK[1] = false;
|
|
|
|
|
|
|
|
|
|
// this._nowContestStart = moment(start).format("MM/DD");
|
|
|
|
|
// this._nowContestEnd = moment(end).format("MM/DD");
|
|
|
|
|
// this._nowContestStartIndex = this._contestIDFormDate(this._nowContestStart);
|
|
|
|
|
// this._nowContestEndIndex = this._nowSearchMagnificationID = this._contestIDFormDate(this._nowContestEnd);
|
|
|
|
|
// this.Title = `${this._nowContestStart}~${this._nowContestEnd}`;
|
|
|
|
|
|
|
|
|
|
// await this.ConnectServer();
|
|
|
|
|
// this.RunRankMagnificationWeek();
|
|
|
|
|
// this.RunRankWinMoneyWeek();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async NextWeek(): Promise<void> {
|
|
|
|
|
let nowContestIndex: number = this._nowContestIndex;
|
|
|
|
|
if (nowContestIndex + 1 < this.ContestData.length) {
|
|
|
|
|
nowContestIndex++;
|
|
|
|
|
} else {
|
|
|
|
|
alert(`到底了`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._isIDupup = true;
|
|
|
|
|
await this.RunSetWeek(nowContestIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async RunSetWeek(nowContestIndex: number): Promise<void> {
|
|
|
|
|
const contest: string = this.ContestData[nowContestIndex];
|
|
|
|
|
let str: string[] = contest.split("~");
|
|
|
|
|
let my: moment.Moment = this._getMomentFormString(this._nowContestDate);
|
|
|
|
|
let start: moment.Moment = this._getMomentFormString(str[0]);
|
|
|
|
|
let end: moment.Moment = this._getMomentFormString(str[1]);
|
|
|
|
|
let diff: number = my.diff(start, "day");
|
|
|
|
|
if (diff < 0) {
|
|
|
|
|
alert(`還沒開放`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._nowContestIndex = nowContestIndex;
|
|
|
|
|
this.Client.isLoading.value = true;
|
|
|
|
|
this._isOK[0] = false;
|
|
|
|
|
this._isOK[1] = false;
|
|
|
|
|
|
|
|
|
|
this._nowContestStart = moment(start).format("MM/DD");
|
|
|
|
|
this._nowContestEnd = moment(end).format("MM/DD");
|
|
|
|
|
this._nowContestStartIndex = this._contestIDFormDate(this._nowContestStart);
|
|
|
|
|
this._nowContestEndIndex = this._contestIDFormDate(this._nowContestEnd);
|
|
|
|
|
if (this._isIDupup) {
|
|
|
|
|
this._nowSearchMagnificationID = this._nowSearchWinMoneyID = this._contestIDFormDate(this._nowContestStart);
|
|
|
|
|
} else {
|
|
|
|
|
this._nowSearchMagnificationID = this._nowSearchWinMoneyID = this._contestIDFormDate(this._nowContestEnd);
|
|
|
|
|
}
|
|
|
|
|
this.Title = `${this._nowContestStart}~${this._nowContestEnd}`;
|
|
|
|
|
|
|
|
|
|
await this.ConnectServer();
|
|
|
|
|
this.RunRankMagnificationWeek();
|
|
|
|
|
this.RunRankWinMoneyWeek();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async RunRankMagnificationWeek(): Promise<void> {
|
|
|
|
|
this._rankMagnificationData = [];
|
|
|
|
|
let req: any = await this.GetRankData(12, this._nowSearchMagnificationID);
|
|
|
|
|
let resp: INetResponse<any> = req.Result;
|
|
|
|
|
if (!resp.IsValid) {
|
|
|
|
|
if (resp.Status === 11) {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Rank 無資料");
|
|
|
|
|
this.OrganizeRankMagnificationData(this._rankMagnificationData);
|
|
|
|
|
this.SetRankMagnificationDataOK();
|
|
|
|
|
} else {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Get RankInfo Fail");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.ParseRankMagnificationData(resp.Data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async RunRankWinMoneyWeek(): Promise<void> {
|
|
|
|
|
this._rankWinMoneyData = [];
|
|
|
|
|
let req: any = await this.GetRankData(11, this._nowSearchWinMoneyID);
|
|
|
|
|
let resp: INetResponse<any> = req.Result;
|
|
|
|
|
if (!resp.IsValid) {
|
|
|
|
|
if (resp.Status === 11) {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Rank 無資料");
|
|
|
|
|
this.OrganizeRankWinMoneyData(this._rankWinMoneyData);
|
|
|
|
|
this.SetRankWinMoneyDataOK();
|
|
|
|
|
} else {
|
|
|
|
|
CSMessage.NetError(resp.Method, resp.Status, "Get RankInfo Fail");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.ParseRankWinMoneyData(resp.Data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region Get
|
|
|
|
|
|
|
|
|
|
private _contestIDFormDate(date: string): number {
|
|
|
|
|
let my = this._getMomentFormString(this._nowContestDate);
|
|
|
|
|
let target = this._getMomentFormString(date);
|
|
|
|
|
let my: moment.Moment = this._getMomentFormString(this._nowContestDate);
|
|
|
|
|
let target: moment.Moment = this._getMomentFormString(date);
|
|
|
|
|
let diffday: number = my.diff(target, "day");
|
|
|
|
|
let id = this._nowContestID - diffday;
|
|
|
|
|
let id: number = this._nowContestID - diffday;
|
|
|
|
|
if (id < 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
@@ -389,11 +546,11 @@ export class BJ_Casino_Data {
|
|
|
|
|
return Arr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Sleep(ms: number) {
|
|
|
|
|
public Sleep(ms: number): Promise<any> {
|
|
|
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AddLog(log: any) {
|
|
|
|
|
public AddLog(log: any): void {
|
|
|
|
|
console.log(log);
|
|
|
|
|
// var textarea = document.getElementById("Log");
|
|
|
|
|
// textarea.value += log + "\n";
|
|
|
|
|
|