标签:cout lld span iostream 不同 string win out hang
[第7次修改]
1 #include <iostream> 2 #include <vector> 3 #include <Windows.h> 4 #include "player.h" 5 6 void PLAYER::damage_display(std::string attacker,std::string is_attacked,int damage) 7 { 8 std::cout<<std::endl; 9 std::cout<<attacker<<"给"<<is_attacked<<"造成了"<<damage<<"点伤害"<<std::endl; 10 Sleep(500); 11 } 12 13 void PLAYER::selectcard(CARD &c) 14 { 15 std::string nulldata("0"); 16 this->Pdata.push_back(nulldata); 17 std::vector<int> selected; 18 selected.push_back(0); 19 int num=0; 20 int times=0; 21 std::cout<<"请输入你想选择的卡片的序号(不同序号之间用空格分隔,输入完毕按Ctrl+Z后按回车,最多6张,否则游戏会崩溃哦,这是数组本身具有的问题。)"<<std::endl; 22 for(int n=1;n<=c.Camount;n++) 23 { 24 std::cout<<"["<<n<<"]"<<c.Cdata[3*n-2]<<std::endl; 25 } 26 if(std::cin>>num) 27 { 28 times++; 29 selected.push_back(num); 30 } 31 32 for(int m=1;m<=times;m++) 33 { 34 int index=selected[m]; 35 this->Pdata.push_back(c.Cdata[3*index-2]); 36 this->Pdata.push_back(c.Cdata[3*index-1]); 37 this->Pdata.push_back(c.Cdata[3*index]); 38 } 39 std::cout<<"[From Console] 数据装载完毕!"<<std::endl; 40 } 41 42 void PLAYER::operate(AI &a,DISPLAY &d) 43 { 44 std::cout<<"请输入想要发起攻击的我方卡片序号."<<std::endl; 45 int index_p=0; 46 int index_e=0; 47 std::cin>>index_p; 48 std::cout<<"请输入被攻击的敌方卡片序号"<<std::endl; 49 std::cin>>index_e; 50 std::string damage_temp=this->Pdata[(index_p*3)-1]; 51 std::string hp_temp=a.Adata[index_e*3]; 52 int damage=dataChanger<int>(damage_temp); 53 int hp=dataChanger<int>(hp_temp); 54 std::string attacker=this->Pdata[index_p*3-2]; 55 std::string is_attacked=a.Adata[index_e*3-2]; 56 if(hp<damage) 57 { 58 std::string new_hp1("0"); 59 a.Adata[index_e*3]=new_hp1; 60 this->damage_display(attacker,is_attacked,damage); 61 } 62 else if(hp>=damage) 63 { 64 int hp_tempx=hp-damage; 65 std::string new_hp2=std::to_string(hp_tempx); 66 a.Adata[3*index_e]=new_hp2; 67 this->damage_display(attacker,is_attacked,damage); 68 } 69 }
标签:cout lld span iostream 不同 string win out hang
原文地址:http://www.cnblogs.com/lostmatch/p/7979673.html