Repository navigation
Expand file tree
/
Copy pathNation-Emulator.cpp
More file actions
609 lines (609 loc) · 11.1 KB
/
Copy pathNation-Emulator.cpp
File metadata and controls
609 lines (609 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#ifndef __linux__
#include <windows.h>
#include <conio.h>
#endif
#include <ctime>
#include <set>
using namespace std;
const int stuckcnt=8000;//到stuckcnt时直接枚举,不使用随机数
string l[8]={"","石器时代","青铜时代","铁器时代","工业时代","原子时代","信息时代","太空时代"};
string so[8]={"","石斧步兵","持矛步兵","铁甲骑兵","步兵连","坦克连","重装合成旅","太空舰队"};
struct nation
{
string name;
long long army;
int level;
bool alive;
};
int n;
int cnt;
set<int>nuclear;
nation x[1000001];
#ifndef __linux__
void lose()
{
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
return;
}
}
cout<<"所有国家都灭亡了,世界再次恢复了沉寂......\n";
system("pause");
exit(0);
}
void win()
{
int f=0;
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
f++;
}
}
if(f>1)
{
return;
}
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
cout<<x[i].name<<"称霸了世界!\n";
cout<<x[i].name<<"数据:\n";
cout<<"战力:"<<x[i].army<<endl;
cout<<"文明等级:"<<l[x[i].level]<<endl;
system("pause");
exit(0);
}
}
}
void randth()
{
srand(time(0)+rand()+clock()%6000);
int b=rand()%7+1;
// cout<<cnt<<endl;
if(cnt==0)
{
lose();
}
if(cnt==1)
{
win();
}
if(b==1)//战争
{
int a=rand()%n+1;
int c=0;
while(x[a].alive==0)
{
c++;
a=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
a=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
int b=rand()%n+1;
c=0;
while(b==a||x[b].alive==0)
{
c++;
b=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive&&i!=a)
{
b=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
cout<<x[a].name<<"向"<<x[b].name<<"宣战\n";
if(x[a].army>x[b].army)
{
cout<<x[a].name<<"将"<<x[b].name<<"打败\n";
x[b].army/=2;
x[a].army-=x[b].army*1.5;
}
else if(x[a].army==x[b].army)
{
cout<<x[a].name<<"与"<<x[b].name<<"打了个平手\n";
}
else
{
cout<<x[b].name<<"将"<<x[a].name<<"打败\n";
x[a].army/=2;
x[b].army-=x[a].army*1.5;
}
}
else if(b==2)//科技爆炸
{
int a=rand()%n+1;
int c=0;
while(x[a].alive==0)
{
c++;
a=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
a=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
if(x[a].level<7)
{
x[a].level++;
cout<<x[a].name<<"发生科技爆炸,进入"<<l[x[a].level]<<endl;
x[a].army+=x[a].level*100;
if(x[a].level==5)
{
nuclear.insert(a);
}
}
}
else if(b==3)
{
int a=rand()%n+1;
int c=0;
while(x[a].alive==0)
{
c++;
a=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
a=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
int t=rand()%10+30;
int bf=t;
if(x[a].level==7)
{
bf*=80;
}
if(x[a].level>=6)
{
bf*=4;
}
if(x[a].level>=5)
{
bf*=3;
}
if(x[a].level>=4)
{
bf*=2;
}
cout<<x[a].name<<"制造了"<<t*5<<"个"<<so[x[a].level]<<",战力增加"<<(x[a].level*x[a].level)*bf<<endl;
x[a].army+=(x[a].level*x[a].level)*bf;
}
else if(nuclear.size()>1&&b==4)
{
int a=rand()%nuclear.size()+1;
set<int>::iterator ss=nuclear.begin();
for(int j=1;j<=a;j++,ss++)
{
ss++;
}
a=*ss;
int b=rand()%n+1;
int c=0;
while(b==a||x[b].alive==0)
{
c++;
b=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive&&i!=a)
{
b=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
if(x[a].level>=5)
{
cout<<x[a].name<<"对"<<x[b].name<<"发动了核打击\n";
if(x[a].level==6)
{
if(x[b].level==6)
{
int xx=rand()%10+1;
if(xx<=6)
{
cout<<x[b].name<<"拦截并击毁了核弹\n";
}
else
{
int xxxx=rand()%3+1;
if(xxxx==1)
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"灭亡了\n";
if(x[b].level>=5)
{
nuclear.erase(b);
}
Sleep(1000);
x[b].alive=0;
cnt--;
}
else
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"文明降级\n";
if(x[b].level==5)
{
nuclear.erase(b);
}
x[b].army/=3;
x[b].level--;
x[b].level=max(x[b].level,1);
Sleep(1000);
}
}
}
else
{
int xxxx=rand()%3+1;
if(xxxx==1)
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"灭亡了\n";
if(x[b].level>=5)
{
nuclear.erase(b);
}
Sleep(1000);
x[b].alive=0;
cnt--;
}
else
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"文明降级\n";
if(x[b].level==5)
{
nuclear.erase(b);
}
x[b].army/=2;
x[b].level--;
x[b].level=max(x[b].level,1);
Sleep(1000);
}
}
}
else
{
int yy=rand()%10+1;
if(yy<=7)
{
if(x[b].level==6)
{
int xx=rand()%10+1;
if(xx<=5)
{
cout<<x[b].name<<"拦截并击毁了所有核弹\n";
}
else
{
int xxxx=rand()%3+1;
if(xxxx==1)
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"灭亡了\n";
if(x[b].level>=5)
{
nuclear.erase(b);
}
Sleep(1000);
x[b].alive=0;
cnt--;
}
else
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"文明降级\n";
x[b].army/=2;
if(x[b].level==5)
{
nuclear.erase(b);
}
x[b].level--;
x[b].level=max(x[b].level,1);
Sleep(1000);
}
}
}
else
{
int xxxx=rand()%3+1;
if(xxxx==1)
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"灭亡了\n";
if(x[b].level>=5)
{
nuclear.erase(b);
}
Sleep(1000);
x[b].alive=0;
cnt--;
}
else
{
cout<<">>>";
cout<<x[a].name<<"将"<<x[b].name<<"用大量核弹炸成了一片废墟,"<<x[b].name<<"文明降级\n";
x[b].army/=2;
if(x[b].level==5)
{
nuclear.erase(b);
}
x[b].level--;
x[b].level=max(x[b].level,1);
Sleep(1000);
}
}
}
else
{
cout<<x[a].name<<"射向"<<x[b].name<<"的核弹打偏了\n";
}
}
}
}
else if(b==5)
{
int ccc=rand()%5+1;
if(ccc<=2)
{
int a=rand()%n+1;
int c=0;
while(x[a].alive==0)
{
c++;
a=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
a=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
int xxx=rand()%20+1;
if(xxx<=2)
{
cout<<">>>"<<x[a].name<<"的群众起义,"<<x[a].name<<"灭亡了\n";
Sleep(1000);
x[a].alive=0;
cnt--;
if(x[a].level>=5)
{
nuclear.erase(a);
}
}
else
{
cout<<x[a].name<<"的群众起义,"<<x[a].name<<"政府成功镇压\n";
x[a].army*=0.7;
}
}
}
else if(b==6)
{
int ccc=rand()%5+1;
if(ccc==1)
{
int a=rand()%n+1;
int c=0;
while(x[a].alive==0)
{
c++;
a=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
a=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
int xxx=rand()%10+1;
if(x[a].level>=4)
{
cout<<x[a].name<<"爆发瘟疫,";
cout<<x[a].name<<"成功控制住了疫情\n";
x[a].army*=0.8;
}
else
{
if(xxx<=2)
{
cout<<">>>"<<x[a].name<<"爆发瘟疫,"<<x[a].name<<"灭亡了\n";
Sleep(1000);
x[a].alive=0;
cnt--;
if(x[a].level>=5)
{
nuclear.erase(a);
}
}
else
{
cout<<x[a].name<<"爆发瘟疫,";
cout<<x[a].name<<"成功控制住了疫情\n";
x[a].army*=0.6;
}
}
}
}
else if(b==7)
{
int ccc=rand()%5+1;
if(ccc==1)
{
int a=rand()%n+1;
int c=0;
while(x[a].alive==0)
{
c++;
a=rand()%n+1;
if(c==stuckcnt)
{
for(int i=1;i<=n;i++)
{
if(x[i].alive)
{
a=i;
break;
}
else if(i==n)
{
win();
}
}
}
}
int xxx=rand()%100+1;
if(xxx<=5||xxx>=90)
{
if(x[a].level>=5)
{
cout<<x[a].name<<"的核电站堆芯熔毁,发生氢气爆炸,"<<x[a].name<<"政府迅速控制住了事态\n";
x[a].army*=0.9;
if(x[a].name=="Japan"||x[a].name=="japan"||x[a].name=="JP"||x[a].name=="jp"||x[a].name=="岛国"||x[a].name=="日本"||x[a].name=="小日子")
{
cout<<"并于2023年8月24日排出了受堆芯污染的核污水\n";//恶搞小日子
}
}
}
}
}
for(int i=1;i<=n;i++)
{
if(x[i].army<=0&&x[i].alive)
{
cout<<">>>"<<x[i].name<<"的军队和人口被消耗殆尽,"<<x[i].name<<"灭亡了\n";
cnt--;
Sleep(1000);
x[i].alive=0;
if(x[i].level>=5)
{
nuclear.erase(i);
}
}
}
}
#endif
int main()
{
#ifndef __linux__
srand(time(0));
LANGID lang=GetUserDefaultUILanguage();
if(lang!=2052)
{
cout<<"I\'m sorry that my Emulator did not support your language.I suggest you to use a Computer With Simplified Chinese(zh-CN).\nPress any key to continue...\n";
getch();
system("cls");
}
system("color b");
system("title 国家模拟器");
cout<<"国家模拟器,Copyright 2025 ZZCjas\n";
cout<<"国家数:";
cin>>n;
cout<<"各个国家的名字:\n";
for(int i=1;i<=n;i++)
{
cin>>x[i].name;
}
system("cls");
cout<<n<<"个国家在一片大陆上诞生了......\n";
cnt=n;
for(int i=1;i<=n;i++)
{
x[i].army=100;
x[i].level=1;
x[i].alive=1;
}
Sleep(1000);
srand(time(0));
while(cnt>1)
{
randth();
Sleep(100);
}
win();
#endif
#ifdef __linux__
cout<<"Error:Please Run the program under Windows\n";
#endif
return 0;
}