diff --git a/.gitignore b/.gitignore index f55cfdb..057fd76 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ __recovery/ *.dsv *.md *.doc -*.txt \ No newline at end of file +*.txt +*.bak \ No newline at end of file diff --git a/GameUnit.cpp b/GameUnit.cpp index 28fbc66..8761f7f 100644 --- a/GameUnit.cpp +++ b/GameUnit.cpp @@ -376,7 +376,7 @@ int __fastcall TWLDiffChip::HandleResult(int res, double wl) bool bLevel = false; TLevelRow* pRow = (TLevelRow*)pPolicy->aRows[iRank]; if(bGlobal && !g_aGames.bFloat && !((TLevelPolicy*)pPolicy)->bInstant){//非立即升降 - if(nWLDiff >= pRow->nCondWin || nWLDiff <= pRow->nCondLos){ //达到升降条件 + if(nWLDiff >= pRow->nCondWin || nWLDiff < pRow->nCondLos){ //达到升降条件 g_aGames.AllBetOff(); bWait = g_aGames.nBetted[2]>0; //等待结算 DebugPrint("wait count: %d", g_aGames.nBetted[2]); @@ -388,11 +388,11 @@ int __fastcall TWLDiffChip::HandleResult(int res, double wl) } if(!bWait){ - if(nWLDiff >= pRow->nCondWin){ //赢走向 + if(nWLDiff >= pRow->nCondWin){ //赢走向,闭区间 iRank = pRow->iWin - 1; bLevel = true; } - else if(nWLDiff <= pRow->nCondLos){ //输走向 + else if(nWLDiff < pRow->nCondLos){ //输走向,开区间 iRank = pRow->iLos - 1; bLevel = true; } diff --git a/PolicyEditFormUnit.cpp b/PolicyEditFormUnit.cpp index c824d2e..15f7b0a 100644 --- a/PolicyEditFormUnit.cpp +++ b/PolicyEditFormUnit.cpp @@ -1240,7 +1240,7 @@ void __fastcall TPolicyEditForm::InitChipGrid(int kind) m_sg->Cells[1][0] = "注码"; m_sg->Cells[2][0] = "大于等于"; m_sg->Cells[3][0] = "走向"; - m_sg->Cells[4][0] = "小于等于"; + m_sg->Cells[4][0] = "小于"; m_sg->Cells[5][0] = "走向"; m_sg->ColWidths[0] = DPIX(60); m_sg->ColWidths[1] = DPIX(66); diff --git a/PolicyUnit.cpp b/PolicyUnit.cpp index 920a140..69510b0 100644 --- a/PolicyUnit.cpp +++ b/PolicyUnit.cpp @@ -1,5 +1,6 @@ //--------------------------------------------------------------------------- #include +#include #include "PolicyUnit.h" #include "GlobalUnit.h" @@ -51,10 +52,56 @@ char *sysChip[SYSCPNUM] = {//kk|pppp pause|dead ,"06-随机注码\n08" ,"07-阶梯-4级\n02000\n1,500,1,500,2;2,500,1,500,3;3,1000,1,500,4;4,1500,1,500,0" ,"08-组合阶梯-3级\n03200\n1,20,500,1,500,2;2,20,500,1,500,3;3,20,1000,1,500,0" - ,"09-赢输次差-单3\n04020\n1,10,2,-10,3;0,20,0,11,1;2,-11,1,-30,0" + ,"09-赢输次差-单3\n04020\n1,10,2,-10,3;0,20,0,10,1;2,-10,1,-30,0" ,"10-赢输次差-总4\n04021\n1,20,2,-20,3;0,40,0,20,1;2,-20,1,-40,4;4,-40,3,-60,0" }; +//内置打法策略描述,索引与sysBet[]一一对应 +static const wchar_t* sysBetDesc[SYSBPNUM] = { + L"无论出庄、出闲还是和局,都下注庄" + ,L"无论出庄、出闲还是和局,都下注闲" + ,L"出庄打庄、出闲打闲,和局不下" + ,L"出庄打闲、出闲打庄,和局不下" + ,L"出庄打庄、出闲打闲;和局不变" + ,L"两闲跟一庄时打闲" + ,L"两庄跟一闲时打庄" + ,L"大路打连:出庄打庄,出闲打闲,和局不下" + ,L"大路打反:出庄打闲,出闲打庄,和局不下" + ,L"大路逢断打反:连庄被闲打断时打庄,连闲被庄打断时打闲" + ,L"大路连二打反:连出两闲后打庄,连出两庄后打闲" + ,L"大路连三打反:连出三闲后打庄,连出三庄后打闲" + ,L"大路逢断打连:连庄被闲打断后改打闲,连闲被庄打断后改打庄" + ,L"大路跳二打连:一庄一闲单跳之后,跟最后一手的方向下注" + ,L"大路跳三打连:庄闲交替三手之后,跟最后一手的方向下注" + ,L"大路组合形态:长龙与连二接转等八种形态出现后,各自跟势下注" + ,L"大眼路全程打庄(红)" + ,L"大眼路全程打闲(蓝)" + ,L"大眼路逢连打连:连出两个及以上时,跟连的方向下注" + ,L"大眼路逢连打断:连出两个及以上时,反向下注" + ,L"小路全程打庄(红)" + ,L"小路全程打闲(蓝)" + ,L"小路二夹一打断:两庄夹一闲后打闲,两闲夹一庄后打庄" + ,L"小强路全程打庄(红)" + ,L"小强路全程打闲(蓝)" + ,L"小强路背靠背打断:两红两蓝直至六红六蓝的成对形态出现后,反向下注" + ,L"小强路特殊打法;可设置「庄问路全红」或「闲问路全红」情况下不打/打庄/打闲" + ,L"珠盘路打法;用台桌当前庄/闲数算差值,「庄比闲多」条件满足时按「庄多下注」、「闲比庄多」条件满足时按「闲多下注」,其他情况不下注" +}; + +//内置注码策略描述,索引与sysChip[]一一对应 +static const wchar_t* sysChipDesc[SYSCPNUM] = { + L"注码一直为1" + ,L"输则进一级加注、赢则退一级减注;最高一级再输即爆缆停止" + ,L"输则注码翻倍,赢则立即回到第1行;末行再输爆缆,新局重启" + ,L"4层×每层7手、每手1注;输进一级、赢回第1层;二层以上赢利回基、输额累加进下层;爆缆暂停1分钟后新局重启" + ,L"每层赢2手即回第1行、输则进一级;注码逐级2/2/3/3/4/4/5/5/8/8/10/10/20;末行输爆缆,暂停1分钟后新局重启" + ,L"每手在「随机最小值」到「随机最大值」(闭区间)内取随机整数作为注码;可被组合阶梯每层选用" + ,L"4级阶梯按盈亏金额升降:注码1/2/3/4,各级赢到500/500/1000/1500回第1级、亏500进下一级,末级输爆缆停止" + ,L"3级组合阶梯:依次选用方案1/2/3并各按20倍执行;赢够500(第3级1000)回第1级、亏够500进下一级,末级输爆缆停止" + ,L"次差在[-10,10)时注码1、[10,20)时注码0、[-30,-10)时注码2;次差≥20或<-30爆缆;单桌计算,爆缆后新局重启" + ,L"次差在[-20,20)时注码1、[20,40)时注码0、[-40,-20)时注码2、[-60,-40)时注码4;次差≥40或<-60爆缆;总体计算,爆缆后新局重启" +}; + int u_iUserBetId = 100, u_iUserChipId = 100; @@ -76,6 +123,7 @@ void TBasePolicy::Reset() { Clear(); name = ""; + desc = ""; type = 0; id = 0; } @@ -478,9 +526,9 @@ vector u_aUserCPLen; ///////////////////////////////////////////////////////////////////////////// //文件定义 -#define USER_BPF_VERSION 0x03 +#define USER_BPF_VERSION 0x04 //0x03起记录desc #define USER_BPF_FILE "betpolicy.dat" -#define USER_CPF_VERSION 0x07 +#define USER_CPF_VERSION 0x08 //0x07起记录desc #define USER_CPF_FILE "chipolicy.dat" //BetPolicy文件头 @@ -587,9 +635,15 @@ int __fastcall SaveBetPolicy(TBetPolicy* pPolicy, FILE* fp) int posStart = ftell(fp); char buff[1024]; - sprintf( buff, "%s", ((AnsiString)pPolicy->name).c_str() ); + //UTF8String显式锁死UTF-8,与系统ACP开关解耦(UTF-8开关机写出字节一致) + sprintf( buff, "%s", ((UTF8String)pPolicy->name).c_str() ); int len = strlen(buff)+1; fwrite( &len, sizeof(int), 1, fp ); + fwrite( buff, sizeof(char), len, fp ); + + sprintf( buff, "%s", ((UTF8String)pPolicy->desc).c_str() ); + len = strlen(buff)+1; + fwrite( &len, sizeof(int), 1, fp ); fwrite( buff, sizeof(char), len, fp ); fwrite( &pPolicy->type, sizeof(int), 1, fp ); @@ -626,11 +680,17 @@ int __fastcall SaveChipPolicy(TChipPolicy* pPolicy, FILE* fp) int posStart = ftell(fp); char buff[1024]; - sprintf( buff, "%s", ((AnsiString)pPolicy->name).c_str() ); + //UTF8String显式锁死UTF-8,与系统ACP开关解耦(UTF-8开关机写出字节一致) + sprintf( buff, "%s", ((UTF8String)pPolicy->name).c_str() ); int len = strlen(buff)+1; fwrite( &len, sizeof(int), 1, fp ); fwrite( buff, sizeof(char), len, fp ); + sprintf( buff, "%s", ((UTF8String)pPolicy->desc).c_str() ); + len = strlen(buff)+1; + fwrite( &len, sizeof(int), 1, fp ); + fwrite( buff, sizeof(char), len, fp ); + fwrite( &pPolicy->type, sizeof(int), 1, fp ); fwrite( &pPolicy->id, sizeof(int), 1, fp ); fwrite( &pPolicy->kind, sizeof(int), 1, fp ); @@ -850,6 +910,32 @@ int __fastcall DeletePolicy(int type, int index) return 0; } //--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +int __fastcall CalcNewPolicyNum(int type) +{ + vector& aPolicies = type==TYPE_P_BET ? g_aBetPolicies : g_aChipPolicies; + String sType = type==TYPE_P_BET ? "打法" : "注码"; + String sPre = "新建" + sType; + int lPre = sPre.Length(); + int nMax = 0; + for(int i=0; iname; + if(name.Pos(sPre)==1){ + String suf = name.SubString(lPre+1, name.Length()-lPre); + int num = 0; + if(TryStrToInt(suf, num) && num>nMax) + nMax = num; + } + } + return nMax; +} +//--------------------------------------------------------------------------- +String __fastcall AutoNewPolicyName(int type) +{ + String sType = type==TYPE_P_BET ? "打法" : "注码"; + return "新建" + sType + IntToStr(CalcNewPolicyNum(type)+1); +} +//--------------------------------------------------------------------------- void __fastcall LoadSystemBetPolicies() { char tmp[1024]; @@ -893,6 +979,7 @@ void __fastcall LoadSystemBetPolicies() } else{ pPolicy->type = 0; + pPolicy->desc = sysBetDesc[i]; g_aBetPolicies.push_back(pPolicy); } } @@ -925,7 +1012,12 @@ void __fastcall LoadUserBetPolicies() fread(&num, sizeof(int), 1, fp); fread(buf, sizeof(char), num, fp); - pPolicy->name = head[3]<=3 ? GBKToUTF8(buf) : String(buf); + pPolicy->name = head[3]<=3 ? GBKToUTF8(buf) : String((UTF8String)buf); //旧版本GBK;新版本UTF-8(bytes为0x04起统一) + if(head[3]>=4){ //新版本才记录desc,紧跟name之后,恒为UTF-8 + fread(&num, sizeof(int), 1, fp); + fread(buf, sizeof(char), num, fp); + pPolicy->desc = String((UTF8String)buf); + } pPolicy->actived = true; fread(&pPolicy->type, sizeof(int), 1, fp); @@ -1060,6 +1152,7 @@ void __fastcall LoadSystemChipPolicies() } else{ pPolicy->type = 0; + pPolicy->desc = sysChipDesc[i]; g_aChipPolicies.push_back(pPolicy); // if(pPolicy->kind==KIND_CHIP_COM){ //根据id查找iPolicy @@ -1106,6 +1199,13 @@ void __fastcall LoadUserChipPolicies() fread(&num, sizeof(int), 1, fp); fread(name, sizeof(char), num, fp); + //新版本才记录desc,紧跟name之后;char[1024]清零保证旧版本时为空串 + char desc[1024] = {0}; + if(head[3]>=8){ + fread(&num, sizeof(int), 1, fp); + fread(desc, sizeof(char), num, fp); + } + fread(&type, sizeof(int), 1, fp); if(head[3]>=5){ @@ -1178,7 +1278,8 @@ void __fastcall LoadUserChipPolicies() pPolicy->type = type; pPolicy->kind = kind; - pPolicy->name = head[3]<=7 ? GBKToUTF8(name) : String(name); + pPolicy->name = head[3]<=7 ? GBKToUTF8(name) : String((UTF8String)name); //旧版本GBK;新版本UTF-8(0x08起统一) + pPolicy->desc = String((UTF8String)desc); //desc只在head[3]>=8,恒为UTF-8 pPolicy->id = id; pPolicy->actived = true; diff --git a/PolicyUnit.h b/PolicyUnit.h index 0e27d3b..9bc0615 100644 --- a/PolicyUnit.h +++ b/PolicyUnit.h @@ -32,6 +32,7 @@ public: class TBasePolicy { public: String name; + String desc; //一句话描述(内置策略装载时填,用户策略保持空) int type; //存储类型 0=内置免费 1=内置付费 2=用户自定义 3=用户定制 int id; //唯一ID int kind; //自定义类型 CHIP:0=普通 1=手数层级 2=组合层级 4=随机 ... BET:0=普通 2=庄闲问路 3=庄闲差... @@ -183,6 +184,8 @@ int __fastcall MinChipOfPolicy(int index); vector __fastcall PolicyInCombo(int iPolicy); int __fastcall FindPolicy(int type, int id); void __fastcall CheckComboRow(TComboRow* row); +int __fastcall CalcNewPolicyNum(int type); +String __fastcall AutoNewPolicyName(int type); extern vector g_aBetPolicies; extern vector g_aChipPolicies; diff --git a/RBmaster.cbproj b/RBmaster.cbproj index 66165c7..a111a0e 100644 --- a/RBmaster.cbproj +++ b/RBmaster.cbproj @@ -235,6 +235,16 @@ ActCodeFormUnit.h 37 + +
AIForm
+ dfm + AIFormUnit.h + 38 +
+ + AI_Hook.h + 39 + BacABThread.h 14 @@ -376,6 +386,56 @@ SettingFormUnit.h 26 + + ResourceItem + RCDATA + betWithChip + + + ResourceItem + RCDATA + comboLadderChip + + + ResourceItem + RCDATA + ladderChip + + + ResourceItem + RCDATA + normalBet + + + ResourceItem + RCDATA + normalChip + + + ResourceItem + RCDATA + specialBet + + + ResourceItem + RCDATA + specialChip + + + ResourceItem + RCDATA + tierChip + + + ResourceItem + RCDATA + winLoseDiffChip + + + ResourceItem + RCDATA + skills +
TableIPForm
dfm @@ -403,19 +463,20 @@ + - - + + + - Base @@ -664,6 +725,66 @@ true + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + + + + .\ + true + + 1 diff --git a/RBmaster.cpp b/RBmaster.cpp index 21841c0..19a62d8 100644 --- a/RBmaster.cpp +++ b/RBmaster.cpp @@ -113,8 +113,8 @@ bool InitCef() GlobalCEFApp->LogProcessInfo = false; //true; // GlobalCEFApp->SingleProcess = false; //true; // GlobalCEFApp->MultiThreadedMessageLoop = true; - GlobalCEFApp->WindowlessRenderingEnabled = true; - GlobalCEFApp->DisableImageLoading = true; +// GlobalCEFApp->WindowlessRenderingEnabled = true; +// GlobalCEFApp->DisableImageLoading = true; GlobalCEFApp->OnWebKitInitialized = _di_TOnWebKitInitializedEvent(new TWebKitInitializeEvent()); @@ -224,7 +224,7 @@ USEFORM("RBmasterMain.cpp", MainForm); bool Startup() { String strAppPath = ExtractFileDir(ParamStr(0)) + "\\"; - strcpy( g_AppPath, ((AnsiString)strAppPath).c_str() ); + strcpy( g_AppPath, ((UTF8String)strAppPath).c_str() ); for(int i=1; i<=ParamCount(); i++){ String sParam = LowerCase(ParamStr(i)); diff --git a/RBmasterMain.cpp b/RBmasterMain.cpp index 029da5c..ceedbc9 100644 --- a/RBmasterMain.cpp +++ b/RBmasterMain.cpp @@ -24,6 +24,7 @@ #include "ResetFormUnit.h" #include "ChipsFormUnit.h" #include "ActCodeFormUnit.h" +#include "AIFormUnit.h" #define USER_VAR_FILE "rbmvrf" #define USER_VAR_VERSION 0x02 @@ -321,6 +322,20 @@ void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose) } } + if(AIForm){ + int mrRet = MessageBox(Handle, L"AI 助手尚未关闭,是否确定退出程序?", L"退出", + MB_ICONQUESTION | MB_OKCANCEL); + + if( mrRet==mrCancel ){ + CanClose = false; + return; + } + + AIForm->Perform( WM_CLOSE, 0, 0 ); + + Sleep(300); + } + Logout(); } @@ -1859,9 +1874,13 @@ bool __fastcall TMainForm::StopWebLoad() m_bWebLogon = false; - if(!m_sActCode.Length()) +// if(!m_sActCode.Length()) g_uid = 0; + u_sApiKey = ""; + if(AIForm) + AIForm->OnLogout(); + if( g_iPlatform==PF_PA ){ m_loginValues[0] = m_loginValues[1] = m_loginValues[2] = m_loginValues[3] = m_loginValues[4] = m_loginValues[5] = ""; @@ -2314,6 +2333,7 @@ void __fastcall TMainForm::UMHttpReturn(TMessage &msg) extm = 0, repeat = bVerify ? op : (op - UR_LOGIN), errRes = 0; + String apiKey; if( errCode==0 ){ int len = urThread->m_sizeOut; @@ -2336,6 +2356,9 @@ void __fastcall TMainForm::UMHttpReturn(TMessage &msg) else if( pos = strstr(tokenPtr, "exp:") ){ sscanf( pos+4, "%d", &extm ); } + else if( pos = strstr(tokenPtr, "key:") ){ + apiKey = pos + 4; + } tokenPtr=strtok(NULL,"|"); } } @@ -2373,7 +2396,7 @@ void __fastcall TMainForm::UMHttpReturn(TMessage &msg) PostMessage(Handle, UM_WEBDEAD, -4, 0 ); } } - else if(g_uid==0 || uid>0){ + else if(g_uid==0 && uid>0){ g_uid = uid; m_tExpire = extm; @@ -2388,7 +2411,11 @@ void __fastcall TMainForm::UMHttpReturn(TMessage &msg) PostMessage(Handle, UM_WEBDEAD, -2, 0 ); } else{ - SetExpireJS(); + SetExpireJS(); + u_sApiKey = apiKey; + + if(AIForm) + AIForm->OnLogin(); } if(bVerify){ @@ -2459,9 +2486,13 @@ void __fastcall TMainForm::UMWebLogin(TMessage &msg) m_bWebLogon = false; - if(!m_sActCode.Length()) +// if(!m_sActCode.Length()) g_uid = 0; + u_sApiKey = ""; + if(AIForm) + AIForm->OnLogout(); + g_MinOnBet = 20; //缺省限红 g_MaxOnBet = 50000; @@ -3663,20 +3694,30 @@ void __fastcall TMainForm::OnSettingClick(TObject *Sender) void __fastcall TMainForm::OnResetClick(TObject *Sender) { - ResetForm = new TResetForm(NULL); - TPoint pt = TPoint( m_panTopBar->Left + m_btnReset->Left - + (m_btnReset->Width - ResetForm->Width)/ 2 - , m_panWeb->Top); - pt = ClientToScreen(pt); - ResetForm->Left = pt.x; - ResetForm->Top = pt.y; + if(AIForm){ + AIForm->BringToFront(); + u_sApiKey = ""; + AIForm->OnLogout(); + } + else{ + AIForm = new TAIForm(NULL); + AIForm->Show(); + } - ResetForm->ShowModal(); - - delete ResetForm; - ResetForm = NULL; - - SetTableFocus(); +// ResetForm = new TResetForm(NULL); +// TPoint pt = TPoint( m_panTopBar->Left + m_btnReset->Left +// + (m_btnReset->Width - ResetForm->Width)/ 2 +// , m_panWeb->Top); +// pt = ClientToScreen(pt); +// ResetForm->Left = pt.x; +// ResetForm->Top = pt.y; +// +// ResetForm->ShowModal(); +// +// delete ResetForm; +// ResetForm = NULL; +// +// SetTableFocus(); } //--------------------------------------------------------------------------- diff --git a/RBmasterMain.h b/RBmasterMain.h index e465341..36512b8 100644 --- a/RBmasterMain.h +++ b/RBmasterMain.h @@ -144,7 +144,7 @@ private: // User declarations int m_iWindowState, m_nLeft, m_nTop, m_nWidth, m_nHeight; - TChromium *m_chrm; + TChromium *m_chrm; //平台无视窗浏览器 TStringList* m_v8Values; HANDLE m_hV8Sema;