//赌徒狂欢1.9
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include<windows.h> 
// 替换Windows特定功能
#ifdef _WIN32
    #include <windows.h>
#else
    // 提供Linux/macOS的替代实现
#endif


using namespace std;
namespace dj {
	bool axj(long long key) {
		return (GetKeyState(key) < 0) ? (true) : (false);
	}
	struct hl {
		long long h,l;
	};
	void de(int x) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
	}
	bool ax(long long key) {
		return (GetKeyState(key) < 0) ? (true) : (false);
	}
	hl wz(bool x = 1, bool n = 1) {
		HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
		HWND h = GetForegroundWindow();
		CONSOLE_FONT_INFO consoleCurrentFont;
		hl hl;
		POINT p;
		if (x) {
			GetCursorPos(&p);
			ScreenToClient(h, &p);
		} else {
			GetCursorPos(&p);
		}
		if (n) {
			GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
			p.x /= consoleCurrentFont.dwFontSize.X;
			p.y /= consoleCurrentFont.dwFontSize.Y;
		}
		hl.h = p.y + 1;
		hl.l = p.x + 1;
		return hl;
	}
	void ycbj() {
		HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
		DWORD mode;
		GetConsoleMode(hStdin, &mode);
		mode &= ~ENABLE_QUICK_EDIT_MODE;
		SetConsoleMode(hStdin, mode);
		return;
	}
	void ycgb() {
		CONSOLE_CURSOR_INFO cursor;
		cursor.bVisible = FALSE;
		cursor.dwSize = sizeof(cursor);
		HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorInfo(handle, &cursor);
		return;
	}
	inline void ydgb(long long h, long long l) {
		COORD pos = { l - 1,h - 1 };
		HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
		SetConsoleCursorPosition(hOut, pos);
		return;
	}
	bool pdbj(int y,int x,int x1,int x2,int ys,string zt) {
		ycgb();
		ycbj();
		hl z=wz(1,1);
		bool a=0;
		if(z.h==y&&z.l>=x1&&z.l<=x2) {
			ydgb(y,x);
			de(ys*16);
			cout<<zt;
			de(ys);
			if(axj(VK_LBUTTON)) {
				a=1;
			}
		} else {
			ydgb(y,x);
			de(ys);
			cout<<zt;
		}
		de(15);
		return a;
	}
};
using namespace dj;//一定要有
long long f=200;
int a,b,ans,k,x,water;
bool blog=1;
bool developerMode = false;  // 开发者模式开关
string devPassword = "9178mod";  // 开发者密码


void developerMenu() {
	system("cls");
	cout << "=== 开发者模式 ===" << endl;
	cout << "当前余额: " << f << endl;
	cout << "圣水数量: " << water << endl;
	cout << "开发者模式: " << (developerMode ? "开启" : "关闭") << endl;
	cout << "==================" << endl;
	while(1) {
		if(pdbj(6,1,1,20,10,"设置余额")) {
			system("cls");
			cout << "请输入新的余额: ";
			long long newBalance;
			cin >> newBalance;
			f = newBalance;
			cout << "余额已设置为: " << f << endl;
			Sleep(1000);
			system("cls");
			developerMenu();
			return;
		}

		if(pdbj(7,1,1,20,10,"添加圣水")) {
			water++;
			cout << "圣水+1,当前数量: " << water << endl;
			Sleep(1000);
			system("cls");
			developerMenu();
			return;
		}

		if(pdbj(8,1,1,20,10,"直接获胜")) {
			f = 100000000;
			cout << "已设置为亿万富翁!" << endl;
			Sleep(1000);
			system("cls");
			developerMenu();
			return;
		}

		if(pdbj(9,1,1,15,10,"返回主菜单")) {
			system("cls");
			return;
		}

		if(pdbj(10,1,1,20,10,"关闭开发者模式")) {
			developerMode = false;
			cout << "开发者模式已关闭" << endl;
			Sleep(1000);
			system("cls");
			return;
		}
	}
}


void gs(string x) {
	int a=x.size();
	for(int i=0; i<=a; ++i) {
		Sleep(100);
		cout<<x[i];
	}
}
void gg() {
	system("cls");
	for(int i=0; i<=20; i++) {
		//cout<<30-i<<"s";
		if(i==0) {
			gs("            Mod牌笔记");
			cout<<endl;
		}
		if(i==1) {
			gs("        学习好助手,你值得拥有");
			cout<<endl;
		}
		if(i==2) {
			gs("     __    ___________");
			cout<<endl;
		}
		if(i==3) {
			gs("     ||    |    M    |");
			cout<<endl;
		}
		if(i==4) {
			gs("     ||    |    o    |");
			cout<<endl;
		}
		if(i==5) {
			gs("     ||    |    d    |");
			cout<<endl;
		}
		if(i==6) {
			gs("     ||    |    牌   |");
			cout<<endl;
		}
		if(i==7) {
			gs("     ||    |    笔   |");
			cout<<endl;
		}
		if(i==8) {
			gs("     \\\b\\/    |    记   |");
			cout<<endl;
		}
		if(i==9) {
			gs("           |_________|");
			cout<<endl;
		}
		if(i==10) {
			cout<<endl;
		}
		if(i==11) {
			cout<<endl;
		}
		if(i==12) {
			cout<<endl;
		}
		if(i==13) {
			gs("如有需要,请拨打445-2753-1756。");
		}
		if(i>13) {
			Sleep(1000);
		}
		//system("cls");
	}
	cout<<"获得15块"<<endl;
	f+=15;
	Sleep(200);
	system("cls");
	return ;
}

void cp() {
	system("cls");
	f-=3;
	for(int i=1; i<=6; i++) {
		cout<<"0-30选一个数,作为你的彩票编码第"<<i<<"位"<<endl;
		cin>>a;
		b=rand()%30+1;//概率可调
		if(a==b)ans*=100;
		else {
			if(ans==1) {
				cout<<"你得到了0元"<<endl;
			} else {
				cout<<"你得到了"<<ans<<"元"<<endl;
				f+=ans;
			}
			Sleep(500);
			system("cls");
			break;
		}
	}
}

void tiger() {
	f-=15;
	ans=1;
	system("cls");
	cout<<"     点击抽奖"<<endl;
	while(!pdbj(2,7,1,16,11,"按下吧")) {
	}
	system("cls");
	int c,d,e;
	c=rand()%30+1;//概率可调
	d=rand()%30+1;//概率可调
	e=rand()%30+1;//概率可调
	cout<<endl;
	cout<<"|"<<c<<"|"<<d<<"|"<<e<<"|"<<endl;
	if(c==d) {
		ans*=10*e/2;
		if(d==e) {
			ans*=100*e;
			cout<<"大奖!";
			Sleep(500);
		}
	} else {
		if(d==e)ans*=e/2;
	}
	if(d==c+1&&e==d+1) {
		ans*=1000;
		cout<<"顺子";
	}
	if(d==c-1&&e==d-1) {
		ans*=900;
		cout<<"反顺子";
	}
	Sleep(500);
	if(ans==1) {
		cout<<"你得了0元"<<endl;
	} else {
		cout<<"你得了"<<ans<<"元"<<endl;
		f+=ans;
		ans=1;
	}
	Sleep(1000);
	system("cls");
}

void winer() {
	system("cls");
	f-=200;
	cout<<"你好,要点什么?"<<endl;
	cout<<"当前余额:"<<f<<endl;
	while(1) {
		if(pdbj(3,1,1,50,5,"黄金酒,500元,可以将购买后你的总额翻十倍;")) {
			system("cls");
			f-=500;
			f*=10;
			cout<<"金子!金子!";
			break;
		}
		if(pdbj(4,1,1,50,5,"生死酒,50%的概率死亡,50%的概率将总额翻10000倍")) {
			system("cls");
			int ed=rand()%2+1;
			if(ed==1) {
				if(water) {
					water-=1;
					cout<<"神明庇护了你";
					break;
				} else {
					cout<<"你死了"<<endl;
					cout<<"达成结局3:死亡";
					Sleep(1000);
					exit(0);
				}
			} else {
				cout<<"恭喜你,活下来了";
				f*=10000;
				Sleep(500);
				break;
			}
		}
		if(pdbj(5,1,1,50,5,"圣水,200元,可以免疫一次死亡;")) {
			system("cls");
			f-=200;
			water++;
			cout<<"神明会庇佑你";
			break;
		}
		if(pdbj(6,1,1,50,5,"可口可乐,50元,可以获得1-500元不等的人民币")) {
			system("cls");
			f-=50;
			int ed=rand()%500+1;
			cout<<"瓶盖上显示你得了"<<ed<<"元"<<endl;
			f+=ed;
			break;
		}
	}
	Sleep(1000);
	system("cls");
	return ;
}

void renlian() {
	cout<<"                         --------"<<endl;
	cout<<"                         (^-^)"<<endl;
	cout<<"                         \\\b\\/[  ]"<<endl;
	cout<<"============================================================"<<endl;
}

void lunpandu() {
    system("cls");
    renlian();
    gs("你好,我叫Bob,你也是来参加轮盘赌的吧");
    Sleep(1500);
    
    system("cls");
    renlian();
    gs("规则就是在你回合,可以选择用枪打谁");
    Sleep(1500);
    
    system("cls");
    renlian();
    gs("如果射向自己,并且是空弹,那么你可以在打一次");
    Sleep(1500);
    
    system("cls");
    renlian();
    gs("如果射向对手,那么无论是不是空弹,都将把回合给到我");
    Sleep(1500);
    
    system("cls");
    renlian();
    gs("那么,开始吧!");
    Sleep(1000);
    
    // 游戏初始化
    int bulletPosition = rand() % 6 + 1;  // 实弹位置
    int currentChamber = 1;  // 当前枪膛位置
    bool playerTurn = true;
    int playerBet = 100;  // 基础赌注
    
    f -= playerBet;  // 扣除入场费
    
    while(true) {
        system("cls");
        renlian();
        cout << "当前枪膛位置: " << currentChamber << "/6" << endl;
        cout << "你的回合" << endl;
        cout << "赌注: " << playerBet << "元" << endl;
        cout << "========================" << endl;
        
        if(playerTurn) {
            // 玩家回合
            if(pdbj(3,1,1,15,10,"射击自己")) {
                if(currentChamber == bulletPosition) {
                    // 中弹
                    if(water > 0) {
                        water--;
                        cout << "圣水救了你一命!" << endl;
                        bulletPosition = rand() % 6 + 1;  // 重新装弹
                        currentChamber = 1;
                        Sleep(1500);
                    } else {
                        cout << "砰!你中弹了..." << endl;
                        cout << "游戏结束" << endl;
                        Sleep(2000);
                        exit(0);
                    }
                } else {
                    // 空弹,继续回合
                    cout << "咔哒...空弹,继续你的回合" << endl;
                    Sleep(1500);
                    continue;
                }
            }
            
            if(pdbj(4,1,1,15,10,"射击Bob")) {
                if(currentChamber == bulletPosition) {
                    // Bob中弹,玩家获胜
                    cout << "砰!Bob中弹了!" << endl;
                    cout << "你赢得了 " << playerBet * 3 << " 元!" << endl;
                    f += playerBet * 3;
                    Sleep(2000);
                    return;
                } else {
                    // 空弹,轮到Bob
                    cout << "咔哒...空弹,轮到Bob了" << endl;
                    playerTurn = false;
                    Sleep(1500);
                }
            }
            
            // 转动枪膛
            currentChamber = (currentChamber % 6) + 1;
            
        } else {
            // Bob的AI回合
            cout << "Bob的回合..." << endl;
            Sleep(1000);
            
            // Bob的简单AI:70%概率射击玩家,30%概率射击自己
            int bobChoice = rand() % 100;
            
            if(bobChoice < 70) {
                // Bob射击玩家
                cout << "Bob选择射击你..." << endl;
                Sleep(1000);
                
                if(currentChamber == bulletPosition) {
                    // 玩家中弹
                    cout << "砰!你被Bob击中了..." << endl;
                    cout << "游戏结束" << endl;
                    Sleep(2000);
                    return;
            } else {
                // Bob射击自己
                cout << "Bob选择射击自己..." << endl;
                Sleep(1000);
                
                if(currentChamber == bulletPosition) {
                    // Bob中弹,玩家获胜
                    cout << "Bob中弹了!" << endl;
                    cout << "你赢得了 " << playerBet * 3 << " 元!" << endl;
                    f += playerBet * 3;
                    Sleep(2000);
                    return;
                } else {
                    // 空弹,Bob继续
                    cout << "咔哒...空弹,Bob继续" << endl;
                    Sleep(1500);
                }
            }
            
            // 转动枪膛
            currentChamber = (currentChamber % 6) + 1;
            playerTurn = true;  // 回到玩家回合
        }
    }
}
}
void renlian_buxie(){
	cout<<"                         IIIIIIII"<<endl;
	cout<<"                         ( ̄へ ̄)"<<endl;
	cout<<"                        __/[  ]"<<endl;
	cout<<"============================================================"<<endl;
}

void pokerbig() {
    srand(time(0));
    int betAmount = 100;  // 基础赌注
    f -= betAmount;
    
    // 初始化玩家和庄家的牌
    int playerCard1 = rand() % 13 + 1;  // 1-13代表A-K
    int playerCard2 = rand() % 13 + 1;
    int dealerCard1 = rand() % 13 + 1;
    int dealerCard2 = rand() % 13 + 1;
    
    string cardNames[] = {"", "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
    
    system("cls");
    renlian_buxie();
    gs("恭喜你来到扑克牌比大小游戏");
    Sleep(1000);
    
    system("cls");
    renlian_buxie();
    gs("规则:比较双方两张牌的点数和,A为1点,JQK为10点");
    Sleep(1500);
    while(true) {
        system("cls");
        renlian_buxie();
        cout << "你的牌: " << cardNames[playerCard1] << " 和 " << cardNames[playerCard2] << endl;
        cout << "当前赌注: " << betAmount << "元" << endl;
        cout << "==========================" << endl;
        
        // 计算点数(J、Q、K算10点)
        int playerPoints = (playerCard1 > 10 ? 10 : playerCard1) + (playerCard2 > 10 ? 10 : playerCard2);
        int dealerPoints = (dealerCard1 > 10 ? 10 : dealerCard1) + (dealerCard2 > 10 ? 10 : dealerCard2);
        cout << "选择比大还是比小:" << endl;
        while(1){
        if(pdbj(10,1,1,15,10,"比大")) {
            // 比大模
            system("cls");
            if(playerPoints > dealerPoints) {
                cout << "你赢了!点数:" << playerPoints << " vs " << dealerPoints << endl;
                f += betAmount * 2;
                cout << "获得 " << betAmount * 2 << " 元!" << endl;
            } else if(playerPoints < dealerPoints) {
                cout << "你输了!点数:" << playerCard1 << " vs " << dealerCard1 << endl;
            } else {
                cout << "平局!点数都是:" << playerPoints << endl;
                f += betAmount;  // 返还赌注
            }
            Sleep(2000);
            return;
        }
        
        if(pdbj(11,1,1,15,10,"比小")) {
            // 比小模式
            system("cls");
            if(playerPoints < dealerPoints) {
                cout << "你赢了!点数:" << playerPoints << " vs " << dealerPoints << endl;
                f += betAmount * 2;
                cout << "获得 " << betAmount * 2 << " 元!" << endl;
            } else if(playerPoints > dealerPoints) {
                cout << "你输了!点数:" << playerPoints << " vs " << dealerPoints << endl;
            } else {
                cout << "平局!点数都是:" << playerPoints << endl;
                f += betAmount;  // 返还赌注
            }
            Sleep(2000);
            return;
        }
        
        if(pdbj(12,1,1,15,10,"退出游戏")) {
            f += betAmount;  // 返还赌注
            return;
        }	
		} 
        
    }
}


void shezhi() {
	system("cls");
	Sleep(100);
	while(1) {
		if(pdbj(1,1,1,8,7,"关于游戏")) {
			Sleep(100);
			system("cls");
			gs("本游戏由Mod笔谈出品");
			cout<<endl;
			gs("      参与者");
			cout<<endl;
			gs("  技术扶持:林培奇");
			cout<<endl;
			gs("  技术扶持:黄嘉赢");
			cout<<endl;
			gs("  界面设计:莫晗");
			cout<<endl;
			gs("  技术实现:莫晗");
			cout<<endl;
			gs("  灵感来源:G币人生");
			cout<<endl;
			gs("https://www.bcoi.cn/d/gfhd/blog/252/");
			cout<<endl;
			gs("  灵感来源2:赌神模拟器");
			cout<<endl;
			gs("https://www.bcoi.cn/d/gfhd/blog/507/68cdf84a445b45c7920cde55#1758328906825");
			cout<<endl;
			gs("  出版:Mod笔谈");
			cout<<endl;
			gs("正版渠道:https://www.bcoi.cn/blog/246/68b67a8535f6ac3821de3868#1756789381892");
			Sleep(3000);
			system("cls");
			continue;
		}
		if(pdbj(2,1,1,6,7,"版本号")) {
			Sleep(100);
			system("cls");
			cout<<"版本:赌徒狂欢1.0.9"<<endl;
			Sleep(5000);
			if(blog) {
				cout<<"余额+200元";
				f+=200;
				blog=0;
			}
			system("cls");
			continue;
		}
		if(pdbj(3,1,1,8,7,"退出")) {
			Sleep(100);
			system("cls");
			return ;
		}
		if(pdbj(4,1,1,1,7,"")) {
			Sleep(100);
			system("cls");
			if(!developerMode) {
				cout << "请输入开发者密码: ";
				string inputPwd;
				cin >> inputPwd;
				if(inputPwd == devPassword) {
					developerMode = true;
					cout << "开发者模式已开启!" << endl;
				} else {
					cout << "密码错误!" << endl;
				}
			} else {
				system("cls");
				developerMenu();
			}
			Sleep(1000);
			system("cls");
			continue;
		}
	}
}

int main() {
	srand(time(0));
	int zslsd=1;
	while(1) {
		ydgb(1,1);
		if(zslsd==1) {
			gs("欢迎来到赌徒狂欢");
			cout<<endl;
			gs("初始金额200元");
			cout<<endl;
			gs("无尽模式开启啦");
			cout<<endl;
		}
		if(pdbj(4,1,1,8,7,"算鸟算鸟")) {
			Sleep(100);
			system("cls");
			Sleep(100);
			while(f>0) {
				if(f>=100000000) {
					cout<<"恭喜你通关本游戏"<<endl;
					cout<<"感谢游玩"<<endl;
					cout<<"达成结局1:亿万富翁";
					Sleep(1000);
					exit(0);
				}

				if(pdbj(1,1,1,16,7,"3元一次的彩票")) {
					system("cls");
					Sleep(500);
					cp();
				}
				if(pdbj(2,1,1,6,7,"看广告")) {
					system("cls");
					Sleep(500);
					gg();
				}
				if(pdbj(3,1,1,20,7,"15元一次,玩老虎机")) {
					system("cls");
					Sleep(500);
					tiger();
				}
				if(pdbj(4,1,1,20,7,"200元,进入酒吧")) {
					system("cls");
					Sleep(500);
					winer();
					system("cls");
				}
				if(pdbj(5,1,1,4,7,"设置")) {
					shezhi();
					Sleep(500);
					system("cls");
				}
				if(pdbj(6,1,1,22,7,"紧张刺激的俄罗斯轮盘赌")) {
					system("cls");
					Sleep(500);
					lunpandu();
				}
				if(pdbj(7,1,1,12,8,"扑克比大小")) {
					system("cls");
					Sleep(500);
					pokerbig();
				}
				cout<<endl;
				cout<<"存款:"<<f<<endl;
			}
			cout<<"你破产了,记得下载反诈APP"<<endl;
			cout<<"达成结局2:破产";
			return 0;
		}
		if(pdbj(5,1,1,8,7,"游玩一下")) {
			system("cls");
			Sleep(100);
			while(f>0) {
				if(pdbj(1,1,1,16,7,"3元一次的彩票")) {
					system("cls");
					Sleep(500);
					cp();
				}
				if(pdbj(2,1,1,6,7,"看广告")) {
					system("cls");
					Sleep(500);
					gg();
				}
				if(pdbj(3,1,1,20,7,"15元一次,玩老虎机")) {
					system("cls");
					Sleep(500);
					tiger();
				}
				if(pdbj(4,1,1,20,7,"200元,进入酒吧")) {
					system("cls");
					Sleep(500);
					winer();
					system("cls");
				}
				if(pdbj(5,1,1,4,7,"设置")) {
					shezhi();
					Sleep(500);
					system("cls");
				}
				if(pdbj(6,1,1,22,7,"紧张刺激的俄罗斯轮盘赌")) {
					system("cls");
					Sleep(500);
					lunpandu();
				}
				if(pdbj(7,1,1,12,8,"扑克比大小")) {
					system("cls");
					Sleep(500);
					pokerbig();
				}
				cout<<endl;
				cout<<"存款:"<<f<<endl;
			}
			cout<<"你破产了,记得下载反诈APP"<<endl;
			cout<<"达成结局2:破产";
			return 0;
		}
		zslsd=2;
	}
}