-
Notifications
You must be signed in to change notification settings - Fork 0
/
DMCR.sql
9647 lines (9110 loc) · 642 KB
/
DMCR.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
-- MySQL dump 10.13 Distrib 8.0.33, for Win64 (x86_64)
--
-- Host: 192.168.0.153 Database: alexander
-- ------------------------------------------------------
-- Server version 8.0.33
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `clan_states`
--
DROP TABLE IF EXISTS `clan_states`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clan_states` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clan_states`
--
LOCK TABLES `clan_states` WRITE;
/*!40000 ALTER TABLE `clan_states` DISABLE KEYS */;
INSERT INTO `clan_states` VALUES (1,'Novice'),(2,'Member'),(3,'Father');
/*!40000 ALTER TABLE `clan_states` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `clans`
--
DROP TABLE IF EXISTS `clans`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clans` (
`id` bigint NOT NULL AUTO_INCREMENT,
`creator` bigint DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`title` varchar(64) NOT NULL,
`signature` varchar(64) NOT NULL,
`info` varchar(256) NOT NULL DEFAULT '""',
`games` bigint NOT NULL DEFAULT '0',
`total_score` bigint NOT NULL DEFAULT '0',
`average_score` bigint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `title` (`title`),
UNIQUE KEY `signature` (`signature`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clans`
--
LOCK TABLES `clans` WRITE;
/*!40000 ALTER TABLE `clans` DISABLE KEYS */;
INSERT INTO `clans` VALUES (1,1,'2023-08-11 15:46:04','THE KITTEH','[KITTEH]','I\'M THE ONE WHO MEOWS!',0,0,0);
/*!40000 ALTER TABLE `clans` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `countries`
--
DROP TABLE IF EXISTS `countries`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `countries` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(64) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=195 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `countries`
--
LOCK TABLES `countries` WRITE;
/*!40000 ALTER TABLE `countries` DISABLE KEYS */;
INSERT INTO `countries` VALUES (1,'Not specified'),(2,'Afghanistan'),(3,'Albania'),(4,'Algeria'),(5,'Andorra'),(6,'Angola'),(7,'Antigua and Barbuda'),(8,'Argentina'),(9,'Armenia'),(10,'Austria'),(11,'Azerbaijan'),(12,'Bahrain'),(13,'Bangladesh'),(14,'Barbados'),(15,'Belarus'),(16,'Belgium'),(17,'Belize'),(18,'Benin'),(19,'Bhutan'),(20,'Bolivia'),(21,'Bosnia and Herzegovina'),(22,'Botswana'),(23,'Brazil'),(24,'Brunei'),(25,'Bulgaria'),(26,'Burkina Faso'),(27,'Burundi'),(28,'Cabo Verde'),(29,'Cambodia'),(30,'Cameroon'),(31,'Canada'),(32,'Central African Republic'),(33,'Chad'),(34,'Channel Islands'),(35,'Chile'),(36,'China'),(37,'Colombia'),(38,'Comoros'),(39,'Congo'),(40,'Costa Rica'),(41,'Cote d\'Ivoire'),(42,'Croatia'),(43,'Cuba'),(44,'Cyprus'),(45,'Czech Republic'),(46,'Denmark'),(47,'Djibouti'),(48,'Dominica'),(49,'Dominican Republic'),(50,'DR Congo'),(51,'Ecuador'),(52,'Egypt'),(53,'El Salvador'),(54,'Equatorial Guinea'),(55,'Eritrea'),(56,'Estonia'),(57,'Eswatini'),(58,'Ethiopia'),(59,'Faeroe Islands'),(60,'Finland'),(61,'France'),(62,'French Guiana'),(63,'Gabon'),(64,'Gambia'),(65,'Georgia'),(66,'Germany'),(67,'Ghana'),(68,'Gibraltar'),(69,'Greece'),(70,'Grenada'),(71,'Guatemala'),(72,'Guinea'),(73,'Guinea-Bissau'),(74,'Guyana'),(75,'Haiti'),(76,'Holy See'),(77,'Honduras'),(78,'Hong Kong'),(79,'Hungary'),(80,'Iceland'),(81,'India'),(82,'Indonesia'),(83,'Iran'),(84,'Iraq'),(85,'Ireland'),(86,'Isle of Man'),(87,'Israel'),(88,'Italy'),(89,'Jamaica'),(90,'Japan'),(91,'Jordan'),(92,'Kazakhstan'),(93,'Kenya'),(94,'Kuwait'),(95,'Kyrgyzstan'),(96,'Laos'),(97,'Latvia'),(98,'Lebanon'),(99,'Lesotho'),(100,'Liberia'),(101,'Libya'),(102,'Liechtenstein'),(103,'Lithuania'),(104,'Luxembourg'),(105,'Macao'),(106,'Madagascar'),(107,'Malawi'),(108,'Malaysia'),(109,'Maldives'),(110,'Mali'),(111,'Malta'),(112,'Mauritania'),(113,'Mauritius'),(114,'Mayotte'),(115,'Mexico'),(116,'Moldova'),(117,'Monaco'),(118,'Mongolia'),(119,'Montenegro'),(120,'Morocco'),(121,'Mozambique'),(122,'Myanmar'),(123,'Namibia'),(124,'Nepal'),(125,'Netherlands'),(126,'Nicaragua'),(127,'Niger'),(128,'Nigeria'),(129,'North Korea'),(130,'North Macedonia'),(131,'Norway'),(132,'Oman'),(133,'Pakistan'),(134,'Panama'),(135,'Paraguay'),(136,'Peru'),(137,'Philippines'),(138,'Poland'),(139,'Portugal'),(140,'Qatar'),(141,'Reunion'),(142,'Romania'),(143,'Russia'),(144,'Rwanda'),(145,'Saint Helena'),(146,'Saint Kitts and Nevis'),(147,'Saint Lucia'),(148,'Saint Vincent and the Grenadines'),(149,'San Marino'),(150,'Sao Tome & Principe'),(151,'Saudi Arabia'),(152,'Senegal'),(153,'Serbia'),(154,'Seychelles'),(155,'Sierra Leone'),(156,'Singapore'),(157,'Slovakia'),(158,'Slovenia'),(159,'Somalia'),(160,'South Africa'),(161,'South Korea'),(162,'South Sudan'),(163,'Spain'),(164,'Sri Lanka'),(165,'State of Palestine'),(166,'Sudan'),(167,'Suriname'),(168,'Sweden'),(169,'Switzerland'),(170,'Syria'),(171,'Taiwan'),(172,'Tajikistan'),(173,'Tanzania'),(174,'Thailand'),(175,'The Bahamas'),(176,'Timor-Leste'),(177,'Togo'),(178,'Trinidad and Tobago'),(179,'Tunisia'),(180,'Turkey'),(181,'Turkmenistan'),(182,'Uganda'),(183,'Ukraine'),(184,'United Arab Emirates'),(185,'United Kingdom'),(186,'United States'),(187,'Uruguay'),(188,'Uzbekistan'),(189,'Venezuela'),(190,'Vietnam'),(191,'Western Sahara'),(192,'Yemen'),(193,'Zambia'),(194,'Zimbabwe');
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `game_log`
--
DROP TABLE IF EXISTS `game_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `game_log` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`as_clan` bigint unsigned DEFAULT NULL COMMENT 'This field is used to track if member has played for the specific clan. The result of this field is used to determine the ''clan state'' of a given player (ie. ''Novice'' | ''Member'')',
`winner_id` bigint unsigned NOT NULL,
`loser_id` bigint unsigned NOT NULL,
`type` tinyint unsigned NOT NULL,
`title` varchar(32) NOT NULL DEFAULT '""',
`winner_nat` tinyint unsigned NOT NULL,
`loser_nat` tinyint unsigned NOT NULL,
`points_won` int NOT NULL DEFAULT '0',
`points_lost` int NOT NULL DEFAULT '0',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`) /*!80000 INVISIBLE */,
KEY `player1_id` (`winner_id`),
KEY `player2_id` (`loser_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `game_log`
--
LOCK TABLES `game_log` WRITE;
/*!40000 ALTER TABLE `game_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `game_log` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `gmids`
--
DROP TABLE IF EXISTS `gmids`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `gmids` (
`id` bigint NOT NULL AUTO_INCREMENT,
`gmid` varchar(20) NOT NULL,
`hasBeenUsed` tinyint NOT NULL DEFAULT '0',
UNIQUE KEY `id` (`id`),
UNIQUE KEY `gmid` (`gmid`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `gmids`
--
LOCK TABLES `gmids` WRITE;
/*!40000 ALTER TABLE `gmids` DISABLE KEYS */;
INSERT INTO `gmids` VALUES (3,'TEST-TEST-TEST-TEST',1),(4,'1111-1111-1111-1111',1);
/*!40000 ALTER TABLE `gmids` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `lobbies`
--
DROP TABLE IF EXISTS `lobbies`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `lobbies` (
`id` bigint NOT NULL AUTO_INCREMENT,
`title` varchar(32) NOT NULL,
`host_id` bigint NOT NULL,
`heartbeat` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`type` int unsigned NOT NULL DEFAULT '0',
`max_players` int unsigned NOT NULL DEFAULT '7',
`players` int unsigned NOT NULL DEFAULT '1',
`password` varchar(45) DEFAULT NULL,
`ip` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `host_id_UNIQUE` (`host_id`),
KEY `lobbies_ibfk_1_idx` (`host_id`),
CONSTRAINT `lobbies_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `players` (`player_id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `lobbies`
--
LOCK TABLES `lobbies` WRITE;
/*!40000 ALTER TABLE `lobbies` DISABLE KEYS */;
/*!40000 ALTER TABLE `lobbies` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `lobby_types`
--
DROP TABLE IF EXISTS `lobby_types`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `lobby_types` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`allow_designed` tinyint unsigned DEFAULT '0',
`allow_ai` tinyint unsigned NOT NULL DEFAULT '0',
`name` varchar(16) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `lobby_types`
--
LOCK TABLES `lobby_types` WRITE;
/*!40000 ALTER TABLE `lobby_types` DISABLE KEYS */;
INSERT INTO `lobby_types` VALUES (1,0,0,'Scored'),(2,0,1,'Custom'),(3,1,1,'Designed');
/*!40000 ALTER TABLE `lobby_types` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `mail_messages`
--
DROP TABLE IF EXISTS `mail_messages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mail_messages` (
`id` bigint NOT NULL AUTO_INCREMENT,
`sent_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`id_from` bigint unsigned NOT NULL,
`id_to` bigint unsigned NOT NULL,
`subject` varchar(32) NOT NULL,
`content` varchar(256) NOT NULL,
`status` bigint unsigned NOT NULL DEFAULT '1',
`removed_by_sender` tinyint unsigned DEFAULT '0',
`removed_by_recipient` tinyint unsigned DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `id_from` (`id_from`),
KEY `id_to` (`id_to`),
KEY `statuses_idx` (`status`),
CONSTRAINT `statuses` FOREIGN KEY (`status`) REFERENCES `mail_statuses` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mail_messages`
--
LOCK TABLES `mail_messages` WRITE;
/*!40000 ALTER TABLE `mail_messages` DISABLE KEYS */;
/*!40000 ALTER TABLE `mail_messages` ENABLE KEYS */;
UNLOCK TABLES;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `mail_messages_BEFORE_INSERT` BEFORE INSERT ON `mail_messages` FOR EACH ROW BEGIN
IF NEW.subject = '' THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "ERR_MAIL_NOSUB"; -- NO SUBJECT
ELSEIF NEW.content = '' THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "ERR_MAIL_NOCON"; -- NO CONTENT
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `mail_statuses`
--
DROP TABLE IF EXISTS `mail_statuses`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mail_statuses` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mail_statuses`
--
LOCK TABLES `mail_statuses` WRITE;
/*!40000 ALTER TABLE `mail_statuses` DISABLE KEYS */;
INSERT INTO `mail_statuses` VALUES (1,'unread'),(2,'read'),(3,'removed');
/*!40000 ALTER TABLE `mail_statuses` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `nations`
--
DROP TABLE IF EXISTS `nations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `nations` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `nations`
--
LOCK TABLES `nations` WRITE;
/*!40000 ALTER TABLE `nations` DISABLE KEYS */;
INSERT INTO `nations` VALUES (1,'India'),(2,'Macedonia'),(3,'Persia'),(4,'Egypt');
/*!40000 ALTER TABLE `nations` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `news`
--
DROP TABLE IF EXISTS `news`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `news` (
`id` int NOT NULL AUTO_INCREMENT,
`posted_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`content` varchar(4096) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `news`
--
LOCK TABLES `news` WRITE;
/*!40000 ALTER TABLE `news` DISABLE KEYS */;
INSERT INTO `news` VALUES (1,'2023-07-15 07:20:05','This is a news entry'),(6,'2023-08-03 06:32:44','This is another news entry');
/*!40000 ALTER TABLE `news` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `players`
--
DROP TABLE IF EXISTS `players`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `players` (
`player_id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(64) DEFAULT NULL,
`nick` varchar(64) DEFAULT NULL,
`mail` varchar(128) NOT NULL,
`icq` varchar(32) DEFAULT NULL,
`site` varchar(255) DEFAULT NULL,
`sex` bigint DEFAULT '1',
`country` bigint NOT NULL DEFAULT '1',
`birthday` varchar(10) NOT NULL,
`phone` varchar(32) DEFAULT NULL,
`gmid` varchar(20) NOT NULL,
`creatip` varchar(16) DEFAULT NULL,
`lastip` varchar(16) DEFAULT NULL,
`score` bigint unsigned NOT NULL DEFAULT '0',
`clan_id` bigint DEFAULT NULL,
`clan_rank` bigint DEFAULT NULL,
`clan_state` bigint DEFAULT NULL,
`pass` varchar(32) NOT NULL,
PRIMARY KEY (`player_id`),
KEY `clan_rank` (`clan_rank`),
KEY `clan_state` (`clan_state`),
KEY `players_ibfk_2` (`country`),
KEY `players_ibfk_1` (`sex`) /*!80000 INVISIBLE */,
KEY `fk1` (`clan_id`) /*!80000 INVISIBLE */,
KEY `mod_id` (`player_id`),
CONSTRAINT `fk3` FOREIGN KEY (`clan_id`) REFERENCES `clans` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `players_ibfk_1` FOREIGN KEY (`sex`) REFERENCES `sexes` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `players_ibfk_2` FOREIGN KEY (`country`) REFERENCES `countries` (`id`) ON UPDATE CASCADE,
CONSTRAINT `players_ibfk_4` FOREIGN KEY (`clan_rank`) REFERENCES `ranks` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `players_ibfk_5` FOREIGN KEY (`clan_state`) REFERENCES `clan_states` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `players`
--
LOCK TABLES `players` WRITE;
/*!40000 ALTER TABLE `players` DISABLE KEYS */;
INSERT INTO `players` VALUES (1,'Norbert Budzinski','norbudzinski','[email protected]','','',2,138,'14/01/1999','','TEST-TEST-TEST-TEST',NULL,NULL,0,1,1,NULL,'password');
/*!40000 ALTER TABLE `players` ENABLE KEYS */;
UNLOCK TABLES;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `players_BEFORE_INSERT` BEFORE INSERT ON `players` FOR EACH ROW BEGIN
IF new.score < 10 THEN
SET new.clan_rank = 1;
ELSEIF new.score < 25 THEN
SET new.clan_rank = 2;
ELSEIF new.score < 50 THEN
SET new.clan_rank = 3;
ELSEIF new.score < 75 THEN
SET new.clan_rank = 4;
ELSEIF new.score < 100 THEN
SET new.clan_rank = 5;
ELSEIF new.score < 125 THEN
SET new.clan_rank = 6;
ELSE
SET new.clan_rank = 7;
END IF;
CALL validate_player(NEW.nick, NEW.pass, NEW.mail);
IF EXISTS(SELECT * FROM players WHERE players.nick = NEW.nick) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'ERR_NICK_EXISTS';
ELSEIF NOT EXISTS(SELECT * FROM gmids WHERE gmid = NEW.gmid) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "ERR_GMID_INVALID";
ELSEIF EXISTS(SELECT * FROM players WHERE mail = NEW.mail) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "ERR_EMAIL_USED";
ELSEIF EXISTS(SELECT * FROM gmids WHERE gmid = NEW.gmid and hasBeenUsed = 1) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "ERR_GMID_USED";
ELSE
UPDATE gmids
SET hasBeenUsed = 1
WHERE gmid = new.gmid;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `players_BEFORE_UPDATE` BEFORE UPDATE ON `players` FOR EACH ROW BEGIN
IF NEW.clan_id != OLD.clan_id THEN
IF (SELECT creator FROM clans WHERE clans.id = OLD.clan_id) = OLD.player_id THEN
DELETE FROM clans WHERE id = OLD.clan_id;
END IF;
END IF;
CALL validate_player(NEW.nick, NEW.pass, NEW.mail);
IF EXISTS(SELECT * FROM players WHERE players.nick = NEW.nick AND NOT(players.nick = NEW.nick)) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'ERR_NICK_EXISTS';
END IF;
IF EXISTS(SELECT * FROM players WHERE players.mail = NEW.mail AND NOT(players.mail = NEW.mail)) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "ERR_EMAIL_USED";
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `punishments`
--
DROP TABLE IF EXISTS `punishments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `punishments` (
`id` int NOT NULL AUTO_INCREMENT,
`published_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`moderator_id` bigint NOT NULL,
`game_id` bigint NOT NULL,
`comment` varchar(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`) /*!80000 INVISIBLE */,
KEY `mod_id` (`moderator_id`),
CONSTRAINT `mod_id` FOREIGN KEY (`moderator_id`) REFERENCES `players` (`player_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `punishments`
--
LOCK TABLES `punishments` WRITE;
/*!40000 ALTER TABLE `punishments` DISABLE KEYS */;
/*!40000 ALTER TABLE `punishments` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `ranks`
--
DROP TABLE IF EXISTS `ranks`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ranks` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `ranks`
--
LOCK TABLES `ranks` WRITE;
/*!40000 ALTER TABLE `ranks` DISABLE KEYS */;
INSERT INTO `ranks` VALUES (1,'Recruit'),(2,'Warrior'),(3,'Veteran'),(4,'Guardsman'),(5,'Corporal'),(6,'Veteran Corporal'),(7,'Guardsmen Corporal'),(8,'Captain'),(9,'Veteran Captain'),(10,'Chief Captain'),(11,'Major'),(12,'Colonel'),(13,'Veteran Colonel');
/*!40000 ALTER TABLE `ranks` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `sessions`
--
DROP TABLE IF EXISTS `sessions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sessions` (
`player_id` bigint NOT NULL,
`session_key` char(36) NOT NULL,
`ip` varchar(16) DEFAULT NULL,
PRIMARY KEY (`player_id`),
CONSTRAINT `sessions_ibfk_1` FOREIGN KEY (`player_id`) REFERENCES `players` (`player_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `sessions`
--
LOCK TABLES `sessions` WRITE;
/*!40000 ALTER TABLE `sessions` DISABLE KEYS */;
INSERT INTO `sessions` VALUES (1,'4d61f321-385e-11ee-a63b-00ffbe07e06c',NULL);
/*!40000 ALTER TABLE `sessions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `sexes`
--
DROP TABLE IF EXISTS `sexes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sexes` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `sexes`
--
LOCK TABLES `sexes` WRITE;
/*!40000 ALTER TABLE `sexes` DISABLE KEYS */;
INSERT INTO `sexes` VALUES (1,'Not specified'),(2,'Male'),(3,'Female');
/*!40000 ALTER TABLE `sexes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `thread_messages`
--
DROP TABLE IF EXISTS `thread_messages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `thread_messages` (
`id` bigint NOT NULL AUTO_INCREMENT,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`author_id` bigint NOT NULL,
`thread_id` bigint NOT NULL,
`content` varchar(512) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `thread_messages_ibfk_1` (`author_id`),
KEY `thread_messages_ibfk_2` (`thread_id`),
CONSTRAINT `thread_messages_ibfk_1` FOREIGN KEY (`author_id`) REFERENCES `players` (`player_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `thread_messages_ibfk_2` FOREIGN KEY (`thread_id`) REFERENCES `threads` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `thread_messages`
--
LOCK TABLES `thread_messages` WRITE;
/*!40000 ALTER TABLE `thread_messages` DISABLE KEYS */;
/*!40000 ALTER TABLE `thread_messages` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `threads`
--
DROP TABLE IF EXISTS `threads`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `threads` (
`id` bigint NOT NULL AUTO_INCREMENT,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`author_id` bigint NOT NULL,
`content` varchar(512) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `threads_ibfk_1` (`author_id`),
CONSTRAINT `threads_ibfk_1` FOREIGN KEY (`author_id`) REFERENCES `players` (`player_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `threads`
--
LOCK TABLES `threads` WRITE;
/*!40000 ALTER TABLE `threads` DISABLE KEYS */;
/*!40000 ALTER TABLE `threads` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vote_answers`
--
DROP TABLE IF EXISTS `vote_answers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vote_answers` (
`id` int NOT NULL AUTO_INCREMENT,
`vote_id` bigint NOT NULL,
`text` varchar(64) NOT NULL,
`votes` bigint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `vote_answers_ibfk_1` (`vote_id`),
CONSTRAINT `vote_answers_ibfk_1` FOREIGN KEY (`vote_id`) REFERENCES `votes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vote_answers`
--
LOCK TABLES `vote_answers` WRITE;
/*!40000 ALTER TABLE `vote_answers` DISABLE KEYS */;
INSERT INTO `vote_answers` VALUES (23,10,'Yes',0),(24,10,'No',0);
/*!40000 ALTER TABLE `vote_answers` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vote_log`
--
DROP TABLE IF EXISTS `vote_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vote_log` (
`id` int NOT NULL AUTO_INCREMENT,
`player_id` int NOT NULL,
`vote_id` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vote_log`
--
LOCK TABLES `vote_log` WRITE;
/*!40000 ALTER TABLE `vote_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `vote_log` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `votes`
--
DROP TABLE IF EXISTS `votes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `votes` (
`id` bigint NOT NULL AUTO_INCREMENT,
`subject` varchar(32) NOT NULL,
`published_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `votes`
--
LOCK TABLES `votes` WRITE;
/*!40000 ALTER TABLE `votes` DISABLE KEYS */;
INSERT INTO `votes` VALUES (10,'Are you a human?','2023-08-08 23:00:39');
/*!40000 ALTER TABLE `votes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping events for database 'alexander'
--
/*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
/*!50106 DROP EVENT IF EXISTS `lobby_cleaner_event` */;
DELIMITER ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
/*!50003 SET character_set_client = utf8mb4 */ ;;
/*!50003 SET character_set_results = utf8mb4 */ ;;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;;
/*!50003 SET @saved_time_zone = @@time_zone */ ;;
/*!50003 SET time_zone = 'SYSTEM' */ ;;
/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `lobby_cleaner_event` ON SCHEDULE EVERY 60 SECOND STARTS '2023-07-28 15:02:25' ON COMPLETION NOT PRESERVE ENABLE DO CALL lobby_cleaner() */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
/*!50003 SET character_set_results = @saved_cs_results */ ;;
/*!50003 SET collation_connection = @saved_col_connection */ ;;
DELIMITER ;
/*!50106 SET TIME_ZONE= @save_time_zone */ ;
--
-- Dumping routines for database 'alexander'
--
/*!50003 DROP FUNCTION IF EXISTS `get_display_nick` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `get_display_nick`(
player_id BIGINT
) RETURNS varchar(64) CHARSET utf8mb4
DETERMINISTIC
BEGIN
RETURN
(SELECT
CONCAT(COALESCE(clans.signature,''), players.nick) AS nick
FROM players
LEFT JOIN clans
ON players.clan_id = clans.id
WHERE players.player_id = player_id);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `get_nation` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `get_nation`(
id bigint
) RETURNS int
DETERMINISTIC
BEGIN
RETURN (SELECT
name
FROM nations
WHERE nations.id = id);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `get_nation_name` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `get_nation_name`(
id bigint
) RETURNS int
DETERMINISTIC
BEGIN
RETURN (SELECT
name
FROM nations
WHERE nations.id = id);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `get_position` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `get_position`(
_player_id bigint
) RETURNS int
DETERMINISTIC
BEGIN
RETURN (SELECT rnk FROM (SELECT player_id, row_number() OVER ( order by score ) as rnk FROM players) AS rnks WHERE player_id = _player_id);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `get_rank` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `get_rank`(
score int
) RETURNS int
DETERMINISTIC
BEGIN
IF score < 10 THEN
RETURN 1;
ELSEIF score < 25 THEN
RETURN 2;
ELSEIF score < 50 THEN
RETURN 3;
ELSEIF score < 75 THEN
RETURN 4;
ELSEIF score < 100 THEN
RETURN 5;
ELSEIF score < 125 THEN
RETURN 6;
ELSEIF score < 150 THEN
RETURN 7;
END IF;
RETURN 1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `has_clan` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `has_clan`(
_player_id bigint
) RETURNS int
DETERMINISTIC
BEGIN
DECLARE _signature BOOLEAN;
SET _signature =
(SELECT
signature
FROM clans
WHERE creator = _player_id);
IF has_clan = 1 THEN
RETURN signature;
ELSE
RETURN 0;
END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `can_be_excluded` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `can_be_excluded`(
id_to_be_excluded bigint,
caller_id bigint
)
BEGIN
SELECT
name,
IF(
clans.creator != id_to_be_excluded AND
players.player_id != caller_id AND
clans.creator = caller_id
, TRUE , FALSE) AS result
FROM players
INNER JOIN clans ON clan_id = 1
WHERE players.player_id = id_to_be_excluded;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `clan_admin` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `clan_admin`(
_player_id bigint,
_new_jointer bigint,
_leaver bigint,
_clan_id bigint,
_again varchar(5)
)
BEGIN
DECLARE _has_clan BOOLEAN;
SET _has_clan = (SELECT
id
FROM clans
WHERE creator = _player_id);
IF _new_jointer != 0 THEN
IF _has_clan THEN
IF _again = 'true' THEN
DELETE
FROM clans
WHERE creator = _player_id;
ELSE
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "DLG_CLAN_REMOVE";
END IF;
END IF;
UPDATE players
SET clan_id = _clan_id
WHERE player_id = _player_id;
ELSEIF _leaver != '' THEN
IF _has_clan THEN
DELETE
FROM clans
WHERE creator = _player_id;
END IF;
UPDATE players