From 93e0b340d82c63b3a179039005313208daae45da Mon Sep 17 00:00:00 2001 From: cuongnm2 Date: Fri, 5 Apr 2024 14:45:18 +0700 Subject: [PATCH] update framework --- assets/Script/Common/Bundle.ts | 7 ------- assets/Script/Common/Configs.ts | 2 +- assets/Script/Common/GameUtil.ts | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/assets/Script/Common/Bundle.ts b/assets/Script/Common/Bundle.ts index 367a0fa..abdc4ac 100644 --- a/assets/Script/Common/Bundle.ts +++ b/assets/Script/Common/Bundle.ts @@ -1,10 +1,3 @@ -// Learn TypeScript: -// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html -// Learn Attribute: -// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html -// Learn life-cycle callbacks: -// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html - const {ccclass, property} = cc._decorator; @ccclass diff --git a/assets/Script/Common/Configs.ts b/assets/Script/Common/Configs.ts index 9ff38b4..ce00787 100644 --- a/assets/Script/Common/Configs.ts +++ b/assets/Script/Common/Configs.ts @@ -8,7 +8,7 @@ namespace Configs { static Coin: number = 0; } - export const SERVER_IP = 'ws://13.251.151.251:3035'; + export const SERVER_IP = 'ws://127.0.0.1:3035'; export const SOCKET_EVENT = { //sys event--------- diff --git a/assets/Script/Common/GameUtil.ts b/assets/Script/Common/GameUtil.ts index a900e34..278a578 100644 --- a/assets/Script/Common/GameUtil.ts +++ b/assets/Script/Common/GameUtil.ts @@ -266,6 +266,42 @@ export default class GameUtil { return ip; } + public CSVToArray( strData, strDelimiter ) { + strDelimiter = (strDelimiter || ","); + var objPattern = new RegExp( + ( + "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" + + "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" + + "([^\"\\" + strDelimiter + "\\r\\n]*))" + ), + "gi" + ); + var arrData = [[]]; + var arrMatches = null; + while (arrMatches = objPattern.exec( strData )){ + var strMatchedDelimiter = arrMatches[ 1 ]; + if ( + strMatchedDelimiter.length && + (strMatchedDelimiter != strDelimiter) + ){ + arrData.push( [] ); + } + if (arrMatches[ 2 ]){ + var strMatchedValue = arrMatches[ 2 ].replace( + new RegExp( "\"\"", "g" ), + "\"" + ); + } else { + var strMatchedValue = arrMatches[ 3 ]; + } + arrData[ arrData.length - 1 ].push( strMatchedValue ); + } + if(arrData.length>0){ + arrData.pop(); + } + return arrData; + } + } class DateUtil extends Date { customFormat = function (formatString) {