Description:
魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为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 bornIts morale is 23.34
表示该该dragon降生时士气是23. 34(四舍五入到小数点后两位)
如果造出的是lion,那么还要多输出一行,例:000:00 blue lion 1 bornIts 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 headquarter000: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 weapon000: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号事件
虽然任何一方的司令部被占领之后,就不会有任何事情发生了。但和司令部被占领同时发生的事件,全都要输出。
Input:
第一行是t,代表测试数据组数每组样例共三行。第一行,五个整数 M,N,R,K, T。其含义为:
每个司令部一开始都有M个生命元( 1 <= M <= 10000)两个司令部之间一共有N个城市( 1 <= N <= 20 )arrow的攻击力是Rlion每经过一场未能杀死敌人的战斗,忠诚度就降低K。要求输出从0时0分开始,到时间T为止(包括T) 的所有事件。T以分钟为单位,0 <= T <= 5000
第二行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的初始生命值。它们都大于0小于等于10000
第三行:五个整数,依次是 dragon 、ninja、iceman、lion、wolf 的攻击力。它们都大于0小于等于10000
Output:
对每组数据,先输出一行:
Case n:
如对第一组数据就输出 Case1:
然后按恰当的顺序和格式输出到时间T为止发生的所有事件。每个事件都以事件发生的时间开头,时间格式是“时: 分”,“时”有三位,“分”有两位。
Sample Input 1:
1
20 1 10 10 1000
20 20 30 10 20
5 5 5 5 5
Sample Output 1:
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
代码:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 #include<iostream> 2 #include<fstream> 3 #include<string> 4 #include<iomanip> 5 #include<vector> 6 using namespace std; 7 #define INT_MAX 2147483647 8 static int Round; //小时数 9 static int R; //arrow的攻击力 10 static int K; //lion减小的忠诚 11 class BaseWeapon 12 { 13 public: 14 int type = 0; 15 int attack; 16 BaseWeapon(int x, int t) :attack(x), type(t) {} 17 virtual int getAttack() { return attack; }; 18 virtual int getTimes() { return 0; } 19 }; 20 21 class Sword :public BaseWeapon 22 { 23 public: 24 Sword(int x) :BaseWeapon(x, 0) {} 25 int getAttack() { 26 int ret = attack; 27 attack = attack*0.8; 28 return ret; 29 } 30 }; 31 32 class Arrow :public BaseWeapon 33 { 34 public: 35 int times = 3; 36 Arrow(int R) :BaseWeapon(R, 2) {} 37 int getAttack() { 38 times--; 39 return attack; 40 } 41 int getTimes() { 42 return times; 43 } 44 }; 45 46 class Bomb :public BaseWeapon 47 { 48 public: 49 Bomb() :BaseWeapon(0, 1) {} 50 }; 51 52 class BaseSoldier; 53 54 class city 55 { 56 public: 57 BaseSoldier* red_ = NULL, *blue_ = NULL; 58 int elements = 0, flag = 0, count_r = 0, count_b = 0; 59 city(int x = 0) :elements(x) {} 60 }; 61 62 class BaseSoldier 63 { 64 public: 65 int id, attack, HP; 66 vector<BaseWeapon*> weapons; 67 bool isWin = false, isLion = false; 68 string com; 69 BaseSoldier(int id_, int HP_, int attack_, vector<BaseWeapon*> w, string c = "red", bool b = false) :id(id_), HP(HP_), attack(attack_), weapons(w), isLion(b), com(c) { 70 if (weapons[0] && weapons[0]->attack == 0) weapons[0] = NULL; 71 } 72 virtual string getName() { return NULL; } 73 virtual void march() {} 74 virtual int getLoyalty() { return INT_MAX; } 75 bool hasArrow() { 76 if (weapons[2] != NULL) { 77 weapons[2]->getAttack(); 78 if (!weapons[2]->getTimes()) 79 weapons[2] = NULL; 80 return true; 81 } 82 return false; 83 } 84 int getAttack(int& weaponAttack) { 85 if (weapons[0] == NULL) 86 weaponAttack = 0; 87 else 88 weaponAttack = weapons[0]->attack; 89 return attack; 90 } 91 void coutweapon() { 92 bool hasWeapon = false; 93 if (weapons[2] != NULL) { 94 hasWeapon = true; 95 cout << "arrow(" << weapons[2]->getTimes() << ')'; 96 } 97 if (weapons[1] != NULL) { 98 if (hasWeapon) 99 cout << ','; 100 cout << "bomb"; 101 hasWeapon = true; 102 } 103 if (weapons[0] != NULL) { 104 if (hasWeapon) 105 cout << ','; 106 cout << "sword(" << weapons[0]->attack << ')'; 107 hasWeapon = true; 108 } 109 if (!hasWeapon) 110 cout << "no weapon"; 111 cout << endl; 112 } 113 virtual void fightback(BaseSoldier* enermy, int city) { 114 cout << setw(3) << setfill('0') << Round << ":40 " << com << ' ' << this->getName() << ' ' << id << " fought back against " << enermy->com << ' ' << enermy->getName() << ' ' << enermy->id << " in city " << city << endl; 115 int earn = 0; 116 if (enermy->isLion) 117 earn = enermy->HP; 118 enermy->HP -= (attack / 2); 119 if (weapons[0] != NULL) { 120 enermy->HP -= weapons[0]->getAttack(); 121 if (weapons[0]->attack == 0) 122 weapons[0] = NULL; 123 } 124 if (enermy->HP <= 0) { 125 HP += earn; 126 isWin = 1; 127 } 128 } 129 virtual void fight(BaseSoldier* enermy, int city) { 130 int earn = 0; 131 if (enermy->HP > 0) { //敌人在先前没有被箭射死 132 cout << setw(3) << setfill('0') << Round << ":40 " << com << ' ' << this->getName() << ' ' << id << " attacked " << enermy->com << ' ' << enermy->getName() << ' ' << enermy->id << " in city " << city << " with "; 133 cout << HP << " elements and force " << attack << endl; 134 if (enermy->isLion) 135 earn = enermy->HP; 136 enermy->HP -= attack; 137 if (weapons[0] != NULL) { 138 enermy->HP -= weapons[0]->getAttack(); 139 if (weapons[0]->attack == 0) 140 weapons[0] = NULL; 141 } 142 if (enermy->HP > 0) { 143 enermy->fightback(this, city); 144 } 145 else { 146 HP += earn; 147 isWin = 1; 148 } 149 } 150 else { 151 isWin = 1; 152 } 153 } 154 virtual void shout(int num) {} 155 virtual double getMo() { return 0; } 156 }; 157 158 class dragon :public BaseSoldier 159 { 160 public: 161 double morale; 162 dragon(int id_, double mor, int HP, int attack_, vector<BaseWeapon*> we, string com) :BaseSoldier(id_, HP, attack_, we, com), morale(mor) {} 163 string getName() { 164 return "dragon"; 165 } 166 virtual double getMo() { return morale; } 167 void fight(BaseSoldier* enermy, int num) { 168 BaseSoldier::fight(enermy, num); 169 if (isWin) 170 morale += 0.2; 171 else 172 morale -= 0.2; 173 } 174 void fightback(BaseSoldier* enermy, int num) { 175 BaseSoldier::fightback(enermy, num); 176 if (isWin) 177 morale += 0.2; 178 else 179 morale -= 0.2; 180 } 181 void shout(int num) { 182 if (morale > 0.8) { 183 cout << setw(3) << setfill('0') << Round << ":40 " << com << " dragon " << id << " yelled in city " << num << endl; 184 } 185 } 186 }; 187 188 class ninja :public BaseSoldier 189 { 190 public: 191 ninja(int id_, int HP, int attack_, vector<BaseWeapon*> we, string com) :BaseSoldier(id_, HP, attack_, we, com) {} 192 string getName() { 193 return "ninja"; 194 } 195 void fightback(BaseSoldier* enermy, int city) { return; } 196 }; 197 198 class iceman :public BaseSoldier 199 { 200 int count = 0; 201 public: 202 iceman(int id_, int HP, int attack_, vector<BaseWeapon*> we, string com) :BaseSoldier(id_, HP, attack_, we, com) {} 203 string getName() { 204 return "iceman"; 205 } 206 void march() { 207 count++; 208 if (count != 2) 209 return; 210 HP -= 9; 211 if (HP < 1) 212 HP = 1; 213 attack += 20; 214 count = 0; 215 } 216 }; 217 218 class lion :public BaseSoldier 219 { 220 public: 221 int loyalty; 222 lion(int id_, int loy, int HP, int attack_, vector<BaseWeapon*> we, string com) :BaseSoldier(id_, HP, attack_, we, com, true), loyalty(loy) {} 223 string getName() { 224 return "lion"; 225 } 226 int getLoyalty() { 227 return loyalty; 228 } 229 void fightback(BaseSoldier* enermy, int city) { 230 BaseSoldier::fightback(enermy, city); 231 if (!isWin) 232 loyalty -= K; 233 } 234 void fight(BaseSoldier* enermy, int city) { 235 BaseSoldier::fight(enermy, city); 236 if (!isWin) 237 loyalty -= K; 238 } 239 }; 240 241 class wolf :public BaseSoldier 242 { 243 public: 244 wolf(int id_, int HP, int attack, vector<BaseWeapon*> we, string com) :BaseSoldier(id_, HP, attack, we, com) {} 245 string getName() { 246 return "wolf"; 247 } 248 void fight(BaseSoldier* enermy, int city) { 249 BaseSoldier::fight(enermy, city); 250 if (isWin) { 251 if (weapons[0] == NULL) 252 weapons[0] = enermy->weapons[0]; 253 if (weapons[1] == NULL) 254 weapons[1] = enermy->weapons[1]; 255 if (weapons[2] == NULL) 256 weapons[2] = enermy->weapons[2]; 257 } 258 } 259 void fightback(BaseSoldier* enermy, int city) { 260 BaseSoldier::fightback(enermy, city); 261 if (isWin) { 262 if (weapons[0] == NULL) 263 weapons[0] = enermy->weapons[0]; 264 if (weapons[1] == NULL) 265 weapons[1] = enermy->weapons[1]; 266 if (weapons[2] == NULL) 267 weapons[2] = enermy->weapons[2]; 268 } 269 } 270 }; 271 272 class command :public city 273 { 274 private: 275 string name; 276 int n_all = 0; 277 public: 278 BaseSoldier* justAdd = NULL; 279 command(char * s, int x) :city(x), name(s) {} 280 bool addIceman(int monsterHP, int attack) { 281 if (elements >= monsterHP) { 282 vector<BaseWeapon*> we(3, NULL); 283 getWeapon(++n_all, attack, we); 284 justAdd = new iceman(n_all, monsterHP, attack, we, name); 285 cout << setw(3) << setfill('0') << Round << ":00"; 286 cout << ' ' << name << ' ' << "iceman " << n_all << " born" << endl; 287 elements -= monsterHP; 288 return true; 289 } 290 return false; 291 } 292 bool addLion(int monsterHP, int attack) { 293 if (elements >= monsterHP) { 294 elements -= monsterHP; 295 vector<BaseWeapon*> we(3, NULL); 296 justAdd = new lion(++n_all, elements, monsterHP, attack, we, name); 297 cout << setw(3) << setfill('0') << Round << ":00"; 298 cout << ' ' << name << ' ' << "lion " << n_all << " born" << endl; 299 cout << "Its loyalty is " << elements << endl; 300 return true; 301 } 302 return false; 303 } 304 bool addWolf(int monsterHP, int attack) { 305 if (elements >= monsterHP) { 306 vector<BaseWeapon*> we(3, NULL); 307 justAdd = new wolf(++n_all, monsterHP, attack, we, name); 308 cout << setw(3) << setfill('0') << Round << ":00"; 309 cout << ' ' << name << ' ' << "wolf " << n_all << " born" << endl; 310 elements -= monsterHP; 311 return true; 312 } 313 return false; 314 } 315 bool addNinja(int monsterHP, int attack) { 316 if (elements >= monsterHP) { 317 vector<BaseWeapon*> we(3, NULL); 318 getWeapon(++n_all, attack, we); 319 getWeapon(n_all + 1, attack, we); 320 justAdd = new ninja(n_all, monsterHP, attack, we, name); 321 cout << setw(3) << setfill('0') << Round << ":00"; 322 cout << ' ' << name << ' ' << "ninja " << n_all << " born" << endl; 323 elements -= monsterHP; 324 return true; 325 } 326 return false; 327 } 328 bool addDragon(int monsterHP, int attack) { 329 if (elements >= monsterHP) { 330 elements -= monsterHP; 331 vector<BaseWeapon*> we(3, NULL); 332 getWeapon(++n_all, attack, we); 333 justAdd = new dragon(n_all, (double)elements / monsterHP, monsterHP, attack, we, name); 334 cout << setw(3) << setfill('0') << Round << ":00"; 335 cout << ' ' << name << ' ' << "dragon " << n_all << " born" << endl; 336 cout << "Its morale is " << setiosflags(ios::fixed) << setprecision(2) << justAdd->getMo() << endl; 337 return true; 338 } 339 return false; 340 } 341 void getWeapon(int id, int attack, vector<BaseWeapon*>& we); 342 }; 343 344 void command::getWeapon(int id, int attack, vector<BaseWeapon*>& we) { 345 int num = id % 3; 346 switch (num) 347 { 348 case 0:we[num] = new Sword(attack / 5); break; 349 case 1:we[num] = new Bomb(); break; 350 case 2:we[num] = new Arrow(R); break; 351 default: 352 break; 353 } 354 } 355 //检查时间是否超过limit 356 bool checkTime(int limit, int hours, int minutes) { 357 int minuTime = hours * 60 + minutes; 358 if (minuTime > limit) 359 return false; 360 return true; 361 } 362 //创建武士 363 void create(int& num, vector<int>& queue, command* com, int HP[], int attack[]) { 364 if (queue[num] == 0 && com->addDragon(HP[0], attack[0])) 365 num++; 366 else if (queue[num] == 1 && com->addNinja(HP[1], attack[1])) 367 num++; 368 else if (queue[num] == 2 && com->addIceman(HP[2], attack[2])) 369 num++; 370 else if (queue[num] == 3 && com->addLion(HP[3], attack[3])) 371 num++; 372 else if (queue[num] == 4 && com->addWolf(HP[4], attack[4])) 373 num++; 374 if (num == 5) 375 num = 0; 376 } 377 //武士前行 378 bool march(vector<city*>& path) { 379 bool blueWin = false, redWin = false, redReachCom = false; 380 if (path[1]->blue_ != NULL) { 381 path[1]->blue_->march(); 382 cout << setw(3) << setfill('0') << Round << ":10"; 383 cout << " blue " << path[1]->blue_->getName() << ' ' << path[1]->blue_->id << " reached red headquarter "; 384 cout << "with " << path[1]->blue_->HP << " elements and force " << path[1]->blue_->attack << endl; 385 if (path[0]->blue_ != NULL) { 386 blueWin = true; 387 cout << setw(3) << setfill('0') << Round << ":10"; 388 cout << " red headquarter was taken" << endl; 389 } 390 path[0]->blue_ = path[1]->blue_; 391 } 392 if (path[path.size() - 2]->red_ != NULL) { 393 redReachCom = 1; 394 if (path[path.size() - 1]->red_ != NULL) 395 redWin = 1; 396 path[path.size() - 1]->red_ = path[path.size() - 2]->red_; 397 } 398 for (int i = 2; i < path.size(); i++) { 399 path[i - 1]->blue_ = path[i]->blue_; 400 } 401 for (int i = path.size() - 2; i > 0; i--) { 402 path[i]->red_ = path[i - 1]->red_; 403 } 404 path[0]->red_ = NULL; 405 path[path.size() - 1]->blue_ = NULL; 406 for (int i = 1; i < path.size() - 1; i++) { 407 if (path[i]->red_ != NULL) { 408 path[i]->red_->march(); 409 cout << setw(3) << setfill('0') << Round << ":10"; 410 cout << " red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " marched to city " << i; 411 cout << " with " << path[i]->red_->HP << " elements and force " << path[i]->red_->attack << endl; 412 } 413 if (path[i]->blue_ != NULL) { 414 path[i]->blue_->march(); 415 cout << setw(3) << setfill('0') << Round << ":10"; 416 cout << " blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " marched to city " << i; 417 cout << " with " << path[i]->blue_->HP << " elements and force " << path[i]->blue_->attack << endl; 418 } 419 } 420 if (redReachCom) { 421 path[path.size() - 1]->red_->march(); 422 cout << setw(3) << setfill('0') << Round << ":10"; 423 cout << " red " << path[path.size() - 1]->red_->getName() << ' ' << path[path.size() - 1]->red_->id << " reached blue headquarter "; 424 cout << "with " << path[path.size() - 1]->red_->HP << " elements and force " << path[path.size() - 1]->red_->attack << endl; 425 if (redWin) { 426 cout << setw(3) << setfill('0') << Round << ":10"; 427 cout << " blue headquarter was taken" << endl; 428 } 429 } 430 if (blueWin || redWin) 431 return 0; //0代表游戏结束 432 return 1; 433 } 434 //输出城市生命元 435 void coutElements(city* red, city* blue) { 436 cout << setw(3) << setfill('0') << Round << ":50 "; 437 cout << red->elements << " elements in red headquarter" << endl; 438 cout << setw(3) << setfill('0') << Round << ":50 "; 439 cout << blue->elements << " elements in blue headquarter" << endl; 440 } 441 //判断lion是否逃跑 442 void lionEscape(vector<city*>& path) { 443 if (path[0]->red_ && path[0]->red_->getLoyalty() <= 0) { //判断红司令部中红lion的忠诚度 444 cout << setw(3) << setfill('0') << Round << ":05 red lion " << path[0]->red_->id << " ran away" << endl; 445 path[0]->red_ = NULL; 446 } 447 for (int i = 1; i < path.size() - 1; i++) { //判断城市中的lion忠诚度 448 if (path[i]->red_ && path[i]->red_->getLoyalty() <= 0) { 449 cout << setw(3) << setfill('0') << Round << ":05 red lion " << path[i]->red_->id << " ran away" << endl; 450 path[i]->red_ = NULL; 451 } 452 if (path[i]->blue_ && path[i]->blue_->getLoyalty() <= 0) { 453 cout << setw(3) << setfill('0') << Round << ":05 blue lion " << path[i]->blue_->id << " ran away" << endl; 454 path[i]->blue_ = NULL; 455 } 456 } 457 if (path[path.size() - 1]->blue_ && path[path.size() - 1]->blue_->getLoyalty() <= 0) { //判断蓝司令部中蓝lion的忠诚度 458 cout << setw(3) << setfill('0') << Round << ":05 red lion " << path[path.size() - 1]->blue_->id << " ran away" << endl; 459 path[path.size() - 1]->blue_ = NULL; 460 } 461 } 462 //放箭 463 void arrowFire(vector<city*>& path) { 464 if (path.size() == 3) 465 return; 466 for (int i = 0; i < path.size(); i++) { 467 if (i <= 1) { //i<=1时只有红武士进攻 468 if (path[i + 1]->blue_ == NULL) 469 continue; 470 if (path[i]->red_ && path[i]->red_->hasArrow()) { 471 path[i + 1]->blue_->HP -= R; 472 if (path[i + 1]->blue_->HP <= 0) { 473 path[i + 1]->blue_->HP = 0; 474 cout << setw(3) << setfill('0') << Round << ":35 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " shot and killed blue " << path[i + 1]->blue_->getName() << ' ' << path[i + 1]->blue_->id << endl; 475 } 476 else 477 cout << setw(3) << setfill('0') << Round << ":35 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " shot" << endl; 478 } 479 continue; 480 } 481 if (i >= path.size() - 2) { //i>=size-2时只有蓝武士进攻 482 if (path[i - 1]->red_ == NULL) 483 continue; 484 if (path[i]->blue_ && path[i]->blue_->hasArrow()) { 485 path[i - 1]->red_->HP -= R; 486 if (path[i - 1]->red_->HP <= 0) { 487 path[i - 1]->red_->HP = 0; 488 cout << setw(3) << setfill('0') << Round << ":35 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " shot and killed red " << path[i - 1]->red_->getName() << ' ' << path[i - 1]->red_->id << endl; 489 } 490 else 491 cout << setw(3) << setfill('0') << Round << ":35 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " shot" << endl; 492 } 493 continue; 494 } 495 if (path[i + 1]->blue_ != NULL) { //红武士放箭 496 if (path[i]->red_ && path[i]->red_->hasArrow()) { 497 path[i + 1]->blue_->HP -= R; 498 if (path[i + 1]->blue_->HP <= 0) { 499 path[i + 1]->blue_->HP = 0; 500 cout << setw(3) << setfill('0') << Round << ":35 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " shot and killed blue " << path[i + 1]->blue_->getName() << ' ' << path[i + 1]->blue_->id << endl; 501 } 502 else 503 cout << setw(3) << setfill('0') << Round << ":35 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " shot" << endl; 504 } 505 } 506 if (path[i - 1]->red_ != NULL) { //蓝武士放箭 507 if (path[i]->blue_ && path[i]->blue_->hasArrow()) { 508 path[i - 1]->red_->HP -= R; 509 if (path[i - 1]->red_->HP <= 0) { 510 path[i - 1]->red_->HP = 0; 511 cout << setw(3) << setfill('0') << Round << ":35 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " shot and killed red " << path[i - 1]->red_->getName() << ' ' << path[i - 1]->red_->id << endl; 512 } 513 else 514 cout << setw(3) << setfill('0') << Round << ":35 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " shot" << endl; 515 } 516 } 517 } 518 } 519 //报告武器情况 520 void coutWeapon(vector<city*>& path) { 521 for (int i = 0; i < path.size(); i++) { 522 if (path[i]->red_ != NULL) { 523 cout << setw(3) << setfill('0') << Round << ":55 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " has "; 524 path[i]->red_->coutweapon(); 525 } 526 } 527 for (int i = 0; i < path.size(); i++) { 528 if (path[i]->blue_ != NULL) { 529 cout << setw(3) << setfill('0') << Round << ":55 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " has "; 530 path[i]->blue_->coutweapon(); 531 } 532 } 533 } 534 //判断红蓝哪个先进攻 535 bool judgeFirstAttack(int flag, int index) { 536 if (flag == 1) 537 return 1; //红进攻 538 if (flag == 2) 539 return 0; //蓝进攻 540 if (index % 2) 541 return 1; 542 return 0; 543 } 544 //判断武士是否使用bomb 545 void firework(vector<city*>& path) { 546 for (int i = 1; i < path.size() - 1; i++) { 547 if (judgeFirstAttack(path[i]->flag, i)) { //红方主动进攻 548 int weaponAttack = 0, attack = 0; 549 if (path[i]->red_ && path[i]->red_->weapons[1] != NULL && path[i]->blue_) { //红存在,有bomb,蓝存在 550 if (path[i]->red_->HP == 0) 551 continue; 552 int element = path[i]->blue_->HP; 553 attack = path[i]->red_->getAttack(weaponAttack); 554 if ((element - attack - weaponAttack > 0) && (path[i]->blue_->getName() != "ninja")) { //检验蓝魔会不会反击 555 attack = path[i]->blue_->getAttack(weaponAttack); 556 element = path[i]->red_->HP; 557 if (element - attack / 2 - weaponAttack <= 0) { //会死 558 cout << setw(3) << setfill('0') << Round << ":38 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " used a bomb and killed blue "; 559 cout << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << endl; 560 path[i]->red_ = NULL; 561 path[i]->blue_ = NULL; 562 } 563 } 564 } 565 if (path[i]->blue_ && path[i]->blue_->weapons[1] != NULL && path[i]->red_) { //蓝存在,有bomb,红存在 566 if (path[i]->red_->HP == 0 || path[i]->blue_->HP == 0) 567 continue; 568 attack = path[i]->red_->getAttack(weaponAttack); 569 int element = path[i]->blue_->HP; 570 if (element - attack - weaponAttack <= 0) { //会死 571 cout << setw(3) << setfill('0') << Round << ":38 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " used a bomb and killed red "; 572 cout << path[i]->red_->getName() << ' ' << path[i]->red_->id << endl; 573 path[i]->red_ = NULL; 574 path[i]->blue_ = NULL; 575 } 576 } 577 } 578 else { //蓝方主动进攻 579 int weaponAttack = 0, attack = 0; 580 if (path[i]->red_ && path[i]->red_->weapons[1] != NULL && path[i]->blue_) { //红存在,有bomb,蓝存在 581 if (path[i]->red_->HP == 0 || path[i]->blue_->HP == 0) 582 continue; 583 attack = path[i]->blue_->getAttack(weaponAttack); 584 int element = path[i]->red_->HP; 585 if (element - attack - weaponAttack <= 0) { //会死 586 cout << setw(3) << setfill('0') << Round << ":38 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " used a bomb and killed blue "; 587 cout << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << endl; 588 path[i]->red_ = NULL; 589 path[i]->blue_ = NULL; 590 } 591 } 592 if (path[i]->blue_ && path[i]->blue_->weapons[1] != NULL && path[i]->red_) { //蓝存在,有bomb,红存在 593 if (path[i]->blue_->HP == 0) 594 continue; 595 int element = path[i]->red_->HP; 596 attack = path[i]->blue_->getAttack(weaponAttack); 597 if ((element - attack - weaponAttack > 0) && (path[i]->red_->getName() != "ninja")) { //检验红魔会不会反击 598 attack = path[i]->red_->getAttack(weaponAttack); 599 element = path[i]->blue_->HP; 600 if (element - attack / 2 - weaponAttack <= 0) { //会死 601 cout << setw(3) << setfill('0') << Round << ":38 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " used a bomb and killed red "; 602 cout << path[i]->red_->getName() << ' ' << path[i]->red_->id << endl; 603 path[i]->red_ = NULL; 604 path[i]->blue_ = NULL; 605 } 606 } 607 } 608 } 609 } 610 } 611 //换旗 612 void changeFlag(city* c, int num) { 613 if (c->count_r == 2) { 614 c->count_r = 1; 615 if (c->flag != 1) 616 cout << setw(3) << setfill('0') << Round << ":40 red flag raised in city " << num << endl; 617 c->flag = 1; //红旗 618 } 619 if (c->count_b == 2) { 620 c->count_b = 1; 621 if (c->flag != 2) 622 cout << setw(3) << setfill('0') << Round << ":40 blue flag raised in city " << num << endl; 623 c->flag = 2; //蓝旗 624 } 625 } 626 //40分钟事件 627 void fortyEvent(vector<city*>& path) { 628 int earn_r = 0, earn_b = 0; 629 for (int i = 1; i < path.size() - 1; i++) { //进攻、反击、死亡、咆哮、升旗事件 630 if (path[i]->red_ == NULL || path[i]->blue_ == NULL) { 631 if (path[i]->red_ && !path[i]->red_->HP) 632 path[i]->red_ = NULL; 633 if (path[i]->blue_ && !path[i]->blue_->HP) 634 path[i]->blue_ = NULL; 635 continue; 636 } 637 if (path[i]->red_->HP == 0 && path[i]->blue_->HP == 0) { //红魔蓝魔都被箭射死 638 path[i]->red_ = NULL; 639 path[i]->blue_ = NULL; 640 continue; 641 } 642 if (!path[i]->red_->HP) { //红魔被箭射死 643 path[i]->blue_->fight(path[i]->red_, i); 644 path[i]->red_ = NULL; 645 if (!judgeFirstAttack(path[i]->flag, i)) //蓝先手 646 path[i]->blue_->shout(i); 647 cout << setw(3) << setfill('0') << Round << ":40 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 648 earn_b += path[i]->elements; //蓝获取城市生命元 649 path[i]->elements = 0; 650 path[i]->count_b++; //计数胜利场数 651 path[i]->count_r = 0; 652 changeFlag(path[i], i); 653 continue; 654 } 655 if (!path[i]->blue_->HP) { //蓝魔被箭射死 656 path[i]->red_->fight(path[i]->blue_, i); 657 path[i]->blue_ = NULL; 658 if (judgeFirstAttack(path[i]->flag, i)) //红先手 659 path[i]->red_->shout(i); 660 cout << setw(3) << setfill('0') << Round << ":40 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 661 earn_r += path[i]->elements; //10红获取城市生命元 662 path[i]->elements = 0; 663 path[i]->count_r++; //计数胜利场数 664 path[i]->count_b = 0; 665 changeFlag(path[i], i); //11 666 continue; 667 } 668 if (judgeFirstAttack(path[i]->flag, i)) { //红先手 669 path[i]->red_->fight(path[i]->blue_, i); 670 if (path[i]->red_->isWin) { 671 cout << setw(3) << setfill('0') << Round << ":40 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " was killed in city " << i << endl; 672 path[i]->blue_ = NULL; 673 path[i]->red_->shout(i); 674 cout << setw(3) << setfill('0') << Round << ":40 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 675 earn_r += path[i]->elements; //红获取城市生命元 676 path[i]->elements = 0; 677 path[i]->count_r++; //计数胜利场数 678 path[i]->count_b = 0; 679 changeFlag(path[i], i); 680 681 } 682 else if (path[i]->blue_->isWin) { 683 cout << setw(3) << setfill('0') << Round << ":40 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " was killed in city " << i << endl; 684 path[i]->red_ = NULL; 685 cout << setw(3) << setfill('0') << Round << ":40 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 686 earn_b += path[i]->elements; //蓝获取城市生命元 687 path[i]->elements = 0; 688 path[i]->count_b++; //计数胜利场数 689 path[i]->count_r = 0; 690 changeFlag(path[i], i); 691 } 692 else { 693 path[i]->red_->shout(i); 694 path[i]->count_r = 0; //平局清零 695 path[i]->count_b = 0; 696 } 697 } 698 else { //蓝先手 699 path[i]->blue_->fight(path[i]->red_, i); 700 if (path[i]->red_->isWin) { 701 cout << setw(3) << setfill('0') << Round << ":40 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " was killed in city " << i << endl; 702 path[i]->blue_ = NULL; 703 cout << setw(3) << setfill('0') << Round << ":40 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 704 earn_r += path[i]->elements; //红获取城市生命元 705 path[i]->elements = 0; 706 path[i]->count_r++; //计数胜利场数 707 path[i]->count_b = 0; 708 changeFlag(path[i], i); 709 } 710 else if (path[i]->blue_->isWin) { 711 cout << setw(3) << setfill('0') << Round << ":40 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " was killed in city " << i << endl; 712 path[i]->red_ = NULL; 713 path[i]->blue_->shout(i); 714 cout << setw(3) << setfill('0') << Round << ":40 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 715 earn_b += path[i]->elements; //蓝获取城市生命元 716 path[i]->elements = 0; 717 path[i]->count_b++; //计数胜利场数,考虑有旗是否还会计数 718 path[i]->count_r = 0; 719 changeFlag(path[i], i); 720 } 721 else { 722 path[i]->blue_->shout(i); 723 path[i]->count_r = 0; //平局清零 724 path[i]->count_b = 0; 725 } 726 } 727 } 728 for (int i = 1; i < path.size() - 1; i++) { //奖励所有赢得比赛的武士 729 if (path[i]->blue_&&path[i]->blue_->isWin) { 730 path[i]->blue_->isWin = 0; 731 if (path[path.size() - 1]->elements >= 8) { 732 path[path.size() - 1]->elements -= 8; 733 path[i]->blue_->HP += 8; 734 } 735 } 736 } 737 for (int i = path.size() - 2; i > 0; i--) { 738 if (path[i]->red_&&path[i]->red_->isWin) { 739 path[i]->red_->isWin = 0; 740 if (path[0]->elements >= 8) { 741 path[0]->elements -= 8; 742 path[i]->red_->HP += 8; 743 } 744 } 745 } 746 path[0]->elements += earn_r; 747 path[path.size() - 1]->elements += earn_b; 748 } 749 //城市发放生命元 750 void add(vector<city*>& path) { 751 for (int i = 1; i < path.size() - 1; i++) { 752 path[i]->elements += 10; 753 } 754 } 755 //30分获取生命元 756 void getElements(vector<city*> path) { 757 for (int i = 1; i < path.size() - 1; i++) { 758 if (path[i]->blue_ != NULL&&path[i]->red_ != NULL) 759 continue; 760 if (path[i]->red_ != NULL) { //只有红魔 761 cout << setw(3) << setfill('0') << Round << ":30 red " << path[i]->red_->getName() << ' ' << path[i]->red_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 762 path[0]->elements += path[i]->elements; 763 path[i]->elements = 0; 764 } 765 if (path[i]->blue_ != NULL) { //只有蓝魔 766 cout << setw(3) << setfill('0') << Round << ":30 blue " << path[i]->blue_->getName() << ' ' << path[i]->blue_->id << " earned " << path[i]->elements << " elements for his headquarter" << endl; 767 path[path.size() - 1]->elements += path[i]->elements; 768 path[i]->elements = 0; 769 } 770 } 771 } 772 int main() 773 { 774 int N; 775 cin >> N; 776 for (int i = 1; i <= N; i++) { 777 int HP_com = 0; 778 int HP[5], attack[5]; 779 int citiesNum, time; 780 cin >> HP_com >> citiesNum >> R >> K >> time; //输入司令部生命,城市数量,arrow攻击,lion减小忠诚,时限 781 vector<city*> path; 782 command red("red", HP_com), blue("blue", HP_com); 783 path.push_back(&red); 784 for (int i = 0; i < citiesNum; i++) { 785 path.push_back(new city(0)); 786 } 787 path.push_back(&blue); 788 cin >> HP[0] >> HP[1] >> HP[2] >> HP[3] >> HP[4]; //dragon, ninja, iceman, lion, wolf 789 cin >> attack[0] >> attack[1] >> attack[2] >> attack[3] >> attack[4]; //输入武士对应攻击 790 cout << "Case " << i << ":" << endl; 791 Round = 0; 792 vector<int> queue_red = { 2,3,4,1,0 }, queue_blue = { 3,0,1,2,4 }; 793 int count_red = 0, count_blue = 0; 794 while (1) { 795 if (!checkTime(time, Round, 0)) 796 break; 797 create(count_red, queue_red, &red, HP, attack); //0分创建red武士事件 798 create(count_blue, queue_blue, &blue, HP, attack); //创建blue武士 799 path[0]->red_ = red.justAdd; 800 path[path.size() - 1]->blue_ = blue.justAdd; 801 red.justAdd = NULL; 802 blue.justAdd = NULL; 803 if (!checkTime(time, Round, 5)) 804 break; 805 lionEscape(path); //5分lion逃跑事件 806 if (!checkTime(time, Round, 10)) 807 break; 808 if (!march(path)) //10分前进事件 809 break; 810 if (!checkTime(time, Round, 20)) 811 break; 812 add(path); //20分城市产出事件 813 if (!checkTime(time, Round, 30)) 814 break; 815 getElements(path); //30分获取生命元事件 816 if (!checkTime(time, Round, 35)) 817 break; 818 arrowFire(path); //35分放箭事件 819 if (!checkTime(time, Round, 38)) 820 break; 821 firework(path); //38分爆炸事件 822 if (!checkTime(time, Round, 40)) 823 break; 824 fortyEvent(path); //40分所有事件 825 if (!checkTime(time, Round, 50)) 826 break; 827 coutElements(&red, &blue); //50分输出生命元数量事件 828 if (!checkTime(time, Round, 55)) 829 break; 830 coutWeapon(path); //55分报告武器情况事件 831 Round++; 832 } 833 } 834 return 0; 835 }