123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- 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();
- var totalProfit = 0;
- function dealMsg(msgType,data) {
- switch(msgType){
- case "GameDataSynNotify":
- betInfoMap.clear();
-
- data.optionInfo.forEach((info) => {
- if (betInfoMap.has(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 {
-
-
- 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;
- });
- var curentRoundProfit = totalBetSum-totalPayAmount;
- totalProfit += curentRoundProfit;
-
- console.log(`====>>>>同步后:总盈亏:${totalProfit/100}¥,\t本局总收入是:${totalBetSum/100}¥,\t庄家总付出金额: ${totalPayAmount/100}¥,\t本局利润是:${(curentRoundProfit)/100}¥`);
- betInfoMap.clear();
- break;
- case "ReadyGameNotify":
- break;
- case "DealNotify":
- break;
- case "ShowOddsNotify":
- break;
- case "StartBetNotify":
- break;
- case "MergeAutoBetNotify":
- break;
- default:
-
- }
- }
|