跳到正文

休闲·娱乐

提供给hdd的代码

ld_mjc约 11 分钟
原文
文章信息与版本

文章信息

收录
2025年12月14日
更新
2025年12月14日
篇幅
约 11 分钟

版本

  1. v1当前
C++
// V.1.22
#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include<conio.h>
using namespace std;
long long strong=0,liliang=1,ya_ling=2,chong_sheng=10000,xiao_lv=1,chong_sheng_num=0,chong_wu=500;
const long long blue=0,yellow=1,red=2,green=3,purple=4,white=5;//颜色
long long ji_xing_mao[2]={0,1},ying_wu[2],qin_lao_shu[2]={0,1};//宠物变量    -名称[0]:数量 -名称[1]:技能等级
void color(long long c){
	switch(c){
		case red:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);break;
		case green:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);break;
		case yellow:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);break;
		case blue:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);break;
		case white:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);break;
		case purple:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);break;
	}
}
long long random(long long x){
	srand(time(0));
	return rand()%x;
}
void Slowsay(string a) {
	long long l = a.size();
	for (long long i = 0; i < l; i++) {
		cout << a[i];
		Sleep(4);
	}
	printf("\n");
}
void cls(){
	system("cls");
}
void s(double n){
	Sleep(n*1000.00);
}
void duan_lian(){
	while(1){
		strong=strong+liliang*xiao_lv*ji_xing_mao[1];
		cout<<strong<<'\n';
		cout<<"按↑退出";
		if(GetAsyncKeyState(VK_UP)) return;
		cls();
	}
}
void shop(){
	while(1){
		while(ya_ling*50-ying_wu[1]<0){
			strong-=ya_ling*50-ying_wu[1];
			ya_ling++;
			liliang++;
		}
		Slowsay("当前哑铃等级:");
		color(blue);
		cout<<"   "<<liliang<<'\n';
		color(white);
		Slowsay("当前力量值:");
		color(red);
		cout<<"   "<<strong<<'\n';
		color(white);
		cout<<ya_ling;
		Slowsay("级哑铃 :");
		color(red);
		cout<<ya_ling*50<<"-"<<ying_wu[1]<<"("<<ya_ling*50-ying_wu[1]<<")";
		color(white);
		cout<<"的力量值"<<'\n';
		Slowsay("换(1) / 自动购买(2) / 退出商店(0) ");
		string a;
		cin>>a;
		if(a=="1"){
			if(strong>=ya_ling*50-ying_wu[1]){
				Slowsay("购买成功!");
				liliang=ya_ling;
				strong=strong-(ya_ling*50-ying_wu[1]);
				ya_ling++;
				s(1);
			}else{
				color(red);
				Slowsay("力量值不足!");
				s(1);
				color(white);
				return;
			}
		}else if(a=="2"){
			while(strong>=ya_ling*50-ying_wu[1]){
				strong-=ya_ling*50-ying_wu[1];
				ya_ling++;
				liliang++;
			}
			cout<<"自动购买结束";
			s(0.5);
		}else if(a=="0") return;
		system("cls");
	}
}
void pet_shop(){
	color(yellow);
	Slowsay("欢迎来到宠物商店");
	cout<<"花费"<<chong_wu;
	Slowsay("力量值就可以抽取一个宠物!");
	Slowsay("抽取(1) / 离开(0)");
	string n;
	cin>>n;
	if(n=="1"){
		if(strong>=chong_wu){
			long long sui_ji=random(10);
			Slowsay("恭喜你抽中了");
			if(sui_ji==0||sui_ji==4||sui_ji==8){
				color(blue);
                cout<<"稀有宠物:急性猫!!!\n";
                color(yellow);
                Slowsay("目前拥有只数:");
                cout<<ji_xing_mao[0]+1<<'\n';
                ji_xing_mao[0]++;
                ji_xing_mao[1]++;
                cout<<"技能:获得"<<ji_xing_mao[1]<<"倍锻炼效率!!!";
			}else if(sui_ji==1||sui_ji==3||sui_ji==5||sui_ji==9){
				color(white);
				cout<<"普通宠物:鹦鹉!!!\n";
				color(yellow);
				Slowsay("目前拥有只数:");
				cout<<ying_wu[0]+1<<'\n';
				ying_wu[0]++;
				ying_wu[1]+=50;
				cout<<"技能:讨价还价(减少哑铃商店购买所需的"<<ying_wu[1]<<"力量值)";
			}else if(sui_ji==2||sui_ji==7){
				color(red);
				cout<<"传奇宠物:勤劳鼠!!!\n";
				color(yellow);
				Slowsay("目前拥有只数:");
				cout<<qin_lao_shu[0]+1<<'\n';
				qin_lao_shu[0]++;
				qin_lao_shu[1]++;
				cout<<"技能:翻倍当前力量值(一次性) 翻倍倍数:"<<qin_lao_shu[1]<<" 翻倍数量:"<<strong*qin_lao_shu[1]-chong_wu;
				strong*=qin_lao_shu[1];
			}else if(sui_ji){
				color(purple);
				cout<<"史诗宠物:\a喜羊羊!!!!!!\n";
				color(yellow);
				cout<<"技能:获得全部宠物!!!!!!";
				qin_lao_shu[0]++,qin_lao_shu[1]++;
				strong*=qin_lao_shu[1];
				ying_wu[0]++;
				ying_wu[1]+=50;
				ji_xing_mao[0]++;
				ji_xing_mao[1]++;
			}
			strong-=chong_wu;
			chong_wu+=random(2500);
		}else{
			color(red);
			cout<<"力量值不足!!!";
			color(white);
			s(1);
			return;
		}
	}else{
		cls();
		color(white);
		return;
	}
	s(4);
	cls();
	color(white);
	return;
}
int main(){
	color(white);
	Slowsay("This is \"休闲游戏(力量)-C++版\"");
	Slowsay("(原文件已被删除,现在是第2版)");
	s(1.5);
	cls();
	Slowsay("Let's go!");
	s(1);
	while(1){
		cls();
		Slowsay("当前力量值:");
		cout<<"  "<<strong<<'\n';
		Slowsay("1.锻炼");
		Slowsay("2.买哑铃");
		Slowsay("3.抽宠物蛋");
		Slowsay("4.重生");
		Slowsay("5.清空力量值");
		string n;
		cout<<"-";
		cin>>n;
		if(n=="1"){
			cls();
			duan_lian();
		}else if(n=="2"){
			cls();
			shop();
		}else if(n=="4"){
			color(red);
			Slowsay("重生:");
			cout<<"花费"<<chong_sheng;
			Slowsay("力量值,将获得双倍效率");
			Slowsay("但会清除所有力量值,和重置哑铃等级");
			Slowsay("目前重生了");
			color(yellow);
			cout<<"  "<<chong_sheng_num<<"次\n";
			color(red);
			Slowsay("确定重生输入1,取消输入2");
			color(white);
			string lf;
			cin>>lf;
			if(lf=="1"&&strong>=chong_sheng){
				liliang=1;
				ya_ling=1;
				strong=0;
				chong_sheng_num++;
				xiao_lv*=2;
				chong_sheng*=2;
			}else if(lf!="2"){
				Slowsay("力量值不足!");
			}
		}else if(n=="3"){
			cls();
			pet_shop();
		}else if(n=="5"){
			cls();
			color(red);
			Slowsay("确定清空?   该选项不可恢复!!!");
			cout<<'\a';
			color(white);
			Slowsay("清空(1) / 不清空(2)");
			string mc_;
			cin>>mc_;
			if(mc_=="1") strong=0;
		}
	}
}
原文