重生赚钱模拟器
The_Que
·
·
闲话
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
int outpause=30;
void O(string s){
for(int i=0;i<s.length();i++){
cout << s[i];
Sleep(outpause);
}
}
void beg(int &money,int* is,int &dead,int &hun,double &hate){
system("cls");
int rd=rand()%100;
if(rd<=hate){
O("有一人看你不顺眼,用长矛把你刺死了。\n");
dead=1;
}else if(rd<=40){
O("你奋力乞讨,却什么也没得到。\n");
hate=min(hate-0.01,0.0);
}else if(rd<=80){
O("你乞讨得到了食物。\n");
if(!is[0]) is[0]=1;
int ra=rand()%50+20;
hun=min(hun+ra,200);
hate+=0.05;
}else{
if(!is[0]) is[0]=1;
if(!is[1]) is[1]=1,O("你乞讨得到了一种叫“钱”的东西。\n");
O("你乞讨获得一些钱和食物。\n");
int ra=rand()%80+30,rb=rand()%10+5;
hun=min(hun+ra,200);
money+=rb;
hate+=0.2;
}
return;
}
int market(int &money,int *is,int &hun,int *buy,int *buff){
system("cls");
while(1){
O("你来到了市场。\n");
O("1.离开\n");
O("2.购买食物\n");
if(is[3]) O("3.购买彩票\n");
if(is[4]) O("4.黑市\n");
while(1){
char ch=getch();
if(ch=='2'){
O("你要花多少$购买食物?1$=5食物");
string s;
while(1){
getline(cin,s);
int num=0;
if(s.length()<9){
for(int i=0;i<s.length();i++){
if(s[i]>='0'&&s[i]<='9') num=num*10+(s[i]-'0');
else num=-1;
}
if(num>0){
if(money<num) O("$不够。\n");
else{
money-=num;
hun=min(hun+num*5,200);
break;
}
}
}
}
break;
}else if(ch=='3'&&is[3]){
if(money<20){
O("你发现钱不够了!\n");
}else{
O("你花了20$买彩票...\n");
Sleep(500);
money-=20;
int ra=rand()%10000;
if(ra>=9999) O("恭喜你,中大奖了!1000$\n"),money+=1000;
else if(ra>=9900){
int rb=rand()%3*100+100;
O("恭喜你,中了"),cout<<rb,O("$\n"),money+=rb;
}else if(ra>=7000){
int rb=rand()%5*5+20;
O("你中了"),cout<<rb,O("$\n"),money+=rb;
}else if(ra>=3000){
int rb=rand()%5*3+5;
O("你中了"),cout<<rb,O("$\n"),money+=rb;
}else{
O("你什么也没中。\n");
}
}
Sleep(500);
system("pause");
break;
}else if(ch=='1'){
system("cls");
return 0;
}else if(ch=='4'&&is[4]){
system("cls");
while(1){
O("商品:\n1.扒手工具[使你偷窃成功概率+10%]100$(限买"),cout<<buy[0],O("/3)\n");
O("2.皮靴[使你偷窃失败逃跑概率+25%]300$(限买"),cout<<buy[1],O("/1)\n");
char c=getch();
if(c=='1'){
if(money<100) O("你发现钱不够了!\n");
else if(buy[0]>=3) O("数量达到上限了!\n");
else{
buy[0]++;
money-=100;
O("购买成功!");
buff[0]+=10;
if(!is[5]) is[5]=1,O("解锁小偷散职");
O("\n");
}
break;
}else if(c=='2'){
if(money<300) O("你发现钱不够了!\n");
else if(buy[1]>=1) O("数量达到上限了!\n");
else{
buy[1]++;
money-=300;
O("购买成功!");
buff[1]+=25;
if(!is[5]) is[5]=1,O("解锁小偷散职");
O("\n");
}
break;
}
}
system("pause");
system("cls");
break;
}
}
system("cls");
}
return 1;
}
void theft(int &money,int *buff,int &dead,double &hate){
system("cls");
int ra=rand()%100;
if(ra<=20-buff[1]/10){
O("你四处望去,却空无一人。\n");
}else{
int rb=rand()%100;
if(rb<=buff[0]){
int rc=rand()%(2*buff[1])+buff[1];
O("偷窃成功,获得"),cout<<rc,O("$\n");
}else{
int rc=rand()%100;
if(rc<=buff[1]){
O("偷窃失败,但你逃跑了\n");
hate+=0.5;
}else if(rc>100-hate){
O("偷窃失败,你尝试逃跑,被当场刺杀。\n"),dead=1;
}else{
O("偷窃失败,你侥幸逃跑了\n");
hate+=1.0;
}
}
}
}
void main_1(){
system("cls");
int ti=1,hger=100,money=0,dead=0;
double hate=0;
int is[105]={0},buy[105]={0};
//buy买的数量,0.扒手1.靴子
//is解锁进度,0.食物1.钱2.市场3.彩票4.黑市5.小偷
int buff[105]={50,40};
while(1){
O("第"),cout<<ti,O("天");
if(is[0]) O("|饥饿值:"),cout<<hger;
if(is[1]) O("|$:"),cout<<money;
cout<<"\n";
O("你要做什么?\n");
O("0.什么也不干\n");
O("1.乞讨\n");
if(is[2]) O("2.去市场\n");
if(is[5]) O("3.偷窃\n");
char ch;
while(1){
ch=getch();
if(ch=='0'){
break;
}else if(ch=='1'){
beg(money,is,dead,hger,hate);
break;
}else if(ch=='2'&&is[2]){
int iss=market(money,is,hger,buy,buff);
if(iss){
break;
}
}else if(ch=='3'&&is[5]){
theft(money,buff,dead,hate);
break;
}
system("cls");
O("第"),cout<<ti,O("天");
if(is[0]) O("|饥饿值:"),cout<<hger;
if(is[1]) O("|$:"),cout<<money;
O("你要做什么?\n");
O("0.什么也不干\n");
O("1.乞讨\n");
if(is[2]) O("2.去市场\n");
if(is[5]) O("3.偷窃\n");
}
system("pause");
if(dead) return;
system("cls");
ti++;
hger-=20;
if(hger<=50&&is[0]==0) O("黄昏了,你感到饥饿。\n"),is[0]=1;
if(money>=10&&is[2]==0) O("你路过了一个市场。\n"),is[2]=1;
if(money>=20&&is[3]==0) O("在市场上,你看到了一种叫“彩票”的东西,那玩意居然卖20$!\n"),is[3]=1;
if(money>=100&&is[3]&&is[4]==0) O("在市场上,你看到了一家奇怪的食物店,当你拿出足\n够多的$时,它竟然问你“干小偷这一行吗?”\n"),is[4]=1;
if(hger<=0){
O("你在饥饿中死去了。\n");
return;
}
system("pause");
system("cls");
}
}
void shezhi(){
while(1){
system("cls");
cout<<"打字间隔:"<<outpause<<"\n";
cout<<"按【1】减小|按【2】增大|按【3】退出\n";
char ch=getch();
if(ch=='1'){
outpause=max(5,outpause-5);
}else if(ch=='2'){
outpause=min(100,outpause+5);
}else if(ch=='3'){
break;
}
}
system("cls");
}
signed main() {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SMALL_RECT windowSize = {0, 0, 45, 9};
SetConsoleWindowInfo(hConsole, TRUE, &windowSize);
SetWindowLongPtrA(GetConsoleWindow(), GWL_STYLE, GetWindowLongPtrA(GetConsoleWindow(),GWL_STYLE)& ~WS_SIZEBOX & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX);
srand(time(0));
while(1){
O("------【重生赚钱模拟器】------\n");
O("这穷苦人生一点都不想呆了!\n");
O("开始游戏?\n");
system("pause");
system("cls");
O("选择模式:\n");
O("1.【中世纪时期】普通模式\n");
O("请做出你的选择!\n");
O("【按o打开设置】\n");
while(1){
char ch=getch();
if(ch=='1'){
main_1();
break;
}else if(ch=='o'){
shezhi();
break;
}
}
system("cls");
}
return 0;
}