魔兽世界终极版

末鹿安然 提交于 2020-01-30 12:47:42

总时间限制: 6000ms 内存限制: 65536kB
描述
魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为1,2,3 … N ( N <= 20 )。红魔军的司令部算作编号为0的城市,蓝魔军的司令部算作编号为N+1的城市。司令部有生命元,用于制造武士。

两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值、攻击力这三种属性。

双方的武士编号都是从1开始计算。红方制造出来的第 n 个武士,编号就是n。同样,蓝方制造出来的第 n 个武士,编号也是n。

武士在刚降生的时候有一个初始的生命值,生命值在战斗中会发生变化,如果生命值减少到0(生命值变为负数时应当做变为0处理),则武士死亡(消失)。

有的武士可以拥有武器。武器有三种,sword, bomb,和arrow,编号分别为0,1,2。

武士降生后就朝对方司令部走,在经过的城市如果遇到敌人(同一时刻每个城市最多只可能有1个蓝武士和一个红武士),就会发生战斗。每次战斗只有一方发起主动进攻一次。被攻击者生命值会减去进攻者的攻击力值和进攻者手中sword的攻击力值。被进攻者若没死,就会发起反击,被反击者的生命值要减去反击者攻击力值的一半(去尾取整)和反击者手中sword的攻击力值。反击可能致敌人于死地。

如果武士在战斗中杀死敌人(不论是主动进攻杀死还是反击杀死),则其司令部会立即向其发送8个生命元作为奖励,使其生命值增加8。当然前提是司令部得有8个生命元。如果司令部的生命元不足以奖励所有的武士,则优先奖励距离敌方司令部近的武士。

如果某武士在某城市的战斗中杀死了敌人,则该武士的司令部立即取得该城市中所有的生命元。注意,司令部总是先完成全部奖励工作,然后才开始从各个打了胜仗的城市回收生命元。对于因司令部生命元不足而领不到奖励的武士,司令部也不会在取得战利品生命元后为其补发奖励。

如果一次战斗的结果是双方都幸存(平局),则双方都不能拿走发生战斗的城市的生命元。

城市可以插旗子,一开始所有城市都没有旗子。在插红旗的城市,以及编号为奇数的无旗城市,由红武士主动发起进攻。在插蓝旗的城市,以及编号为偶数的无旗城市,由蓝武士主动发起进攻。

当某个城市有连续两场战斗都是同一方的武士杀死敌人(两场战斗之间如果有若干个战斗时刻并没有发生战斗,则这两场战斗仍然算是连续的;但如果中间有平局的战斗,就不算连续了) ,那么该城市就会插上胜方的旗帜,若原来插着败方的旗帜,则败方旗帜落下。旗帜一旦插上,就一直插着,直到被敌人更换。一个城市最多只能插一面旗帜,旗帜没被敌人更换前,也不会再次插同颜色的旗。

各种武器有其特点:

sword武器的初始攻击力为拥有它的武士的攻击力的20%(去尾取整)。但是sword每经过一次战斗(不论是主动攻击还是反击),就会变钝,攻击力变为本次战斗前的80% (去尾取整)。sword攻击力变为0时,视为武士失去了sword。如果武士降生时得到了一个初始攻击力为0的sword,则视为武士没有sword.

arrow有一个攻击力值R。如果下一步要走到的城市有敌人,那么拥有arrow的武士就会放箭攻击下一个城市的敌人(不能攻击对方司令部里的敌人)而不被还击。arrow使敌人的生命值减少R,若减至小于等于0,则敌人被杀死。arrow使用3次后即被耗尽,武士失去arrow。两个相邻的武士可能同时放箭把对方射死。

拥有bomb的武士,在战斗开始前如果判断自己将被杀死(不论主动攻击敌人,或者被敌人主动攻击都可能导致自己被杀死,而且假设武士可以知道敌人的攻击力和生命值),那么就会使用bomb和敌人同归于尽。武士不预测对方是否会使用bomb。

武士使用bomb和敌人同归于尽的情况下,不算是一场战斗,双方都不能拿走城市的生命元,也不影响城市的旗帜。

不同的武士有不同的特点。

dragon可以拥有一件武器。编号为n的dragon降生时即获得编号为 n%3 的武器。dragon还有“士气”这个属性,是个浮点数,其值为它降生后其司令部剩余生命元的数量除以造dragon所需的生命元数量。dragon 在一次在它主动进攻的战斗结束后,如果还没有战死,而且士气值大于0.8,就会欢呼。dragon每取得一次战斗的胜利(敌人被杀死),士气就会增加0.2,每经历一次未能获胜的战斗,士气值就会减少0.2。士气增减发生在欢呼之前。

ninja可以拥有两件武器。编号为n的ninja降生时即获得编号为 n%3 和 (n+1)%3的武器。ninja 挨打了也从不反击敌人。

iceman有一件武器。编号为n的iceman降生时即获得编号为 n%3 的武器。iceman 每前进两步,在第2步完成的时候,生命值会减少9,攻击力会增加20。但是若生命值减9后会小于等于0,则生命值不减9,而是变为1。即iceman不会因走多了而死。

lion 有“忠诚度”这个属性,其初始值等于它降生之后其司令部剩余生命元的数目。每经过一场未能杀死敌人的战斗,忠诚度就降低K。忠诚度降至0或0以下,则该lion逃离战场,永远消失。但是已经到达敌人司令部的lion不会逃跑。Lion在己方司令部可能逃跑。lion 若是战死,则其战斗前的生命值就会转移到对手身上。所谓“战斗前”,就是每个小时的40分前的一瞬间。

wolf降生时没有武器,但是在战斗中如果获胜(杀死敌人),就会缴获敌人的武器,但自己已有的武器就不缴获了。被缴获的武器当然不能算新的,已经被用到什么样了,就是什么样的。

以下是不同时间会发生的不同事件:

在每个整点,即每个小时的第0分, 双方的司令部中各有一个武士降生。

红方司令部按照 iceman、lion、wolf、ninja、dragon 的顺序制造武士。

蓝方司令部按照 lion、dragon、ninja、iceman、wolf 的顺序制造武士。

制造武士需要生命元。

制造一个初始生命值为 m 的武士,司令部中的生命元就要减少 m 个。

如果司令部中的生命元不足以制造某武士,那么司令部就等待,直到获得足够生命元后的第一个整点,才制造该武士。例如,在2:00,红方司令部本该制造一个 wolf ,如果此时生命元不足,那么就会等待,直到生命元足够后的下一个整点,才制造一个 wolf。

在每个小时的第5分,该逃跑的lion就在这一时刻逃跑了。

在每个小时的第10分:所有的武士朝敌人司令部方向前进一步。即从己方司令部走到相邻城市,或从一个城市走到下一个城市。或从和敌军司令部相邻的城市到达敌军司令部。

在每个小时的第20分:每个城市产出10个生命元。生命元留在城市,直到被武士取走。

在每个小时的第30分:如果某个城市中只有一个武士,那么该武士取走该城市中的所有生命元,并立即将这些生命元传送到其所属的司令部。

在每个小时的第35分,拥有arrow的武士放箭,对敌人造成伤害。放箭事件应算发生在箭发出的城市。注意,放箭不算是战斗,因此放箭的武士不会得到任何好处。武士在没有敌人的城市被箭射死也不影响其所在城市的旗帜更换情况。

在每个小时的第38分,拥有bomb的武士评估是否应该使用bomb。如果是,就用bomb和敌人同归于尽。

在每个小时的第40分:在有两个武士的城市,会发生战斗。 如果敌人在5分钟前已经被飞来的arrow射死,那么仍然视为发生了一场战斗,而且存活者视为获得了战斗的胜利。此情况下不会有“武士主动攻击”,“武士反击”,“武士战死”的事件发生,但战斗胜利后应该发生的事情都会发生。如Wolf一样能缴获武器,旗帜也可能更换,等等。在此情况下,Dragon同样会通过判断是否应该轮到自己主动攻击来决定是否欢呼。

在每个小时的第50分,司令部报告它拥有的生命元数量。

在每个小时的第55分,每个武士报告其拥有的武器情况。

武士到达对方司令部后就算完成任务了,从此就呆在那里无所事事。

任何一方的司令部里若是出现了2个敌人,则认为该司令部已被敌人占领。

任何一方的司令部被敌人占领,则战争结束。战争结束之后就不会发生任何事情了。

给定一个时间,要求你将从0点0分开始到此时间为止的所有事件按顺序输出。事件及其对应的输出样例如下:

1) 武士降生

输出样例: 000:00 blue lion 1 born

表示在 0点0分,编号为1的蓝魔lion武士降生
如果造出的是dragon,那么还要多输出一行,例:

000:00 blue dragon 1 born
Its morale is 23.34

表示该该dragon降生时士气是23. 34(四舍五入到小数点后两位)

如果造出的是lion,那么还要多输出一行,例:
000:00 blue lion 1 born
Its loyalty is 24

表示该lion降生时的忠诚度是24

2) lion逃跑

输出样例: 000:05 blue lion 1 ran away
表示在 0点5分,编号为1的蓝魔lion武士逃走

3) 武士前进到某一城市

输出样例: 000:10 red iceman 1 marched to city 1 with 20 elements and force 30
表示在 0点10分,红魔1号武士iceman前进到1号城市,此时他生命值为20,攻击力为30
对于iceman,输出的生命值和攻击力应该是变化后的数值

4)武士放箭

输出样例: 000:35 blue dragon 1 shot
表示在 0点35分,编号为1的蓝魔dragon武士射出一支箭。如果射出的箭杀死了敌人,则应如下输出:
000:35 blue dragon 1 shot and killed red lion 4
表示在 0点35分,编号为1的蓝魔dragon武士射出一支箭,杀死了编号为4的红魔lion。

5)武士使用bomb

输出样例: 000:38 blue dragon 1 used a bomb and killed red lion 7
表示在 0点38分,编号为1的蓝魔dragon武士用炸弹和编号为7的红魔lion同归于尽。

6) 武士主动进攻

输出样例:000:40 red iceman 1 attacked blue lion 1 in city 1 with 20 elements and force 30
表示在0点40分,1号城市中,红魔1号武士iceman 进攻蓝魔1号武士lion,在发起进攻前,红魔1号武士iceman生命值为20,攻击力为 30

7) 武士反击

输出样例:001:40 blue dragon 2 fought back against red lion 2 in city 1
表示在1点40分,1号城市中,蓝魔2号武士dragon反击红魔2号武士lion

8) 武士战死

输出样例:001:40 red lion 2 was killed in city 1
被箭射死的武士就不会有这一条输出。

9) 武士欢呼

输出样例:003:40 blue dragon 2 yelled in city 4

10) 武士获取生命元( elements )

输出样例:001:40 blue dragon 2 earned 10 elements for his headquarter

输出不包括在30分不是通过战斗获取的elements

11) 旗帜升起

输出样例:004:40 blue flag raised in city 4

12) 武士抵达敌军司令部

输出样例:001:10 red iceman 1 reached blue headquarter with 20 elements and force 30
(此时他生命值为20,攻击力为30)对于iceman,输出的生命值和攻击力应该是变化后的数值

13) 司令部被占领

输出样例:003:10 blue headquarter was taken

14)司令部报告生命元数量

000:50 100 elements in red headquarter
000:50 120 elements in blue headquarter
表示在0点50分,红方司令部有100个生命元,蓝方有120个

15)武士报告武器情况

000:55 blue wolf 2 has arrow(2),bomb,sword(23)
000:55 blue wolf 4 has no weapon
000:55 blue wolf 5 has sword(20)
表示在0点55分,蓝魔2号武士wolf有一支arrow(这支arrow还可以用2次),一个bomb,还有一支攻击力为23的sword。
蓝魔4号武士wolf没武器。
蓝魔5号武士wolf有一支攻击力为20的sword。
交代武器情况时,次序依次是:arrow,bomb,sword。如果没有某种武器,某种武器就不用提。报告时,先按从西向东的顺序所有的红武士报告,然后再从西向东所有的蓝武士报告。

输出事件时:

首先按时间顺序输出;

同一时间发生的事件,按发生地点从西向东依次输出. 武士前进的事件, 算是发生在目的地。

在一次战斗中有可能发生上面的 6 至 11 号事件。这些事件都算同时发生,其时间就是战斗开始时间。一次战斗中的这些事件,序号小的应该先输出。

两个武士同时抵达同一城市,则先输出红武士的前进事件,后输出蓝武士的。

显然,13号事件发生之前的一瞬间一定发生了12号事件。输出时,这两件事算同一时间发生,但是应先输出12号事件

虽然任何一方的司令部被占领之后,就不会有任何事情发生了。但和司令部被占领同时发生的事件,全都要输出。

输入
第一行是t,代表测试数据组数
每组样例共三行。
第一行,五个整数 M,N,R,K, T。其含义为:

每个司令部一开始都有M个生命元( 1 <= M <= 10000)
两个司令部之间一共有N个城市( 1 <= N <= 20 )
arrow的攻击力是R
lion每经过一场未能杀死敌人的战斗,忠诚度就降低K。
要求输出从0时0分开始,到时间T为止(包括T) 的所有事件。T以分钟为单位,0 <= T <= 5000

第二行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的初始生命值。它们都大于0小于等于10000

第三行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的攻击力。它们都大于0小于等于10000

输出
对每组数据,先输出一行:
Case n:
如对第一组数据就输出 Case1:
然后按恰当的顺序和格式输出到时间T为止发生的所有事件。每个事件都以事件发生的时间开头,时间格式是“时: 分”,“时”有三位,“分”有两位。

样例输入

1
20 1 10 10 1000
20 20 30 10 20
5 5 5 5 5

样例输出

Case 1:
000:00 blue lion 1 born
Its loyalty is 10
000:10 blue lion 1 marched to city 1 with 10 elements and force 5
000:30 blue lion 1 earned 10 elements for his headquarter
000:50 20 elements in red headquarter
000:50 20 elements in blue headquarter
000:55 blue lion 1 has no weapon
001:00 blue dragon 2 born
Its morale is 0.00
001:10 blue lion 1 reached red headquarter with 10 elements and force 5
001:10 blue dragon 2 marched to city 1 with 20 elements and force 5
001:30 blue dragon 2 earned 10 elements for his headquarter
001:50 20 elements in red headquarter
001:50 10 elements in blue headquarter
001:55 blue lion 1 has no weapon
001:55 blue dragon 2 has arrow(3)
002:10 blue dragon 2 reached red headquarter with 20 elements and force 5
002:10 red headquarter was taken
#include<iomanip>#include<string>#include<iomanip>#include<vector>#include<set>using namespace std;//输入的顺序是dragon 、ninja、iceman、lion、wolf//红方司令部按照iceman、lion、wolf、ninja、dragon的顺序循环制造武士//蓝方司令部按照lion、dragon、ninja、iceman、wolf的顺序循环制造武士enum Cwpn { Csword, Cbomb, Carrow };//表示武器种类enum Cwor { Cdragon, Cninja, Ciceman, Clion, Cwolf };//表示武士种类enum Ckind { Cborn, Cescape, Cmarch, Crub, Cresult, Cyell, Creach_taken, Cleft_HP, Cwarrior_result };//表示事件种类enum Ccolor { Cred, Cblue };//表示武士或司令部的颜色enum Cflag { Credflag, Cblueflag, Cnoflag };//表示城市中的旗帜string string_wpn[3] = { "sword","bomb","arrow" };//武器的名字string string_wor[5] = { "dragon", "ninja", "iceman", "lion", "wolf" };//武士的名字string string_color[2] = { "red","blue" };//武士或司令部 颜色的名字int use_of_HP[5] = { 0 };//武士的生命值//待输入int attack[5] = { 0 };//武士的攻击力//待输入class city;class headquarter;class warrior;class dragon;class ninja;class iceman;class lion;class wolf;class weapon;class sword;class bomb;class arrow;int nowtime = 0;//从0开始的分钟数int minute = 0;int hour = 0;int gr = 0;int M = 0, N = 0, R = 0, K = 0, T = 0;//M-初始生命元 N-中间城市数 R-arrow攻击力 K-lion每走一步忠诚度降低K T-要输出0~T分钟所有事件bool endflag = false;//游戏结束标志//======================================================================================================//标记该做第几个武士 的数 +1int plus_one(int a){	if (a <= 3)  return a + 1;	else  return 0;}//======================================================================================================class city{public:	int num;//编号	Cflag flag = Cnoflag;	int HP;	int HP_win_get = 0;	warrior * warrior_in_city[2] = { NULL,NULL };//城市中的武士	warrior * warrior_in_city_temp[2] = { NULL,NULL };	int warrior_in_city_num = 0;//城市中武士的数目(射箭之前),只能为0,1,2	int fight_die_mark = 0;//记录战死的情况(真的发生了一对一的战斗)0-没人死,1-红的死,2-蓝的死,3-红蓝都死	int arrow_die_mark = 0;//记录被箭射死的情况:0-没人死,1-红的死,2-蓝的死,3-红蓝都死	int change_flag = 0;//记录胜负数量用于决定什么时候换旗	int lion_HP_mark[2] = { 0,0 };	void produce_HP();};city mycity[21];//------------------------------------------//武士class warrior{public:	Ccolor color;//颜色	Cwor kind;//种族	int ID;//编号	int HP;//生命值	int ATT;//攻击力	headquarter * home;//指向他出生的司令部	int place;//在哪个位置	weapon * weapon_ptr[3] = { NULL,NULL,NULL };//指向武士拥有的武器,sword bomb arrow对号入座	double morale;//士气值,对dragon以外没用	int loyalty;//忠诚度,对lion以外没用	int go_on_step = 0;//走的步数,对iceman以外没用		warrior(int hHP, int total, Ccolor headcolor);	void march();	virtual void rob_unsure() {}	virtual ~warrior();	void fight(warrior* ptr);	void fightback(warrior* ptr);};class dragon :public warrior{public:	dragon(int hHP, int total, Ccolor headcolor); //此时司令部中怪物总数还没有++};class ninja :public warrior{public:	ninja(int hHP, int total, Ccolor headcolor);//此时司令部中怪物总数还没有++};class iceman:public warrior{public:	iceman(int hHP, int total, Ccolor headcolor);//此时司令部中怪物总数还没有++};class lion :public warrior{public:	lion(int hHP, int total, Ccolor headcolor);//此时司令部中怪物总数还没有++};class wolf :public warrior{public:	wolf(int hHP, int total, Ccolor headcolor);//此时司令部中怪物总数还没有++};//------------------------------------------class weapon {public:	int beiyong = 0;	warrior* owner = NULL;	virtual int & get_ATT() = 0;	virtual int & get_left_time() = 0;	virtual void left_time_minus_one() {};	virtual void blunt();	weapon(warrior* ptr);};class sword :public weapon {public:	int ATT;	sword(warrior* ptr);	virtual int & get_ATT();	virtual void blunt();	virtual int & get_left_time();};class bomb :public weapon {public:	bomb(warrior* ptr);	virtual int & get_ATT();	virtual int & get_left_time();};class arrow :public weapon {public:	int ATT = R;	int left_time = 3;	arrow(warrior* ptr);	virtual int & get_left_time();	virtual void left_time_minus_one();	virtual int & get_ATT();};//------------------------------------------class headquarter :public city{public:	Ccolor color;//颜色	int HP = 0;//生命元	vector<warrior*> warrior_ptr;//司令部生产的的武士列表(未完全删除!!!!)	int total_num = 0;//该司令部所拥有的武士总数(不管死活)	int exist_num = 0;//该司令部所拥有的活着的武士总数	int num_of_warrior[5] = { 0 };//每种武士的数目,按题中统一的顺序	warrior* warrior_in_headquarter[2] = { NULL,NULL };//目前站在司令部的武士	warrior* warrior_in_headquarter_temp[2] = { NULL,NULL };	warrior* warrior_do_nothing[2] = { NULL,NULL };//到达司令部无所事事的武士列表	int warrior_do_nothing_counter = 0;	int occupy_num = 0;//此司令部已经有多少敌军	int order[5] = { 0 };//生产顺序	int to_make = 0;//该制造(按他自己的标准排的)第几种武士了	//bool stop_or_not = false;//是否不再生产武士	headquarter() {}; //构造函数	bool able_to_make_temp();//是否还能继续制造眼下即将要制造的武士,能-true 不能-false	void make_warrior();//制造一个武士	void print_HP();//报告生命元数量};headquarter red, blue;//======================================================================================================//city成员函数void city::produce_HP() {	this->HP += 10;	return;}//---------------------------------------------------------------------//warrior类成员函数warrior::warrior(int hHP, int total, Ccolor headcolor) {	color = headcolor;	if (color == Cred) {		home = &red;		place = 0;	}	else {		home = &blue;		place = N + 1;	}	ID = total + 1;}//武士前进一步void warrior::march() {	if (color == Cred) {		if (place == 0) {//武士还在司令部			place++;			mycity[place].warrior_in_city_temp[0] = this;		}		else if (place >= 1 && place <= N - 1) {			mycity[place].warrior_in_city[0] = NULL;			place++;			mycity[place].warrior_in_city_temp[0] = this;		}		else if (place == N) {			mycity[place].warrior_in_city[0] = NULL;			place++;			blue.warrior_in_headquarter_temp[0] = this;			blue.warrior_do_nothing[blue.warrior_do_nothing_counter] = this;			blue.warrior_do_nothing_counter++;		}	}	else {		if (place == N + 1) {			place--;			mycity[place].warrior_in_city_temp[1] = this;		}		else if (place >= 2 && place <= N) {			mycity[place].warrior_in_city[1] = NULL;			place--;			mycity[place].warrior_in_city_temp[1] = this;		}		else if (place == 1) {			mycity[place].warrior_in_city[1] = NULL;			place--;			red.warrior_in_headquarter_temp[1] = this;			red.warrior_do_nothing[red.warrior_do_nothing_counter] = this;			red.warrior_do_nothing_counter++;		}	}	if (kind == Ciceman) {		go_on_step++;		if (go_on_step % 2 == 0) {			ATT += 20;			if (HP <= 9)				HP = 1;			else HP -= 9;		}	}}warrior::~warrior() {	home->exist_num--;	home->num_of_warrior[kind]--;}void warrior::fight(warrior* ptr) {	if (weapon_ptr[0] != NULL) {//有sword		ptr->HP = ptr->HP - ATT - weapon_ptr[0]->get_ATT();		weapon_ptr[0]->blunt();		if (weapon_ptr[0]->get_ATT() <= 0)			weapon_ptr[0] = NULL;	}	else if (weapon_ptr[0] == NULL)//没有sword		ptr->HP -= ATT;}void warrior::fightback(warrior* ptr) {	if (kind != Cninja) {		if (weapon_ptr[0] != NULL) {//有sword			ptr->HP = ptr->HP - ATT / 2 - weapon_ptr[0]->get_ATT();			weapon_ptr[0]->blunt();			if (weapon_ptr[0]->get_ATT() <= 0)				weapon_ptr[0] = NULL;		}		else if (weapon_ptr[0] == NULL)//没有sword			ptr->HP -= ATT / 2;	}}//dragon成员函数dragon::dragon(int hHP, int total, Ccolor headcolor) :warrior(hHP, total, headcolor) {//此时司令部中怪物总数还没有++	kind = Cdragon;	HP = use_of_HP[0];	ATT = attack[0];	double temp_hHP = hHP;	morale = temp_hHP / use_of_HP[0];	int weaponid = ID % 3;	switch (weaponid) {	case 0:weapon_ptr[0] = new sword(this); 		if (weapon_ptr[0]->get_ATT() == 0)			weapon_ptr[0] = NULL; 		break;	case 1:weapon_ptr[1] = new bomb(this); break;	case 2:weapon_ptr[2] = new arrow(this); break;	}}//ninja成员函数ninja::ninja(int hHP, int total, Ccolor headcolor) :warrior(hHP, total, headcolor) {//此时司令部中怪物总数还没有++	kind = Cninja;	HP = use_of_HP[1];	ATT = attack[1];	int weaponid;	for (int i = 0; i < 2; i++) {		if (i == 1) weaponid = (ID + 1) % 3;		else weaponid = ID % 3;		switch (weaponid) {		case 0:weapon_ptr[0] = new sword(this);			if (weapon_ptr[0]->get_ATT() == 0)				weapon_ptr[0] = NULL;			break;		case 1:weapon_ptr[1] = new bomb(this); break;		case 2:weapon_ptr[2] = new arrow(this); break;		}	}}//iceman成员函数iceman::iceman(int hHP, int total, Ccolor headcolor) :warrior(hHP, total, headcolor) {//此时司令部中怪物总数还没有++	kind = Ciceman;	HP = use_of_HP[2];	ATT = attack[2];	int weaponid = ID % 3;	switch (weaponid) {	case 0:weapon_ptr[0] = new sword(this); 		if (weapon_ptr[0]->get_ATT() == 0)			weapon_ptr[0] = NULL; 		break;	case 1:weapon_ptr[1] = new bomb(this); break;	case 2:weapon_ptr[2] = new arrow(this); break;	}}//lion成员函数lion::lion(int hHP, int total, Ccolor headcolor) :warrior(hHP, total, headcolor) {//此时司令部中怪物总数还没有++	kind = Clion;	HP = use_of_HP[3];	ATT = attack[3];	loyalty = hHP;}//wolf成员函数wolf::wolf(int hHP, int total, Ccolor headcolor) :warrior(hHP, total, headcolor) {//此时司令部中怪物总数还没有++	kind = Cwolf;	HP = use_of_HP[4];	ATT = attack[4];}//---------------------------------------------------------------------//weapon成员函数weapon::weapon(warrior* ptr) {	owner = ptr;}void weapon::blunt() {}//sword成员函数int & sword::get_ATT() {	return ATT;}sword::sword(warrior* ptr):weapon(ptr) {	ATT = ptr->ATT * 2 / 10;}void sword::blunt() {	ATT = ATT * 8 / 10;}int & sword::get_left_time() {	return beiyong;}//bomb成员函数bomb::bomb(warrior* ptr) :weapon(ptr) {};int & bomb::get_ATT() {	return beiyong;}int & bomb::get_left_time() {	return beiyong;}//arrow成员函数arrow::arrow(warrior* ptr) :weapon(ptr) {};int & arrow::get_left_time() {	return left_time;}void arrow::left_time_minus_one() {	left_time--;	if (left_time == 0)		owner->weapon_ptr[2] = NULL;}int & arrow::get_ATT() {	return beiyong;}//---------------------------------------------------------------------//headquarter成员函数//是否还能继续制造眼下即将要制造的武士,能-true 不能-falsebool headquarter::able_to_make_temp() {	return use_of_HP[order[to_make]] <= HP;}//制造一个武士void headquarter::make_warrior() {	HP -= use_of_HP[order[to_make]];	warrior* temp = NULL;	switch (order[to_make]) {	case 0:temp = new dragon(HP, total_num, color);		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " " << string_color[color] << " dragon " << temp->ID << " born" << endl;		cout << "Its morale is ";		printf("%.2f", temp->morale);		cout << endl;		break;	case 1:temp = new ninja(HP, total_num, color);		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " " << string_color[color] << " ninja " << temp->ID << " born" << endl;		break;	case 2:temp = new iceman(HP, total_num, color);		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " " << string_color[color] << " iceman " << temp->ID << " born" << endl;		break;	case 3:temp = new lion(HP, total_num, color);		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " " << string_color[color] << " lion " << temp->ID << " born" << endl;		cout << "Its loyalty is " << temp->loyalty << endl;		break;	case 4:temp = new wolf(HP, total_num, color);		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " " << string_color[color] << " wolf " << temp->ID << " born" << endl;		break;	}	warrior_in_headquarter[color] = temp;	++num_of_warrior[order[to_make]];	++total_num;	++exist_num;	to_make = plus_one(to_make);}//报告生命元数量void headquarter::print_HP() {	cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " " << HP << " elements in " << string_color[color] << " headquarter" << endl;}//======================================================================================================void mymove(warrior** src, warrior** dest) {	dest[0] = src[0]; src[0] = NULL;	dest[1] = src[1]; src[1] = NULL;	return;}void renew_warrior_in_city_num() {	for (int i = 1; i <= N; i++) {		mycity[i].warrior_in_city_num = 0;		for (int j = 0; j < 2; j++) {			if (mycity[i].warrior_in_city[j] != NULL) {				mycity[i].warrior_in_city_num++;			}		}	}}void march_print(){	if (red.warrior_in_headquarter[1] != NULL) {		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[red.warrior_in_headquarter[1]->kind] << " " << red.warrior_in_headquarter[1]->ID << " reached red headquarter with " << red.warrior_in_headquarter[1]->HP << " elements and force " << red.warrior_in_headquarter[1]->ATT << endl;		red.occupy_num++;	}	if (red.occupy_num == 2){		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red headquarter was taken" << endl;		endflag = true;	}	for (int i = 1; i <= N; i++) {		for (int j = 0; j < 2; j++) {			if (mycity[i].warrior_in_city[j] != NULL) {				cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " " << string_color[j] << " " << string_wor[mycity[i].warrior_in_city[j]->kind] << " " << mycity[i].warrior_in_city[j]->ID << " marched to city " << i << " with " << mycity[i].warrior_in_city[j]->HP << " elements and force " << mycity[i].warrior_in_city[j]->ATT << endl;			}		}	}	if (blue.warrior_in_headquarter[0] != NULL) {		cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[blue.warrior_in_headquarter[0]->kind] << " " << blue.warrior_in_headquarter[0]->ID << " reached blue headquarter with " << blue.warrior_in_headquarter[0]->HP << " elements and force " << blue.warrior_in_headquarter[0]->ATT << endl;		blue.occupy_num++;		if (blue.occupy_num == 2) {			cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue headquarter was taken" << endl;			endflag = true;		}	}}//======================================================================================================//======================================================================================================//======================================================================================================//让该逃跑的狮子逃跑void lion_ecsape() {	if (red.warrior_in_headquarter[0] != NULL) {		if (red.warrior_in_headquarter[0]->kind == Clion) {			if (red.warrior_in_headquarter[0]->loyalty <= 0) {				cout << setw(3) << setfill('0') << hour << ":05 red lion " << red.warrior_in_headquarter[0]->ID << " ran away" << endl;				red.warrior_in_headquarter[0] = NULL;			}		}	}	for (int i = 1; i <= N; i++) {		for (int j = 0; j < 2; j++) {//先看红色再看蓝色			if (mycity[i].warrior_in_city[j] != NULL) {				if (mycity[i].warrior_in_city[j]->kind == Clion/*如果这位是lion*/) {					if (mycity[i].warrior_in_city[j]->loyalty <= 0) {						cout << setw(3) << setfill('0') << hour << ":05 " << string_color[j] << " lion " << mycity[i].warrior_in_city[j]->ID << " ran away" << endl;						mycity[i].warrior_in_city[j] = NULL;					}				}			}		}	}	if (blue.warrior_in_headquarter[1] != NULL) {		if (blue.warrior_in_headquarter[1]->kind == Clion) {			if (blue.warrior_in_headquarter[1]->loyalty <= 0) {				cout << setw(3) << setfill('0') << hour << ":05 blue lion " << blue.warrior_in_headquarter[1]->ID << " ran away" << endl;				blue.warrior_in_headquarter[1] = NULL;			}		}	}}//所有武士前进一步void warrior_march(){    for (int i = 0; i < 2; i++)		if (red.warrior_in_headquarter[i] != NULL)			red.warrior_in_headquarter[i]->march();	for (int i = 1; i <= N; i++)		for (int j = 0; j < 2; j++)			if (mycity[i].warrior_in_city[j] != NULL)				mycity[i].warrior_in_city[j]->march();	for (int i = 0; i < 2; i++)		if (blue.warrior_in_headquarter[i] != NULL)			blue.warrior_in_headquarter[i]->march();}//------------------------------------------------------------//武士放箭void warrior_shot_arrow() {	for (int i = 1; i <= N; i++)		mycity[i].arrow_die_mark = 0;	//红色司令部,只能红武士向右放箭射蓝武士	if (red.warrior_in_headquarter[0] != NULL && mycity[1].warrior_in_city[1] != NULL) {//存在一对敌人		if (red.warrior_in_headquarter[0]->weapon_ptr[2] != NULL) {//有arrow,可以放箭			red.warrior_in_headquarter[0]->weapon_ptr[2]->left_time_minus_one();//arrow减少			mycity[1].warrior_in_city[1]->HP -= R;//中箭的人HP减少			if (mycity[1].warrior_in_city[1]->HP <= 0) {//如果射死了				mycity[1].arrow_die_mark += 2;				cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[red.warrior_in_headquarter[0]->kind] << " " << red.warrior_in_headquarter[0]->ID << " shot and killed blue " << string_wor[mycity[1].warrior_in_city[1]->kind] <<" "<< mycity[1].warrior_in_city[1]->ID << endl;			}			else cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[red.warrior_in_headquarter[0]->kind] << " " << red.warrior_in_headquarter[0]->ID << " shot" << endl;		}	}	//city 1 red shot blue	if (mycity[1].warrior_in_city[0] != NULL && mycity[2].warrior_in_city[1] != NULL) {		if (mycity[1].warrior_in_city[0]->weapon_ptr[2] != NULL) {			mycity[1].warrior_in_city[0]->weapon_ptr[2]->left_time_minus_one();			mycity[2].warrior_in_city[1]->HP -= R;			if (mycity[2].warrior_in_city[1]->HP <= 0) {				mycity[2].arrow_die_mark += 2;				cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[1].warrior_in_city[0]->kind] << " " << mycity[1].warrior_in_city[0]->ID << " shot and killed blue " << string_wor[mycity[2].warrior_in_city[1]->kind] << " " << mycity[1 + 1].warrior_in_city[1]->ID << endl;			}			else cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[1].warrior_in_city[0]->kind] << " " << mycity[1].warrior_in_city[0]->ID << " shot" << endl;		}	}	//2~N-1的城市按序号依次筛选,红武士射蓝武士	for (int i = 2; i <= N-1; i++) {		if (mycity[i].warrior_in_city[0] != NULL && mycity[i + 1].warrior_in_city[1] != NULL) {			if (mycity[i].warrior_in_city[0]->weapon_ptr[2] != NULL) {				mycity[i].warrior_in_city[0]->weapon_ptr[2]->left_time_minus_one();				mycity[i + 1].warrior_in_city[1]->HP -= R;				if (mycity[i + 1].warrior_in_city[1]->HP <= 0) {					mycity[i + 1].arrow_die_mark += 2;					cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << " shot and killed blue " << string_wor[mycity[i+1].warrior_in_city[1]->kind] << " " << mycity[i + 1].warrior_in_city[1]->ID << endl;				}				else cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << " shot" << endl;			}		}		if (mycity[i].warrior_in_city[1] != NULL && mycity[i - 1].warrior_in_city[0] != NULL) {			if (mycity[i].warrior_in_city[1]->weapon_ptr[2] != NULL) {				mycity[i].warrior_in_city[1]->weapon_ptr[2]->left_time_minus_one();				mycity[i - 1].warrior_in_city[0]->HP -= R;				if (mycity[i - 1].warrior_in_city[0]->HP <= 0) {					mycity[i - 1].arrow_die_mark += 1;					cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << " shot and killed red " << string_wor[mycity[i - 1].warrior_in_city[0]->kind] << " " << mycity[i - 1].warrior_in_city[0]->ID << endl;				}				else cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << " shot" << endl;			}		}	}	if (mycity[N].warrior_in_city[1] != NULL && mycity[N-1].warrior_in_city[0] != NULL) {		if (mycity[N].warrior_in_city[1]->weapon_ptr[2] != NULL) {			mycity[N].warrior_in_city[1]->weapon_ptr[2]->left_time_minus_one();			mycity[N - 1].warrior_in_city[0]->HP -= R;			if (mycity[N - 1].warrior_in_city[0]->HP <= 0) {				mycity[N - 1].arrow_die_mark += 1;				cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[N].warrior_in_city[1]->kind] << " " << mycity[N].warrior_in_city[1]->ID << " shot and killed red " << string_wor[mycity[N - 1].warrior_in_city[0]->kind] << " " << mycity[N - 1].warrior_in_city[0]->ID << endl;			}			else cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[N].warrior_in_city[1]->kind] << " " << mycity[N].warrior_in_city[1]->ID << " shot" << endl;		}	}	//蓝色司令部,只能蓝武士射红武士	if (blue.warrior_in_headquarter[1] != NULL && mycity[N].warrior_in_city[0] != NULL) {		if (blue.warrior_in_headquarter[1]->weapon_ptr[2] != NULL) {			blue.warrior_in_headquarter[1]->weapon_ptr[2]->left_time_minus_one();			mycity[N].warrior_in_city[0]->HP -= R;			if (mycity[N].warrior_in_city[0]->HP <= 0) {				mycity[N].arrow_die_mark += 1;				cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[blue.warrior_in_headquarter[1]->kind] << " " << blue.warrior_in_headquarter[1]->ID << " shot and killed red " << string_wor[mycity[N].warrior_in_city[0]->kind] << " " << mycity[N].warrior_in_city[0]->ID << endl;			}			else cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[blue.warrior_in_headquarter[1]->kind] << " " << blue.warrior_in_headquarter[1]->ID << " shot" << endl;		}	}}//------------------------------------------------------------//武士放炸弹void warrior_use_bomb() {	for (int i = 1; i <= N; i++) {//逐个城市判断		if (mycity[i].warrior_in_city_num == 2)			if (mycity[i].warrior_in_city[0]->HP > 0 && mycity[i].warrior_in_city[1]->HP > 0) {				int red_ATT = mycity[i].warrior_in_city[0]->ATT;				int red_sword = 0;				if (mycity[i].warrior_in_city[0]->weapon_ptr[0] != NULL)					red_sword = mycity[i].warrior_in_city[0]->weapon_ptr[0]->get_ATT();				int blue_ATT = mycity[i].warrior_in_city[1]->ATT;				int blue_sword = 0;				if (mycity[i].warrior_in_city[1]->weapon_ptr[0] != NULL)					blue_sword = mycity[i].warrior_in_city[1]->weapon_ptr[0]->get_ATT();				int red_decide = 0;				int blue_decide = 0;				if (mycity[i].flag == Credflag || mycity[i].flag == Cnoflag && i % 2 == 1) {//红色先手					red_decide = blue_sword + blue_ATT / 2;					blue_decide = red_sword + red_ATT;					if (mycity[i].warrior_in_city[1]->kind != Cninja) {						if (blue_decide >= mycity[i].warrior_in_city[1]->HP							&& mycity[i].warrior_in_city[1]->weapon_ptr[1] != NULL) {//蓝武士用bomb							mycity[i].warrior_in_city[1]->weapon_ptr[1] = NULL;							mycity[i].warrior_in_city[0]->HP = 0; mycity[i].warrior_in_city[1]->HP = 0;							cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << " used a bomb and killed red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << endl;						}						else if (red_decide >= mycity[i].warrior_in_city[0]->HP							&& mycity[i].warrior_in_city[0]->weapon_ptr[1] != NULL							&& blue_decide < mycity[i].warrior_in_city[1]->HP) {//红武士用bomb							mycity[i].warrior_in_city[0]->weapon_ptr[1] = NULL;							mycity[i].warrior_in_city[0]->HP = 0; mycity[i].warrior_in_city[1]->HP = 0;							cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << " used a bomb and killed blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << endl;						}					}					else {						if (blue_decide >= mycity[i].warrior_in_city[1]->HP							&& mycity[i].warrior_in_city[1]->weapon_ptr[1] != NULL) {//蓝武士用bomb							mycity[i].warrior_in_city[1]->weapon_ptr[1] = NULL;							mycity[i].warrior_in_city[0]->HP = 0; mycity[i].warrior_in_city[1]->HP = 0;							cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << " used a bomb and killed red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << endl;						}					}				}				else if (mycity[i].flag == Cblueflag || mycity[i].flag == Cnoflag && i % 2 == 0) {//蓝色先手					red_decide = blue_ATT + blue_sword;					blue_decide = red_ATT / 2 + red_sword;					if (mycity[i].warrior_in_city[0]->kind != Cninja) {						if (red_decide >= mycity[i].warrior_in_city[0]->HP							&& mycity[i].warrior_in_city[0]->weapon_ptr[1] != NULL) {//红武士用bomb							mycity[i].warrior_in_city[0]->weapon_ptr[1] = NULL;							mycity[i].warrior_in_city[0]->HP = 0; mycity[i].warrior_in_city[1]->HP = 0;							cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << " used a bomb and killed blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << endl;						}						else if (blue_decide >= mycity[i].warrior_in_city[1]->HP							&& mycity[i].warrior_in_city[1]->weapon_ptr[1] != NULL							&& red_decide < mycity[i].warrior_in_city[0]->HP) {//蓝武士用bomb							mycity[i].warrior_in_city[1]->weapon_ptr[1] = NULL;							mycity[i].warrior_in_city[0]->HP = 0; mycity[i].warrior_in_city[1]->HP = 0;							cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << " used a bomb and killed red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << endl;						}					}					else {						if (red_decide >= mycity[i].warrior_in_city[0]->HP							&& mycity[i].warrior_in_city[0]->weapon_ptr[1] != NULL) {//红武士用bomb							mycity[i].warrior_in_city[0]->weapon_ptr[1] = NULL;							mycity[i].warrior_in_city[0]->HP = 0; mycity[i].warrior_in_city[1]->HP = 0;							cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << " used a bomb and killed blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << endl;						}					}				}			}	}}//------------------------------------------------------------//此处已经保证了双方都有血 // 攻击顺序 // i-城市编号void attack_between_two(int i, warrior * wred, warrior * wblue){	if (mycity[i].flag == Credflag || mycity[i].flag == Cnoflag && i % 2 == 1) {//红色先手		wred->fight(wblue);		cout << setw(3) << setfill('0') << hour << ":40 red " << string_wor[wred->kind] << " " << wred->ID << " attacked blue " << string_wor[wblue->kind] << " " << wblue->ID << " in city " << i << " with " << wred->HP << " elements and force " << wred->ATT << endl;		if (wblue->HP > 0) {//蓝色没死,则反击			wblue->fightback(wred);			if (wblue->kind != Cninja)				cout << setw(3) << setfill('0') << hour << ":40 blue " << string_wor[wblue->kind] << " " << wblue->ID << " fought back against red " << string_wor[wred->kind] << " " << wred->ID << " in city " << i << endl;			if (wred->HP <= 0) {//蓝色反击杀死红色				cout << setw(3) << setfill('0') << hour << ":40 red " << string_wor[wred->kind] << " " << wred->ID << " was killed in city " << i << endl;				mycity[i].fight_die_mark += 1;			}		}		else {//红色杀死蓝色			cout << setw(3) << setfill('0') << hour << ":40 blue " << string_wor[wblue->kind] << " " << wblue->ID << " was killed in city " << i << endl;			mycity[i].fight_die_mark += 2;		}	}	else if (mycity[i].flag == Cblueflag || mycity[i].flag == Cnoflag && i % 2 == 0) {//蓝色先手		wblue->fight(wred);		cout << setw(3) << setfill('0') << hour << ":40 blue " << string_wor[wblue->kind] << " " << wblue->ID << " attacked red " << string_wor[wred->kind] << " " << wred->ID << " in city " << i << " with " << wblue->HP << " elements and force " << wblue->ATT << endl;		if (wred->HP > 0) {//红色没死,则反击			wred->fightback(wblue);			if (wred->kind != Cninja)				cout << setw(3) << setfill('0') << hour << ":40 red " << string_wor[wred->kind] << " " << wred->ID << " fought back against blue " << string_wor[wblue->kind] << " " << wblue->ID << " in city " << i << endl;			if (wblue->HP <= 0) {//红色反击杀死蓝色				cout << setw(3) << setfill('0') << hour << ":40 blue " << string_wor[wblue->kind] << " " << wblue->ID << " was killed in city " << i << endl;				mycity[i].fight_die_mark += 2;			}		}		else {//蓝色杀死红色			cout << setw(3) << setfill('0') << hour << ":40 red " << string_wor[wred->kind] << " " << wred->ID << " was killed in city " << i << endl;			mycity[i].fight_die_mark += 1;		}	}}void attack_in_world(){//发生战斗	for (int i = 1; i <= N; i++) {//逐个城市看有没有战争,如果有,进行战争		//fight and fight back		mycity[i].fight_die_mark = 0;		if (mycity[i].warrior_in_city[0] != NULL && mycity[i].warrior_in_city[1] != NULL){			if (mycity[i].warrior_in_city[0]->HP > 0 && mycity[i].warrior_in_city[1]->HP > 0) {				attack_between_two(i, mycity[i].warrior_in_city[0], mycity[i].warrior_in_city[1]);			}		}		//dragon yell		if (mycity[i].warrior_in_city_num == 2) {			for (int j = 0; j < 2; j++) {//先看红色再看蓝色				if (mycity[i].warrior_in_city[j]->kind == Cdragon/*如果这位是dragon*/) {					if (mycity[i].warrior_in_city[j]->HP > 0/*这位活着*/) {						if (mycity[i].warrior_in_city[1 - j]->HP <= 0/*另一位死了*/)							mycity[i].warrior_in_city[j]->morale += 0.2;						else if (mycity[i].warrior_in_city[1 - j]->HP > 0/*另一位也活着*/)							mycity[i].warrior_in_city[j]->morale -= 0.2;						if (mycity[i].warrior_in_city[j]->color == mycity[i].flag || (mycity[i].flag == Cnoflag && (i + 1) % 2 == j))							if (mycity[i].warrior_in_city[j]->morale > 0.8)								cout << setw(3) << setfill('0') << hour << ":40 " << string_color[j] << " dragon " << mycity[i].warrior_in_city[j]->ID << " yelled in city " << i << endl;					}				}			}		}		//wolf rob		if (mycity[i].warrior_in_city_num == 2) {			for (int j = 0; j < 2; j++) {//先看红色再看蓝色				if (mycity[i].warrior_in_city[j]->kind == Cwolf/*如果这位是wolf*/) {					if (mycity[i].warrior_in_city[j]->HP > 0/*这位活着*/) {						if (mycity[i].warrior_in_city[1 - j]->HP <= 0/*另一位死了*/) {							for (int k = 0; k < 3; k++) {								if (mycity[i].warrior_in_city[j]->weapon_ptr[k] == NULL && mycity[i].warrior_in_city[1 - j]->weapon_ptr[k] != NULL) {									mycity[i].warrior_in_city[j]->weapon_ptr[k] = mycity[i].warrior_in_city[1 - j]->weapon_ptr[k];									mycity[i].warrior_in_city[1 - j]->weapon_ptr[k] = NULL;									mycity[i].warrior_in_city[j]->weapon_ptr[k]->owner = mycity[i].warrior_in_city[j];								}							}						}					}				}			}		}		//get HP(temp) and change flag		if (mycity[i].warrior_in_city_num == 2) {			if (mycity[i].warrior_in_city[0]->HP > 0 && mycity[i].warrior_in_city[1]->HP <= 0) {				if (mycity[i].change_flag <= 0)					mycity[i].change_flag -= 1;				else mycity[i].change_flag = -1;				mycity[i].warrior_in_city[0]->home->HP_win_get += mycity[i].HP;				cout << setw(3) << setfill('0') << hour << ":40 red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << " earned "<<mycity[i].HP<<" elements for his headquarter" << endl;				mycity[i].HP = 0;				//if (i == 9)cout << "红色赢一次 红色赢一次 红色赢一次 红色赢一次 红色赢一次 红色赢一次 红色赢一次 红色赢一次 红色赢一次 红色赢一次" << endl;			}			else if (mycity[i].warrior_in_city[0]->HP <= 0 && mycity[i].warrior_in_city[1]->HP > 0) {				if(mycity[i].change_flag>=0)					mycity[i].change_flag += 1;				else mycity[i].change_flag = 1;				mycity[i].warrior_in_city[1]->home->HP_win_get += mycity[i].HP;				cout << setw(3) << setfill('0') << hour << ":40 blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << " earned " << mycity[i].HP << " elements for his headquarter" << endl;				mycity[i].HP = 0;				//if (i == 9)cout << "蓝色赢一次 蓝色赢一次 蓝色赢一次 蓝色赢一次 蓝色赢一次 蓝色赢一次 蓝色赢一次 蓝色赢一次 蓝色赢一次 蓝色赢一次" << endl;			}			else if (mycity[i].warrior_in_city[0]->HP > 0 && mycity[i].warrior_in_city[1]->HP > 0) {				mycity[i].change_flag = 0;				//if(i==9) cout << "平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局 平局" << endl;			}			//else if (i == 9) cout << "无事发生 无事发生 无事发生 无事发生 无事发生 无事发生 无事发生 无事发生 无事发生 无事发生 无事发生 无事发生" << endl;			//----------------change flag------------------			if (mycity[i].change_flag == -2) {				Cflag temp = mycity[i].flag;				mycity[i].flag = Credflag;				if(temp!=Credflag)					cout << setw(3) << setfill('0') << hour << ":40 red flag raised in city " << i << endl;			}			else if (mycity[i].change_flag == 2) {				Cflag temp = mycity[i].flag;				mycity[i].flag = Cblueflag;				if (temp != Cblueflag)					cout << setw(3) << setfill('0') << hour << ":40 blue flag raised in city " << i << endl;			}		}	}	//红色司令部奖励武士	for (int i = N; i >= 1; i--)		if (mycity[i].warrior_in_city_num == 2)			if (mycity[i].warrior_in_city[0]->HP > 0 && mycity[i].warrior_in_city[1]->HP <= 0 && red.HP >= 8) {				mycity[i].warrior_in_city[0]->HP += 8;				red.HP -= 8;			}	//蓝色司令部奖励武士	for (int i = 1; i <= N; i++)		if (mycity[i].warrior_in_city_num == 2)			if (mycity[i].warrior_in_city[1]->HP > 0 && mycity[i].warrior_in_city[0]->HP <= 0 && blue.HP >= 8) {				mycity[i].warrior_in_city[1]->HP += 8;				blue.HP -= 8;			}	red.HP += red.HP_win_get; red.HP_win_get = 0;	blue.HP += blue.HP_win_get; blue.HP_win_get = 0;}//------------------------------------------------------------void record_lion_HP() {	for (int i = 1; i <= N; i++) {		for (int j = 0; j < 2; j++) {//先看红色再看蓝色			if (mycity[i].warrior_in_city[j] != NULL) {				if (mycity[i].warrior_in_city[j]->kind == Clion/*如果这位是lion*/) {					if (mycity[i].warrior_in_city[j]->HP > 0/*这位活着*/) {						mycity[i].lion_HP_mark[j] = mycity[i].warrior_in_city[j]->HP;					}				}			}		}	}}void lion_alive_loyalty_decrease() {	for (int i = 1; i <= N; i++) {		if (mycity[i].warrior_in_city_num == 2) {			for (int j = 0; j < 2; j++) {//先看红色再看蓝色				if (mycity[i].warrior_in_city[j]->kind == Clion/*如果这位是lion*/) {					if (mycity[i].warrior_in_city[j]->HP > 0/*这位活着*/) {						if (mycity[i].warrior_in_city[1 - j]->HP > 0/*另一位没死*/) {							mycity[i].warrior_in_city[j]->loyalty -= K;						}					}				}			}		}	}}void lion_dead_HP_move() {	for (int i = 1; i <= N; i++) {		if (mycity[i].warrior_in_city_num == 2) {			for (int j = 0; j < 2; j++) {//先看红色再看蓝色				if (mycity[i].warrior_in_city[j]->kind == Clion/*如果这位是lion*/) {					if (mycity[i].warrior_in_city[j]->HP <= 0/*这位死了*/) {						if (mycity[i].warrior_in_city[1 - j]->HP > 0/*另一位没死*/) {							mycity[i].warrior_in_city[1 - j]->HP += mycity[i].lion_HP_mark[j];						}					}				}			}		}	}}void delete_dead() {	for (int i = 1; i <= N; i++) {		for (int j = 0; j < 2; j++) {			if (mycity[i].warrior_in_city[j]!=NULL) {				if (mycity[i].warrior_in_city[j]->HP <= 0) {					mycity[i].warrior_in_city[j] = NULL;				}			}		}	}}//------------------------------------------------------------void print_weapon(warrior* tempwarrior) {	if (tempwarrior->weapon_ptr[0] == NULL && tempwarrior->weapon_ptr[1] == NULL && tempwarrior->weapon_ptr[2] == NULL)		cout << setw(3) << setfill('0') << hour << ":55 " << string_color[tempwarrior->color] << " " << string_wor[tempwarrior->kind] << " " << tempwarrior->ID << " has no weapon" << endl;	else {		cout << setw(3) << setfill('0') << hour << ":55 " << string_color[tempwarrior->color] << " " << string_wor[tempwarrior->kind] << " " << tempwarrior->ID << " has ";		bool first_flag = true;		for (int k = 2; k >= 0; k--) {			if (tempwarrior->weapon_ptr[k] != NULL) {				if (first_flag == false)  cout << ",";				switch (k) {				case 0:cout << "sword(" << tempwarrior->weapon_ptr[k]->get_ATT() << ")";					break;				case 1:cout << "bomb";					break;				case 2:cout << "arrow(" << tempwarrior->weapon_ptr[k]->get_left_time() << ")";					break;				}				first_flag = false;			}		}		cout << endl;	}}void warrior_report() {	for (int j = 0; j < 2; j++) {		if (j == 1) {			for (int k = 0; k < 2; k++) {				warrior* tempwarrior = red.warrior_do_nothing[k];				if (tempwarrior != NULL)					print_weapon(tempwarrior);			}		}		for (int i = 1; i <= N; i++) {			warrior* tempwarrior = mycity[i].warrior_in_city[j];			if (tempwarrior != NULL) {				print_weapon(tempwarrior);			}		}		if (j == 0) {			for (int k = 0; k < 2; k++) {				warrior* tempwarrior = blue.warrior_do_nothing[k];				if (tempwarrior != NULL)					print_weapon(tempwarrior);			}		}	}}//======================================================================================================void timepass(int endtime){	while (nowtime <= endtime && endflag != true) {		minute = nowtime % 60;		hour = nowtime / 60;		switch (minute){		case 0:			//先判断能不能制造			if (red.able_to_make_temp() == true)				red.make_warrior();			if (blue.able_to_make_temp() == true)				blue.make_warrior();			break;		case 5:			lion_ecsape();			break;		case 10:			warrior_march();			//从temp搬到正式的数组里			mymove(red.warrior_in_headquarter_temp, red.warrior_in_headquarter);			mymove(blue.warrior_in_headquarter_temp, blue.warrior_in_headquarter);			for (int i = 1; i <= N; i++)				mymove(mycity[i].warrior_in_city_temp, mycity[i].warrior_in_city);			march_print();			break;		case 20:			for (int i = 1; i <= N; i++)				mycity[i].produce_HP();			break;		case 30:			//没有对手的武士取走生命元			renew_warrior_in_city_num();			for (int i = 1; i <= N; i++) {				if (mycity[i].warrior_in_city_num == 1) {					if (mycity[i].warrior_in_city[0] != NULL) {//red						red.HP += mycity[i].HP;						cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " red " << string_wor[mycity[i].warrior_in_city[0]->kind] << " " << mycity[i].warrior_in_city[0]->ID << " earned "<<mycity[i].HP<<" elements for his headquarter" << endl;						mycity[i].HP = 0;					}					else if (mycity[i].warrior_in_city[1] != NULL) {						blue.HP += mycity[i].HP;						cout << setw(3) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute << " blue " << string_wor[mycity[i].warrior_in_city[1]->kind] << " " << mycity[i].warrior_in_city[1]->ID << " earned "<< mycity[i].HP<<" elements for his headquarter" << endl;						mycity[i].HP = 0;					}				}			}			break;		case 35:			//有arrow的武士放箭			warrior_shot_arrow();			break;		case 38:			//拥有bomb的武士评估是否应该使用bomb。如果是,就用bomb和敌人同归于尽			warrior_use_bomb();			break;		case 40:			for (int i = 1; i <= N; i++)				for (int j = 0; j < 2; j++)					mycity[i].lion_HP_mark[j] = 0;			record_lion_HP();			attack_in_world();			lion_alive_loyalty_decrease();//lion忠诚度修改			lion_dead_HP_move();//lion的HP转移			delete_dead();//删掉HP<=0的武士			break;		case 50:			red.print_HP();			blue.print_HP();			break;		case 55:			warrior_report();			break;		default:break;		}		++nowtime;	}}//======================================================================================================void reset() {	for (int i = 1; i <= N; i++) {		mycity[i].arrow_die_mark = 0;		mycity[i].change_flag = 0;		mycity[i].fight_die_mark = 0;		mycity[i].flag = Cnoflag;		mycity[i].HP = 0;		mycity[i].HP_win_get = 0;		for (int j = 0; j < 2; j++) {			mycity[i].warrior_in_city[j] = NULL;			mycity[i].warrior_in_city_temp[j] = NULL;			mycity[i].lion_HP_mark[j] = 0;		}		mycity[i].warrior_in_city_num = 0;	}	for (int j = 0; j < 2; j++) {		red.warrior_do_nothing[j] = NULL;		blue.warrior_do_nothing[j] = NULL;		red.warrior_in_headquarter[j] = NULL;		blue.warrior_in_headquarter[j] = NULL;		red.warrior_in_headquarter_temp[j] = NULL;		blue.warrior_in_headquarter_temp[j] = NULL;	}	red.total_num = 0; blue.total_num = 0;	red.HP_win_get = 0; blue.HP_win_get = 0;	red.occupy_num = 0; blue.occupy_num = 0;	red.to_make = 0; blue.to_make = 0;	red.change_flag = 0; red.warrior_do_nothing_counter = 0;	blue.change_flag = 0; blue.warrior_do_nothing_counter = 0;	endflag = false;	nowtime = 0; minute = 0; hour = 0;}//======================================================================================================int main(){	red.color = Cred; 	blue.color = Cblue; 	red.order[0] = 2;red.order[1] = 3;red.order[2] = 4;red.order[3] = 1;red.order[4] = 0;	blue.order[0] = 3; blue.order[1] = 0; blue.order[2] = 1; blue.order[3] = 2; blue.order[4] = 4;	cin >> gr;	int counter = 1;	while (gr > 0) {		reset();		cout << "Case " << counter << ":" << endl;		cin >> M >> N >> R >> K >> T;		red.HP = M; blue.HP = M;		for (int i = 0; i < 5; i++)			cin >> use_of_HP[i];		for (int i = 0; i < 5; i++)			cin >> attack[i];		timepass(T);		counter++;		gr--;	}	return 0;}
发布了40 篇原创文章 · 获赞 1 · 访问量 586
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!