#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
string name[1001]={"狂乱","三重打击"};
string xiao_guo[1001]={"打出手牌中的一张牌,消耗之。","造成7点伤害3次。"};
string tips[1001]={"由于一些技术原因,计数器通常从0开始。"};
int cost[1001]={1,2};
int pc_hp=80,max_pc_hp=80,f,full_f=4,/*费用*/pc_fy,pc_gd/*格挡*/;
struct npc{
int hp,max_hp;
int attack;
int fy;
int id;
}boss[1001]={(100,100,10,5)};
vector<int> shou_p,ka_zu;
int init_chou_p=4;
queue<int> p_dui;
vector<int> q_p_dui,chu_wai;
vector<npc> all_boss;
int berserk;//力量
void shan_chu(vector<auto> v,int x){
vector<auto> a;
for(int i=0;i<v.size();i++){
if(i!=x)a.push_back(v[i]);
}
v=a;
}
void clean(queue<int> q){//清理队列
while(q.size()){
q.pop();
}
}
void chou_pai(int num){
for(int i=1;i<=num;i++){
if(shou_p.size()<10&&p_dui.empty()){
//shuffle(q_p_dui.begin(),q_p_dui.end(),md19937);
for(int x:q_p_dui)p_dui.push(x);
q_p_dui.clear();
}
if(shou_p.size()<10){
shou_p.push_back(p_dui.front());
p_dui.pop();
}
}
}
void qi_pai(int where/*弃置手牌中的一张牌*/){
q_p_dui.push_back(where);
shan_chu(shou_p,where);
}
void choose(){//选择卡组
}
void xiao_hao(int where/*消耗手牌中的一张牌*/){
chu_wai.push_back(where);
shan_chu(shou_p,where);
}
void zhan_shi(){//展示手牌
while(1){
int x;
for(int i=0;i<shou_p.size();i++){
cout<<i<<"."<<"名字:"<<name[shou_p[i]]<<"id:"<<shou_p[i]<<endl;
}
cout<<"你要查看哪张卡牌的效果?若无需查看,输入-1"<<endl;
cin>>x;
if(x==-1){
system("cls");
break;
}
cout<<xiao_guo[shou_p[x]]<<endl;
Sleep(2000);
system("pause");
system("cls");
}
for(int i=0;i<shou_p.size();i++){
cout<<i<<"."<<"名字:"<<name[shou_p[i]]<<"id:"<<shou_p[i]<<endl;
}
}
void cha_kan(){//展示怪物
}
int link_sp(){//选中一张手牌
while(1){
int x;
zhan_shi();
cout<<"选择一张手牌,输入它的位置:";
cin>>x;
cout<<endl;
if(0<=x&&x<shou_p.size())return x;
else{
cout<<"手牌不存在!"<<endl;
Sleep(2000);
system("cls");
}
}
}
int link_gw(){//选中一只怪物
while(1){
int x;
cha_kan();
cout<<"选择一只怪物,输入它的位置:";
cin>>x;
cout<<endl;
if(0<=x&&x<all_boss.size())return x;
else{
cout<<"怪物不存在!"<<endl;
Sleep(2000);
system("cls");
}
}
}
void npc_hurt(int x,int damage){//npc受伤
all_boss[x].hp-=damage+berserk-pc_fy;
cout<<"第"<<x<<"个怪物受到了"<<damage+berserk-pc_fy<<"点伤害!";
if(all_boss[x].hp<=0){
shan_chu(all_boss,x);
cout<<"其因此而死亡!";
}
Sleep(2000);
system("cls");
}
void pc_hurt(int damage){
pc_hp-=max(damage-pc_fy-pc_gd,0);
pc_gd-=min(damage-pc_fy,pc_gd);
cout<<"你还剩"<<pc_hp<<"点血,"<<pc_gd<<"点格挡。";
Sleep(2000);
system("cls");
}
void use(int card_id,int where/*为-1则不存在*/){
if(where)qi_pai(where);
if(card_id==0){
int x=link_sp();
if(where)qi_pai(where);
use(shou_p[x],-1);
xiao_hao(x);
}
if(card_id==1){
int x=link_gw();
if(where)qi_pai(where);
npc_hurt(x,7);
npc_hurt(x,7);
npc_hurt(x,7);
}
Sleep(2000);
system("cls");
}
void init_fight(){//初始化战斗
choose();
pc_hp=max_pc_hp;
all_boss.clear();
//shuffle(ka_zu+1,ka_zu+cnt_kz+1,md19937);
clean(p_dui);
q_p_dui.clear();
chu_wai.clear();
shou_p.clear();
for(int i=0;i<ka_zu.size();i++){
p_dui.push(ka_zu[i]);
}
chou_pai(init_chou_p);
}
bool check_lose(){
if(pc_hp<=0){
cout<<"你输了!"<<endl;
system("pause");
system("cls");
return 1;
}
return 0;
}
bool check_win(){
bool f=1;
for(npc x:all_boss){
if(x.hp>0)f=0;
}
if(f){
cout<<"你赢了!"<<endl;
system("pause");
system("cls");
}
return f;
}
void pc_fight(){//玩家行动
cout<<"现在是你的回合!"<<endl;
Sleep(2000);
system("cls");
f=full_f;
while(1){
int x;
zhan_shi();
cout<<"输入你要使用的那张卡的位置,若要结束回合,输入-1"<<endl;
cin>>x;
if(!x)break;
else if(0<=x&&x<shou_p.size())use(shou_p[x],x);
else{
cout<<"位置不存在!"<<endl;
Sleep(2000);
system("cls");
}
}
}
void npc_fight(){//怪物行动
cout<<"现在是怪物的回合!"<<endl;
Sleep(2000);
system("cls");
for(npc x:all_boss){
if(x.id==0){//test
pc_hurt(x.attack);
}
}
}
void fight(){//战斗
init_fight();
while(1){
if(check_lose())break;
pc_fight();
if(check_win())break;
npc_fight();
}
}
void init_fight(){
for(int i=1;i<=1000;i++){
boss[i].id=i;
}
}
void game(){
init_fight();
fight();
}
int main(){
game();
}