@@ -440,18 +440,22 @@ private void checkUniqueOpti(GameConfig gameConfig, ExportReport exportReport) {
440
440
}
441
441
442
442
private void checkLeaguePopups (QuestionConfig questionConfig , String tag , ExportReport exportReport ) {
443
- if (!questionConfig .getWelcomeLanguageMap ().containsKey (Constants .LANGUAGE_ID_ENGLISH )
444
- || questionConfig .getWelcomeLanguageMap ().get (Constants .LANGUAGE_ID_ENGLISH ).isEmpty ()) {
443
+ if (
444
+ !questionConfig .getWelcomeLanguageMap ().containsKey (Constants .LANGUAGE_ID_ENGLISH )
445
+ || questionConfig .getWelcomeLanguageMap ().get (Constants .LANGUAGE_ID_ENGLISH ).isEmpty ()
446
+ ) {
445
447
exportReport .addItem (
446
448
ReportItemType .WARNING , tag + "Missing welcome_"
447
449
+ Constants .LANGUAGE_CODE [Constants .LANGUAGE_ID_ENGLISH - 1 ] + ".html file."
448
450
);
449
451
} else {
450
452
for (int languageId : questionConfig .getWelcomeLanguageMap ().keySet ()) {
451
453
//Avoid checking the same popup twice if duplicated
452
- if (languageId != Constants .LANGUAGE_ID_ENGLISH
453
- && questionConfig .getWelcomeLanguageMap ().get (languageId )
454
- .equals (questionConfig .getWelcomeLanguageMap ().get (Constants .LANGUAGE_ID_ENGLISH ))) {
454
+ if (
455
+ languageId != Constants .LANGUAGE_ID_ENGLISH
456
+ && questionConfig .getWelcomeLanguageMap ().get (languageId )
457
+ .equals (questionConfig .getWelcomeLanguageMap ().get (Constants .LANGUAGE_ID_ENGLISH ))
458
+ ) {
455
459
continue ;
456
460
}
457
461
@@ -485,8 +489,10 @@ private void checkBoss(QuestionConfig questionConfig, String tag, ExportReport e
485
489
}
486
490
487
491
private void checkStatement (QuestionConfig questionConfig , String tag , ExportReport exportReport ) {
488
- if (!questionConfig .getStatementsLanguageMap ().containsKey (Constants .LANGUAGE_ID_ENGLISH )
489
- || questionConfig .getStatementsLanguageMap ().get (Constants .LANGUAGE_ID_ENGLISH ).isEmpty ()) {
492
+ if (
493
+ !questionConfig .getStatementsLanguageMap ().containsKey (Constants .LANGUAGE_ID_ENGLISH )
494
+ || questionConfig .getStatementsLanguageMap ().get (Constants .LANGUAGE_ID_ENGLISH ).isEmpty ()
495
+ ) {
490
496
exportReport .addItem (ReportItemType .ERROR , tag + "Missing statement_en.html file. An English statement is mandatory." );
491
497
}
492
498
}
@@ -536,10 +542,12 @@ private void checkQuestionsTypeValidity(GameConfig gameConfig, QuestionConfig qu
536
542
}
537
543
if (questionConfig .getSortingOrder () == null ) {
538
544
throw new MissingConfigException ("An optimization game must have a sorting_order property in config.ini." );
539
- } else if (!"ASC" .equalsIgnoreCase (questionConfig .getSortingOrder ())
540
- && !"DESC" .equalsIgnoreCase (questionConfig .getSortingOrder ())) {
541
- throw new MissingConfigException ("The sorting order for an optimization game must be ASC (ascendant) or DESC (descendant)" );
542
- }
545
+ } else if (
546
+ !"ASC" .equalsIgnoreCase (questionConfig .getSortingOrder ())
547
+ && !"DESC" .equalsIgnoreCase (questionConfig .getSortingOrder ())
548
+ ) {
549
+ throw new MissingConfigException ("The sorting order for an optimization game must be ASC (ascendant) or DESC (descendant)" );
550
+ }
543
551
}
544
552
545
553
switch (gameConfig .getGameType ()) {
@@ -735,8 +743,9 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
735
743
}
736
744
}, StandardCharsets .UTF_8 );
737
745
} else if (exchange .getRelativePath ().equals ("/statement" )) {
738
- File statementFileEN = sourceFolderPath .resolve ("config/statement_en.html" ).toFile ();
739
- File statementFileFR = sourceFolderPath .resolve ("config/statement_fr.html" ).toFile ();
746
+ File statementFileEN = getStatementFile (sourceFolderPath , "en" );
747
+ File statementFileFR = getStatementFile (sourceFolderPath , "fr" );
748
+
740
749
if (exchange .getRequestMethod ().equalToString ("GET" )) {
741
750
JsonObject statements = new JsonObject ();
742
751
String statementEN = FileUtils .readFileToString (statementFileEN , StandardCharsets .UTF_8 );
@@ -784,6 +793,15 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
784
793
}
785
794
}
786
795
796
+ private File getStatementFile (Path sourceFolderPath , String langId ) {
797
+ File file = sourceFolderPath .resolve ("config/statement_" + langId + ".html" ).toFile ();
798
+ if (!file .exists ()) {
799
+ file = sourceFolderPath .resolve ("config/statement_" + langId + ".html.tpl" ).toFile ();
800
+ }
801
+ return file ;
802
+
803
+ }
804
+
787
805
private JsonElement toJsonElement (String statementFR ) {
788
806
return Optional .ofNullable (statementFR )
789
807
.map (s -> (JsonElement ) new JsonPrimitive (s ))
0 commit comments