[add] 自己計算get
This commit is contained in:
parent
04789455a3
commit
e741029939
@ -113,9 +113,9 @@ export class EnumeratorExecutor implements IEnumeratorV2Started {
|
||||
this._enumerator = null;
|
||||
this.error = e;
|
||||
if (e instanceof Error) {
|
||||
cc.error(e.stack);
|
||||
console.error(e.stack);
|
||||
} else {
|
||||
cc.error(`Error: ${JSON.stringify(e)}`);
|
||||
console.error(`Error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -130,14 +130,13 @@ export class EnumeratorExecutor implements IEnumeratorV2Started {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
catch (e) {
|
||||
this.doneFlag = true;
|
||||
this.error = e;
|
||||
if (e instanceof Error) {
|
||||
cc.error(e.stack);
|
||||
console.error(e.stack);
|
||||
} else {
|
||||
cc.error(`Error: ${JSON.stringify(e)}`);
|
||||
console.error(`Error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
result = { done: true, value: e };
|
||||
}
|
||||
|
@ -2,30 +2,32 @@ import { INetRequest } from "../../script/Engine/CatanEngine/NetManagerV2/Core/I
|
||||
import { INetResponse } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetResponse";
|
||||
import { ClientData } from "../../shared/protocols/define/interface";
|
||||
import { RpcSlot1SpinRequest, RpcSlot1SpinResponse } from "../../shared/protocols/Slot1Request";
|
||||
import { RandomEx } from "../../Utils/Number/RandomEx";
|
||||
|
||||
export default function* (clientData: ClientData, req: INetRequest<RpcSlot1SpinRequest>): IterableIterator<any> {
|
||||
const data: RpcSlot1SpinRequest = req.Data
|
||||
|
||||
const temps: string[] = [
|
||||
`{"slot":[13,9,5,14,4,9,4,12,12,11,4,14,8,7,6],"line":[[[10,6],195,300],[[10,6],213,300]]}`,
|
||||
`{"slot":[9,9,10,13,4,5,4,3,4,11,10,14,14,14,5]}`,
|
||||
`{"slot":[12,6,8,12,11,7,12,11,5,5,11,5,3,10,9]}`,
|
||||
`{"slot":[4,6,11,13,8,12,12,3,4,10,7,5,14,14,4]}`,
|
||||
`{"slot":[5,9,9,3,11,10,4,5,12,5,4,14,12,5,9],"line":[[[10,6],195,300],[[10,6],213,300]]}`,
|
||||
`{"slot":[14,4,10,3,11,5,14,3,12,6,10,6,14,5,12],"line":[[[0,6,12],49,750]],"scatter":[[[3,7],3000]]}`,
|
||||
`{"slot":[9,14,13,4,11,4,7,6,14,6,12,13,9,12,12]}`,
|
||||
`{"slot":[10,3,12,13,5,6,4,8,4,9,13,14,11,14,4]}`,
|
||||
`{"slot":[10,14,13,9,8,6,6,6,4,13,13,12,9,14,4],"line":[[[5,6,7],122,3000]]}`,
|
||||
`{"slot":[11,13,9,8,5,8,5,5,13,9,14,9,12,4,7]}`,
|
||||
];
|
||||
const Data: any = JSON.parse(temps[RandomEx.GetInt(0, temps.length)]);
|
||||
// const freeTemps: string[] = [
|
||||
// `{"slot":[13,9,5,14,4,9,4,12,12,11,4,14,8,7,6],"line":[[[10,6],195,300],[[10,6],213,300]]}`,
|
||||
// `{"slot":[9,9,10,13,4,5,4,3,4,11,10,14,14,14,5]}`,
|
||||
// `{"slot":[12,6,8,12,11,7,12,11,5,5,11,5,3,10,9]}`,
|
||||
// `{"slot":[4,6,11,13,8,12,12,3,4,10,7,5,14,14,4]}`,
|
||||
// `{"slot":[5,9,9,3,11,10,4,5,12,5,4,14,12,5,9],"line":[[[10,6],195,300],[[10,6],213,300]]}`,
|
||||
// `{"slot":[14,4,10,3,11,5,14,3,12,6,10,6,14,5,12],"line":[[[0,6,12],49,750]],"scatter":[[[3,7],3000]]}`,
|
||||
// `{"slot":[9,14,13,4,11,4,7,6,14,6,12,13,9,12,12]}`,
|
||||
// `{"slot":[10,3,12,13,5,6,4,8,4,9,13,14,11,14,4]}`,
|
||||
// `{"slot":[10,14,13,9,8,6,6,6,4,13,13,12,9,14,4],"line":[[[5,6,7],122,3000]]}`,
|
||||
// `{"slot":[11,13,9,8,5,8,5,5,13,9,14,9,12,4,7]}`,
|
||||
// ];
|
||||
// const Data: any = JSON.parse(freeTemps[RandomEx.GetInt(0, freeTemps.length)]);
|
||||
const { count, freeData } = clientData.free;
|
||||
const slotData: any = freeData[count];
|
||||
|
||||
const response: INetResponse<RpcSlot1SpinResponse> = {
|
||||
Status: 0,
|
||||
Method: req.Method,
|
||||
Data,
|
||||
Data: slotData,
|
||||
IsValid: true
|
||||
};
|
||||
clientData.free.count++;
|
||||
return response;
|
||||
}
|
@ -6,27 +6,112 @@ import { RandomEx } from "../../Utils/Number/RandomEx";
|
||||
|
||||
export default function* (clientData: ClientData, req: INetRequest<RpcSlot1SpinRequest>): IterableIterator<any> {
|
||||
const data: RpcSlot1SpinRequest = req.Data
|
||||
clientData.free = null;
|
||||
|
||||
|
||||
// // 原始的编码字符串
|
||||
// // // {"slot":[4,4,1,12,14,9,10,1,6,4,8,9,1,14,10],"scatter":[[[2,7,12],100]],"pay":[[1,-100]],"get":[[1,100]],"money":9990624}
|
||||
// // const encodedStr = 'H4sIAAAAAAAAA1WOMQ+CMBCF/0vnG9paRdkcSRwMjoahQjE1hZIWooTw371TSLS54d3ru7tvYpylE4vO97mJg+uztvbkNNq2WcVSAax2/rnIe/BDR5qj7UNDUipgtq3M62Rjz9KrUrBNgMMGSxbw2b1+gQIBQoJQcADBsdmhtaeGPMGLGZhutRujjbkxLq50Zz0uaJh4dJexuXm3wlY2mJIiX16kOdI5CQkeo5Wx/B/oKMp/oshZB2PQnPG9ARdrnfUWAQAA';
|
||||
|
||||
// // {"slot":[5,6,14,6,5,11,12,3,14,11,6,2,11,2,12],"line":[[[5,11,12,13,9],161,1500]],"pay":[[1,-100]],"get":[[1,1500]],"money":9991524}
|
||||
// const encodedStr = 'H4sIAAAAAAAAA11Pu27DMAz8F84cQjlSEG9FpwAdinQMMqi2XKiQJcOykRqB/72kH0OrQTreEXenJxygfEIOabi6PIbhEpskTGt9vNRQEkIT0mODX30aO8EHplPfClRHBB9r9/Pm8wDlrdBIZ6QjFoSk77iYb5pGI4pB3mFVYSEjQ4NKHr7UfUaw0YYp+3x1LuS94Lud9nZkaGGn9jMFbsbVqjRGjtAIDx/q13VSCMFHt7Q3JMNWY02nAs9csLMT63rm4O/uY/Hcg2rfu0qS1y/zP1/EQDrm6u9q93/pxNZN7xyzM59fbBqv0msBAAA=';
|
||||
|
||||
// // 解码 Base64
|
||||
// const decodedBytes = Buffer.from(encodedStr, 'base64');
|
||||
|
||||
// // 解压缩 zlib 数据
|
||||
// gunzip(decodedBytes, (err, decompressedBytes) => {
|
||||
// if (err) {
|
||||
// console.error('解压缩失败:', err);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 解析 JSON 数据
|
||||
// try {
|
||||
// const jsonData = JSON.parse(decompressedBytes.toString());
|
||||
// console.log(JSON.stringify(jsonData, null, 4));
|
||||
// } catch (parseErr) {
|
||||
// console.error('JSON 解析失败:', parseErr);
|
||||
// }
|
||||
// });
|
||||
|
||||
const temps: string[] = [
|
||||
`{"slot":[11,4,8,9,5,2,13,10,7,9,10,6,6,12,4],"line":[[[5,11,12],161,2000]],"get":[[1,2000]]}`,
|
||||
`{"slot":[11,4,8,9,5,2,13,10,7,9,10,6,6,12,4],"line":[[[5,11,12],161,2000]]}`,
|
||||
|
||||
`{"slot":[9,6,2,5,4,14,10,9,13,10,4,5,5,2,2]}`,
|
||||
|
||||
`{"slot":[4,3,3,3,9,10,14,14,9,4,7,8,8,5,10],"free":[[1,2,3],3],"scatter":[[[1,2,3],3000]],"get":[[1,2000]]}`,
|
||||
`{"slot":[4,3,3,3,9,10,14,14,9,4,7,8,8,5,10],"free":[[1,2,3],3],"scatter":[[[1,2,3],3000]]}`,
|
||||
];
|
||||
const Data: any = JSON.parse(temps[RandomEx.GetInt(0, temps.length)]);
|
||||
clientData.money -= data.pay;
|
||||
if (Data.get) {
|
||||
clientData.money += Data.get[0][1];
|
||||
const slotData: any = JSON.parse(temps[RandomEx.GetInt(0, temps.length)]);
|
||||
|
||||
let totalGet: number = 0;
|
||||
if (slotData.line) {
|
||||
totalGet += getLineGet(slotData.line);
|
||||
}
|
||||
Data["pay"] = [[1, -data.pay]];
|
||||
Data["money"] = clientData.money;
|
||||
if (slotData.scatter) {
|
||||
totalGet += getScatterGet(slotData.scatter);
|
||||
}
|
||||
if (slotData.free) {
|
||||
const count = slotData.free[1];
|
||||
const { freeData, totalFreeGet } = getFree(count);
|
||||
totalGet += totalFreeGet;
|
||||
clientData.free = { count: 0, freeData };
|
||||
}
|
||||
if (totalGet) {
|
||||
slotData.get = [[1, totalGet]];
|
||||
}
|
||||
|
||||
clientData.money -= data.pay;
|
||||
if (slotData.get) {
|
||||
clientData.money += slotData.get[0][1];
|
||||
}
|
||||
slotData["pay"] = [[1, -data.pay]];
|
||||
slotData["money"] = clientData.money;
|
||||
|
||||
const response: INetResponse<RpcSlot1SpinResponse> = {
|
||||
Status: 0,
|
||||
Method: req.Method,
|
||||
Data,
|
||||
Data: slotData,
|
||||
IsValid: true
|
||||
};
|
||||
return response;
|
||||
}
|
||||
|
||||
function getFree(count: number) {
|
||||
const freeData = [];
|
||||
let totalFreeGet = 0;
|
||||
const freeTemps: string[] = [
|
||||
`{"slot":[13,9,5,14,4,9,4,12,12,11,4,14,8,7,6],"line":[[[10,6],195,300],[[10,6],213,300]]}`,
|
||||
`{"slot":[9,9,10,13,4,5,4,3,4,11,10,14,14,14,5]}`,
|
||||
`{"slot":[12,6,8,12,11,7,12,11,5,5,11,5,3,10,9]}`,
|
||||
`{"slot":[4,6,11,13,8,12,12,3,4,10,7,5,14,14,4]}`,
|
||||
`{"slot":[5,9,9,3,11,10,4,5,12,5,4,14,12,5,9],"line":[[[10,6],195,300],[[10,6],213,300]]}`,
|
||||
`{"slot":[14,4,10,3,11,5,14,3,12,6,10,6,14,5,12],"line":[[[0,6,12],49,750]],"scatter":[[[3,7],3000]]}`,
|
||||
`{"slot":[9,14,13,4,11,4,7,6,14,6,12,13,9,12,12]}`,
|
||||
`{"slot":[10,3,12,13,5,6,4,8,4,9,13,14,11,14,4]}`,
|
||||
`{"slot":[10,14,13,9,8,6,6,6,4,13,13,12,9,14,4],"line":[[[5,6,7],122,3000]]}`,
|
||||
`{"slot":[11,13,9,8,5,8,5,5,13,9,14,9,12,4,7]}`,
|
||||
];
|
||||
for (let i: number = 0; i < count; i++) {
|
||||
const slotData: any = JSON.parse(freeTemps[RandomEx.GetInt(0, freeTemps.length)]);
|
||||
freeData.push(slotData);
|
||||
if (slotData.line) {
|
||||
totalFreeGet += getLineGet(slotData.line);
|
||||
}
|
||||
}
|
||||
return { freeData, totalFreeGet }
|
||||
}
|
||||
|
||||
function getLineGet(lines: number[][]): number {
|
||||
let totalGet: number = 0;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
totalGet += line[2]
|
||||
}
|
||||
return totalGet;
|
||||
}
|
||||
|
||||
function getScatterGet(scatter: number[][]): number {
|
||||
let totalGet: number = scatter[0][1];
|
||||
return totalGet;
|
||||
}
|
@ -8,6 +8,7 @@ import "module-alias/register";
|
||||
import WebSocket, { WebSocketServer } from 'ws';
|
||||
|
||||
/*
|
||||
http://119.77.165.60/MyWeb/SD2/slot1/index.html?token=test&slotid=1&v=1724652287&host=127.0.0.1&language=zh-tw&logo=2&pl=1
|
||||
http://entry.lybobet.com/casino_sd_2/resource-internal/_Debug/slot1/index.html?token=test&slotid=1&v=1724652287&host=127.0.0.1&language=zh-tw&logo=2&pl=1
|
||||
ws://192.168.5.36:9005
|
||||
ws://127.0.0.1:9005
|
||||
|
@ -6,4 +6,5 @@ export interface ClientData {
|
||||
id: number;
|
||||
name: string;
|
||||
money: number;
|
||||
free?: { count: number, freeData: any[] };
|
||||
}
|
Loading…
Reference in New Issue
Block a user