-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB_lib.sql
1750 lines (1470 loc) · 131 KB
/
DB_lib.sql
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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-----------------------------------------------
-----------------------------------------------
-- Tags
-----------------------------------------------
-----------------------------------------------
-- Typetags for all, land combat, and naval combat units
INSERT OR IGNORE INTO Tags
(Tag, Vocabulary)
VALUES
('DB_CLASS_ALL', 'ABILITY_CLASS'),
('DB_CLASS_ALL_COMBAT', 'ABILITY_CLASS'),
('DB_CLASS_LAND_ALL', 'ABILITY_CLASS'),
('DB_CLASS_LAND_COMBAT', 'ABILITY_CLASS'),
('DB_CLASS_LAND_CAVALRY', 'ABILITY_CLASS'),
('DB_CLASS_LAND_NON_CAVALRY', 'ABILITY_CLASS'),
('DB_CLASS_LAND_MELEE_NON_CAVALRY', 'ABILITY_CLASS'),
('DB_CLASS_NAVAL_ALL', 'ABILITY_CLASS'),
('DB_CLASS_NAVAL_COMBAT', 'ABILITY_CLASS'),
('DB_CLASS_AIR_COMBAT', 'ABILITY_CLASS'),
('DB_CLASS_LAND_MELEE_ATTACKER', 'ABILITY_CLASS'),
('DB_CLASS_LAND_RANGED_ATTACKER', 'ABILITY_CLASS'),
('DB_CLASS_LAND_BOMBARD_ATTACKER', 'ABILITY_CLASS'),
('DB_CLASS_NAVAL_MELEE_ATTACKER', 'ABILITY_CLASS'),
('DB_CLASS_NAVAL_RANGED_ATTACKER', 'ABILITY_CLASS'),
('DB_CLASS_NAVAL_BOMBARD_ATTACKER', 'ABILITY_CLASS')
;
INSERT OR IGNORE INTO Tags (Tag, Vocabulary)
SELECT 'DB_CLASS_' || UnitType, 'ABILITY_CLASS' FROM Units ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_ALL' FROM Units ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_ALL_COMBAT' FROM Units WHERE (Combat > 0 OR RangedCombat > 0 OR Bombard > 0) AND (FormationClass = 'FORMATION_CLASS_LAND_COMBAT' OR FormationClass = 'FORMATION_CLASS_NAVAL' OR FormationClass = 'FORMATION_CLASS_AIR') ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_ALL' FROM Units WHERE Domain = 'DOMAIN_LAND' ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_COMBAT' FROM Units WHERE (Combat > 0 OR RangedCombat > 0 OR Bombard > 0) AND FormationClass = 'FORMATION_CLASS_LAND_COMBAT' ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_NAVAL_ALL' FROM Units WHERE Domain = 'DOMAIN_SEA' ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_NAVAL_COMBAT' FROM Units WHERE (Combat > 0 OR RangedCombat > 0 OR Bombard > 0) AND FormationClass = 'FORMATION_CLASS_NAVAL' ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_AIR_COMBAT' FROM Units WHERE (Combat > 0 OR RangedCombat > 0 OR Bombard > 0) AND FormationClass = 'FORMATION_CLASS_AIR' ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_MELEE_ATTACKER' FROM Units WHERE FormationClass = 'FORMATION_CLASS_LAND_COMBAT' AND Combat > 0 AND RangedCombat = 0 AND Bombard = 0 ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_RANGED_ATTACKER' FROM Units WHERE FormationClass = 'FORMATION_CLASS_LAND_COMBAT' AND RangedCombat > 0 ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_BOMBARD_ATTACKER' FROM Units WHERE FormationClass = 'FORMATION_CLASS_LAND_COMBAT' AND Bombard > 0 ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_CAVALRY' FROM Units WHERE FormationClass = 'FORMATION_CLASS_LAND_COMBAT' AND PromotionClass LIKE '%CAVALRY%' AND PromotionClass NOT LIKE '%ANTI_CAVALRY%' ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_NON_CAVALRY' FROM Units WHERE FormationClass = 'FORMATION_CLASS_LAND_COMBAT' AND (PromotionClass LIKE '%ANTI_CAVALRY%' OR PromotionClass NOT LIKE '%CAVALRY%') ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_LAND_MELEE_NON_CAVALRY' FROM Units WHERE FormationClass = 'FORMATION_CLASS_LAND_COMBAT' AND Combat > 0 AND RangedCombat = 0 AND Bombard = 0 AND (PromotionClass LIKE '%ANTI_CAVALRY%' OR PromotionClass NOT LIKE '%CAVALRY%') ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_NAVAL_MELEE_ATTACKER' FROM Units WHERE FormationClass = 'FORMATION_CLASS_NAVAL' AND Combat > 0 AND RangedCombat = 0 AND Bombard = 0 ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_NAVAL_RANGED_ATTACKER' FROM Units WHERE FormationClass = 'FORMATION_CLASS_NAVAL' AND RangedCombat > 0 ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_NAVAL_BOMBARD_ATTACKER' FROM Units WHERE FormationClass = 'FORMATION_CLASS_NAVAL' AND Bombard > 0 ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_NAVAL_BOMBARD_ATTACKER' FROM Units WHERE FormationClass = 'FORMATION_CLASS_NAVAL' AND Bombard > 0 ;
INSERT OR IGNORE INTO TypeTags (Type, Tag)
SELECT UnitType, 'DB_CLASS_' || UnitType FROM Units ;
-----------------------------------------------
-----------------------------------------------
-- Requirements
-----------------------------------------------
-----------------------------------------------
-- Major Civ
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_PLAYER_IS_MAJOR', 'REQUIREMENT_PLAYER_IS_MAJOR') ;
-- Game eras
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_ANCIENT', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_ANCIENT', 'EraType', 'ERA_ANCIENT') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_ANCIENT', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_ANCIENT', 'DB_REQ_ERA_IS_ANCIENT') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_CLASSICAL', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_CLASSICAL', 'EraType', 'ERA_CLASSICAL') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_CLASSICAL', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_CLASSICAL', 'DB_REQ_ERA_IS_CLASSICAL') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_MEDIEVAL', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_MEDIEVAL', 'EraType', 'ERA_MEDIEVAL') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_MEDIEVAL', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_MEDIEVAL', 'DB_REQ_ERA_IS_MEDIEVAL') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_RENAISSANCE', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_RENAISSANCE', 'EraType', 'ERA_RENAISSANCE') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_RENAISSANCE', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_RENAISSANCE', 'DB_REQ_ERA_IS_RENAISSANCE') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_INDUSTRIAL', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_INDUSTRIAL', 'EraType', 'ERA_INDUSTRIAL') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_INDUSTRIAL', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_INDUSTRIAL', 'DB_REQ_ERA_IS_INDUSTRIAL') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_MODERN', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_MODERN', 'EraType', 'ERA_MODERN') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_MODERN', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_MODERN', 'DB_REQ_ERA_IS_MODERN') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_ATOMIC', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_ATOMIC', 'EraType', 'ERA_ATOMIC') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_ATOMIC', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_ATOMIC', 'DB_REQ_ERA_IS_ATOMIC') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_INFORMATION', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_INFORMATION', 'EraType', 'ERA_INFORMATION') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_INFORMATION', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_INFORMATION', 'DB_REQ_ERA_IS_INFORMATION') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_ERA_IS_FUTURE', 'REQUIREMENT_GAME_ERA_IS') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_ERA_IS_FUTURE', 'EraType', 'ERA_FUTURE') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_ERA_IS_FUTURE', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_ERA_IS_FUTURE', 'DB_REQ_ERA_IS_FUTURE') ;
-- Civ not founded religion
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_PLAYER_NOT_FOUNDED_RELIGION', 'REQUIREMENT_PLAYER_FOUNDED_NO_RELIGION') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_PLAYER_NOT_FOUNDED_RELIGION', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_PLAYER_NOT_FOUNDED_RELIGION', 'DB_REQ_PLAYER_NOT_FOUNDED_RELIGION') ;
-- Civ founded religion
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType, Inverse) VALUES ('DB_REQ_PLAYER_FOUNDED_RELIGION', 'REQUIREMENT_PLAYER_FOUNDED_NO_RELIGION', 1) ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_PLAYER_FOUNDED_RELIGION', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_PLAYER_FOUNDED_RELIGION', 'DB_REQ_PLAYER_FOUNDED_RELIGION') ;
-- AI has founded religion
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_PLAYER_IS_AI_AND_HAS_FOUNDED_RELIGION', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_PLAYER_IS_AI_AND_HAS_FOUNDED_RELIGION', 'REQUIRES_PLAYER_IS_AI'),
('DB_REQSET_PLAYER_IS_AI_AND_HAS_FOUNDED_RELIGION', 'DB_REQ_PLAYER_FOUNDED_RELIGION') ;
-- Major Civilization having a capital city and has not founded a religion (getting a free starting prophet when they settle their capital)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_FREE_PROPHET', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_FREE_PROPHET', 'DB_REQ_ERA_IS_ANCIENT'),
('DB_REQSET_FREE_PROPHET', 'DB_REQ_PLAYER_IS_MAJOR'),
('DB_REQSET_FREE_PROPHET', 'DB_REQ_PLAYER_NOT_FOUNDED_RELIGION'),
('DB_REQSET_FREE_PROPHET', 'REQUIRES_CAPITAL_CITY') ;
-- Classical era with Capital City (Saladin's free prophet)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_CAPITAL_CITY_IN_CLASSICAL_ERA', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_CAPITAL_CITY_IN_CLASSICAL_ERA', 'DB_REQ_ERA_IS_CLASSICAL'),
('DB_REQSET_CAPITAL_CITY_IN_CLASSICAL_ERA', 'REQUIRES_CAPITAL_CITY') ;
-- City follows pantheon (DB_REQ_CITY_FOLLOWS_PANTHEON, DB_REQSET_CITY_FOLLOWS_PANTHEON)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_CITY_FOLLOWS_PANTHEON', 'REQUIREMENT_CITY_FOLLOWS_PANTHEON') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_CITY_FOLLOWS_PANTHEON', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_CITY_FOLLOWS_PANTHEON', 'DB_REQ_CITY_FOLLOWS_PANTHEON') ;
-- City follows religion (DB_REQ_CITY_FOLLOWS_RELIGION, DB_REQSET_CITY_FOLLOWS_RELIGION)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_CITY_FOLLOWS_RELIGION', 'REQUIREMENT_CITY_FOLLOWS_RELIGION') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_CITY_FOLLOWS_RELIGION', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_CITY_FOLLOWS_RELIGION', 'DB_REQ_CITY_FOLLOWS_RELIGION') ;
-- City has X population (DB_REQ_CITY_HAS_2_POPULATION, DB_REQSET_CITY_HAS_2_POPULATION)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQ_CITY_HAS_' || x || '_POPULATION', 'REQUIREMENT_CITY_HAS_X_POPULATION' FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQ_CITY_HAS_' || x || '_POPULATION', 'Amount', x FROM counter ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_POPULATION', 'REQUIREMENTSET_TEST_ALL' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_POPULATION', 'DB_REQ_CITY_HAS_' || x || '_POPULATION' FROM counter ;
-- City has X population and follows religion (DB_REQ_CITY_HAS_2_POPULATION_AND_FOLLOWS_RELIGION, DB_REQSET_CITY_HAS_2_POPULATION_AND_FOLLOWS_RELIGION)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_POPULATION_AND_FOLLOWS_RELIGION', 'REQUIREMENTSET_TEST_ALL' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_POPULATION_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_HAS_' || x || '_POPULATION' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_POPULATION_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_FOLLOWS_RELIGION' FROM counter ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQ_CITY_HAS_' || x || '_POPULATION_AND_FOLLOWS_RELIGION', 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 99)
SELECT 'DB_REQ_CITY_HAS_' || x || '_POPULATION_AND_FOLLOWS_RELIGION', 'RequirementSetId', 'DB_REQSET_CITY_HAS_' || x || '_POPULATION_AND_FOLLOWS_RELIGION' FROM counter ;
-- City has X specialty districts (DB_REQ_CITY_HAS_2_DISTRICTS, DB_REQSET_CITY_HAS_2_DISTRICTS)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQ_CITY_HAS_' || x || '_DISTRICTS', 'REQUIREMENT_CITY_HAS_X_SPECIALTY_DISTRICTS' FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQ_CITY_HAS_' || x || '_DISTRICTS', 'Amount', x FROM counter ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_DISTRICTS', 'REQUIREMENTSET_TEST_ALL' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_DISTRICTS', 'DB_REQ_CITY_HAS_' || x || '_DISTRICTS' FROM counter ;
-- City has X specialty districts and follows religion (DB_REQ_CITY_HAS_2_DISTRICTS_AND_FOLLOWS_RELIGION, DB_REQSET_CITY_HAS_2_DISTRICTS_AND_FOLLOWS_RELIGION)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_DISTRICTS_AND_FOLLOWS_RELIGION', 'REQUIREMENTSET_TEST_ALL' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_DISTRICTS_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_HAS_' || x || '_DISTRICTS' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_DISTRICTS_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_FOLLOWS_RELIGION' FROM counter ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQ_CITY_HAS_' || x || '_DISTRICTS_AND_FOLLOWS_RELIGION', 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 18)
SELECT 'DB_REQ_CITY_HAS_' || x || '_DISTRICTS_AND_FOLLOWS_RELIGION', 'RequirementSetId', 'DB_REQSET_CITY_HAS_' || x || '_DISTRICTS_AND_FOLLOWS_RELIGION' FROM counter ;
-- City has a certain building, including wonders (DB_REQ_CITY_HAS_LIBRARY, DB_REQSET_CITY_HAS_LIBRARY)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(BuildingType, 10), 'REQUIREMENT_CITY_HAS_BUILDING' FROM Buildings ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(BuildingType, 10), 'BuildingType', BuildingType FROM Buildings ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(BuildingType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Buildings ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(BuildingType, 10), 'DB_REQ_CITY_HAS_' || SUBSTR(BuildingType, 10) FROM Buildings ;
-- City has a certain building AND follows religion (DB_REQ_CITY_HAS_BROADCAST_CENTER_AND_FOLLOWS_RELIGION, DB_REQSET_CITY_HAS_BROADCAST_CENTER_AND_FOLLOWS_RELIGION)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(BuildingType, 10) || '_AND_FOLLOWS_RELIGION', 'REQUIREMENTSET_TEST_ALL' FROM Buildings ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(BuildingType, 10) || '_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_HAS_' || SUBSTR(BuildingType, 10) FROM Buildings ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(BuildingType, 10) || '_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_FOLLOWS_RELIGION' FROM Buildings ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(BuildingType, 10) || '_AND_FOLLOWS_RELIGION', 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Buildings ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(BuildingType, 10) || '_AND_FOLLOWS_RELIGION', 'RequirementSetId', 'DB_REQSET_CITY_HAS_' || SUBSTR(BuildingType, 10) || '_AND_FOLLOWS_RELIGION' FROM Buildings ;
-- City has any level-3 building (DB_REQ_CITY_HAS_LEVEL3_HSBUILDING, DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING', 'REQUIREMENTSET_TEST_ANY') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING' , 'DB_REQ_CITY_HAS_' || SUBSTR(BuildingType, 10) || '_AND_FOLLOWS_RELIGION' FROM Buildings WHERE PrereqDistrict = 'DISTRICT_HOLY_SITE' AND BuildingType != 'BUILDING_SHRINE' AND BuildingType != 'BUILDING_TEMPLE' AND BuildingType != 'BUILDING_STAVE_CHURCH' AND BuildingType != 'BUILDING_PRASAT';
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_CITY_HAS_LEVEL3_HSBUILDING', 'REQUIREMENT_REQUIREMENTSET_IS_MET') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_CITY_HAS_LEVEL3_HSBUILDING', 'RequirementSetId', 'DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING') ;
-- City has any level-3 building AND follows religion (DB_REQ_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION, DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_HAS_LEVEL3_HSBUILDING'),
('DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION', 'REQUIRES_CITY_FOLLOWS_RELIGION') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION', 'REQUIREMENT_REQUIREMENTSET_IS_MET') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION', 'RequirementSetId', 'DB_REQSET_CITY_HAS_LEVEL3_HSBUILDING_AND_FOLLOWS_RELIGION') ;
-- City has a certain district (DB_REQ_CITY_HAS_HOLY_SITE, DB_REQSET_CITY_HAS_HOLY_SITE)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(DistrictType, 10), 'REQUIREMENT_CITY_HAS_DISTRICT' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(DistrictType, 10), 'DistrictType', DistrictType FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(DistrictType, 10), 'DB_REQ_CITY_HAS_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
-- City has a certain district AND follows religion (DB_REQ_CITY_HAS_HOLY_SITE_AND_FOLLOWS_RELIGION, DB_REQSET_CITY_HAS_HOLY_SITE_AND_FOLLOWS_RELIGION)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(DistrictType, 10) || '_AND_FOLLOWS_RELIGION', 'REQUIREMENTSET_TEST_ALL' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(DistrictType, 10) || '_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_HAS_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_CITY_HAS_' || SUBSTR(DistrictType, 10) || '_AND_FOLLOWS_RELIGION', 'DB_REQ_CITY_FOLLOWS_RELIGION' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(DistrictType, 10) || '_AND_FOLLOWS_RELIGION', 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_CITY_HAS_' || SUBSTR(DistrictType, 10) || '_AND_FOLLOWS_RELIGION', 'RequirementSetId', 'DB_REQSET_CITY_HAS_' || SUBSTR(DistrictType, 10) || '_AND_FOLLOWS_RELIGION' FROM Districts WHERE TraitType IS NULL ;
-- City has X terrain type (DB_REQ_CITY_HAS_2_DESERT, DB_REQSET_CITY_HAS_2_DESERT)
-- Currently just does deserts because that's the only terrain I'm interested in for this. Modify the where clauses to include other terrains. (Without the where clause it creates over a thousand unnecessary requirements.)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9), 'REQUIREMENT_CITY_HAS_X_TERRAIN_TYPE' FROM counter LEFT JOIN Terrains WHERE TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9), 'TerrainType', TerrainType FROM counter LEFT JOIN Terrains WHERE TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9), 'Hills', 0 FROM counter LEFT JOIN Terrains WHERE TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9), 'Amount', x FROM counter LEFT JOIN Terrains WHERE TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9), 'REQUIREMENTSET_TEST_ALL' FROM counter LEFT JOIN Terrains WHERE TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9), 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) FROM counter LEFT JOIN Terrains WHERE TerrainType LIKE '%DESERT%' ;
-- City has X terrain type, including hill versions (DB_REQ_CITY_HAS_2_DESERT_OR_DESERT_HILLS, DB_REQSET_CITY_HAS_2_DESERT_OR_DESERT_HILLS)
-- Currently just does deserts because that's the only terrain I'm interested in for this. Modify the where clauses to include other terrains. (Without the where clause it creates over a thousand unnecessary requirements.)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'REQUIREMENT_CITY_HAS_X_TERRAIN_TYPE' FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'TerrainType', TerrainType FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'Hills', 1 FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
-- For some reason, the "Amount" argument is off by 1. When Value is set to 2/4/6 the requirement is actually satisfied with 1/3/5 matching tiles... thus why this query sets the Value to x + 1
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'Amount', x + 1 FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'REQUIREMENTSET_TEST_ALL' FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQSET_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS' FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
-- Follows religion AND has X terrain type, including hill versions (DB_REQSET_CITY_FOLLOWS_RELIGION_AND_HAS_2_DESERT_OR_DESERT_HILLS)
-- Currently just does deserts because that's the only terrain I'm interested in for this. Modify the where clauses to include other terrains. (Without the where clause it creates over a thousand unnecessary requirements.)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQSET_CITY_FOLLOWS_RELIGION_AND_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'REQUIREMENTSET_TEST_ALL' FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQSET_CITY_FOLLOWS_RELIGION_AND_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'DB_REQ_CITY_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS' FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 37)
SELECT 'DB_REQSET_CITY_FOLLOWS_RELIGION_AND_HAS_' || x || '_' || SUBSTR(TerrainType, 9) || '_OR_' || SUBSTR(TerrainType, 9) || '_HILLS', 'REQUIRES_CITY_FOLLOWS_RELIGION' FROM counter LEFT JOIN Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' AND TerrainType LIKE '%DESERT%' ;
-- District is... (DB_REQ_IS_HOLY_SITE, DB_REQSET_IS_HOLY_SITE)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_' || SUBSTR(DistrictType, 10), 'REQUIREMENT_DISTRICT_TYPE_MATCHES' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_' || SUBSTR(DistrictType, 10), 'DistrictType', DistrictType FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_' || SUBSTR(DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(DistrictType, 10), 'DB_REQ_IS_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
-- Next to a certain district (DB_REQ_NEXT_TO_HOLY_SITE, DB_REQSET_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_NEXT_TO_' || SUBSTR(DistrictType, 10), 'REQUIREMENT_PLOT_ADJACENT_DISTRICT_TYPE_MATCHES' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_NEXT_TO_' || SUBSTR(DistrictType, 10), 'DistrictType', DistrictType FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_NEXT_TO_' || SUBSTR(DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_NEXT_TO_' || SUBSTR(DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
-- District is X and next to district Y (DB_REQ_IS_CAMPUS_NEXT_TO_HOLY_SITE, DB_REQSET_IS_CAMPUS_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_' || SUBSTR(a.DistrictType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Districts AS a LEFT JOIN Districts AS b WHERE a.TraitType IS NULL AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(a.DistrictType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_IS_' || SUBSTR(a.DistrictType, 10) FROM Districts AS a LEFT JOIN Districts AS b WHERE a.TraitType IS NULL AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(a.DistrictType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Districts AS a LEFT JOIN Districts AS b WHERE a.TraitType IS NULL AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_' || SUBSTR(a.DistrictType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Districts AS a LEFT JOIN Districts AS b WHERE a.TraitType IS NULL AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_' || SUBSTR(a.DistrictType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'RequirementSetId', 'DB_REQSET_IS_' || SUBSTR(a.DistrictType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Districts AS a LEFT JOIN Districts AS b WHERE a.TraitType IS NULL AND b.TraitType IS NULL ;
-- Plot is terrain (DB_REQ_IS_PLAINS, DB_REQSET_IS_PLAINS)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_' || SUBSTR(TerrainType, 9), 'REQUIREMENT_PLOT_TERRAIN_TYPE_MATCHES' FROM Terrains ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_' || SUBSTR(TerrainType, 9), 'TerrainType', TerrainType FROM Terrains ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_' || SUBSTR(TerrainType, 9), 'REQUIREMENTSET_TEST_ALL' FROM Terrains ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(TerrainType, 9), 'DB_REQ_IS_' || SUBSTR(TerrainType, 9) FROM Terrains ;
-- Plot is next to terrain (DB_REQ_IS_NEXT_TO_PLAINS, DB_REQSET_IS_NEXT_TO_PLAINS)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_NEXT_TO_' || SUBSTR(TerrainType, 9), 'REQUIREMENT_PLOT_ADJACENT_TERRAIN_TYPE_MATCHES' FROM Terrains ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_NEXT_TO_' || SUBSTR(TerrainType, 9), 'TerrainType', TerrainType FROM Terrains ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_NEXT_TO_' || SUBSTR(TerrainType, 9), 'MinRange', 0 FROM Terrains ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_NEXT_TO_' || SUBSTR(TerrainType, 9), 'MaxRange', 1 FROM Terrains ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_NEXT_TO_' || SUBSTR(TerrainType, 9), 'REQUIREMENTSET_TEST_ALL' FROM Terrains ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_NEXT_TO_' || SUBSTR(TerrainType, 9), 'DB_REQ_IS_NEXT_TO_' || SUBSTR(TerrainType, 9) FROM Terrains ;
-- Plot is terrain X or next to terrain X (DB_REQ_IS_PLAINS_OR_NEXT_TO_PLAINS, DB_REQSET_IS_PLAINS_OR_NEXT_TO_PLAINS) [[NOT TESTED]]
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_' || SUBSTR(TerrainType, 9), 'REQUIREMENTSET_TEST_ANY' FROM Terrains ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_' || SUBSTR(TerrainType, 9), 'DB_REQ_IS_' || SUBSTR(TerrainType, 9) FROM Terrains ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_' || SUBSTR(TerrainType, 9), 'DB_REQ_IS_NEXT_TO_' || SUBSTR(TerrainType, 9) FROM Terrains ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_' || SUBSTR(TerrainType, 9), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Terrains ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_' || SUBSTR(TerrainType, 9), 'RequirementSetId', 'DB_REQSET_IS_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_' || SUBSTR(TerrainType, 9) FROM Terrains ;
-- Plot is terrain X and is next to district Y (DB_REQ_IS_PLAINS_NEXT_TO_HOLY_SITE, DB_REQSET_IS_PLAINS_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Terrains AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_IS_' || SUBSTR(a.TerrainType, 9) FROM Terrains AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Terrains AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Terrains AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'RequirementSetId', 'DB_REQSET_IS_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Terrains AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
-- Plot is any terrain of a certain type (DB_REQ_IS_ANY_PLAINS, DB_REQSET_IS_ANY_PLAINS)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(TerrainType, 9), 'REQUIREMENTSET_TEST_ANY' FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(a.TerrainType, 9), 'DB_REQ_IS_' || SUBSTR(b.TerrainType, 9) FROM Terrains AS a INNER JOIN Terrains AS b ON SUBSTR(a.TerrainType, 0, 12) = SUBSTR(b.TerrainType, 0, 12) WHERE a.TerrainType NOT LIKE '%HILLS%' AND a.TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_ANY_' || SUBSTR(TerrainType, 9), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_ANY_' || SUBSTR(TerrainType, 9), 'RequirementSetId', 'DB_REQSET_IS_ANY_' || SUBSTR(TerrainType, 9) FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
-- Plot is next to any terrain of a certain type (DB_REQ_IS_NEXT_TO_ANY_PLAINS, DB_REQSET_IS_NEXT_TO_ANY_PLAINS) [[NOT TESTED]]
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'REQUIREMENTSET_TEST_ANY' FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'DB_REQ_IS_NEXT_TO_' || SUBSTR(TerrainType, 9) FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'RequirementSetId', 'DB_REQSET_IS_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9) FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
-- Plot is terrain of a certain type or next to terrain of that type (DB_REQ_IS_ANY_PLAINS_OR_NEXT_TO_ANY_PLAINS, DB_REQSET_IS_ANY_PLAINS_OR_NEXT_TO_ANY_PLAINS) [[NOT TESTED]]
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'REQUIREMENTSET_TEST_ANY' FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'DB_REQ_IS_ANY_' || SUBSTR(TerrainType, 9) FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'DB_REQ_IS_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9) FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_ANY_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_ANY_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9), 'RequirementSetId', 'DB_REQSET_IS_ANY_' || SUBSTR(TerrainType, 9) || '_OR_NEXT_TO_ANY_' || SUBSTR(TerrainType, 9) FROM Terrains WHERE TerrainType NOT LIKE '%HILLS%' AND TerrainType NOT LIKE '%MOUNTAIN%' ;
-- Plot is terrain of a certain type X and is next to district Y (DB_REQ_IS_ANY_PLAINS_NEXT_TO_HOLY_SITE, DB_REQSET_IS_ANY_PLAINS_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Terrains AS a LEFT JOIN Districts AS b WHERE a.TerrainType NOT LIKE '%HILLS%' AND a.TerrainType NOT LIKE '%MOUNTAIN%' AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_IS_ANY_' || SUBSTR(a.TerrainType, 9) FROM Terrains AS a LEFT JOIN Districts AS b WHERE a.TerrainType NOT LIKE '%HILLS%' AND a.TerrainType NOT LIKE '%MOUNTAIN%' AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_IS_ANY_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Terrains AS a LEFT JOIN Districts AS b WHERE a.TerrainType NOT LIKE '%HILLS%' AND a.TerrainType NOT LIKE '%MOUNTAIN%' AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_IS_ANY_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Terrains AS a LEFT JOIN Districts AS b WHERE a.TerrainType NOT LIKE '%HILLS%' AND a.TerrainType NOT LIKE '%MOUNTAIN%' AND b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_IS_ANY_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'RequirementSetId', 'DB_REQSET_IS_ANY_' || SUBSTR(a.TerrainType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Terrains AS a LEFT JOIN Districts AS b WHERE a.TerrainType NOT LIKE '%HILLS%' AND a.TerrainType NOT LIKE '%MOUNTAIN%' AND b.TraitType IS NULL ;
-- Plot is any water/arctic (DB_REQ_IS_ANY_WATER, DB_REQSET_IS_ANY_WATER)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('DB_REQSET_IS_ANY_WATER', 'REQUIREMENTSET_TEST_ANY'),
('DB_REQSET_IS_ANY_ARCTIC', 'REQUIREMENTSET_TEST_ANY') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_IS_ANY_WATER', 'DB_REQ_IS_ANY_COAST'),
('DB_REQSET_IS_ANY_WATER', 'DB_REQ_IS_ANY_OCEAN'),
('DB_REQSET_IS_ANY_ARCTIC', 'DB_REQ_IS_ANY_SNOW'),
('DB_REQSET_IS_ANY_ARCTIC', 'DB_REQ_IS_ANY_TUNDRA') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES
('DB_REQ_IS_ANY_WATER', 'REQUIREMENT_REQUIREMENTSET_IS_MET'),
('DB_REQ_IS_ANY_ARCTIC', 'REQUIREMENT_REQUIREMENTSET_IS_MET') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES
('DB_REQ_IS_ANY_WATER', 'RequirementSetId', 'DB_REQSET_IS_ANY_WATER'),
('DB_REQ_IS_ANY_ARCTIC', 'RequirementSetId', 'DB_REQSET_IS_ANY_ARCTIC') ;
-- "Normal Desert": no oasis/floodplains (DB_REQ_IS_NORMAL_DESERT, DB_REQSET_IS_NORMAL_DESERT)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType, Inverse) VALUES
('DB_REQ_IS_NOT_FLOODPLAINS', 'REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES', 1),
('DB_REQ_IS_NOT_OASIS', 'REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES', 1),
('DB_REQ_IS_NOT_FLOODPLAINS_OR_OASIS', 'REQUIREMENT_REQUIREMENTSET_IS_MET', 0),
('DB_REQ_IS_NORMAL_DESERT', 'REQUIREMENT_REQUIREMENTSET_IS_MET', 0) ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES
('DB_REQ_IS_NOT_FLOODPLAINS', 'FeatureType', 'FEATURE_FLOODPLAINS'),
('DB_REQ_IS_NOT_OASIS', 'FeatureType', 'FEATURE_OASIS'),
('DB_REQ_IS_NOT_FLOODPLAINS_OR_OASIS', 'RequirementSetId', 'DB_REQSET_IS_NOT_FLOODPLAINS_OR_OASIS'),
('DB_REQ_IS_NORMAL_DESERT', 'RequirementSetId', 'DB_REQSET_IS_NORMAL_DESERT') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('DB_REQSET_IS_NOT_FLOODPLAINS_OR_OASIS', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_IS_NORMAL_DESERT', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_IS_NOT_FLOODPLAINS_OR_OASIS', 'DB_REQ_IS_NOT_FLOODPLAINS'),
('DB_REQSET_IS_NOT_FLOODPLAINS_OR_OASIS', 'DB_REQ_IS_NOT_OASIS'),
('DB_REQSET_IS_NORMAL_DESERT', 'DB_REQ_IS_ANY_DESERT'),
('DB_REQSET_IS_NORMAL_DESERT', 'DB_REQ_IS_NOT_FLOODPLAINS_OR_OASIS') ;
-- Plot has feature (DB_REQ_HAS_FOREST, DB_REQSET_HAS_FOREST)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_HAS_' || SUBSTR(FeatureType, 9), 'REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES' FROM Features ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_HAS_' || SUBSTR(FeatureType, 9), 'FeatureType', FeatureType FROM Features ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_HAS_' || SUBSTR(FeatureType, 9), 'REQUIREMENTSET_TEST_ALL' FROM Features ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(FeatureType, 9), 'DB_REQ_HAS_' || SUBSTR(FeatureType, 9) FROM Features ;
-- Plot has feature X and is next to district Y (DB_REQ_HAS_STONE_NEXT_TO_HOLY_SITE, DB_REQSET_HAS_STONE_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.FeatureType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Features AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.FeatureType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_HAS_' || SUBSTR(a.FeatureType, 9) FROM Features AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.FeatureType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Features AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_HAS_' || SUBSTR(a.FeatureType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Features AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_HAS_' || SUBSTR(a.FeatureType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'RequirementSetId', 'DB_REQSET_HAS_' || SUBSTR(a.FeatureType, 9) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Features AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
-- Some resources from Resourceful2 (so that it doesn't throw an error if Resourceful2 is missing)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES
('DB_REQ_HAS_HONEY', 'REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES'),
('DB_REQ_HAS_MUSHROOMS', 'REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES'),
('DB_REQ_HAS_ORCA', 'REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES
('DB_REQ_HAS_HONEY', 'ResourceType', 'RESOURCE_HONEY'),
('DB_REQ_HAS_MUSHROOMS', 'ResourceType', 'RESOURCE_MUSHROOMS'),
('DB_REQ_HAS_ORCA', 'ResourceType', 'RESOURCE_ORCA') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('DB_REQSET_HAS_HONEY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_HAS_MUSHROOMS', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_HAS_ORCA', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_HAS_HONEY', 'DB_REQ_HAS_HONEY'),
('DB_REQSET_HAS_MUSHROOMS', 'DB_REQ_HAS_MUSHROOMS'),
('DB_REQSET_HAS_ORCA', 'DB_REQ_HAS_ORCA') ;
-- Plot has resource (DB_REQ_HAS_STONE, DB_REQSET_HAS_STONE)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_HAS_' || SUBSTR(ResourceType, 10), 'REQUIREMENT_PLOT_RESOURCE_TYPE_MATCHES' FROM Resources ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_HAS_' || SUBSTR(ResourceType, 10), 'ResourceType', ResourceType FROM Resources ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_HAS_' || SUBSTR(ResourceType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Resources ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(ResourceType, 10), 'DB_REQ_HAS_' || SUBSTR(ResourceType, 10) FROM Resources ;
-- Plot has resource X and is next to district Y (DB_REQ_HAS_STONE_NEXT_TO_HOLY_SITE, DB_REQSET_HAS_STONE_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.ResourceType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Resources AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.ResourceType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_HAS_' || SUBSTR(a.ResourceType, 10) FROM Resources AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.ResourceType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Resources AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_HAS_' || SUBSTR(a.ResourceType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Resources AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_HAS_' || SUBSTR(a.ResourceType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'RequirementSetId', 'DB_REQSET_HAS_' || SUBSTR(a.ResourceType, 10) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Resources AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
-- Plot has improvement (DB_REQ_HAS_AIRSTRIP, DB_REQSET_HAS_AIRSTRIP)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_HAS_' || SUBSTR(ImprovementType, 13), 'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES' FROM Improvements ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_HAS_' || SUBSTR(ImprovementType, 13), 'ImprovementType', ImprovementType FROM Improvements ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_HAS_' || SUBSTR(ImprovementType, 13), 'REQUIREMENTSET_TEST_ALL' FROM Improvements ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(ImprovementType, 13), 'DB_REQ_HAS_' || SUBSTR(ImprovementType, 13) FROM Improvements ;
-- Plot has a standard resource improvement or industry/corporation (DB_REQSET_HAS_STANDARD_RESOURCE_IMPROVEMENT_OR_INDUSTRY_OR_CORPORATION, DB_REQ_HAS_STANDARD_RESOURCE_IMPROVEMENT_OR_INDUSTRY_OR_CORPORATION)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_HAS_STANDARD_RESOURCE_IMPROVEMENT_OR_INDUSTRY_OR_CORPORATION', 'REQUIREMENTSET_TEST_ANY') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT DISTINCT 'DB_REQSET_HAS_STANDARD_RESOURCE_IMPROVEMENT_OR_INDUSTRY_OR_CORPORATION', 'DB_REQ_HAS_' || SUBSTR(ImprovementType, 13) FROM Improvement_ValidResources WHERE ImprovementType NOT IN (SELECT ImprovementType FROM Improvements WHERE DefenseModifier > 0 OR AirSlots > 0 OR WeaponSlots > 0) ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_HAS_STANDARD_RESOURCE_IMPROVEMENT_OR_INDUSTRY_OR_CORPORATION', 'REQUIREMENT_REQUIREMENTSET_IS_MET') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_HAS_STANDARD_RESOURCE_IMPROVEMENT_OR_INDUSTRY_OR_CORPORATION', 'RequirementSetId', 'DB_REQSET_HAS_STANDARD_RESOURCE_IMPROVEMENT_OR_INDUSTRY_OR_CORPORATION') ;
-- Plot has improvement X and is next to district Y (DB_REQ_HAS_MINE_NEXT_TO_HOLY_SITE, DB_REQSET_HAS_MINE_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.ImprovementType, 13) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Improvements AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.ImprovementType, 13) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_HAS_' || SUBSTR(a.ImprovementType, 13) FROM Improvements AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_HAS_' || SUBSTR(a.ImprovementType, 13) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Improvements AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_HAS_' || SUBSTR(a.ImprovementType, 13) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Improvements AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_HAS_' || SUBSTR(a.ImprovementType, 13) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10), 'RequirementSetId', 'DB_REQSET_HAS_' || SUBSTR(a.ImprovementType, 13) || '_NEXT_TO_' || SUBSTR(b.DistrictType, 10) FROM Improvements AS a LEFT JOIN Districts AS b WHERE b.TraitType IS NULL ;
-- Specific Mines (DB_REQ_HAS_STRATEGIC_MINE, DB_REQSET_HAS_STRATEGIC_MINE)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES
('DB_REQ_HAS_BONUS_MINE', 'REQUIREMENT_REQUIREMENTSET_IS_MET'),
('DB_REQ_HAS_LUXURY_MINE', 'REQUIREMENT_REQUIREMENTSET_IS_MET'),
('DB_REQ_HAS_STRATEGIC_MINE', 'REQUIREMENT_REQUIREMENTSET_IS_MET') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES
('DB_REQ_HAS_BONUS_MINE', 'RequirementSetId', 'PLOT_HAS_BONUS_MINE_REQUIREMENTS'),
('DB_REQ_HAS_LUXURY_MINE', 'RequirementSetId', 'PLOT_HAS_LUXURY_MINE_REQUIREMENTS'),
('DB_REQ_HAS_STRATEGIC_MINE', 'RequirementSetId', 'PLOT_HAS_STRATEGIC_MINE_REQUIREMENTS');
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('DB_REQSET_HAS_BONUS_MINE', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_HAS_LUXURY_MINE', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_HAS_STRATEGIC_MINE', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_HAS_BONUS_MINE', 'DB_REQ_HAS_BONUS_MINE'),
('DB_REQSET_HAS_LUXURY_MINE', 'DB_REQ_HAS_LUXURY_MINE'),
('DB_REQSET_HAS_STRATEGIC_MINE', 'DB_REQ_HAS_STRATEGIC_MINE') ;
-- Strategic Mine next to district (DB_REQ_STRATEGIC_MINE_NEXT_TO_HOLY_SITE, DB_REQSET_STRATEGIC_MINE_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_STRATEGIC_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_STRATEGIC_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'DB_REQ_HAS_STRATEGIC_MINE' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_STRATEGIC_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_STRATEGIC_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_STRATEGIC_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'RequirementSetId', 'DB_REQSET_STRATEGIC_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
-- Bonus Mine OR Luxury Mine (DB_REQ_HAS_BONUS_OR_LUXURY_MINE, DB_REQSET_HAS_BONUS_OR_LUXURY_MINE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_HAS_BONUS_OR_LUXURY_MINE', 'REQUIREMENTSET_TEST_ANY') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_HAS_BONUS_OR_LUXURY_MINE', 'DB_REQ_HAS_LUXURY_MINE'),
('DB_REQSET_HAS_BONUS_OR_LUXURY_MINE', 'DB_REQ_HAS_BONUS_MINE') ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_HAS_BONUS_OR_LUXURY_MINE', 'REQUIREMENT_REQUIREMENTSET_IS_MET');
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_HAS_BONUS_OR_LUXURY_MINE', 'RequirementSetId', 'DB_REQSET_HAS_BONUS_OR_LUXURY_MINE');
-- Bonus or Luxury mine next to district (DB_REQ_BONUS_OR_LUXURY_MINE_NEXT_TO_HOLY_SITE, DB_REQSET_BONUS_OR_LUXURY_MINE_NEXT_TO_HOLY_SITE)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
SELECT 'DB_REQSET_BONUS_OR_LUXURY_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'REQUIREMENTSET_TEST_ALL' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_BONUS_OR_LUXURY_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'DB_REQ_HAS_BONUS_OR_LUXURY_MINE' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
SELECT 'DB_REQSET_BONUS_OR_LUXURY_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'DB_REQ_NEXT_TO_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
SELECT 'DB_REQ_BONUS_OR_LUXURY_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'REQUIREMENT_REQUIREMENTSET_IS_MET' FROM Districts WHERE TraitType IS NULL ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
SELECT 'DB_REQ_BONUS_OR_LUXURY_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10), 'RequirementSetId', 'DB_REQSET_BONUS_OR_LUXURY_MINE_NEXT_TO_' || SUBSTR(DistrictType, 10) FROM Districts WHERE TraitType IS NULL ;
-- Plot is Breathtaking (DB_REQ_BREATHTAKING_APPEAL, DB_REQSET_BREATHTAKING_APPEAL)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_BREATHTAKING_APPEAL', 'REQUIREMENT_PLOT_IS_APPEAL_BETWEEN') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_BREATHTAKING_APPEAL', 'MinimumAppeal', 4) ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_BREATHTAKING_APPEAL', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_BREATHTAKING_APPEAL', 'DB_REQ_BREATHTAKING_APPEAL') ;
-- Units being near friendly and enemy cities that follow our religion (DB_REQ_UNIT_NEAR_FRIENDLY_RELIGIOUS_CITY, DB_REQSET_UNIT_NEAR_FRIENDLY_RELIGIOUS_CITY)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('DB_REQSET_UNIT_NEAR_FRIENDLY_RELIGIOUS_CITY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_UNIT_NEAR_ENEMY_RELIGIOUS_CITY', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_UNIT_NEAR_FRIENDLY_RELIGIOUS_CITY', 'REQUIRES_UNIT_NEAR_FRIENDLY_RELIGIOUS_CITY'),
('DB_REQSET_UNIT_NEAR_ENEMY_RELIGIOUS_CITY', 'REQUIRES_UNIT_NEAR_ENEMY_RELIGIOUS_CITY') ;
-- Plot within X tiles of where the modifier is attached (DB_REQ_WITHIN_9_TILES, DB_REQSET_WITHIN_9_TILES)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 0 x UNION SELECT x + 1 FROM counter WHERE x < 20)
SELECT 'DB_REQ_WITHIN_' || x || '_TILES', 'REQUIREMENT_PLOT_ADJACENT_TO_OWNER' FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 0 x UNION SELECT x + 1 FROM counter WHERE x < 20)
SELECT 'DB_REQ_WITHIN_' || x || '_TILES', 'MinDistance', 0 FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 0 x UNION SELECT x + 1 FROM counter WHERE x < 20)
SELECT 'DB_REQ_WITHIN_' || x || '_TILES', 'MaxDistance', x FROM counter ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 0 x UNION SELECT x + 1 FROM counter WHERE x < 20)
SELECT 'DB_REQSET_WITHIN_' || x || '_TILES', 'REQUIREMENTSET_TEST_ALL' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 0 x UNION SELECT x + 1 FROM counter WHERE x < 20)
SELECT 'DB_REQSET_WITHIN_' || x || '_TILES', 'DB_REQ_WITHIN_' || x || '_TILES' FROM counter ;
-- Reqset for being within 2 tiles of owner (e.g. great generals)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_AOE_OWNER_ADJACENCY', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_AOE_OWNER_ADJACENCY', 'AOE_REQUIRES_OWNER_ADJACENCY') ;
-- Unit is Religious (all)
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_UNIT_IS_RELIGIOUS_ALL', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_UNIT_IS_RELIGIOUS_ALL', 'REQUIRES_UNIT_IS_RELIGIOUS_ALL') ;
-- Unit is Guru
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_UNIT_IS_GURU', 'REQUIREMENT_UNIT_TYPE_MATCHES') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_UNIT_IS_GURU', 'UnitType', 'UNIT_GURU') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_UNIT_IS_GURU', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_UNIT_IS_GURU', 'DB_REQ_UNIT_IS_GURU') ;
-- Unit is Great Prophet
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_UNIT_IS_GREAT_PROPHET', 'REQUIREMENT_UNIT_TYPE_MATCHES') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_UNIT_IS_GREAT_PROPHET', 'UnitType', 'UNIT_GREAT_PROPHET') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_UNIT_IS_GREAT_PROPHET', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_UNIT_IS_GREAT_PROPHET', 'DB_REQ_UNIT_IS_GREAT_PROPHET') ;
-- Unit next to Guru
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_NEXTTO_GURU', 'REQUIREMENT_PLOT_ADJACENT_FRIENDLY_UNIT_TYPE_MATCHES') ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value) VALUES ('DB_REQ_NEXTTO_GURU', 'UnitType', 'UNIT_GURU') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_NEXTTO_GURU', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_NEXTTO_GURU', 'DB_REQ_NEXTTO_GURU') ;
-- Unit next to Great Prophet
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType) VALUES ('DB_REQ_NEXTTO_GREAT_PROPHET', 'REQUIREMENT_PLOT_NEARBY_UNIT_TAG_MATCHES') ;
INSERT OR IGNORE INTO RequirementArguments
(RequirementId, Name, Value)
VALUES
('DB_REQ_NEXTTO_GREAT_PROPHET', 'MaxDistance', 2),
('DB_REQ_NEXTTO_GREAT_PROPHET', 'MinDistance', 0),
('DB_REQ_NEXTTO_GREAT_PROPHET', 'Tag', 'DB_CLASS_GREAT_PROPHET') ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_NEXTTO_GREAT_PROPHET', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES ('DB_REQSET_NEXTTO_GREAT_PROPHET', 'DB_REQ_NEXTTO_GREAT_PROPHET') ;
/*
-- Non-religious unit belongs to civ that founded the religion that has this belief
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('DB_REQSET_FOUNDERS_COMBAT_UNIT', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_FOUNDERS_COMBAT_UNIT', 'REQUIRES_NON_RELIGIOUS_UNIT'),
('DB_REQSET_FOUNDERS_COMBAT_UNIT', 'REQUIRES_PLAYER_FOUNDED_RELIGION') ;
-- Inquisitor unit belongs to civ that founded the religion that has this belief
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES ('DB_REQSET_FOUNDERS_INQUISITOR', 'REQUIREMENTSET_TEST_ALL') ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('DB_REQSET_FOUNDERS_INQUISITOR', 'REQUIRES_UNIT_IS_INQUISITOR'),
('DB_REQSET_FOUNDERS_INQUISITOR', 'REQUIRES_PLAYER_FOUNDED_RELIGION') ;
*/
-- Governor with X titles (DB_REQSET_CITY_HAS_PANTHEON_AND_2_GOV_TITLE_ESTABLISHED)
INSERT OR IGNORE INTO Requirements (RequirementId, RequirementType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 6)
SELECT 'DB_REQ_CITY_HAS_' || x || '_TITLE_GOVERNOR_ESTABLISHED', 'REQUIREMENT_CITY_HAS_GOVERNOR_WITH_X_TITLES' FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 6)
SELECT 'DB_REQ_CITY_HAS_' || x || '_TITLE_GOVERNOR_ESTABLISHED', 'Amount', x FROM counter ;
INSERT OR IGNORE INTO RequirementArguments (RequirementId, Name, Value)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 6)
SELECT 'DB_REQ_CITY_HAS_' || x || '_TITLE_GOVERNOR_ESTABLISHED', 'Established', 1 FROM counter ;
INSERT OR IGNORE INTO RequirementSets (RequirementSetId, RequirementSetType)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 6)
SELECT 'DB_REQSET_CITY_HAS_PANTHEON_AND_' || x || '_GOV_TITLE_ESTABLISHED', 'REQUIREMENTSET_TEST_ALL' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 6)
SELECT 'DB_REQSET_CITY_HAS_PANTHEON_AND_' || x || '_GOV_TITLE_ESTABLISHED', 'DB_REQ_CITY_HAS_' || x || '_TITLE_GOVERNOR_ESTABLISHED' FROM counter ;
INSERT OR IGNORE INTO RequirementSetRequirements (RequirementSetId, RequirementId)
WITH counter as (SELECT 1 x UNION SELECT x + 1 FROM counter WHERE x < 6)
SELECT 'DB_REQSET_CITY_HAS_PANTHEON_AND_' || x || '_GOV_TITLE_ESTABLISHED', 'REQUIRES_CITY_FOLLOWS_PANTHEON' FROM counter ;
-- Embarked and not-Embarked
INSERT OR IGNORE INTO Requirements
(RequirementId, RequirementType, Inverse)
VALUES
('DB_REQ_EMBARKED', 'REQUIREMENT_UNIT_EMBARKED', 0),
('DB_REQ_NOT_EMBARKED', 'REQUIREMENT_UNIT_EMBARKED', 1)
;
INSERT OR IGNORE INTO RequirementSets
(RequirementSetId, RequirementSetType)
VALUES
('DB_REQSET_EMBARKED', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_NOT_EMBARKED', 'REQUIREMENTSET_TEST_ALL')
;
INSERT OR IGNORE INTO RequirementSetRequirements
(RequirementSetId, RequirementId)
VALUES
('DB_REQSET_EMBARKED', 'DB_REQ_EMBARKED'),
('DB_REQSET_NOT_EMBARKED', 'DB_REQ_NOT_EMBARKED')
;
-- Attacking and Defending
INSERT OR IGNORE INTO Requirements
(RequirementId, RequirementType, Inverse)
VALUES
('DB_REQ_ATTACKING', 'REQUIREMENT_PLAYER_IS_ATTACKING', 0),
('DB_REQ_DEFENDING', 'REQUIREMENT_PLAYER_IS_ATTACKING', 1)
;
INSERT OR IGNORE INTO RequirementSets
(RequirementSetId, RequirementSetType)
VALUES
('DB_REQSET_ATTACKING', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING', 'REQUIREMENTSET_TEST_ALL')
;
INSERT OR IGNORE INTO RequirementSetRequirements
(RequirementSetId, RequirementId)
VALUES
('DB_REQSET_ATTACKING', 'DB_REQ_ATTACKING'),
('DB_REQSET_DEFENDING', 'DB_REQ_DEFENDING')
;
-- Home and Away
INSERT OR IGNORE INTO Requirements
(RequirementId, RequirementType, Inverse)
VALUES
('DB_REQ_INSIDE_HOME_TERRITORY', 'REQUIREMENT_UNIT_IN_OWNER_TERRITORY', 0),
('DB_REQ_INSIDE_FOREIGN_TERRITORY', 'REQUIREMENT_UNIT_IN_ENEMY_TERRITORY', 0),
('DB_REQ_OUTSIDE_HOME_TERRITORY', 'REQUIREMENT_UNIT_IN_OWNER_TERRITORY', 1),
('DB_REQ_OUTSIDE_FOREIGN_TERRITORY', 'REQUIREMENT_UNIT_IN_ENEMY_TERRITORY', 1),
('DB_REQ_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF', 'REQUIREMENT_NEAR_RELIGIOUS_CITY', 0),
('DB_REQ_INSIDE_HOME_TERRITORY_WITH_BELIEF', 'REQUIREMENT_NEAR_RELIGIOUS_CITY', 0)
;
INSERT OR IGNORE INTO RequirementArguments
(RequirementId, Name, Value)
VALUES
('DB_REQ_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF', 'FriendlyCity', 0),
('DB_REQ_INSIDE_HOME_TERRITORY_WITH_BELIEF', 'FriendlyCity', 1)
;
INSERT OR IGNORE INTO RequirementSets
(RequirementSetId, RequirementSetType)
VALUES
('DB_REQSET_INSIDE_HOME_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_OUTSIDE_HOME_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_OUTSIDE_FOREIGN_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_OUTSIDE_HOME_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_OUTSIDE_FOREIGN_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_OUTSIDE_HOME_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_OUTSIDE_FOREIGN_TERRITORY', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_OUTSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_OUTSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_OUTSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_OUTSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_OUTSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_OUTSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'REQUIREMENTSET_TEST_ALL')
;
INSERT OR IGNORE INTO RequirementSetRequirements
(RequirementSetId, RequirementId)
VALUES
('DB_REQSET_INSIDE_HOME_TERRITORY', 'DB_REQ_INSIDE_HOME_TERRITORY'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY', 'DB_REQ_INSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_OUTSIDE_HOME_TERRITORY', 'DB_REQ_OUTSIDE_HOME_TERRITORY'),
('DB_REQSET_OUTSIDE_FOREIGN_TERRITORY', 'DB_REQ_OUTSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY', 'DB_REQ_INSIDE_HOME_TERRITORY'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY', 'DB_REQ_ATTACKING'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY', 'DB_REQ_INSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY', 'DB_REQ_ATTACKING'),
('DB_REQSET_ATTACKING_OUTSIDE_HOME_TERRITORY', 'DB_REQ_OUTSIDE_HOME_TERRITORY'),
('DB_REQSET_ATTACKING_OUTSIDE_HOME_TERRITORY', 'DB_REQ_ATTACKING'),
('DB_REQSET_ATTACKING_OUTSIDE_FOREIGN_TERRITORY', 'DB_REQ_OUTSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_ATTACKING_OUTSIDE_FOREIGN_TERRITORY', 'DB_REQ_ATTACKING'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY', 'DB_REQ_INSIDE_HOME_TERRITORY'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY', 'DB_REQ_DEFENDING'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY', 'DB_REQ_INSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY', 'DB_REQ_DEFENDING'),
('DB_REQSET_DEFENDING_OUTSIDE_HOME_TERRITORY', 'DB_REQ_OUTSIDE_HOME_TERRITORY'),
('DB_REQSET_DEFENDING_OUTSIDE_HOME_TERRITORY', 'DB_REQ_DEFENDING'),
('DB_REQSET_DEFENDING_OUTSIDE_FOREIGN_TERRITORY', 'DB_REQ_OUTSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_DEFENDING_OUTSIDE_FOREIGN_TERRITORY', 'DB_REQ_DEFENDING'),
('DB_REQSET_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_HOME_TERRITORY'),
('DB_REQSET_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIRES_OPPONENT_IS_OTHER_RELIGION'),
('DB_REQSET_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIRES_OPPONENT_IS_OTHER_RELIGION'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_HOME_TERRITORY'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_ATTACKING'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIRES_OPPONENT_IS_OTHER_RELIGION'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_ATTACKING'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIRES_OPPONENT_IS_OTHER_RELIGION'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_HOME_TERRITORY'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_DEFENDING'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIRES_OPPONENT_IS_OTHER_RELIGION'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_FOREIGN_TERRITORY'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_DEFENDING'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'REQUIRES_OPPONENT_IS_OTHER_RELIGION'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_ENEMY_OTHER_RELIGION_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF'),
('DB_REQSET_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_HOME_TERRITORY_WITH_BELIEF'),
('DB_REQSET_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_ATTACKING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_ATTACKING'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_HOME_TERRITORY_WITH_BELIEF'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_ATTACKING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_ATTACKING'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_DEFENDING_INSIDE_FOREIGN_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_DEFENDING'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_INSIDE_HOME_TERRITORY_WITH_BELIEF'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_OPPONENT_IS_NOT_CITY_OR_ENCAMPMENT'),
('DB_REQSET_DEFENDING_INSIDE_HOME_TERRITORY_WITH_BELIEF_NOT_CITY_OR_ENCAMPMENT', 'DB_REQ_DEFENDING')
;
-- Combat Type is ranged, melee
INSERT OR IGNORE INTO Requirements
(RequirementId, RequirementType, Inverse)
VALUES
('DB_REQ_MELEE_COMBAT', 'REQUIREMENT_COMBAT_TYPE_MATCHES', 0),
('DB_REQ_RANGED_COMBAT', 'REQUIREMENT_COMBAT_TYPE_MATCHES', 0)
;
INSERT OR IGNORE INTO RequirementArguments