没有标题 不要运行 是单独传代码的 看到划走

#include
#include
#include
#include
#include
using namespace std;

struct game
{
	int coin;
	int HP;
	int wuqi1;
	int wuqi2;
}player;

int index(string arr[],string mubiao)
{
	for(int j=0;j<(sizeof(arr)/sizeof(string));j++)
	{
		if(arr[j]==mubiao)
		{
			return j;
		}
	}
}

void out(string output)
{
	if (output == "endl") cout<>player.coin;
	readFile.close();
	/*HP初始化*/
	ofstream te("HP.txt");
	te.close(); 
	ifstream h("HP.txt",ios::in);
	h>>player.HP;
	h.close(); 
	if (player.HP==0)
	{
		ofstream hh("HP.txt");
		player.HP=100;
		hh<<100;
	}
	/*********/
	ofstream wuqi1bianhao("武器1.txt");
	wuqi1bianhao.close();
	ifstream temp;
	temp.open("武器1.txt");
	temp>>player.wuqi1;
	temp.close();
	ofstream wuqi2bianhao("武器2.txt");
	wuqi1bianhao.close();
	ifstream temp1;
	temp1.open("武器2.txt");
	temp1>>player.wuqi2;
	temp1.close();
	/*********/ 
	string diren[15] = {"普通敌军","old six","特种部队","端着电脑的程序员","高级陆战部队" };
	int direnshanghai[15] = {   20    ,   35    ,    30    ,        35        ,       25  };
	int direnxueliang[15] = { 80     ,   160   ,   150    ,       180        ,      100   };
	string wuqi[15] = {"撬棍","镰刀","m1911手枪","m134重机枪","M416突击步枪","RPG火箭筒","AKM突击步枪","uzi冲锋枪","AWM狙击枪","M24狙击枪"};
	int wuqishanghai[15] = {10  ,  10  ,   25      ,    50      ,     45       ,     60    ,      50     ,    40     ,     50 ,    46     };
	int wuqijiage[15] = {100 , 100     ,  250      ,   700      ,     650      ,   1000   ,    700      ,     500   ,      600,      550  };
	string beibao[10];
	/*读取背包*/ 
	ofstream tem("玩家背包.txt");
	tem.close();
    ifstream infile("玩家背包.txt");
    int item=0;
    if (!infile.fail())
    {
        while (!infile.eof())
        {
        	if (infile==0)
        	{
        		break;
			}
            infile >> beibao[item];
            item++;
        }
    }
    infile.close();
	/********/
	s:
		out("欢迎来到{战争游戏}");out("endl");
		out("1.商店");out("endl");
		out("2.战争");out("endl");
		out("3.背包");out("endl");
		out("4.金币");out("endl");
		while (true)
		{
			int ch=getch();
			if (ch=='1')
			{
				system("cls");
				for(int i=0;i<10;i++)
				{
					cout<>op;
				if (op=="0")
				{
					system("cls");
					goto s;
				} 
				if (player.coin>=wuqijiage[index(wuqi,op)])
				{
					ofstream d("coin.txt");
					player.coin-=wuqijiage[index(wuqi,op)];
					d<>zhiling;
						if (zhiling==1)
						{
							int playerzhandouli = (wuqishanghai[player.wuqi1]+wuqishanghai[player.wuqi2]);
							int direndeshanghai = direnshanghai[direnbianhao];
							cout<>player.HP;
								x.close();
								cout<<"你死了!";
								Sleep(1000);
								goto s;
							}
							if (drxl<=0)
							{
								Sleep(1000);
								system("cls");
								ifstream x("HP.txt");
								x>>player.HP;
								x.close();
								cout<<"你赢了!";
								cout<<"金币+50";
								player.coin+=50;
								ofstream y("coin.txt");
								y<>player.HP;
								x.close();
								cout<<"你死了!";
								Sleep(1000);
								goto s;
							}
							if (drxl<=0)
							{
								Sleep(1000);
								system("cls");
								ifstream x("HP.txt");
								x>>player.HP;
								x.close();
								cout<<"你赢了!";
								cout<<"金币+50";
								player.coin+=50;
								ofstream y("coin.txt");
								y<

你可能感兴趣的:(c++)