正文
增加 590 行删除 317 行
1234567818 行未改动272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082097 行未改动2172182192202212222232243 行未改动22822923023123223323423523645 行未改动2822832842852862872882892906 行未改动2972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403412 行未改动34434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741823 行未改动4424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944957 行未改动5035045055065075085095105114 行未改动5165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246 行未改动6316326336346356366376386396406416426436446453 行未改动649650651652653654655## 0.1.4beta版### 代码```cpp#include <bits/stdc++.h>using namespace std;#ifdef _WIN32#define CLEAR_SCREEN system("cls")18 行未改动}#define GETCH getch_char()#endifclass enemy // 敌人总基类{public:struct enemykind{string name;int bl_v;int enemy_at_power;};enemykind kind[1000]={{" natural",500,100},{},};int Enemy_Unit_Combination[10][10000]={{1,1,1,1,1}};int e[100],at_power[100];string enemy_name[100];void emy(int en_co)//敌方初始化{for(int i=1;i<=5;i++){enemy_name[i]=kind[Enemy_Unit_Combination[i][en_co-1]].name;e[i]=kind[Enemy_Unit_Combination[i][en_co-1]].bl_v;at_power[i]=kind[Enemy_Unit_Combination[i][en_co-1]].enemy_at_power;}}void print()//显示敌方状态{cout<<" 敌方状态 "<<endl;cout<<" -----------------------------------------------------------------------"<<endl;cout<<" | | | | | |"<<endl;cout<<" 名字";for(int i=1;i<=5;i++){cout<<"|";if(e[i]==0){printf(" ");continue;}cout<<enemy_name[i];//printf("%13s",enemy_name[i]);}cout<<"|"<<endl;cout<<"生命值";for(int i=1;i<=5;i++){cout<<"|";if(e[i]==0){//string s="消亡";cout<<" 消亡";continue;}printf("%13d",e[i]);}cout<<"|"<<endl;cout<<"攻击力";for(int i=1;i<=5;i++){cout<<"|";if(e[i]==0){printf(" ");continue;}printf("%13d",at_power[i]);}cout<<"|"<<endl;cout<<" 位置| 1 | 2 | 3 | 4 | 5 |"<<endl;cout<<" -----------------------------------------------------------------------"<<endl;}int ifkia()//全灭判断{for(int i=0;i<10;i++){if(e[i]){return 0;}}return 1;}private:};class Ordinary_Enemy : public enemy //普通敌人{public:virtual void attack_1(int* player_data,int bianhao) = 0;//第一种普攻virtual void attack_2(int* player_data,int bianhao) = 0;//第二种普攻};class Elite_Enemy : public enemy //精英敌人{public:virtual void attack_1(int* player_life) = 0;//第一种普攻virtual void attack_2(int* player_life) = 0;//第二种普攻virtual void eattack(int* player_life) = 0;//e技能virtual void generate() = 0;//召唤virtual void qattacking(int* player_life) = 0;//大招蓄力virtual void qattack(int* player_life) = 0;//大招};class Boss : public enemy //boss or boss的一个形态{public:virtual void attack_1(int* player_life) = 0;//第一种普攻virtual void attack_2(int* player_life) = 0;//第二种普攻virtual void eattack_1(int* player_life) = 0;//第一种e技能virtual void eattack_2(int* player_life) = 0;//第二种e技能virtual void eattack_3(int* player_life) = 0;//第三种e技能virtual void strenger(int* player_life) = 0;//强化virtual void generate() = 0;//召唤virtual void qattacking(int* player_life) = 0;//大招蓄力virtual void qattack(int* player_life) = 0;//大招};class Natural_Number : public Ordinary_Enemy{public:void attack_1(int* player_data,int bianhao)//从玩家血量中选择最大的两个数,拼和成一个百分数,此次攻击所造成的的伤害为攻击力与这个百分数乘算的结果{int p_l = *player_data;// 步骤1:提取玩家血量的每一位数字int every_b_l[5] = {0};int digit_count = 0; // 记录实际提取的数字位数int temp = p_l;// 分解玩家血量的每一位数字while (temp > 0 && digit_count < 5){every_b_l[digit_count++] = temp % 10; // 取个位数字temp = temp / 10; // 去掉个位}int num1, num2;// 对提取的数字降序排序std::sort(every_b_l, every_b_l+5, std::greater<int>());num1 = every_b_l[0]; // 最大的数字num2 = every_b_l[1]; // 第二大的数字// cout<<num1<<endl<<num2<<endl;// 步骤3:拼接成百分数(比如num1=9, num2=5 → 95% → 0.95)double percentage = (num1 * 10 + num2) / 100.0;percentage*=at_power[bianhao];*player_data-=percentage;}void attack_2(int* player_date,int bianhao)//从玩家能量中选择最大的一个数,拼和成一个百分数,此次攻击会吸取玩家能量,大小为攻击力与这个百分数乘算的结果,此次攻击后玩家不会获得手机{int p_l = *player_date;// 步骤1:提取玩家能量的每一位数字int every_b_l[5] = {0}; // 初始化数组,最多存储5位数字int digit_count = 0; // 记录实际提取的数字位数int temp = p_l;// 分解玩家能量的每一位数字while (temp > 0 && digit_count < 5){every_b_l[digit_count++] = temp % 10; // 取个位数字temp = temp / 10; // 去掉个位}int num1;// 对提取的数字降序排序std::sort(every_b_l, every_b_l + 5, std::greater<int>());num1 = every_b_l[0]; // 最大的数字// 步骤3:拼接成百分数(比如num1=9, num2=5 → 95% → 0.95)double percentage = (num1) / 100.0;*player_date-=percentage*at_power[bianhao];}};enemy en_o;//敌人对象class The_lost//玩家{public:7 行未改动The_lost(){att_power=100;lostnl=0;}void lostaskill(int d,int *lostnl,int *e,int *rationality)//普攻{*lostnl=*lostnl+20;3 行未改动damage_record += damage;cout<<"【回复状态】记录普攻伤害:"<<damage<<" 累计:"<<damage_record<<endl;}*rationality+=1;if(e[d] <= 0){e[d] = 0;}}45 行未改动}//每回合结束时调用,更新回复状态void update_recovery_state() {if(recovery_state){int damage_record_per=0.5;recovery_turn--;cout<<"【回复状态】剩余回合:"<<recovery_turn<<endl;6 行未改动if(recovery_turn==0){recovery_state = false;damage_record = 0;}}}private:int qenergy=10;//e技能能量、q技能能量};class operate//操作类{public:int generate()//生成敌方{cout<<"战斗开始"<<endl;en_o.emy(1);en_o.print();return 0;}The_lost lost;queue <string>actionqueue;//行动队列queue <int>numberqueue;//编号队列//行动队列中的单位会轮换行动int select(int rs)//选择角色{for(int i=1;i<=5;i++){actionqueue.push(en_o.enemy_name[i]);numberqueue.push(i);}for(int i=1;i<=rs;i++){string rolename;cout<<"踏上前来,你是:(me)"<<endl;cin>>rolename;actionqueue.push(rolename);numberqueue.push(i);}while (!en_o.ifkia())//回合轮换{// int o;//cin>>o;//---------------------------------------------------------------------------------------------------------------------------------------------------------string ppp=actionqueue.front();2 行未改动actionqueue.pop();numberqueue.pop();actionqueue.push(ppp);numberqueue.push(a);}cout<<"战斗胜利"<<endl;return 0;}int move(string role){if(role=="me")//迷途之人便是你 你的操作{//cout<<"迷途之人"<<endl;cout<<" 选择操作 当前能量:"<<lost.lostnl<<" 理性点:"<<lost.rationality<<" 生命值:"<<lost.life<<endl;cout<<"a:普攻 e:技能 q:大招"<<endl;char operationoptions;operationoptions=GETCH;if(operationoptions=='a'){int d;CLEAR_SCREEN;en_o.print();cout<<"发动普攻,请选择目标1~5:"<<endl;char d_char = GETCH;d = d_char - '0';//d-=1;lost.lostaskill(d,&lost.lostnl,en_o.e,&lost.rationality);CLEAR_SCREEN;en_o.print();cout<<endl;}if(operationoptions=='e'){int d;CLEAR_SCREEN;en_o.print();cout<<"发动技能,请选择目标(1~5):"<<endl;int d_char = GETCH;d = d_char - '0';//d-=1;en_o.print();lost.losteskill(d,&lost.lostnl,en_o.e,&lost.rationality);CLEAR_SCREEN;en_o.print();cout<<endl;}if(operationoptions=='q'){//en_o.print();lost.lostqskill(&lost.lostnl);CLEAR_SCREEN;en_o.print();cout<<endl;}lost.update_recovery_state();}else if(role==" natural"){Natural_Number natural_number;CLEAR_SCREEN;en_o.print();unsigned int seed = chrono::system_clock::now().time_since_epoch().count();mt19937 engine(seed);uniform_int_distribution<int> int_dist(1, 4);int random_int = int_dist(engine);cout<<"敌方"<<numberqueue.front()<<"号敌人,natural_number行动"<<endl;std::this_thread::sleep_for(std::chrono::milliseconds(1000));CLEAR_SCREEN;en_o.print();cout<<"敌方"<<numberqueue.front()<<"号敌人,natural_number发动技能:"<<endl;if(180-lost.lostnl<30){if(random_int>=2){natural_number.attack_2(&lost.lostnl,numberqueue.front());23 行未改动}}std::this_thread::sleep_for(std::chrono::milliseconds(1000));CLEAR_SCREEN;en_o.print();}return 0;}};class display//显示类{public:string screen_stirp[20]={"==============================================================",//0 //界面显示条,长最长60+2字符"| |",//1"| wating. |",//2"| wating.. |",//3"| wating... |",//4"| "," |",//小型区(10+1)// 5 6" "};//mini款// 7//------------------------------------------------------------------------游戏开始显示struct AnimationFrame {string text;string progress_bar;};// 预定义动画帧vector<AnimationFrame> loading_frames = {{screen_stirp[2], "□□□□□□□□□□□□□□□□□□□□"},{screen_stirp[3], "■□□□□□□□□□□□□□□□□□□□"},{screen_stirp[4], "■■□□□□□□□□□□□□□□□□□□"},{screen_stirp[2], "■■■□□□□□□□□□□□□□□□□□"},{screen_stirp[3], "■■■■□□□□□□□□□□□□□□□□"},{screen_stirp[4], "■■■■■□□□□□□□□□□□□□□□"},{screen_stirp[2], "■■■■■■□□□□□□□□□□□□□□"},{screen_stirp[3], "■■■■■■■□□□□□□□□□□□□□"},{screen_stirp[4], "■■■■■■■■□□□□□□□□□□□□"},{screen_stirp[2], "■■■■■■■■■□□□□□□□□□□□"},{screen_stirp[3], "■■■■■■■■■■□□□□□□□□□□"},{screen_stirp[4], "■■■■■■■■■■■□□□□□□□□□"},{screen_stirp[2], "■■■■■■■■■■■■□□□□□□□□"},{screen_stirp[3], "■■■■■■■■■■■■■□□□□□□□"},{screen_stirp[4], "■■■■■■■■■■■■■■□□□□□□"},{screen_stirp[2], "■■■■■■■■■■■■■■■□□□□□"},{screen_stirp[3], "■■■■■■■■■■■■■■■■□□□□"},{screen_stirp[4], "■■■■■■■■■■■■■■■■■□□□"},{screen_stirp[2], "■■■■■■■■■■■■■■■■■■□□"},{screen_stirp[3], "■■■■■■■■■■■■■■■■■■■□"},{screen_stirp[4], "■■■■■■■■■■■■■■■■■■■■"}};7 行未改动cout << frame.progress_bar;cout << screen_stirp[7] + screen_stirp[7] + screen_stirp[6] << endl;cout << screen_stirp[1] << endl << screen_stirp[0] << endl;}int start_screen()//开始屏幕显示{int a;cout<<screen_stirp[0]<<endl<<screen_stirp[1]<<endl;4 行未改动cout<<"输入任意内容以开始游戏:";cin>>a;cout<<endl;cout<<"欢迎来到“名为数学的游戏”游戏马上开始"<<endl;// 播放加载动画for (const auto& frame : loading_frames) {render_frame(frame);std::this_thread::sleep_for(std::chrono::milliseconds(300));}return 0;}//------------------------------------------------------------------------游戏开始显示//------------------------------------------------------------------------角色 or 战斗int display_role(){string nameye[10][10]={{"me"}};// 显示角色string name;int page=1;int max_page=2;cout<<screen_stirp[0]<<endl;cout<<"|所有角色: |"<<endl;cout<<screen_stirp[5]<<"1."<<nameye[page-1][0]<<" "<<screen_stirp[6]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[0]<<endl;cout<<"输入角色序号1~9 z:上一页 x:下一页"<<endl;name=GETCH;if(name=="z"){if(page==1){page=max_page;}page--;}else if(name=="x"){if(page==max_page){page=1;}page++;}else if(nameye[page-1][stoi(name)-1]=="me"){cout<<"角色名称:"<<nameye[page-1][stoi(name)-1]<<endl;cout<<"角色技能:"<<endl;cout << screen_stirp[7] + "天赋:探索者 羁绊:独行者" << endl;cout << screen_stirp[7] + screen_stirp[7] + "天赋: 作为独行于此的你,步步为艰,你将探索此地,学习便是你最好的武器,(经过学习你将会获得新的一套技能)" << endl;cout << screen_stirp[7] + "形态:无知 初来乍到,你一无所知" << endl;cout << screen_stirp[7] + screen_stirp[7] + "普攻a: 回复一个理性点,对指定敌方单体造成80%攻击力的伤害,回复20能量" << endl;cout << screen_stirp[7] + screen_stirp[7] + "E技能e: 消耗一个理性点,对指定敌方单体造成200%攻击力的伤害,回复30能量" << endl;cout << screen_stirp[7] + screen_stirp[7] + "Q技能q: 消耗180能量,回复两个理性点,进入「回复」状态,持续三回合,此状态下记录角色造成的伤害,在状态中,每回合结束后将记录的伤害的50%转化为血量回复量" << endl;}else{cout<<"(请勿重复进行无效输入,否则电脑堆栈将爆炸)木有欧"<<endl;display_role();}return 0;}int choose_look_or_fight(){cout<<screen_stirp[0]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<"| 输入“c”查看角色 |"<<endl;cout<<"| 输入“f”开始战斗 |"<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[0]<<endl;string a;a=GETCH;if(a=="c"){display_role();}else if(a=="f"){operate fight;fight.generate();fight.select(1);//只有一个角色}else{system("./game");return 0;}return 0;}};int main(){6 行未改动#endifdisplay screen;//screen.start_screen();//不知道为啥,把注释解了就会出事screen.choose_look_or_fight();// operate fight;// fight.generate();// fight.select(1);//只有一个角色return 0;}```### 更新细则1. 多端适应2. 更新的交互3. 一堆bug3 行未改动- [x] 战斗- [x] 查看角色技能- [x] 更好的显示- [x] 更好的交互- [ ] 敌人行动- [ ] 养成- [ ] ...12345678910111218 行未改动31323334353637387 行未改动46474849505152535455565758593 行未改动63646566676869707145 行未改动1171181191201211221231241256 行未改动1321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642 行未改动26726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338423 行未改动4084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205217 行未改动5295305315325335345355365374 行未改动5425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606 行未改动6676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119123 行未改动916917918919920921922923924925926927928## 0.1.5.a版### 代码注:请在同一个文件夹内创建下面几个文件,保证文件名字正确#### game.cpp```cpp#include <bits/stdc++.h>#include "tool.cpp"#include "enemy.cpp"using namespace std;#ifdef _WIN32#define CLEAR_SCREEN system("cls")18 行未改动}#define GETCH getch_char()#endifclass The_lost//玩家{public:7 行未改动The_lost(){att_power=100;lostnl=0;life=1500;name="lost";recovery_state = false;recovery_turn = 0;damage_record = 0;rationality=0;}void lostaskill(int d,int *lostnl,int *e,int *rationality)//普攻{*lostnl=*lostnl+20;3 行未改动damage_record += damage;cout<<"【回复状态】记录普攻伤害:"<<damage<<" 累计:"<<damage_record<<endl;}*rationality+=1;if(e[d] <= 0){e[d] = 0;}}45 行未改动}//每回合结束时调用,更新回复状态void update_recovery_state() {if(recovery_state){int damage_record_per=0.5;recovery_turn--;cout<<"【回复状态】剩余回合:"<<recovery_turn<<endl;6 行未改动if(recovery_turn==0){recovery_state = false;damage_record = 0;}}}private:int qenergy=180;//e技能能量、q技能能量};string screen_stirp[20]={"==============================================================",//0 //界面显示条,长最长60+2字符"| |",//1"| wating. |",//2"| wating.. |",//3"| wating... |",//4"| "," |",//小型区(10+1)// 5 6" "};//mini款// 7The_lost lost;int bag[100000];string storage_breakdown[100000]={"金币","升级书"};string spoil[100000]={"50.5"};class operate//操作类{public:string operate_log[10000];int start_fight(){while(1){int copy_o=0;cout<<"=============================================================="<<endl;cout<<"| 选择关卡 |"<<endl;cout<<"| ----- |"<<endl;cout<<"| | 1 | |"<<endl;cout<<"| ----- |"<<endl;cout<<"| 按q退出 |"<<endl;cout<<"=============================================================="<<endl;string a;a=GETCH;if(a=="q"){break;}while(1){CLEAR_SCREEN;cout<<"选择第"<<a<<"关"<<endl;cout<<"按s开始 按c查看详情 按k修改行为复制是否开启,当前:";if(copy_o){cout<<"■"<<endl;}else{cout<<"□"<<endl;}cout<<"按q退出"<<endl;string o;o=GETCH;if(o=="s"){select(stoi(a));}else if(o=="c"){CLEAR_SCREEN;cout << "关卡" << a << "详情:" << endl;cout << "按任意键返回" << endl;GETCH;CLEAR_SCREEN;}else if(o=="k"){copy_o = !copy_o;CLEAR_SCREEN;}else if(o=="q"){break;}}}}int generate(int level)//生成敌方{cout<<"战斗开始"<<endl;enemy.emy(level);enemy.print();return 0;}queue <string>actionqueue;//行动队列queue <int>numberqueue;//编号队列//行动队列中的单位会轮换行动int select(int number_of_level)//选择关卡{generate(number_of_level);for(int i=1;i<=1;i++){string rolename="lost";actionqueue.push(rolename);numberqueue.push(i);}for(int i=1;i<=5;i++){actionqueue.push(enemy.enemy_name[i]);numberqueue.push(i);}int if_vitcter=0;while (1)//回合轮换{// int o;//cin>>o;//---------------------------------------------------------------------------------------------------------------------------------------------------------string ppp=actionqueue.front();2 行未改动actionqueue.pop();numberqueue.pop();actionqueue.push(ppp);numberqueue.push(a);if(enemy.ifkia()){if_vitcter=1;break;}else if(lost.life<=0){if_vitcter=0;break;}}if(if_vitcter){cout<<"战斗胜利"<<endl;lost.att_power=100;lost.lostnl=0;lost.life=1500;lost.name="lost";lost.recovery_state = false;lost.recovery_turn = 0;lost.damage_record = 0;lost.rationality=0;int give[1000];string strgive[1000];tool.char_dependent_segmentation(strgive,spoil[number_of_level-1],'.');tool.str_to_int(give,strgive);cout<<"获得:"<<endl;for(int i=0;i<10;i++){if(give[i]){cout<<screen_stirp[7]<<storage_breakdown[i]<<":"<<give[i]<<endl;bag[i]+=give[i];}}}else{cout<<"战斗失败"<<endl;lost.att_power=100;lost.lostnl=0;lost.life=1500;lost.name="lost";lost.recovery_state = false;lost.recovery_turn = 0;lost.damage_record = 0;lost.rationality=0;}return 0;}int move(string role){if(role=="lost"){cout<<" 选择操作 当前能量:"<<lost.lostnl<<" 理性点:"<<lost.rationality<<" 生命值:"<<lost.life<<endl;cout<<"a:普攻 e:技能 q:大招"<<endl;char operationoptions;operationoptions=GETCH;if(operationoptions=='a'){int d;CLEAR_SCREEN;enemy.print();cout<<"发动普攻,请选择目标1~5:"<<endl;char d_char = GETCH;d = d_char - '0';//d-=1;lost.lostaskill(d,&lost.lostnl,enemy.e,&lost.rationality);CLEAR_SCREEN;enemy.print();cout<<endl;}if(operationoptions=='e'){int d;CLEAR_SCREEN;enemy.print();cout<<"发动技能,请选择目标(1~5):"<<endl;int d_char = GETCH;d = d_char - '0';//d-=1;enemy.print();lost.losteskill(d,&lost.lostnl,enemy.e,&lost.rationality);CLEAR_SCREEN;enemy.print();cout<<endl;}if(operationoptions=='q'){//enemy.print();lost.lostqskill(&lost.lostnl);CLEAR_SCREEN;enemy.print();cout<<endl;}lost.update_recovery_state();}else if(role==" natural"&&enemy.e[numberqueue.front()]>0){Natural_Number natural_number;CLEAR_SCREEN;enemy.print();unsigned int seed = chrono::system_clock::now().time_since_epoch().count();mt19937 engine(seed);uniform_int_distribution<int> int_dist(1, 4);int random_int = int_dist(engine);cout<<"敌方"<<numberqueue.front()<<"号敌人,natural_number发动技能:"<<endl;if(180-lost.lostnl<10){if(random_int>=2){natural_number.attack_2(&lost.lostnl,numberqueue.front());23 行未改动}}std::this_thread::sleep_for(std::chrono::milliseconds(1000));CLEAR_SCREEN;enemy.print();}return 0;}//养成int yangcheng2(string name){cout<<screen_stirp[0]<<endl;cout<<"所选角色:"<<name<<endl;cout<<screen_stirp[5]<<"1. "<<screen_stirp[6]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[0]<<endl;}int yangcheng1(){string nameye[10][10]={{"lost(1)"}};// 显示角色string name;int page=1;int max_page=2;while (1){cout<<screen_stirp[0]<<endl;cout<<"|所有角色: |"<<endl;cout<<screen_stirp[5]<<"1."<<nameye[page-1][0]<<" "<<screen_stirp[6]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[0]<<endl;cout<<"输入角色序号1~9 z:上一页 x:下一页 q:退出"<<endl;name=GETCH;if(name=="z"){if(page==1){page=max_page;}page--;}else if(name=="x"){if(page==max_page){page=1;}page++;}else if(name=="q"){CLEAR_SCREEN;return 0;}else if(name>="1"&&name<="9"){yangcheng2(nameye[page-1][stoi(name)-1]);}}}};operate o;class display//显示类{public://------------------------------------------------------------------------游戏开始显示struct AnimationFrame {string text;string progress_bar;};// 预定义动画帧vector<AnimationFrame> loading_frames = {{screen_stirp[2], "□□□□□□□□□□□□□□□□□□□□"},{screen_stirp[3], "■□□□□□□□□□□□□□□□□□□□"},{screen_stirp[4], "■■□□□□□□□□□□□□□□□□□□"},{screen_stirp[2], "■■■□□□□□□□□□□□□□□□□□"},{screen_stirp[3], "■■■■□□□□□□□□□□□□□□□□"},{screen_stirp[4], "■■■■■□□□□□□□□□□□□□□□"},{screen_stirp[2], "■■■■■■□□□□□□□□□□□□□□"},{screen_stirp[3], "■■■■■■■□□□□□□□□□□□□□"},{screen_stirp[4], "■■■■■■■■□□□□□□□□□□□□"},{screen_stirp[2], "■■■■■■■■■□□□□□□□□□□□"},{screen_stirp[3], "■■■■■■■■■■□□□□□□□□□□"},{screen_stirp[4], "■■■■■■■■■■■□□□□□□□□□"},{screen_stirp[2], "■■■■■■■■■■■■□□□□□□□□"},{screen_stirp[3], "■■■■■■■■■■■■■□□□□□□□"},{screen_stirp[4], "■■■■■■■■■■■■■■□□□□□□"},{screen_stirp[2], "■■■■■■■■■■■■■■■□□□□□"},{screen_stirp[3], "■■■■■■■■■■■■■■■■□□□□"},{screen_stirp[4], "■■■■■■■■■■■■■■■■■□□□"},{screen_stirp[2], "■■■■■■■■■■■■■■■■■■□□"},{screen_stirp[3], "■■■■■■■■■■■■■■■■■■■□"},{screen_stirp[4], "■■■■■■■■■■■■■■■■■■■■"}};7 行未改动cout << frame.progress_bar;cout << screen_stirp[7] + screen_stirp[7] + screen_stirp[6] << endl;cout << screen_stirp[1] << endl << screen_stirp[0] << endl;}int start_screen()//开始屏幕显示{int a;cout<<screen_stirp[0]<<endl<<screen_stirp[1]<<endl;4 行未改动cout<<"输入任意内容以开始游戏:";cin>>a;cout<<endl;cout<<"欢迎来到“名为数学的游戏”游戏马上开始"<<endl;// 播放加载动画for (const auto& frame : loading_frames) {render_frame(frame);std::this_thread::sleep_for(std::chrono::milliseconds(300));}return 0;}//------------------------------------------------------------------------游戏开始显示//------------------------------------------------------------------------角色 or 战斗int display_role(){string nameye[10][10]={{"lost(1)"}};// 显示角色string name;int page=1;int max_page=2;while (1){cout<<screen_stirp[0]<<endl;cout<<"|所有角色: |"<<endl;cout<<screen_stirp[5]<<"1."<<nameye[page-1][0]<<" "<<screen_stirp[6]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[0]<<endl;cout<<"输入角色序号1~9 z:上一页 x:下一页 q:退出"<<endl;name=GETCH;if(name=="z"){if(page==1){page=max_page;}page--;}else if(name=="x"){if(page==max_page){page=1;}page++;}else if(name=="q"){CLEAR_SCREEN;return 0;}else if(nameye[page-1][stoi(name)-1]=="lost(1)"){CLEAR_SCREEN;cout<<"角色名称:"<<nameye[page-1][stoi(name)-1]<<endl;cout<<"角色技能:"<<endl;cout << screen_stirp[7] + "天赋:探索者 形态:1" << endl;cout << screen_stirp[7] + screen_stirp[7] + "天赋: 作为独行于此的你,步步为艰,你将探索此地,学习便是你最好的武器,(经过学习你将会获得新的一套技能)" << endl;cout << screen_stirp[7] + "形态:无知 初来乍到,你一无所知" << endl;cout << screen_stirp[7] + screen_stirp[7] + "普攻a: 回复一个理性点,对指定敌方单体造成80%攻击力的伤害,回复20能量" << endl;cout << screen_stirp[7] + screen_stirp[7] + "E技能e: 消耗一个理性点,对指定敌方单体造成200%攻击力的伤害,回复30能量" << endl;cout << screen_stirp[7] + screen_stirp[7] + "Q技能q: 消耗180能量,回复两个理性点,进入「回复」状态,持续三回合,此状态下记录角色造成的伤害,在状态中,每回合结束后将记录的伤害的50%转化为血量回复量" << endl;cout << "按任意键以返回" << endl;string returnq;returnq=GETCH;}CLEAR_SCREEN;}}int choose(){while(1){cout<<screen_stirp[0]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<"| 输入“c”查看角色 |"<<endl;cout<<"| 输入“f”开始战斗 |"<<endl;cout<<"| 输入“g”养成角色 |"<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[1]<<endl;cout<<screen_stirp[0]<<endl;string a;a=GETCH;if(a=="c"){CLEAR_SCREEN;display_role();}else if(a=="f"){o.select(1);}else if(a=="g"){CLEAR_SCREEN;o.yangcheng1();}else{CLEAR_SCREEN;}}}};int main(){6 行未改动#endifdisplay screen;//screen.start_screen();//不知道为啥,把注释解了就会出事screen.choose();// operate fight;// fight.generate();// fight.select(1);//只有一个角色return 0;}```#### tool.cpp```cpp#include <bits/stdc++.h>using namespace std;struct TOOL{template<size_t N>void char_dependent_segmentation(string (&ans)[N],string in,char a)//依照a分割字符串in,存入ans{int w=0;for(char y:in){if(y==a){w++;}else{ans[w]+=y;}}}template<size_t N>void str_to_int(int (&ans)[N],string in[N])//将字符串数组转换为int数组{for(int i=0;i<n;i++){if(in[i]==""){ans[i]=0;continue;}ans[i]=stoi(in[i]);}}}tool;```#### enemy.cpp```cpp#include <bits/stdc++.h>#include "tool.cpp"using namespace std;class Enemy // 敌人总基类{public:struct enemykind{string name;int bl_v;int enemy_at_power;};enemykind kind[1000]={{" natural",200,50},{},};int Enemy_Unit_Combination[10000][10]={{1,1,1,1,1}};int e[100],at_power[100];string enemy_name[100];void emy(int en_co)//敌方初始化{for(int i=1;i<=5;i++){enemy_name[i]=kind[Enemy_Unit_Combination[en_co-1][i-1]-1].name;e[i]=kind[Enemy_Unit_Combination[en_co-1][i-1]-1].bl_v;at_power[i]=kind[Enemy_Unit_Combination[en_co-1][i-1]-1].enemy_at_power;}}void print()//显示敌方状态{cout<<" 敌方状态 "<<endl;cout<<" -----------------------------------------------------------------------"<<endl;cout<<" | | | | | |"<<endl;cout<<" 名字";for(int i=1;i<=5;i++){cout<<"|";if(e[i]==0){printf(" ");continue;}cout<<enemy_name[i];//printf("%13s",enemy_name[i]);}cout<<"|"<<endl;cout<<"生命值";for(int i=1;i<=5;i++){cout<<"|";if(e[i]==0){//string s="消亡";cout<<" 消亡";continue;}printf("%13d",e[i]);}cout<<"|"<<endl;cout<<"攻击力";for(int i=1;i<=5;i++){cout<<"|";if(e[i]==0){printf(" ");continue;}printf("%13d",at_power[i]);}cout<<"|"<<endl;cout<<" 位置| 1 | 2 | 3 | 4 | 5 |"<<endl;cout<<" -----------------------------------------------------------------------"<<endl;}int ifkia()//全灭判断{for(int i=1;i<=5;i++){if(e[i]){return 0;}}return 1;}private:};Enemy enemy;//敌人对象class Ordinary_Enemy : public Enemy //普通敌人{public:virtual void attack_1(int* player_data,int bianhao) = 0;//第一种普攻virtual void attack_2(int* player_data,int bianhao) = 0;//第二种普攻};class Elite_Enemy : public Enemy //精英敌人{public:virtual void attack_1(int* player_life) = 0;//第一种普攻virtual void attack_2(int* player_life) = 0;//第二种普攻virtual void eattack(int* player_life) = 0;//e技能virtual void generate() = 0;//召唤virtual void qattacking(int* player_life) = 0;//大招蓄力virtual void qattack(int* player_life) = 0;//大招};class Boss : public Enemy //boss or boss的一个形态{public:virtual void attack_1(int* player_life) = 0;//第一种普攻virtual void attack_2(int* player_life) = 0;//第二种普攻virtual void eattack_1(int* player_life) = 0;//第一种e技能virtual void eattack_2(int* player_life) = 0;//第二种e技能virtual void eattack_3(int* player_life) = 0;//第三种e技能virtual void strenger(int* player_life) = 0;//强化virtual void generate() = 0;//召唤virtual void qattacking(int* player_life) = 0;//大招蓄力virtual void qattack(int* player_life) = 0;//大招};class Natural_Number : public Ordinary_Enemy{public:void attack_1(int* player_data,int bianhao) override {//从玩家血量中选择最大的两个数,拼和成一个百分数,此次攻击所造成的的伤害为攻击力与这个百分数乘算的结果int p_l = *player_data;// 步骤1:提取玩家血量的每一位数字int every_b_l[5] = {0};int digit_count = 0; // 记录实际提取的数字位数int temp = p_l;// 分解玩家血量的每一位数字while (temp > 0 && digit_count < 5){every_b_l[digit_count++] = temp % 10; // 取个位数字temp = temp / 10; // 去掉个位}int num1, num2;// 对提取的数字降序排序std::sort(every_b_l, every_b_l+5, std::greater<int>());num1 = every_b_l[0]; // 最大的数字num2 = every_b_l[1]; // 第二大的数字// cout<<num1<<endl<<num2<<endl;// 步骤3:拼接成百分数(比如num1=9, num2=5 → 95% → 0.95)double percentage = (num1 * 10 + num2) / 100.0;percentage*=enemy.at_power[bianhao];*player_data-=percentage;cout<<"-"<<percentage<<endl;}void attack_2(int* player_date,int bianhao) override{//从玩家能量中选择最大的一个数,拼和成一个百分数,此次攻击会吸取玩家能量,大小为攻击力与这个百分数乘算的结果,此次攻击后玩家不会获得手机int p_l = *player_date;// 步骤1:提取玩家能量的每一位数字int every_b_l[5] = {0}; // 初始化数组,最多存储5位数字int digit_count = 0; // 记录实际提取的数字位数int temp = p_l;// 分解玩家能量的每一位数字while (temp > 0 && digit_count < 5){every_b_l[digit_count++] = temp % 10; // 取个位数字temp = temp / 10; // 去掉个位}int num1;// 对提取的数字降序排序std::sort(every_b_l, every_b_l + 5, std::greater<int>());num1 = every_b_l[0]; // 最大的数字// 步骤3:拼接成百分数(比如num1=9, num2=5 → 95% → 0.95)double percentage = (num1) / 100.0;*player_date-=percentage*enemy.at_power[bianhao];cout<<"-"<<percentage*enemy.at_power[bianhao]<<endl;}};```### 更新细则1. 多端适应2. 更新的交互3. 一堆bug3 行未改动- [x] 战斗- [x] 查看角色技能- [x] 更好的显示- [x] 更好的交互- [x] 敌人行动- [ ] 养成- [ ] ...### bug修复- [x] 受攻击后血量异常变化or不扣血注释:现在的你终于可以被打死了- [x] 敌人第一次攻击时会打你两轮注释:你终于不怕在开局被打个半死了- [ ] ...