/***********************************************************************
*Copyright (c)2012 , 天际边工作室
*All rights reserved.
**
文件名称：	Country.cpp
*摘要：		游戏国家类
**
*修改历史：
*	版本    日期     作者     改动内容和原因
*   ----------------------------------------------------
*	1.0    2012-10-13  wstjb     基本的功能完成
***********************************************************************/

#include "Country.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "PublicFun.h"

extern  PAINTSTRUCT ps;
extern 	HDC hdc;
extern 	HBITMAP hbmp; 
extern 	HBITMAP hbmp2; 
extern 	BITMAP bmp;
extern 	HDC hdcMem;
extern 	HDC hdcTmp;
extern 	RECT rect;
extern 	HWND hwnd;


using namespace std;


void Country::Init()
{

	wlogfile(1,__FUNCTION__,"开始",0);
	for(int u=0;u<CITYMAX;u++)
	{
		posx[u]=0;
		posy[u]=0;
	}
}


void Country::Show()
{
	wlogfile(1,__FUNCTION__,"开始",0);
}

int Country::GetCityNum(int num,int choice)
{
		wlogfile(1,__FUNCTION__,"开始",0);
		int cityown[1];
		int cityto[CITYMAX];
		char name[NORMALSTRLEN];
		sprintf_s(name,"Res//citytowho%d.sdt",choice+1);
		GetLine(name,num,cityown,cityto);
		return cityown[0];
}


int Country::GetHeroNum(int num,int choice)
{
		wlogfile(1,__FUNCTION__,"开始",0);
		int heroown[1];
		int heroto[HEROMAX];
		char name[NORMALSTRLEN];
		sprintf_s(name,"Res\\Hero\\herotowho%d.sdt",choice+1);
		GetLine(name,num,heroown,heroto);
		return heroown[0];
}

int Country::GetCityPostion(int pox,int poy,int choice,int num)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	/*int j=0;
	int owner[40];
	char *name;
	//ChangeRes(name);
	if (choice==DZNQ)name="Res\\City\\setowner1.sdt";
	if (choice==CCJQ)name="Res\\City\\setowner2.sdt";
	if (choice==CBZZ)name="Res\\City\\setowner3.sdt";
	if (choice==SGDL)name="Res\\City\\setowner4.sdt";
	ifstream infile(name,ios::in);
	for(int g=0;g<40;g++)
	{
		
			infile>>posx[g];
			infile>>posy[g];
			infile>>owner[g];
			if(posx[g]==pox&&posy[g]==poy)
			{
				if(citylist.city[g].owner==ownernum)
				{
					return 1;
				}
				else if(citylist.city[g].owner==99)
				{
					return 3;
				}
				else
				{
					return 2;
				}
			}
	}
	infile.close();
	//ChangeRes(name);*/
	
	return 0;
}
