|
@@ -0,0 +1,171 @@
|
|
|
+function printStack(){
|
|
|
+ const stack = new Error().stack;
|
|
|
+ console.log("调用堆栈:",stack);
|
|
|
+}
|
|
|
+
|
|
|
+const originalConsoleLog = console.log;
|
|
|
+
|
|
|
+function isHighSurrogate(codeUnit) {
|
|
|
+ return codeUnit >= 0xD800 && codeUnit <= 0xDBFF;
|
|
|
+}
|
|
|
+
|
|
|
+function isLowSurrogate(codeUnit) {
|
|
|
+ return codeUnit >= 0xDC00 && codeUnit <= 0xDFFF;
|
|
|
+}
|
|
|
+
|
|
|
+function splitAndPrintString(str, maxSize) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let strLength = str.length;
|
|
|
+ for (let i = 0; i < strLength; i += maxSize) {
|
|
|
+ let end = i + maxSize;
|
|
|
+
|
|
|
+
|
|
|
+ if (end < str.length && isHighSurrogate(str.charCodeAt(end - 1)) && isLowSurrogate(str.charCodeAt(end))) {
|
|
|
+ end++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strLength > maxSize) {
|
|
|
+ if (i === 0) {
|
|
|
+ originalConsoleLog(str.slice(i, end), "__>>__");
|
|
|
+ } else if (end >= strLength) {
|
|
|
+ originalConsoleLog("__<<__", str.slice(i, end));
|
|
|
+ } else {
|
|
|
+ originalConsoleLog("__<<__", str.slice(i, end), "__>>__");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ originalConsoleLog(str.slice(i, end));
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+console.log = function (...args) {
|
|
|
+ const maxChunkSize = 800;
|
|
|
+
|
|
|
+
|
|
|
+ const combinedString = args.map(arg => {
|
|
|
+ if (typeof arg === 'object') {
|
|
|
+ try {
|
|
|
+ return JSON.stringify(arg);
|
|
|
+ } catch (e) {
|
|
|
+ return "啊啊啊啊啊,解析失败了" + e.message;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return String(arg);
|
|
|
+ }
|
|
|
+ }).join(' ');
|
|
|
+
|
|
|
+
|
|
|
+ splitAndPrintString(combinedString, maxChunkSize);
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+var OptionInfo = { option: 0, odds: 1, totalBet: 0 }
|
|
|
+
|
|
|
+var betInfoMap = new Map();
|
|
|
+
|
|
|
+function dealMsg(msgType,data) {
|
|
|
+ switch(msgType){
|
|
|
+ case "GameDataSynNotify":
|
|
|
+ betInfoMap.clear();
|
|
|
+ console.log("====>>>>啦啦啦啦",data.optionInfo);
|
|
|
+ data.optionInfo.forEach((info) => {
|
|
|
+ if (betInfoMap.has(info.option)) {
|
|
|
+ console.log("====>>>>有这个option",info.option);
|
|
|
+
|
|
|
+ let existingInfo = betInfoMap.get(info.option);
|
|
|
+ existingInfo.totalBet += info.totalBet;
|
|
|
+ existingInfo.option = info.option;
|
|
|
+ existingInfo.odds = info.odds;
|
|
|
+
|
|
|
+ betInfoMap.set(info.option, existingInfo);
|
|
|
+ } else {
|
|
|
+ console.log("====>>>>没有这个option",info.option);
|
|
|
+
|
|
|
+ betInfoMap.set(info.option, {
|
|
|
+ odds: info.odds,
|
|
|
+ totalBet: info.totalBet,
|
|
|
+ option: info.option
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log("====>>>>同步后自己的数据",[...betInfoMap]);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "BetNotify":
|
|
|
+ var detail = data.detail;
|
|
|
+ var option = detail.option;
|
|
|
+ var betAmount = detail.betAmount;
|
|
|
+ if (betInfoMap.has(option)) {
|
|
|
+
|
|
|
+ let existingInfo = betInfoMap.get(option);
|
|
|
+ existingInfo.totalBet += betAmount;
|
|
|
+ existingInfo.option = info.option;
|
|
|
+ existingInfo.odds = info.odds;
|
|
|
+ betInfoMap.set(option, existingInfo);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ betInfoMap.set(option, {
|
|
|
+ odds: detail.odds,
|
|
|
+ totalBet: betAmount,
|
|
|
+ limitRed: 0
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "StopBetNotify":
|
|
|
+ break;
|
|
|
+ case "StartSettlementNotify":
|
|
|
+ break;
|
|
|
+ case "GameRoundEndNotify":
|
|
|
+
|
|
|
+ let totalPayAmount = 0;
|
|
|
+
|
|
|
+
|
|
|
+ data.playerSettle.forEach(player => {
|
|
|
+
|
|
|
+ player.settle.forEach(settleItem => {
|
|
|
+
|
|
|
+ totalPayAmount += settleItem.winAmount;
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ if (data.otherPlayers && data.otherPlayers.settle) {
|
|
|
+ data.otherPlayers.settle.forEach(settleItem => {
|
|
|
+
|
|
|
+ totalPayAmount += settleItem.winAmount;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let totalBetSum = 0;
|
|
|
+
|
|
|
+
|
|
|
+ betInfoMap.forEach((value, key) => {
|
|
|
+
|
|
|
+ totalBetSum += value.totalBet;
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log(`====>>>>同步后:本局总收入是:${totalBetSum/100}¥ ,庄家总付出金额: ${totalPayAmount/100}¥,利润是:${(totalBetSum-totalPayAmount)/100}¥`);
|
|
|
+ betInfoMap.clear();
|
|
|
+ break;
|
|
|
+ case "ReadyGameNotify":
|
|
|
+ break;
|
|
|
+ case "DealNotify":
|
|
|
+ break;
|
|
|
+ case "ShowOddsNotify":
|
|
|
+ break;
|
|
|
+ case "StartBetNotify":
|
|
|
+ break;
|
|
|
+ case "MergeAutoBetNotify":
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+
|
|
|
+ }
|
|
|
+}
|