- gf24153 的博客
《工作模拟器内测服》
- @ 2025-12-10 13:52:12
-O2 -lm -std=c++14
使用前加入编译环境
#include <bits/stdc++.h>//工作模拟器
#include <windows.h>
#include <string>
#define ll long long
using namespace std;
char dt[16][40]= {
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','+','+',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S',' ','+','+',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#',' ',' ','M','M',' ',' ','B','B',' ',' ','P','P',' ',' ','S',' ','+','+',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','=',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','J',' ',' ','T','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C',' ',' ','T','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','G','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'}
};
int xueli_value = 0;
int xueli_level = 0;
int kecheng[7] = {0};
bool has_student_card = false;
int library_bonus = 0;
int tired_max=100;
int car_owned = 0;
bool car_unlocked[4] = {1, 0, 0, 0};
int car_price[4] = {0, 800, 2000, 5000};
string car_names[4] = {"徒步", "千里马", "牛车", "马车"};
int car_cd_table[4] = {10, 3, 6, 1};
int current_cargo = 0;
int max_cargo_limit = 0;
bool has_cargo_task = false;
int cargo_limits[4] = {0, 100, 1000, 800};
bool has_passenger = false;
int passenger_start_x = 0;
int passenger_start_y = 0;
int passenger_end_x = 0;
int passenger_end_y = 0;
int fare_earned = 0;
int loan_amount = 0;
int total_loan_debt = 0;
int sack_count = 0;
int dry_food_count = 0;
int coffee_count = 0;
bool sack_effect_active = false;
namespace gongjv {
inline void cd(int x) {
Sleep(x);
system("cls");
}
void ggb() {
HWND hwnd = GetConsoleWindow();
LONG style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME);
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}
bool SetWindowTopMost(HWND hWnd, bool topmost, bool noActivate = true) {
if (!IsWindow(hWnd)) return false;
UINT flags = SWP_NOMOVE | SWP_NOSIZE;
if (noActivate) flags |= SWP_NOACTIVATE; // 关键:置顶但不抢焦点
return SetWindowPos(hWnd,
topmost ? HWND_TOPMOST : HWND_NOTOPMOST,
0, 0, 0, 0,
flags);
}
bool axj(long long key) {
return (GetKeyState(key) < 0) ? (true) : (false);
}
struct hl {
long long h,l;
};
inline void de(int x) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
}
int djde1(int x) {
int y=0;
switch(x) {
case 1:
y=7;
break;
case 2:
y=15;
break;
case 3:
y=2;
break;
case 4:
y=10;
break;
case 5:
y=3;
break;
case 6:
y=11;
break;
case 7:
y=9;
break;
case 8:
y=14;
break;
case 9:
y=12;
break;
}
return y;
}
void pzde2(int x) {
int y=0;
switch(x) {
case 1:
y=15;
break;
case 2:
y=10;
break;
case 3:
y=11;
break;
case 4:
y=14;
break;
case 5:
y=4;
break;
}
de(y);
}
int pzde1(int x) {
int y=0;
switch(x) {
case 1:
y=15;
break;
case 2:
y=10;
break;
case 3:
y=11;
break;
case 4:
y=14;
break;
case 5:
y=4;
break;
}
return y;
}
void djde2(int x) {
int y=0;
switch(x) {
case 1:
y=7;
break;
case 2:
y=15;
break;
case 3:
y=2;
break;
case 4:
y=10;
break;
case 5:
y=3;
break;
case 6:
y=11;
break;
case 7:
y=9;
break;
case 8:
y=14;
break;
case 9:
y=12;
break;
}
de(y);
}
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;
}
hl GetActiveWindowSize() {
HWND hwnd = GetForegroundWindow();
RECT rect;
if (GetClientRect(hwnd, &rect)) {
int clientWidth = rect.right - rect.left;
int clientHeight = rect.bottom - rect.top;
hl sas= {clientWidth /8,clientHeight /16};
return sas;
}
}
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) {
h-=1;
l-=1;
COORD pos = { (short)l,(short)h };
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
return;
}
inline void ydgb_zj_sc(int x,string zt) {
ll s1=GetActiveWindowSize().h/2;
ll s2=zt.size()/2;
ydgb(x,s1-s2);
cout<<zt;
}
inline void ydgb_zj(int x,string zt) {
ll s1=GetActiveWindowSize().h/2;
ll s2=zt.size()/2;
ydgb(x,s1-s2);
}
inline void ydgb_zj(int x,int zt) {
ll s1=GetActiveWindowSize().h/2;
ll s2=zt/2;
ydgb(x,s1-s2);
}
inline hl ydgb_zj_hl(string zt) {
ll s1=GetActiveWindowSize().h/2;
ll s2=zt.size()/2;
hl z= {s1-s2,s1+s2};
return z;
}
inline 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;
}
inline bool pddj_zj(int h,int ys,string zt) {
int s1=GetActiveWindowSize().h/2;
int s2=zt.size()/2;
if(pdbj(h,s1-s2,s1-s2,s2+s1,ys,zt)) {
return 1;
} else {
return 0;
}
}
inline bool pddj_zj_kh(int h,int ys,string zt,string z1="",string z2="") {
int s1=GetActiveWindowSize().h/2;
int s2=zt.size()/2;
ydgb(h,s1-s2-z1.size()-1);
cout<<z1<<"[";
ydgb(h,s1+s2);
cout<<"]"<<z2;
if(pdbj(h,s1-s2,s1-s2,s2+s1,ys,zt)) {
return 1;
} else {
return 0;
}
}
inline bool pddj_kh(int h,int x,int ys,string zt,string z1="",string z2="") {
int s2=zt.size();
ydgb(h,x);
cout<<z1<<"[";
ydgb(h,x+z1.size()+s2+1);
cout<<"]"<<z2;
if(pdbj(h,x+z1.size()+1,x+z1.size()+1,s2+x+z1.size(),ys,zt)) {
return 1;
} else {
return 0;
}
}
inline string wjcc(string x, string y) {
std::string full_path = x + "\\" + y;
// 只创建目录,不创建文件
std::string command = "if not exist " + x + " mkdir " + x;
int ret = system(command.c_str());
return full_path;
}
inline string in_str(ll x) {
string y="";
const string z[]= {"0","1","2","3","4","5","6","7","8","9"};
while(x) {
y+=z[x%10];
x/=10;
}
reverse(y.begin(),y.end());
return y;
}
};
using namespace gongjv;
int wzx=5,wzy=2,money=2000,tired=50,health=100,shang1=1,kuan1=1,shang2=20,kuan2=8,scsuo=0;
void gongdi() {
cout<<" "<<"一片工地,好像是某户人家要建造房屋?";
cout<<" 是否上工?";
while(1) {
if(pdbj(3,20,20,20,7,"是")) {
break;
}
if(pdbj(4,20,20,20,7,"否")) {
return;
}
}
system("cls");
int zhuanshu=0;
int wzx_gong=1,wzy_gong=2;
char gdt[8][10]= {
{'#',' ',' ',' ',' ','e',' ',' ',' ','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#',' ',' ',' ',' ',' ',' ',' ','d',' '},
{'#',' ',' ',' ',' ',' ',' ',' ','d',' '},
{'#',' ',' ',' ',' ',' ',' ',' ','d',' '},
{'#',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#','s',' ',' ',' ',' ',' ',' ',' ','#'},
{'#','#','#','#','#','#','#','#','#','#'},
};
ggb();
ycgb();
bool f=0;
ycbj();
int yd=0;
for(int hu=1; 1; ++hu) {
if(yd) {
if(hu%10==0)yd=0;
}
ydgb(1,1);
for(int i=0; i<8; i++) {
ydgb(i+1,1);
for(int j=0; j<10; j++) {
if(i==wzx_gong&&j==wzy_gong) {
cout<<"I";
if(gdt[i][j]=='d') {
system("cls");
return ;
system("cls");
}
if(gdt[i][j]=='s') {
if(zhuanshu<9) {
zhuanshu+=1;
Sleep(100);
} else {
f=1;
}
}
if(gdt[i][j]=='e') {
money+=zhuanshu;
tired-=zhuanshu;
zhuanshu=0;
f=0;
}
} else {
cout<<gdt[i][j];
}
}
if(i==0) {
cout<<" d:门口,会离开工地";
}
if(i==1) {
cout<<" s:取砖处 当前砖数:"<<zhuanshu;
}
if(i==2) {
cout<<" e:放砖处 已拥有金额:"<<money;
}
}
cout<<endl;
if(f) {
cout<<"已经到达最大限度";
} else {
if(gdt[wzx_gong][wzy_gong]=='e') {
system("cls");
wzx_gong=1;
wzy_gong=5;
}
}
if(tired<=0) {
system("cls");
cout<<"你因过度劳累,被工友抬出了施工现场,请及时吃饭哦";
Sleep(500);
return ;
}
if(health<=0) {
system("cls");
cout<<"你在工地咳得很厉害,工友让你赶紧去买点药";
cd(500);
return ;
}
if(axj('W')&&!yd) {
ydgb(wzx_gong+1,wzy_gong+1);
cout<<" ";
if(wzx_gong>0)wzx_gong-=1;
hu=1;
yd=1;
}
if(axj('S')&&!yd) {
ydgb(wzx_gong+1,wzy_gong+1);
cout<<" ";
if(wzx_gong<6)wzx_gong+=1;
hu=1;
yd=1;
}
if(axj('A')&&!yd) {
ydgb(wzx_gong+1,wzy_gong+1);
cout<<" ";
if(wzy_gong>1)wzy_gong-=1;
hu=1;
yd=1;
}
if(axj('D')&&!yd) {
ydgb(wzx_gong+1,wzy_gong+1);
cout<<" ";
if(wzy_gong<8)wzy_gong+=1;
hu=1;
yd=1;
}
Sleep(1);
}
}
void shop() {
system("cls");
cout << "===== 商铺 ====" << endl;
cout << "当前余额: " << money << " 元" << endl << endl;
while(1) {
if(pddj_zj(3, 7, "麻袋 - 300元 (下一次载货必定装满当前车辆最大承重的800斤以上)")) {
if(money >= 300) {
money -= 300;
sack_count += 1;
system("cls");
cout << "购买成功!获得1个麻袋,当前麻袋库存: " << sack_count << endl;
Sleep(1500);
system("cls");
return;
} else {
system("cls");
cout << "余额不足!购买麻袋需要300元" << endl;
Sleep(1500);
system("cls");
}
}
if(pddj_zj(4, 7, "干粮 - 50元 (随时随地恢复40点饱食度)")) {
if(money >= 50) {
money -= 50;
dry_food_count += 1;
system("cls");
cout << "购买成功!获得1份干粮,当前干粮库存: " << dry_food_count << endl;
Sleep(1500);
system("cls");
return;
} else {
system("cls");
cout << "余额不足!购买干粮需要50元" << endl;
Sleep(1500);
system("cls");
}
}
if(pddj_zj(5, 7, "速溶咖啡 - 80元 (随时随地恢复30点健康值)")) {
if(money >= 80) {
money -= 80;
coffee_count += 1;
system("cls");
cout << "购买成功!获得1盒速溶咖啡,当前速溶咖啡库存: " << coffee_count << endl;
Sleep(1500);
system("cls");
return;
} else {
system("cls");
cout << "余额不足!购买速溶咖啡需要80元" << endl;
Sleep(1500);
system("cls");
}
}
if(pddj_zj(6, 7, "离开杂货铺")) {
system("cls");
return;
}
}
}
void backpack() {
system("cls");
cout << "===== 我的背包 ====" << endl;
cout << "当前饱食度: " << tired << "/" << tired_max << endl;
cout << "当前健康值: " << health << "/100" << endl << endl;
cout << "当前道具库存:" << endl;
// 仅当库存大于0时才显示对应道具
if(sack_count > 0) {
cout << "麻袋: " << sack_count << " 个" << endl;
}
if(dry_food_count > 0) {
cout << "干粮: " << dry_food_count << " 份" << endl;
}
if(coffee_count > 0) {
cout << "速溶咖啡: " << coffee_count << " 盒" << endl;
}
// 完全没有任何道具时给提示
if(sack_count == 0 && dry_food_count == 0 && coffee_count == 0) {
cout << "背包空空如也,还没有任何道具哦~" << endl;
}
cout << endl;
while(1) {
// 仅当存在对应道具时才展示使用按钮,避免点击后提示无道具
int current_line = 8;
bool has_available_item = false;
if(sack_count > 0) {
has_available_item = true;
if(pddj_zj(current_line, 7, "使用麻袋")) {
sack_count -= 1;
sack_effect_active = true;
system("cls");
cout << "已使用麻袋!下一次前往货运点装货时,货物将直接装满当前座驾的最大承重!" << endl;
Sleep(1500);
system("cls");
return;
}
current_line++;
}
if(dry_food_count > 0) {
has_available_item = true;
if(pddj_zj(current_line, 7, "使用干粮")) {
dry_food_count -= 1;
tired = min(tired_max, tired + 40);
system("cls");
cout << "使用干粮成功!饱食度恢复40点,当前饱食度: " << tired << "/" << tired_max << endl;
Sleep(1500);
system("cls");
return;
}
current_line++;
}
if(coffee_count > 0) {
has_available_item = true;
if(pddj_zj(current_line, 7, "使用速溶咖啡")) {
coffee_count -= 1;
health = min(100, health + 30);
system("cls");
cout << "使用速溶咖啡成功!健康值恢复30点,当前健康值: " << health << "/100" << endl;
Sleep(1500);
system("cls");
return;
}
current_line++;
}
if(pddj_zj(current_line, 7, "关闭背包")) {
system("cls");
return;
}
}
}
void menu(int f) {
if(f==1) {
if(tired>tired_max-5) {
cout<<"你确定你吃的下?";
Sleep(500);
return;
}
cout<<"欢迎光临";
Sleep(1000);
system("cls");
cout<<" 菜单";
while(1) {
if(pddj_zj(2,7,"1. 清灼时蔬, 15元 (+20体力, +40健康)" )) {
tired+=20;
health+=40;
money-=15;
if(tired>tired_max) {
tired=tired_max;
}
break;
}
if(pddj_zj(3,7,"2. 香辣土豆丝, 20元 (+40体力, +5健康)" )) {
tired+=40;
health+=5;
money-=20;
int md=rand()%100+1;
cd(1000);
if(md<40) {
cout<<"作者看到你吃了他兄弟,非常生气,揍了你一顿!";
cd(1000);
health-=40;
}
if(tired>tired_max) {
tired=tired_max;
}
break;
}
if(pddj_zj(4,7,"3. 红烧肉, 50元 (+60体力, +10健康)" )) {
tired+=60;
health+=10;
money-=50;
int md=rand()%100+1;
cd(1000);
if(md<15) { // 15%概率吃坏肚子
cout<<"红烧肉太油腻,你吃坏肚子了!";
cd(1000);
health-=20;
tired-=10;
}
if(tired>tired_max) {
tired=tired_max;
}
break;
}
if(pddj_zj(5,7,"4. 海鲜炒饭, 35元 (+40体力, +20健康)" )) {
tired+=50;
health+=20;
money-=35;
int md=rand()%100+1;
cd(1000);
if(md<10) { // 10%概率海鲜过敏
cout<<"你对海鲜过敏,浑身起疹子!";
cd(1000);
health-=30;
}
if(tired>tired_max) {
tired=tired_max;
}
break;
}
if(pddj_zj(6,7,"5. 营养套餐, 80元 (+50体力, +50健康)" )) {
tired+=80;
health+=50;
money-=80;
cd(1000);
if(tired>tired_max) {
tired=tired_max;
}
break;
}
if(pddj_zj(7,7,"6.可口可乐, 5元 (+15体力, -5健康)" )) {
tired+=15;
health-=5;
money-=5;
cd(1000);
if(tired>tired_max) {
tired=tired_max;
}
break;
}
if(pddj_zj(8,7,"7. 豪华大餐, 150元 (+100体力, +80健康)" )) {
if(money < 150) {
cout<<"钱不够吃豪华大餐!";
cd(1000);
continue;
}
tired+=100;
tired = 100; // 体力上限100
health+=80;
health = 100; // 健康上限100
money-=150;
cout<<"享用豪华大餐,状态全满!";
cd(1000);
if(tired>tired_max) {
tired=tired_max;
}
break;
}
// === 新增食物选项结束 ===
if(pddj_zj(9,7,"8. 离开餐馆" )) {
break;
}
}
system("cls");
// 显示用餐后的状态
cout<<"用餐完毕!当前状态:"<<endl;
cout<<"体力: "<<tired<<"/"<<tired_max<<endl;
cout<<"健康: "<<health<<"/100"<<endl;
cout<<"余额: "<<money<<"元"<<endl;
Sleep(1500);
system("cls");
} else if(f==2) {
cd(500);
while(1) {
// 原有药物
if(pddj_zj(1,7,"1. 藿香正气水,20元一瓶 (+50健康)")) {
if(money < 20) {
system("cls");
cout<<"余额不足!";
cd(800);
continue;
}
health = min(100, health + 50); // 确保不超过100
money -= 20;
cd(800);
break;
}
if(pddj_zj(2,7,"2. 止咳药,10元一瓶 (+30健康)")) {
if(money < 10) {
system("cls");
cout<<"余额不足!";
cd(800);
continue;
}
health = min(100, health + 30);
money -= 10;
cd(800);
break;
}
// === 新增药物选项开始 ===
if(pddj_zj(3,7,"3. 强效恢复剂,50元 (健康回满,消耗体力)")) {
if(money < 50) {
system("cls");
cout<<"余额不足!";
cd(800);
continue;
}
if(health >= 100) {
system("cls");
cout<<"你的健康已经是满的,不需要这个。";
cd(800);
continue;
}
// 计算恢复量并扣除相应体力
int heal_amount = 100 - health;
int stamina_cost = heal_amount / 2; // 每恢复2点健康扣1点体力
if(tired < stamina_cost) {
system("cls");
cout<<"体力不足,无法承受药效!";
cd(800);
continue;
}
health = 100;
tired -= stamina_cost;
money -= 50;
system("cls");
cout<<"使用了强效恢复剂!健康已回满。"<<endl;
cout<<"因药效强烈,体力减少了"<<stamina_cost<<"点。";
cd(1200);
break;
}
if(pddj_zj(4,7,"4. 体力增强剂,100元 (+10体力上限)")) {
if(money < 100) {
system("cls");
cout<<"余额不足!";
cd(800);
continue;
}
tired = tired_max+10;
money -= 100;
tired_max+=10;
cd(800);
break;
}
// === 新增药物选项结束 ===
if(pddj_zj(5,7,"5. 离开药店")) {
break;
}
}
cd(500);
}
}
void car_shop() {
system("cls");
cout << "=====高级马场=====" << endl;
cout << "当前坐骑: " << car_names[car_owned] << endl;
cout << "当前金额: " << money << " 元" << endl << endl;
while(1) {
// 千里马选项
if(pddj_zj(5, 7, car_unlocked[1] ? (car_owned == 1 ? "1. 千里马,负重能力弱,速度较快 - ★当前使用" : "1. 更换千里马,负重能力弱,速度较快") : "1. 购买千里马,负重能力弱,速度较快 - 800元")) {
if(car_unlocked[1]) {
// 已拥有千里马,直接切换为千里马
if(car_owned == 1) {
system("cls");
cout << "你当前正骑着千里马,无需重复切换!" << endl;
Sleep(1500);
system("cls");
return;
}
system("cls");
car_owned = 1;
max_cargo_limit=cargo_limits[car_owned];
cout << "已成功更换座驾为千里马!" << endl;
Sleep(1500);
return;
} else if(money >= car_price[1]) {
money -= car_price[1];
car_owned = 1;
car_unlocked[1] = 1; // 打上已购买标记
max_cargo_limit=cargo_limits[car_owned];
system("cls");
cout << "交易成功!已获得千里马!" << endl;
Sleep(1500);
return;
} else {
system("cls");
cout << "金额不足!需要800元" ;
Sleep(1500);
system("cls");
car_shop();
return;
}
}
// 牛车选项
if(pddj_zj(6, 7, car_unlocked[2] ? (car_owned == 2 ? "2. 牛车,负重能力强,速度较慢 - ★当前使用" : "2. 更换牛车,负重能力强,速度较慢") : "2. 购买牛车,负重能力强,速度较慢 - 2000元")) {
if(car_unlocked[2]) {
// 已拥有牛车,直接切换为牛车
if(car_owned == 2) {
system("cls");
cout << "你当前正骑着牛车,无需重复切换!" << endl;
Sleep(1500);
system("cls");
return;
}
system("cls");
car_owned = 2;
max_cargo_limit=cargo_limits[car_owned];
cout << "已成功更换座驾为牛车!" << endl;
Sleep(1500);
return;
} else if(money >= car_price[2]) {
money -= car_price[2];
car_owned = 2;
car_unlocked[2] = 1; // 打上已购买标记
max_cargo_limit=cargo_limits[car_owned];
system("cls");
cout << "交易成功!已获得牛车!" << endl;
Sleep(1500);
return;
} else {
system("cls");
cout << "金元不足!需要2000元";
Sleep(1500);
system("cls");
car_shop();
return;
}
}
// 马车选项
if(pddj_zj(7, 7, car_unlocked[3] ? (car_owned == 3 ? "3. 马车,负重能力较强,速度超快 - ★当前使用" : "3. 更换马车,负重能力较强,速度超快") : "3. 购买马车,负重能力较强,速度超快 - 5000元")) {
if(car_unlocked[3]) {
// 已拥有马车,直接切换为马车
if(car_owned == 3) {
system("cls");
cout << "你当前正驾驶着马车,无需重复切换!" << endl;
Sleep(1500);
system("cls");
return;
}
system("cls");
car_owned = 3;
max_cargo_limit=cargo_limits[car_owned];
cout << "已成功更换座驾为马车!"<<endl;
Sleep(1500);
return;
} else if(money >= car_price[3]) {
money -= car_price[3];
car_owned = 3;
car_unlocked[1] = true; // 打上已购买标记
max_cargo_limit=cargo_limits[car_owned];
system("cls");
cout << "交易成功!已获得马车!"<<endl;
Sleep(1500);
return;
} else {
system("cls");
cout << "金额不足!需要10000元";
Sleep(1500);
system("cls");
car_shop();
return;
}
}
// 放马切回徒步功能
if(pddj_zj(8, 7, car_owned == 0 ? "4. 徒步模式 - ★当前使用" : "4. 放马步行,切回徒步模式")) {
system("cls");
car_owned = 0;
max_cargo_limit=cargo_limits[car_owned];
cout << "你把坐骑暂时拴在马场,切换为步行模式!" << endl;
Sleep(1500);
return;
}
// 离开选项
if(pddj_zj(9, 7, "离开马场")) {
system("cls");
return;
}
}
}
// 出租车功能函数
void pickup_passenger() {
if (has_passenger) {
cout << "已经有乘客在车上!" << endl;
Sleep(1000);
return;
}
if (car_owned == 0) {
cout << "需要至少拥有匹马才能接客!" << endl;
Sleep(1000);
return;
}
has_passenger = true;
passenger_start_x = wzx;
passenger_start_y = wzy;
// 随机生成目的地
passenger_end_x = rand() % 14 + 1; // 1-14之间的随机行
passenger_end_y = rand() % 38 + 1; // 1-38之间的随机列
// 确保目的地不是障碍物
while (!dt[passenger_end_x][passenger_end_y] == ' ') {
passenger_end_x = rand() % 14 + 1;
passenger_end_y = rand() % 38 + 1;
}
dt[passenger_end_x][passenger_end_y]='E';
cout << "接到乘客!目的地坐标: (" << passenger_end_x << "," << passenger_end_y << ")" << endl;
cout << "请将乘客送到E点下车" << endl;
Sleep(1500);
}
void car_people() {
system("cls");
cout << "=== 客运货运枢纽 (P点) ===" << endl;
cout << "当前座驾: " << car_names[car_owned] << endl;
cout << "最大载货上限: " << cargo_limits[car_owned] << " 斤" << endl;
// 状态校验前置,直接拦截非法操作
if (has_passenger) {
cout << "车上已有乘客,无法装载货物!请先将乘客送到E点下车。" << endl;
Sleep(1500);
system("cls");
return ;
}
if (has_cargo_task) {
cout << "车上已有" << current_cargo << "斤货物,无法装载客人!请先将货物运送到T点卸货。" << endl;
Sleep(1500);
system("cls");
return;
}
// 无任何任务时弹出二选一菜单
cout << "\n请选择你要进行的操作:" << endl;
while(1) {
if(pddj_zj(6, 7, "1. 装填货物")) {
if (car_owned == 0) {
cout << "你是步行状态,没有任何运载工具,根本没法拉货!" << endl;
Sleep(1500);
break;
}
// 生成20~1000之间的随机重量,不能超过当前车辆的载重上限
int rand_weight = rand() % 981 + 20;
// 新增麻袋效果校验
if(sack_effect_active) {
rand_weight = cargo_limits[car_owned]+800; // 直接强制为当前车辆最大载重
sack_effect_active = false; // 消耗掉麻袋效果
system("cls");
cout << "麻袋已使用"<< endl;
Sleep(1500);
} else if(rand_weight > cargo_limits[car_owned]) {
rand_weight = cargo_limits[car_owned];
}
current_cargo = rand_weight;
has_cargo_task = true;
system("cls");
cout << "装货成功!本次装载货物重量为 " << current_cargo << " 斤" << endl;
cout << "请将这批货物安全运送到T点的守卫处完成交付结算运费!" << endl;
Sleep(2000);
break;
}
if(pddj_zj(7, 7, "2. 装载客人接取出租订单")) {
pickup_passenger();
return;
}
}
wzx += 1;
system("cls");
return ;
}
void dropoff_passenger() {
if (!has_passenger) {
cout << "车上没有乘客!" << endl;
Sleep(1000);
return;
}
// 计算曼哈顿距离
int distance = abs(passenger_start_x - wzx) + abs(passenger_start_y - wzy);
dt[passenger_end_x][passenger_end_y]=' ';
// 计算车费:曼哈顿距离 × 车辆等级 ÷ 2
fare_earned = distance * car_owned / 2;
if (fare_earned < 1) fare_earned = 1; // 最低车费1元
money += fare_earned;
cout << "乘客已送达!" << endl;
cout << "行驶距离: " << distance << " 格" << endl;
cout << "车辆等级: " << car_owned << endl;
cout << "获得车费: " << fare_earned << " 元" << endl;
cout << "当前余额: " << money << " 元" << endl;
has_passenger = false;
fare_earned = 0;
Sleep(2000);
}
void show_passenger_info() {
if (has_passenger) {
cout << "=== 乘客信息 ===" << endl;
cout << "当前位置: (" << wzx << "," << wzy << ")" << endl;
cout << "目的地: (" << passenger_end_x << "," << passenger_end_y << ")" << endl;
cout << "剩余距离: " << (abs(wzx - passenger_end_x) + abs(wzy - passenger_end_y)) << " 格" << endl;
cout << "车辆等级: " << car_owned << endl;
cout << "预计车费: " << ((abs(passenger_start_x - passenger_end_x) + abs(passenger_start_y - passenger_end_y)) * car_owned / 2) << " 元" << endl;
} else {
cout << "车上没有乘客" << endl;
}
Sleep(2000);
}
void chifan() {
int wzx_eat=2,wzy_eat=1;
char meishijie[5][10]= {
{'#','#','#','#','#','#','#','#','#','#'},
{' ',' ',' ','m','*',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ','*',' ',' ',' ',' ',' '},
{'#','#','#','#','#','#','#','#','#','#'},
};
system("mode con cols=50 lines=20");
ggb();
ycgb();
ycbj();
int yd=0;
for(int hu=1; 1; ++hu) {
if(yd) {
if(hu%10==0)yd=0;
}
ydgb(1,1);
for(int i=0; i<5; i++) {
ydgb(i+1,1);
for(int j=0; j<10; j++) {
if(i==wzx_eat&&j==wzy_eat) {
cout<<"I";
if(meishijie[i][j]=='*') {
system("cls");
cout<<" 一家小餐馆,你要吃吗?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
menu(1);
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_eat=2;
system("cls");
break;
}
if(meishijie[i][j]=='m') {
system("cls");
cout<<" 一个药店,药到病除";
while(1) {
if(pddj_zj(2,7,"买药")) {
system("cls");
menu(2);
break;
}
if(pddj_zj(3,7,"算了")) {
break;
}
}
wzx_eat=2;
system("cls");
break;
}
if(j==0) {
return;
}
} else {
cout<<meishijie[i][j];
}
}
if(i==0) {
cout<<" 余额:"<<money;
}
}
if(axj('W')&&!yd) {
ydgb(wzx_eat+1,wzy_eat+1);
cout<<" ";
if(wzx_eat>1)wzx_eat-=1;
hu=1;
yd=1;
}
if(axj('S')&&!yd) {
ydgb(wzx_eat+1,wzy_eat+1);
cout<<" ";
if(wzx_eat<3)wzx_eat+=1;
hu=1;
yd=1;
}
if(axj('A')&&!yd) {
ydgb(wzx_eat+1,wzy_eat+1);
cout<<" ";
if(wzy_eat>0)wzy_eat-=1;
hu=1;
yd=1;
}
if(axj('D')&&!yd) {
ydgb(wzx_eat+1,wzy_eat+1);
cout<<" ";
if(wzy_eat<8)wzy_eat+=1;
hu=1;
yd=1;
}
Sleep(1);
}
}
void shuoming() {
cout<<" 这有一座奇怪的建筑,叫:游戏公司?";
while(1) {
if(pddj_zj(2,7,"进入")) {
break;
}
if(pddj_zj(3,7,"算了")) {
return;
}
}
system("cls");
cout<<"策划:说吧,你是不是想问点啥?"<<endl;
Sleep(1000);
cout<< "“我”:这是什么地方?"<<endl ;
Sleep(1000);
cout<<"策划:你不必知道。"<<endl;
Sleep(100);
while(1) {
if(pdbj(4,1,1,28,7,"为什么,你不是说让我问的吗?")) {
system("cls");
cout<<"策划:说吧,你是不是想问点啥?"<<endl;
cout<< "“我”:这是什么地方?"<<endl ;
cout<<"策划:你不必知道。"<<endl;
cout<<"“我”:为什么,你不是说让我问的吗?"<<endl;
Sleep(1000);
cout<<"策划:那你出去吧!"<<endl;
Sleep(1000);
system("cls");
break;
}
if(pdbj(5,1,1,16,7,"那你想要谁知道?")) {
system("cls");
cout<<"策划:说吧,你是不是想问点啥?"<<endl;
cout<< "“我”:这是什么地方?"<<endl ;
cout<<"策划:你不必知道。"<<endl;
cout<<"“我”:那你想要谁知道?"<<endl;
Sleep(1000);
cout<<"策划:屏幕后面的人。"<<endl;
Sleep(1000);
system("cls");
break;
}
}
while(1) {
ydgb(1,1);
cout<<"策划:好了,你想问什么关于游戏的,主角已经走了"<<endl;
if(pdbj(2,1,1,14,7,"什么时候更新!")) {
system("cls");
cout<<"策划:好了,你想问什么关于游戏的,主角已经走了"<<endl;
cout<<"我:什么时候更新!"<<endl;
cd(1000);
cout<<"mod:没办法,我家电脑运行不了这代码"<<endl;
cd(1000);
cout<<"mod:所以没法在家更新"<<endl;
cd(1000);
cout<<"mod:但是别担心,我会在学校努力更新的!"<<endl;
cd(1000);
}
if(pdbj(3,1,1,20,7,"你是怎么造的这游戏?")) {
system("cls");
cout<<"策划:好了,你想问什么关于游戏的,主角已经走了"<<endl;
cout<<"我:你是怎么造的这游戏?"<<endl;
cd(1000);
cout<<"mod:我本来不想造和工作有关的游戏"<<endl;
cd(1000);
cout<<"mod:但是其他人造的奇奇怪怪的,根本没有游戏背景可言的"<<endl;
cd(1000);
cout<<"mod:最关键的是,没有点击和地图!"<<endl;
cd(1000);
cout<<"mod:打工游戏没有地图是不完整的!"<<endl;
cd(1000);
cout<<"mod:点击是游戏的灵魂!"<<endl;
cd(1000);
cout<<"我:所以就是这么个原因啊……";
cd(1000);
system("cls");
}
if(pdbj(4,1,1,8,7,"介绍介绍")) {
system("cls");
cout<<"策划:好了,你想问什么关于游戏的,主角已经走了"<<endl;
cout<<"我:介绍介绍"<<endl;
cd(1000);
cout<<"mod:这几乎是我独自创造的游戏"<<endl;
cd(1000);
cout<<"mod:但佩奇(培奇)也帮了点忙"<<endl;
cd(1000);
cout<<"mod:对了,这游戏有结局哦,还不止一个,快去探索吧!"<<endl;
cd(1000);
system("cls");
}
if(pdbj(5,1,1,8,7,"再见")) {
system("cls");
return ;
}
}
}
void print_xueli_level() {
string levels[] = {"童生", "秀才", "举人", "解元", "贡士", "进士", "探花", "状元"};
if(xueli_level >= 0 && xueli_level < 8) {
cout << levels[xueli_level];
} else {
cout << "未知学历";
}
}
void check_xueli() {
system("cls");
cout << "=== 私塾学历信息 ===" << endl;
cout << "当前学历: ";
print_xueli_level();
cout << endl;
cout << "学历值: " << xueli_value << "/";
int required[] = {100, 300, 600, 1000, 1500, 2200, 3000, 9999};
if(xueli_level < 7) {
cout << required[xueli_level] << endl;
cout << "还需: " << (required[xueli_level] - xueli_value) << "学历值";
} else {
cout << "MAX" << endl;
cout << "已达最高状元学历!";
}
cout << endl << endl << "=== 各科目学习情况 ===" << endl;
string subject_names[] = {"四书", "五经", "六艺", "策论"};
for(int i = 0; i < 4; i++) {
cout << subject_names[i] << ": " << kecheng[i] << "次学习";
cout << " (+" << min(kecheng[i] * 3, 25) << "%科举概率)" << endl;
}
cout << endl << "书房自习加成: +" << library_bonus << "%科举及格概率";
Sleep(3000);
system("cls");
}
bool random_event() {
int chance = rand() % 100;
if(chance < 10) { // 10%概率
return 1;
// 本次学习获得的学历值翻倍
}
return 0;
}
void study_subject(int subject_id) {
string subject_names[] = {"四书", "五经", "六艺", "策论"};
int study_gain[4] = {8, 10, 7, 9};
system("cls");
if(tired<10) {
cout<<"你太累了,先吃点饭再来私塾上课!"<<endl;
Sleep(1000);
system("cls");
return ;
}
system("cls");
cout << "正在跟随先生学习" << subject_names[subject_id] << "..." << endl;
Sleep(800);
kecheng[subject_id] += 1; // 该科目学习次数+1
xueli_value += study_gain[subject_id]; // 增加学历值
tired -= 10; // 消耗体力
if(random_event()) {
cout << "今天先生讲的知识点格外通透!学习效率翻倍!"<<endl;
xueli_value+=study_gain[subject_id];
}
cout << "学习完成!" << endl;
cout << subject_names[subject_id] << "学习次数: " << kecheng[subject_id] << endl;
cout << "当前学历值: " << xueli_value << endl;
Sleep(1000);
system("cls");
}
void library_study() {
system("cls");
Sleep(100);
cout << "书房自习中......" << endl;
while(1) {
if(pddj_zj(2, 7, "自习1钟头")) {
if(tired >= 15) {
library_bonus += 5;
tired -= 15;
system("cls");
cout << "在书房自习完成!科举及格概率+" << library_bonus << "%";
Sleep(1000);
break;
} else {
system("cls");
cout << "体力不足,先去吃点东西补充精力吧!";
Sleep(1000);
break;
}
}
if(pddj_zj(3, 7, "自习2钟头")) {
if(tired >= 25) {
library_bonus += 10;
tired -= 25;
system("cls");
cout << "在书房自习完成!科举及格概率+" << library_bonus << "%";
Sleep(1000);
break;
} else {
system("cls");
cout << "体力不足,先去吃点东西补充精力吧!";
Sleep(1000);
break;
}
}
if(pddj_zj(4, 7, "自习3钟头")) {
if(tired >= 35) {
library_bonus += 15;
tired -= 35;
system("cls");
cout << "在书房自习完成!科举及格概率+" << library_bonus << "%";
Sleep(1000);
break;
} else {
system("cls");
cout << "体力不足,先去吃点东西补充精力吧!";
Sleep(1000);
break;
}
}
}
system("cls");
return ;
}
void take_exam() {
system("cls");
Sleep(100);
int required_value[] = {100, 300, 600, 1000, 1500, 2200, 3000}; // 各等级所需学历值
if(xueli_value < required_value[xueli_level]) {
cout << "学历值不足!需要" << required_value[xueli_level] << ",当前" << xueli_value;
Sleep(1000);
return ;
}
// 计算基础及格概率
int pass_rate = 30; // 基础30%
// 4门科目加成
for(int i = 0; i < 4; i++) {
pass_rate += min(kecheng[i] * 3, 25); // 每学习一次+3%,最多+25%
}
// 书房加成
pass_rate += library_bonus;
// 体力影响
if(tired < 30) pass_rate -= 20;
else if(tired > 70) pass_rate += 10;
Sleep(1000);
pass_rate = max(10, min(pass_rate, 95)); // 限制在10%-95%
cout << "本次科举及格概率: " << pass_rate << "%" << endl;
cout << "是否参加科举考试?";
while(1) {
if(pddj_zj(2, 7, "参加科举")) {
system("cls");
int result = rand() % 100 + 1;
if(result <= pass_rate) {
// 考试通过
xueli_level++;
library_bonus = 0; // 重置书房加成
cout << "恭喜!科举及第!" << endl;
cout << "新学历: ";
print_xueli_level();
Sleep(1500);
system("cls");
return;
} else {
cout << "很遗憾,本次科举落榜... " << endl;
cout << "可以继续跟着先生学习或者去书房自习提高及格概率";
Sleep(1500);
return ;
}
}
}
}
void school_main() {
system("cls");
int wzx_len=2,wzy_len=2;
system("mode con cols=50 lines=30");
// 精简后私塾地图布局:C=教导堂 M=四书斋 E=五经堂 H=六艺阁 P=策论居 L=习武场 B=书房 T=考房
// 地图严格定义6行14列,完全没有数组越界问题
char school_map[6][14] = {
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'d',' ',' ','C',' ','M',' ','E',' ','H',' ','P',' ','#'},
{'o',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'o',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'r',' ',' ',' ',' ','L',' ','B',' ','T',' ',' ',' ','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#'}
};
ggb();
ycgb();
ycbj();
int yd=0;
// 循环范围严格匹配地图6行的定义,完全不会读取越界内存
for(int hu=1; 1; ++hu) {
if(yd) {
if(hu%10==0)yd=0;
}
ydgb(1,1);
for(int i=0; i<6; i++) {
ydgb(i+1,1);
for(int j=0; j<14; j++) {
if(i==wzx_len&&j==wzy_len) {
cout<<"I";
if(school_map[i][j]=='C') {
system("cls");
cout<<" 教导先生:要查询当前功名详情吗?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
check_xueli();
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
if(school_map[i][j]=='B') {
system("cls");
cout<<" 是否进入书房静心自习?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
library_study();
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
if(school_map[i][j]=='T') {
system("cls");
cout<<" 是否进入考房参加科举考试?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
take_exam();
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
if(school_map[i][j]=='M') {
system("cls");
cout<<" 是否上四书讲习课?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
study_subject(0);
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
if(school_map[i][j]=='E') {
system("cls");
cout<<" 是否上五经诵读课?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
study_subject(1);
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
if(school_map[i][j]=='H') {
system("cls");
cout<<" 是否上六艺实践课?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
study_subject(2);
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
if(school_map[i][j]=='P') {
system("cls");
cout<<" 是否练习策论写作?";
while(1) {
if(pddj_zj(2,7,"是")) {
system("cls");
study_subject(3);
break;
}
if(pddj_zj(3,7,"否")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
if(school_map[i][j]=='L') {
system("cls");
cout<<" 是否在此练习强身健体?";
while(1) {
if(pddj_zj(2,7,"开始习武")) {
system("cls");
tired -= 15;
health += 15;
cout << "你打完一套拳,气血通畅,体力-15,健康+15!" << endl;
Sleep(1500);
break;
}
if(pddj_zj(3,7,"改日再来")) {
break;
}
}
wzx_len=2;
wzy_len=2;
system("cls");
break;
}
// 左侧出口返回城镇,自动定位到私塾S点相邻位置,不会错位
if(j==0) {
system("cls");
wzx = 3;
wzy = 15;
return;
}
} else {
cout<<school_map[i][j];
}
}
// 地图顶部实时显示状态
if(i==0) {
cout<<" 当前功名:";
print_xueli_level();
cout<<" 饱食度:"<<tired;
}
}
// 移动边界严格适配6行14列的迷你地图,完全不会穿墙出界
if(axj('W')&&!yd) {
ydgb(wzx_len+1,wzy_len+1);
cout<<" ";
if(wzx_len>1)wzx_len-=1;
hu=1;
yd=1;
}
if(axj('S')&&!yd) {
ydgb(wzx_len+1,wzy_len+1);
cout<<" ";
if(wzx_len<4)wzx_len+=1;
hu=1;
yd=1;
}
if(axj('A')&&!yd) {
ydgb(wzx_len+1,wzy_len+1);
cout<<" ";
if(wzy_len>0)wzy_len-=1;
hu=1;
yd=1;
}
if(axj('D')&&!yd) {
ydgb(wzx_len+1,wzy_len+1);
cout<<" ";
if(wzy_len<12)wzy_len+=1;
hu=1;
yd=1;
}
Sleep(1);
}
}
void enter_school() {
if(!has_student_card) {
system("cls");
cout << "私塾先生:要进入私塾读书需要先考取童生身份,需要先缴纳100元(报名费)。" << endl;
cout << "当前持有金钱:" << money << "元" << endl;
if(money >= 100) {
money -= 100;
has_student_card = true;
scsuo = 1; // 设置可以进入私塾的标志
cout << "恭喜你成为童生!可以进入私塾跟随先生求学了。";
Sleep(500);
system("cls");
school_main();
} else {
cout << "储蓄不足,先去打工赚钱攒学费吧!";
}
system("cls");
return;
}
system("cls");
// 进入私塾地图
school_main();
}
void bank_service() {
system("cls");
cout << "=== 便民银行 ===" << endl;
cout << "当前余额: " << money << " 元" << endl;
cout << "当前待还贷款总额: " << total_loan_debt << " 元" << endl << endl;
// 进入银行首先自动检测还款规则:余额达到待还数额立刻全额还款
if(money >= total_loan_debt && total_loan_debt > 0) {
cout << "检测到您的余额已足够结清所有贷款,正在自动还款..." << endl;
money -= total_loan_debt;
cout << "还款成功!本次共结清 " << total_loan_debt << " 元。" << endl;
loan_amount = 0;
total_loan_debt = 0;
cout << "当前余额: " << money << " 元" << endl;
Sleep(2000);
system("cls");
}
while(1) {
// 功能1:申请新贷款
if(pddj_zj(4, 7, "1. 申请新贷款")) {
if(total_loan_debt > 0) {
system("cls");
cout << "您还有未结清的贷款,无法重复申请新贷款!" << endl;
cout << "请先还清现有贷款后再来办理。";
Sleep(1500);
system("cls");
break;
}
// 计算最高可贷额度:当前财产的150% 向下取整
int max_loan = (int)(money * 1.5);
if(max_loan <= 0) {
system("cls");
cout << "您当前财产不足,无法申请贷款。";
Sleep(1500);
system("cls");
break;
}
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
FlushConsoleInputBuffer(hStdin);
system("cls");
cout << "=== 申请贷款 ===" << endl;
cout << "当前最高可贷额度: " << max_loan << " 元" << endl;
cout << "贷款利率: 固定2%" << endl;
cout << "您可以选择0到" << max_loan << "区间内的任意金额作为贷款本金" << endl;
cout << "输入贷款金额:";
int input_loan;
cin >> input_loan;
// 金额合法性校验
if(input_loan <= 0 || input_loan > max_loan) {
system("cls");
cout << "输入的贷款金额不合法!可贷款区间是1~" << max_loan << "元";
Sleep(1500);
system("cls");
break;
}
// 计算最终待还总额
loan_amount = input_loan;
total_loan_debt = loan_amount + (int)(loan_amount * 0.02);
money += loan_amount;
system("cls");
cout << "贷款发放成功!" << endl;
cout << "到账本金: " << loan_amount << " 元" << endl;
cout << "产生总利息: " << (int)(loan_amount * 0.02) << " 元" << endl;
cout << "当前总待还贷款: " << total_loan_debt << " 元" << endl;
cout << "当前余额: " << money << " 元";
Sleep(2000);
system("cls");
break;
}
// 功能2:手动主动提前还款
if(pddj_zj(5,7,"2. 手动提前结清贷款")) {
if(total_loan_debt <=0) {
system("cls");
cout << "您当前没有未偿还的贷款,无需还款。";
Sleep(1500);
system("cls");
break;
}
if(money < total_loan_debt) {
system("cls");
cout << "余额不足以结清所有贷款,无法完成全额提前还款。" << endl;
cout << "当前余额: " << money << " 元" << endl;
cout << "待还总额: " << total_loan_debt << " 元";
Sleep(1500);
system("cls");
break;
}
money -= total_loan_debt;
system("cls");
cout << "提前还款成功!" << endl;
cout << "已全额结清所有贷款,共支付 " << total_loan_debt << " 元。" << endl;
loan_amount = 0;
total_loan_debt = 0;
cout << "当前余额: " << money << " 元";
Sleep(1500);
system("cls");
break;
}
if(pddj_zj(6,7,"3. 离开银行")) {
system("cls");
return;
}
}
}
struct Achievement {
bool graduated_high_school = false;
bool graduated_college = false;
bool all_subjects_max = false;
bool library_fan = false; // 图书馆常客
} achievement;
void check_achievements() {
// 检查并解锁成就
if(xueli_level >= 2 && !achievement.graduated_high_school) {
cout << "成就解锁:高中毕业!";
money += 500; // 成就奖励
achievement.graduated_high_school = true;
}
// ... 其他成就
}//未完成部分!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void guard() {
cout<<"你要干嘛?";
while(1) {
if(pddj_zj(2,7,"我去城门一趟,这是路费,200000" )) {
int mod=rand()%100+1;
if(money>=200000&&mod<=10) {
money-=200000;
cd(100);
cout<<"经过长途跋涉,你终于回到了China"<<endl;
cout<<"达成隐藏结局1:回家~~";
exit(0);
} else if(money>=200000) {
cd(1);
cout<<"守卫:这不是钱不钱的问题"<<endl;
Sleep(1000);
return;
} else {
cd(1);
cout<<"没钱你还出啥城?"<<endl;
Sleep(1000);
return;
}
}
if(pddj_zj(3,7,"没事")) {
return;
}
if(pddj_zj(4,7,"卸货")) {
if (has_cargo_task && current_cargo > 0) {
int reward = current_cargo*0.75;
system("cls");
cout << "守卫检查完毕,允许通行。" << endl;
cout << "货物交付成功!" << endl;
cout << "运送重量: " << current_cargo << " 斤" << endl;
cout << "获得报酬: " << reward << " 元" << endl;
money += reward;
current_cargo = 0;
has_cargo_task = false;
cout << "\n任务完成,可以继续去 P 点接新任务。" << endl;
Sleep(2000);
return;
} else {
system("cls");
cout << "守卫:此处为城池出入口,请遵守秩序。" << endl;
if (!has_cargo_task) {
cout << "(提示:当前无货物运输任务)" << endl;
}
Sleep(1500);
return;
}
}
}
}
void jiajiao() {
system("cls");
// 检查学历等级是否达到初中(等级1)
if(xueli_level < 1) {
cout << "家教中心:抱歉,您的学历过低,我们无法录取你!" << endl;
cout << "当前学历:";
print_xueli_level();
Sleep(2000);
system("cls");
return;
}
// 检查体力是否足够
if(tired < 20) {
cout << "家教中心:您太累了,需要先休息一下!" << endl;
cout << "当前饱食度:" << tired << "/100" << endl;
Sleep(2000);
system("cls");
return;
}
cout << "家教中心:上班快乐!" << endl;
cout << "当前学历:";
print_xueli_level();
cout << endl;
cout << "家教工作每次消耗20饱食度" << endl;
cout << "薪资:100 * 学历等级 = " << 100 * (xueli_level + 1) << "元" << endl;
cout << "学历值增加:" << (xueli_level + 1) * 10 << "点" << endl;
cout << "当前饱食度:" << tired << "/100" << endl;
cout << "当前余额:" << money << "元" << endl;
while(1) {
if(pddj_zj(8, 7, "开始家教工作")) {
// 扣除饱食度
tired -= 20;
// 计算薪资(100 * 学历等级)
int salary = 100 * (xueli_level + 1);
money += salary;
// 增加学历值(根据学历等级增加)
int xueli_gain = (xueli_level + 1) * 10;
xueli_value += xueli_gain;
system("cls");
cout << "家教工作完成!" << endl;
cout << "获得薪资:" << salary << "元" << endl;
cout << "增加学历值:" << xueli_gain << "点" << endl;
cout << "当前饱食度:" << tired << "/100" << endl;
cout << "当前余额:" << money << "元" << endl;
cout << "当前学历值:" << xueli_value << endl;
Sleep(2000);
system("cls");
return;
}
if(pddj_zj(9, 7, "取消")) {
system("cls");
return;
}
}
}
int main() {
srand(time(0));
ggb();
ycgb();
ycbj();
int yd=0;
int move_cd = 0;
int car_cd_table[4] = {10, 3, 6, 1};
for(int hu=1; 1; ++hu) {
if(move_cd > 0) {
move_cd--;
}
ydgb(1,1);
for(int i=kuan1; i<kuan2; i++) {
ydgb(i-kuan1+1,1);
for(int j=shang1; j<shang2; j++) {
if(i==wzx && j==wzy) {
cout<<"I";
if(dt[i][j]=='+') {
system("cls");
gongdi();
wzx=4;
kuan1=3;
kuan2=10;
health-=30;
system("cls");
break;
}
if(dt[i][j]=='=') {
system("cls");
chifan();
wzy-=1;
shang1-=1;
shang2-=1;
system("cls");
}
if(dt[i][j]=='S') {
system("cls");
enter_school();
wzx+=1;
system("cls");
}
if(dt[i][j]=='G') {
system("cls");
shuoming();
wzy-=1;
system("cls");
}
if(dt[i][j]=='T') {
cd(1);
guard();
shang1=1;
kuan1=1;
shang2=20;
kuan2=8;
wzx=5;
wzy=2;
cd(1);
}
if(dt[i][j]=='J') {
system("cls");
jiajiao();
wzx += 1;
system("cls");
}
if(dt[i][j]=='C') {
system("cls");
car_shop();
wzx += 1;
system("cls");
}
if(dt[i][j]=='P') {
system("cls");
car_people();
wzx += 1;
system("cls");
}
if(dt[i][j]=='E') {
system("cls");
if (has_passenger) {
dropoff_passenger();
} else {
cout << "这里只能放客,不能接客!" << endl;
Sleep(1000);
}
system("cls");
}
if(dt[i][j]=='B') {
system("cls");
bank_service();
wzx += 1;
system("cls");
}
// 主角移动循环里的碰撞判断区域新增以下内容:
if(dt[i][j]=='M') {
system("cls");
shop();
wzx += 1;
system("cls");
}
} else {
cout<<dt[i][j];
}
}
if(i==kuan1) {
cout<<" 余额:"<<money;
}
}
cout<<"坐标:("<<wzx<<","<<wzy<<")";
cout<<endl;
cout<<"饱食度:"<<tired<<endl;
cout <<"按WASD移动,按下B打开背包"<<endl;
if (has_passenger) {
cout << " 乘客:有";
}
if(move_cd == 0) {
if(axj('B') && !yd) {
backpack();
hu = 1;
}
if(axj('W')) {
if(kuan1>0) {
kuan1-=1;
kuan2-=1;
}
ydgb(wzx+1,wzy+1);
cout<<" ";
if(wzx>1)wzx-=1;
move_cd = car_cd_table[car_owned];
}
if(axj('S')) {
if(kuan2<=15) {
kuan1+=1;
kuan2+=1;
}
ydgb(wzx+1,wzy+1);
cout<<" ";
if(wzx<14)wzx+=1;
move_cd = car_cd_table[car_owned];
}
if(axj('A')) {
if(shang1>0) {
shang1-=1;
shang2-=1;
}
ydgb(wzx+1,wzy+1);
cout<<" ";
if(wzy>1)wzy-=1;
move_cd = car_cd_table[car_owned];
}
if(axj('D')) {
if(shang2<=39) {wdw
shang1+=1;
shang2+=1;
}
ydgb(wzx+1,wzy+1);
cout<<" ";
if(wzy<38)wzy+=1;
move_cd = car_cd_table[car_owned];
}
}
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
keybd_event('W', 0, KEYEVENTF_KEYUP, 0);
keybd_event('S', 0, KEYEVENTF_KEYUP, 0);
keybd_event('A', 0, KEYEVENTF_KEYUP, 0);
keybd_event('D', 0, KEYEVENTF_KEYUP, 0);
Sleep(10); // 保留原帧间隔,运行更流畅稳定
}
return 0;
}