版本比较
小游戏
正文
增加 162 行删除 53 行
1123456789101112131415161718192021222324252627282930315323334353681 行未改动1181191201211221231241251261271281291301311321331341351361371381391401411425 行未改动1481491501511521531541551561261571581591601613 行未改动1651661671681381391691411701711721441451461471481491501731741751761541771781791801811829 行未改动19219319419517217317417517619619719817719920020120253 行未改动25625725825926023926126226326426569 行未改动3353363373383393403413423433448 行未改动35335435535633333435735835933636036136236334036436534234336636736836937034637137237337437537637735337837935535638038138238338438536038638738838939039139236736839339439539639739839940040137640240340437837938040540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945079 行未改动53053153253353453553647147247353753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856947557057157257357422 行未改动5975985996005065075085095105115126016026036046054 行未改动610611612613525526614615616617618619620621622623624625626627628629630631632633634635636637638639640641545546642643644645646647648649650651652653654655```## 0.1.4beta版### 代码```cpp#include <bits/stdc++.h>
using namespace std;#ifdef _WIN32#define CLEAR_SCREEN system("cls")#define GETCH _getch()#include <conio.h>#include <windows.h>#else #define CLEAR_SCREEN system("clear") #include <termios.h> #include <unistd.h> // Linux/Mac 无回显读取 char getch_char() { struct termios oldt, newt; char ch; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newt); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldt); return ch; } #define GETCH getch_char()#endif
class enemy//敌人总基类class enemy // 敌人总基类{public:
struct enemykind81 行未改动};
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技能5 行未改动};
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}; // 初始化数组,最多存储5位数字 int every_b_l[5] = {0}; int digit_count = 0; // 记录实际提取的数字位数 int temp = p_l;
// 分解玩家血量的每一位数字3 行未改动 temp = temp / 10; // 去掉个位 }
int num1, num2; if (digit_count >= 2) { // 对提取的数字降序排序 std::sort(every_b_l, every_b_l + digit_count, std::greater<int>()); std::sort(every_b_l, every_b_l+5, std::greater<int>()); num1 = every_b_l[0]; // 最大的数字 num2 = every_b_l[1]; // 第二大的数字 } else if (digit_count == 1) { // 只有1位数字时,补0(比如血量是5,取5和0) num1 = every_b_l[0]; num2 = 0; } // cout<<num1<<endl<<num2<<endl;
// 步骤3:拼接成百分数(比如num1=9, num2=5 → 95% → 0.95) double percentage = (num1 * 10 + num2) / 100.0; *player_data-=percentage*at_power[bianhao]; percentage*=at_power[bianhao]; *player_data-=percentage; } void attack_2(int* player_date,int bianhao)//从玩家能量中选择最大的一个数,拼和成一个百分数,此次攻击会吸取玩家能量,大小为攻击力与这个百分数乘算的结果,此次攻击后玩家不会获得手机 { int p_l = *player_date;9 行未改动 temp = temp / 10; // 去掉个位 }
int num1; if (digit_count >= 2) { // 对提取的数字降序排序 std::sort(every_b_l, every_b_l + digit_count, std::greater<int>()); num1 = every_b_l[0]; // 最大的数字 // 对提取的数字降序排序 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]; }53 行未改动 { e[d] = 0; } }
void lostqskill(int *lostnl,int *e)//大招 void lostqskill(int *lostnl)//大招 { if(*lostnl>=qenergy) { *lostnl-=qenergy;69 行未改动 numberqueue.push(i); } while (!en_o.ifkia())//回合轮换 { // int o; //cin>>o;//--------------------------------------------------------------------------------------------------------------------------------------------------------- string ppp=actionqueue.front(); int a=numberqueue.front(); move(ppp); actionqueue.pop();8 行未改动 { if(role=="me")//迷途之人便是你 你的操作 { //cout<<"迷途之人"<<endl; cout<<" 选择操作 当前能量:"<<lost.lostnl<<" 理性点:"<<lost.rationality<<endl; cout<<"a e q"<<endl; cout<<" 选择操作 当前能量:"<<lost.lostnl<<" 理性点:"<<lost.rationality<<" 生命值:"<<lost.life<<endl; cout<<"a:普攻 e:技能 q:大招"<<endl; char operationoptions; cin>>operationoptions; operationoptions=GETCH; if(operationoptions=='a') { int d; system("clear"); CLEAR_SCREEN; en_o.print(); cout<<"请选择目标(1~5):"<<endl; cin>>d; cout<<"发动普攻,请选择目标1~5:"<<endl; char d_char = GETCH; d = d_char - '0'; //d-=1; lost.lostaskill(d,&lost.lostnl,en_o.e,&lost.rationality); system("clear"); CLEAR_SCREEN; en_o.print(); cout<<endl; } if(operationoptions=='e') { int d; system("clear"); CLEAR_SCREEN; en_o.print(); cout<<"请选择目标(1~5):"<<endl; cin>>d; 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); system("clear"); CLEAR_SCREEN; en_o.print(); cout<<endl; } if(operationoptions=='q') { //en_o.print(); lost.lostqskill(&lost.lostnl,en_o.e); system("clear"); lost.lostqskill(&lost.lostnl); CLEAR_SCREEN; en_o.print(); cout<<endl; } lost.update_recovery_state(); } else if(role==" natural") { system("clear"); Natural_Number natural_number; CLEAR_SCREEN; en_o.print(); cout<<"敌方行动: "<<endl; std::this_thread::sleep_for(std::chrono::milliseconds(500)); system("clear"); 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()); cout<<"attack_2"<<endl; cout<<"抽取了玩家能量,玩家能量剩余:"<<lost.lostnl<<endl; } else { natural_number.attack_1(&lost.life,numberqueue.front()); cout<<"attack_1"<<endl; cout<<"攻击玩家,玩家生命剩余:"<<lost.life<<endl; } } else { if(random_int==1) { natural_number.attack_2(&lost.lostnl,numberqueue.front()); cout<<"attack_2"<<endl; cout<<"抽取了玩家能量,玩家能量剩余:"<<lost.lostnl<<endl; } else { natural_number.attack_1(&lost.life,numberqueue.front()); cout<<"attack_1"<<endl; cout<<"攻击玩家,玩家生命剩余:"<<lost.life<<endl; } } std::this_thread::sleep_for(std::chrono::milliseconds(1000)); CLEAR_SCREEN; en_o.print(); } return 0; }79 行未改动//------------------------------------------------------------------------角色 or 战斗
int display_role() { string nameye[10][10]={{"me"}}; // 显示角色 string name; cout<<"请输入名称(me):"; cin>>name; if(name=="me") 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<<"角色名称:"<<name<<endl; 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;22 行未改动 cout<<screen_stirp[1]<<endl; cout<<screen_stirp[1]<<endl; cout<<screen_stirp[0]<<endl; string a; // 清除输入缓冲区 cin.ignore(numeric_limits<streamsize>::max(),'\n'); cout<<"请输入:"; cin>>a; // 清除输入缓冲区 cin.ignore(numeric_limits<streamsize>::max(), '\n'); a=GETCH; if(a=="c") { display_role(); }4 行未改动 fight.select(1);//只有一个角色 } else { cout<<"(请勿重复进行无效输入,否则电脑堆栈将爆炸)无效输入,请重新输入:"<<endl; choose_look_or_fight(); system("./game"); return 0; } return 0; }
};
int main(){
#ifdef _WIN32 SetConsoleOutputCP(65001); // Windows GBK SetConsoleCP(65001); #else setlocale(LC_ALL, ""); // Linux/Mac UTF-8 #endif
display screen; //screen.start_screen();//不知道为啥,把注释解了就会出事 screen.choose_look_or_fight(); // operate fight; // fight.generate(); // fight.select(1);//只有一个角色 return 0;}```在团队123186的团队文件里有它的压缩包,我建了个git仓库 对于没有下过Git的,详见:[git下载地址](https://git-scm.com/install/)### 更新细则1. 多端适应2. 更新的交互3. 一堆bug### 画饼- [x] 第一个角色- [x] 角色技能- [x] 战斗- [x] 查看角色技能- [x] 更好的显示- [x] 更好的交互- [ ] 敌人行动- [ ] 养成- [ ] ...