自制游戏——国争

devtools/2025/1/20 12:41:36/

自制小游戏,分享给大家

//0——步兵(k)
//1——弓箭手(k)
//2——炮兵(k) 
//3——土地(平方公里) 
//4——能量(t) 
//5——钱(元宝) 
//6——等级 
//7——城池 
#include <bits/stdc++.h>
using namespace std;
double xing[100];
int thing(){cout << "---------------------------------------事件--------------------------------------" << endl;cout << " [1]招兵 [2]休息  [3]进攻  [4]提示/目标  [5]退出 [6]国家 [7]国家城池 [其余]显示能量" << endl;return 0;
};
double munny(){random_device rd;mt19937 rang(rd());uniform_int_distribution<int> munny(200,1000);int man = munny(rang);cout << "增加钱数" << man << endl;xing[5] = xing[5] + man;return xing[100];
}
int tu(){random_device rd;mt19937 rang(rd());uniform_int_distribution<int> di(200,1000);int num=di(rang);cout << "增加土地" << num << endl;xing[3] = xing[3] + num;return xing[100];
}
double sun(){random_device rd;mt19937 rang(rd());uniform_int_distribution<int> bing(0,200);uniform_int_distribution<int> mei(0,10);switch (mei(rang)) {case 1:case 2:case 3:case 4:case 5: cout << "步兵损失" << bing(rang) << endl;xing[0] -= bing(rang); if(xing[0] <= 0){xing[0] = 0;}break;case 6:case 7:case 8:cout << "弓箭手损失" << bing(rang) << endl;xing[1] -= bing(rang); if(xing[1] <= 0){xing[1] = 0;}break;default:cout << "炮兵损失" << bing(rang) << endl;xing[2] -= bing(rang); if(xing[2] <= 0){xing[2] = 0;}break;}return xing[100];
}
int mu(){cout << "目标:称霸天下,成为10级国家" << endl;cout << "提示:能量为零时,游戏将会自动结束"  << endl;cout << "提示:打仗可以增加钱" << endl;cout << "加油吧,我们神圣的君主" << endl;return 0;
};
double guo(){cout << "步兵:" << xing[0] << endl;cout << "弓箭手:" << xing[1] << endl;cout << "炮兵:" << xing[2] << endl;cout << "土地:" << xing[3] << endl;cout << "能量:" << xing[4] << endl;cout << "钱:" << xing[5] << endl; cout << "等级:" << xing[6] << endl;cout << "已有城池:" << xing[7] << endl;return xing[100];
};
double gongruo(){if(xing[0] != 0 && xing[1] != 0 && xing[2] != 0){random_device rd;mt19937 rang(rd());uniform_int_distribution<int> num(10,200);switch (num(rang)/10) {case 1:case 2:case 3:case 4:case 5:case 6:case 7:cout << "遇上了小土匪" << endl;_sleep(0.5*1000);cout << "全歼敌人" << endl;cout << "无伤亡" << endl; munny();break;case 11:case 12:case 13:case 14:case 15:cout << "遇上了A国敌人" << endl;_sleep(0.5*1000);cout << "歼灭敌人" << endl;sun();munny();tu();break;case 16:case 17:case 18:cout << "遇上了B国敌人" << endl;_sleep(0.5*1000);cout << "歼灭敌人" << endl;sun();	munny();tu();break;default:cout << "遇上了3级国家主力军队" << endl;cout << "交战中" << endl;cout << "······" << endl;_sleep(0.5*1000);if(xing[6]==3){cout << "你险胜" << endl;cout <<  "步兵还有1000" << endl; cout <<  "弓箭手还有500" << endl; cout <<  "炮兵还有100" << endl; xing[0]=1000; xing[1] = 500;xing[2] = 100;cout << "获得10000元宝" << endl;tu();}else if(xing[6]>3){printf("完胜");_sleep(0.5*1000);cout << "歼灭敌人" << endl;printf("无伤亡");	munny();tu();}else{cout << "你惨败" << endl;cout << "所有军队被全歼" << endl;xing[0] = 0;xing[1] = 0;xing[2] = 0; }break;}}else{cout << "兵力不足" << endl;}return xing[100];
};
double gongzhong(){if(xing[0] != 0 && xing[1] != 0 && xing[2] != 0){random_device rd;mt19937 rang(rd());uniform_int_distribution<int> num(10,200);switch (num(rang)/10) {case 1:case 2:case 3:case 4:cout << "遇上了3级国家军队" << endl;_sleep(0.5*1000);cout << "全歼敌人" << endl;cout << "无伤亡" << endl; munny();break;case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:cout << "遇上了4级国家部队" << endl;_sleep(0.5*1000);cout << "歼灭敌人" << endl;sun();munny();tu();break;case 16:case 17:case 18:cout << "遇上了5级国家敌人" << endl;_sleep(0.5*1000);cout << "歼灭敌人" << endl;sun();	munny();tu();break;default:cout << "遇上了7级国家主力军队" << endl;cout << "交战中" << endl;cout << "······" << endl;_sleep(0.5*1000);if(xing[6]==7){cout << "你险胜" << endl;cout <<  "步兵还有100" << endl; cout <<  "弓箭手还有100" << endl; cout <<  "炮兵还有100" << endl; xing[0]=100; xing[1] = 100;xing[2] = 100;cout << "获得10000元宝" << endl;tu();}else if(xing[6]>7){printf("完胜");_sleep(0.5*1000);cout << "歼灭敌人" << endl;printf("无伤亡");	munny();tu();}else{cout << "你惨败" << endl;cout << "所有军队被全歼" << endl;xing[0] = 0;xing[1] = 0;xing[2] = 0; }break;}}else{cout << "兵力不足" << endl;}return xing[100];
}
double gongqiang(){if(xing[0] != 0 && xing[1] != 0 && xing[2] != 0){random_device rd;mt19937 rang(rd());uniform_int_distribution<int> num(10,200);switch (num(rang)/10) {case 1:case 2:case 3:case 4:cout << "遇上了8级国家军队" << endl;_sleep(0.5*1000);cout << "全歼敌人" << endl;cout << "无伤亡" << endl; munny();break;case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:cout << "遇上了10级国家先锋队" << endl;_sleep(0.5*1000);cout << "歼灭敌人" << endl;sun();munny();tu();break;default:cout << "遇上了10级国家主力军队" << endl;cout << "交战中" << endl;cout << "······" << endl;_sleep(0.5*1000);if(xing[6]==9&&xing[0]>1000&&xing[1]>500){cout << "你险胜" << endl;cout <<  "步兵还有100" << endl; cout <<  "弓箭手还有100" << endl; cout <<  "炮兵还有100" << endl; xing[0]=100; xing[1] = 100;xing[2] = 100;cout << "获得10000元宝" << endl;tu();}else if(xing[6]>9&&xing[2]>1000){printf("完胜");_sleep(0.5*1000);cout << "歼灭敌人" << endl;printf("无伤亡");	munny();tu();}else{cout << "你惨败" << endl;cout << "所有军队被全歼" << endl;xing[0] = 0;xing[1] = 0;xing[2] = 0; }break;}}else{cout << "兵力不足" << endl;}return xing[100];
}
double zhao(){if(xing[5] >= 50){cout << "花钱50" << endl;xing[5] = xing[5] - 50;cout << "开始寻兵" << endl;cout << "寻兵中" << endl;_sleep(1*100); random_device rd;mt19937 rang(rd());uniform_int_distribution<int> num(1,100);switch (num(rang)/10) {case 1:case 2:case 3:case 4:xing[0] += 50;cout << "恭喜" << endl;cout << "步兵增加五十(k)" << endl;cout << "又增加国家兵力啦!" << endl;break;case 5:case 6:case 7:xing[1] += 50;cout << "恭喜" << endl;cout << "弓箭手增加五十(k)" << endl;cout << "又增加国家兵力啦!" << endl;break;case 8:case 9:xing[2] += 50;cout << "恭喜" << endl;cout << "炮手增加五十(k)" << endl;cout << "又增加国家兵力啦!" << endl;break;default:cout << "哎呀" << endl;cout << "啥都没有" << endl;break;}	}else{cout << "没钱啦!" << endl;}return xing[100];
};
double xiu(){xing[4] = 100;return xing[100];
};
double dengji(){if(xing[7]>=50){printf("恭喜你,晋升为10级国家\n");xing[6] = 10;}else if(xing[7]>=45){printf("恭喜你,晋升为9级国家\n");xing[6] = 9;}else if(xing[7]>=40){printf("恭喜你,晋升为8级国家\n");xing[6] = 8;}else if(xing[7]>=35){printf("恭喜你,晋升为7级国家\n");xing[6] = 7;}else if(xing[7]>=30){printf("恭喜你,晋升为6级国家\n");xing[6] = 6;}else if(xing[7]>=25){printf("恭喜你,晋升为5级国家\n");xing[6] = 5;}else if(xing[7]>=20){printf("恭喜你,晋升为4级国家\n");xing[6] = 4;}else if(xing[7]>=14){printf("恭喜你,晋升为3级国家\n");xing[6] = 3;}else if(xing[7]>=7){printf("恭喜你,晋升为2级国家\n");xing[6] = 2;}return xing[100];
} 
double chengchi(){int num=xing[3];int sum=xing[7];printf("大人,您现在拥有的城池数为:%d\n",sum);printf("您拥有%d平方公里的土地(除去已有城池所占的土地)\n",num); printf("每700平方公里的土地可以建造一座城池\n");if(xing[3]>=700){printf("大人,您要建造几座城池?\n");double n;cin >> n;if(n*700>xing[3]){printf("钱不够,滚开!别妨碍我做生意!\n");}else{xing[3] = xing[3]-n*700;num = xing[3];xing[7]+=n;sum=xing[7];printf("支付完毕\n");printf("剩余%d的土地空闲\n",num);printf("已有城池%d\n",sum);dengji();}}else{printf("这么点钱就要买城池?哼,滚开!别妨碍我做买卖!\n");}return xing[100];
} 
int main(){cout << "------------欢迎来到《国争》------------" << endl;cout << "您是蜀国" << endl;cout << "拥有步兵1k,土地1000平方公里,钱1000元宝"  << endl;cout << "要在各个王国中成为一代霸主" << endl;cout << "目标:国家等级10级" << endl;cout << "加油!" << endl; xing[0] = 1000;xing[1] = 0;xing[2] = 0;xing[3] = 200;xing[4] = 100; xing[5] = 1000; xing[6] = 1; xing[7] = 1;int yn = 1;while(yn == 1){thing();int num;cin >> num;switch (num) {case 1:zhao();xing[4] -= 5;if(xing[4] <= 0){yn = yn + 1;cout << "能量不足" << endl;}break;case 2:xiu();break;case 3:if(xing[6]<5) {gongruo();}else if(xing[6]<9){gongzhong();}else{gongqiang();}xing[4] -= 5;if(xing[4] <= 0){yn = yn + 1;cout << "能量不足" << endl;}if(xing[6] >= 10){cout << "游戏结束,完成目标"  << endl;cout << "称霸天下,晋升10级国家" << endl;return 0;}break;case 4:mu();break;case 5:yn = yn + 1;if(xing[6] < 10){cout << "游戏结束,未完成目标。"  << endl;}else{cout << "游戏结束,完成目标"  << endl;}break;case 6:guo();break;case 7:chengchi();if(xing[6] == 10){cout << "游戏结束,完成目标"  << endl;cout << "称霸天下,晋升10级国家" << endl;return 0;}break;default:cout << xing[4] << endl;break;}}return 0;
}


http://www.ppmy.cn/devtools/152086.html

相关文章

【RK3588 docker编译问题】

问题集合 问题1&#xff1a; 编译lunch出现问题 12:31:21 Build sandboxing disabled due to nsjail error. 12:31:22 Build sandboxing disabled due to nsjail error. In file included from build/make/core/config.mk:313: In file included from build/make/core/envset…

从零创建一个 Django 项目

1. 准备环境 在开始之前&#xff0c;确保你的开发环境满足以下要求&#xff1a; 安装了 Python (推荐 3.8 或更高版本)。安装 pip 包管理工具。如果要使用 MySQL 或 PostgreSQL&#xff0c;确保对应的数据库已安装。 创建虚拟环境 在项目目录中创建并激活虚拟环境&#xff…

Java基础--类和对象

目录 什么是类&#xff1f; 什么是对象 为什么java会设计对象 Java对象该怎么用 程序执行流程 类的加载顺序 什么是类&#xff1f; 类是构建对象的模板&#xff0c;一个类可以创建多个对象&#xff0c;每个对象的数据的最初来源来自对象 public class Student{public in…

Python从0到100(八十四):神经网络-卷积神经网络训练CIFAR-10数据集

前言&#xff1a; 零基础学Python&#xff1a;Python从0到100最新最全教程。 想做这件事情很久了&#xff0c;这次我更新了自己所写过的所有博客&#xff0c;汇集成了Python从0到100&#xff0c;共一百节课&#xff0c;帮助大家一个月时间里从零基础到学习Python基础语法、Pyth…

Vue.js组件开发-解决PDF签章预览问题

在Vue.js组件开发中&#xff0c;解决PDF签章预览问题可能涉及多个方面&#xff0c;包括选择合适的PDF预览库、配置PDF.js&#xff08;或其封装库如vue-pdf&#xff09;以正确显示签章、以及处理可能的兼容性和性能问题。 步骤和建议&#xff1a; 1. 选择合适的PDF预览库 ‌vu…

数字图像处理:实验三

hello&#xff01;uu们大家好&#xff0c;这里是我们第三章实验的学习&#xff0c;在这里我们将学到以下几个任务&#xff0c;第一、基本灰度变换操作&#xff0c;第二、二值化的应用&#xff0c;额外的还有GMM模型的操作等&#xff0c;我们先从前面开始&#xff0c;了解知识点…

设计和优化用于 AR、HUD 和高级显示系统的表面浮雕光栅

表面浮雕光栅是许多光学系统中的关键组件&#xff0c;在控制增强现实 &#xff08;AR&#xff09; 显示器、平视显示器 &#xff08;HUD&#xff09; 和其他先进光子器件中的光传播方面发挥着关键作用。作为在这个领域工作的工程师和设计师&#xff0c;您了解针对特定应用优化这…

游戏画质升级史的思考

画质代入感大众玩家对游戏的第一印象与评判标准 大众玩家还没到靠游戏性等内在因素来评判游戏的程度。 画面的重要性&#xff0c;任何时候都不能轻视。 行业就是靠摩尔定律来推动进步的。 NS2机能达到PS4到PS4PRO之间的水准&#xff0c;5050达到8G显存&#xff0c;都会引发连…