The game

· · 个人记录

更新日志

  1. 框架打好 --2022/3/4

代码

#include<bits/stdc++.h>
#include<Windows.h>
using namespace std;
int shudu=25;
struct initialize{
    string name;
    int level;
    int props;
    int has;
    int moneys;
}lead;

int props=7;
int prop_have[1289]={0};
string prop[]={" ","quick acting Jiuxin Pill",
   "egg","guiling paste","snow ball",
   "little purse","purse","big purse"};
string prop_level[]={" ","s","n","s","b","b","a","s"};
int prop_abil[]={0,3,1,3,1,2,2,2};
//n,b,a,s

int animals=6;
int have[153]={0};
string names[]={" ","firefox","cure cat",
"leopard","arctic fox",
"lowrie"};
int blood[]={0,100,100,100,200,200};
int abil[]={0,1,3,2,1,0};
//1 fight 2 money 3 cure
int money[]={0,0,0,30,0,0};
int fight[]={0,20,0,0,80,80};
int cures[]={0,0,20,0,0,0};
string level[]={" ","n","n","n","b","b"};
// n,b,a,s,ss,sss,ssr,srr

int days=1;
int all_days=1;
string week[8]={"","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday",
"Sunday"};

int can_fight=0,can_cure=0,get_money=0;
int fights=0,cure,moneys=0;
int injur=0;

void out(string l,string s){
    for(int i=0;i<l.size();i++){
        cout<<l[i];
        Sleep(shudu);
    }
    for(int i=0;i<s.size();i++){
        cout<<s[i];
        Sleep(shudu);
    }
}
void get_animals(int i){
    have[i]=1;
    switch(abil[i]){
        case 1:{
        can_fight++;
        break;
        }
        case 2:{
            get_money++;
            break;
        }
        case 3:{
            can_cure++;
            break;
        }
    }
}
void get_props(int i){
    prop_have[i]=1;
    switch(abil[i]){
        case 1:{
           fights++;
           break;
        }
        case 2:{
            moneys++;
            break;
        }
        case 3:{
            cure++;
            break;
        }
    }
}
}
void talk_start(){
system("cls");
out("Scholar:","Hello!I'm Scholar.\n");
out("        ","What's your name?\n");
cin>>lead.name;
out("Scholar:",lead.name);
out(",\n        ","Do you want to have an adventure?\n");
while(MessageBox(NULL,"Yes? or no?","Question",MB_YESNO)!=IDYES);
out(lead.name,":Yes!\n");
out("Scholar:","Ok,These is a magical world.\n");
out("        ","And these are many intriguing animals.\n");
out("        ","The animals have incredible ability.\n");
out("        ","Some one can help you fight.\n");
out("        ","Some one can help you get extra money.\n");
out("        ","Some one can cure you and other animals.\n");
out("        ","Let us go!\n");
system("pause");
system("cls");
out("Scholar:","First,we need to get animals like this.\n");
out("        ","Humm...I have three animals like this.\n");
out("        ","They are firefox,cure cat,and leopard.\n");
out("        ","Which animal do you want?\n");
out("(Tips:","1.firefox,2.cure cat,3.leopard.)\n");
int xuze;
cin>>xuze;
for(int i=1;i<=10;i++){
if(xuze>=1&&xuze<=3){
break;
}
else{
if(xuze>3)
out("(Tips:","It's too big!)\n");
if(xuze<3)
out("(Tips:","It's too small!)\n");
cin>>xuze;
}
}
if(xuze>=1&&xuze<=3){
out("Scholar:","Here you are.\n");
out("(Tips:","You get it!)\n");
have[xuze]=1;
switch(abil[xuze]){
case 1:{
can_fight++;
break;
}
case 2:{
get_money++;
break;
}
case 3:{
can_cure++;
break;
}
}
}
else{
out("Scholar:","Ok,I lied.In fact,I have 5 animals.\n");
while(xuze<=0||xuze>5){
out("Scholar:","I don't have this animal(QWQ).\n");
out("        ","It's really!\n");
cin>>xuze;
}
out("Scholar:","Here you are.\n");
out("(Tips:","You get it!)\n");

}
system("pause");
system("cls");
}
void case_fight(){
out("(Tips:","You choised fight");
if(can_fight){
out(".)","\n");

}
else{
out(",","But you have no fighting animals.)\n");
return ;
}
}
void case_cure(){
out("(Tips:","You choised cure animals");
if(injur){
out(".)","\n");
out("In treatment","......\n");
int time=(injur*2000);
Sleep(time);
out("(Tips:","Your animals are healthy now!)\n");
blood[1]=100;
blood[2]=100;
blood[3]=100;
blood[4]=200;
blood[5]=200;
}
else{
out(",","But you animals aren't hurt.)\n");
return ;
}
}
void case_money(){
out("(Tips:","You choised geet money");
int gets=0;
if(get_money){
out(".)","\n");
for(int i=1;i<=animals;i++){
if(have[i]&&abil[i]==3){
gets==money[i];
}
}
out("getting  money","......\n");
out("(Tips:","You gets ");
cout<<gets;
out(" moneys.)","\n");
lead.moneys+=gets;
}
else{
out(",","But you have no can get money animals.)\n");
return ;
}
}
void knapsack(){
out("1.animals knapsack;","2.prop knapsack\n");
int xuze;
cin>>xuze;
while(xuze>2||xuze<1){
out("Input Error!","Please try agina!\n");
cin>>xuze;
}
if(xuze==1){
for(int i=1;i<=animals;i++){
if(have[i]){
out("No",".");
cout<<i;
out(" name:",names[i]);
out(" blood",":");
cout<<blood[i];
out(" abil",":");
switch(abil[xuze]){
case 1:{
out("fight"," ");
break;
}
case 2:{
out("cure"," ");
break;
}
case 3:{
out("get"," money ");
break;
}
}
out("level:",level[i]);
out(" You have ","");
cout<<have[i];
cout<<endl;

}
}
}
if(xuze==2){
for(int i=1;i<=props;i++){
out("No",".");
cout<<i;
out(" name:",prop[i]);
out(" level:",prop_level[i]);
out(" abil",":");
switch(abil[xuze]){
case 1:{
out("fight"," ");
break;
}
case 2:{
out("cure"," ");
break;
}
case 3:{
out("get"," money ");
break;
}
}
out(" You have"," ");
cout<<prop_have[i]<<endl;
}
}
}
void shop(){

}
void start(){
out("Please output the speed you want:","(In milliseconds)\n");
cin>>shudu;
}
void a_day(){
system("cls");
int xuze=0;
do{
out("name:",lead.name);
out("\nlevel",":");
cout<<lead.level;
out("\nToday:",week[days]);
out("\nYou play it"," ");
cout<<all_days;
out(" days\nMoney",":");
cout<<lead.moneys;
out("\n","1.fight;2.cure animals;3.knapsack;4.shop;5.get money;6.Adjust speed;7.next day\n");
cin>>xuze;
switch(xuze){
case 1:{
case_fight();
break;
}
case 2:{
case_cure();
break;
}
case 3:{
knapsack();
break;
}
case 4:{
shop();
break;
}
case 5:{
case_money();
break;
}
case 6:{
start();
break;
}
case 7:break;
default :{
out("Input Error!","Please try agina!");
cin>>xuze;
break;
}
}
system("pause");
system("cls");
if(lead.has==0){
out("You don't have any animals!","\n");
out("Good","bye!");
system("shutdown -s -t 100");
}
}while(xuze!=7);
}
void inti(){
lead.has=0;
lead.moneys=1000;
}
int main(){
// MessageBox(NULL,"","",MB_OKCANCEL);
start();
// talk_start();
inti();
while(1){
a_day();
if(days==7)days=0;
days++;
all_days++;
}
return 0;
}