guess-the-year-web-component 3.2.1 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/guess-the-year.d.ts.map +1 -1
- package/dist/guess-the-year.js +25 -12
- package/dist/guess-the-year.js.map +1 -1
- package/dist/lib/ApiService.d.ts.map +1 -1
- package/dist/lib/ApiService.js +14 -9
- package/dist/lib/ApiService.js.map +1 -1
- package/dist/lib/Util.d.ts +1 -0
- package/dist/lib/Util.d.ts.map +1 -1
- package/dist/lib/Util.js +19 -0
- package/dist/lib/Util.js.map +1 -1
- package/dist/lib/i18n/EN.d.ts.map +1 -1
- package/dist/lib/i18n/EN.js +33 -11
- package/dist/lib/i18n/EN.js.map +1 -1
- package/dist/lib/i18n/NL.d.ts.map +1 -1
- package/dist/lib/i18n/NL.js +33 -11
- package/dist/lib/i18n/NL.js.map +1 -1
- package/dist/main.js +62 -51
- package/package.json +1 -1
- package/src/guess-the-year.ts +25 -12
- package/src/lib/ApiService.ts +14 -9
- package/src/lib/Util.ts +12 -0
- package/src/lib/i18n/EN.ts +33 -11
- package/src/lib/i18n/NL.ts +33 -11
package/package.json
CHANGED
package/src/guess-the-year.ts
CHANGED
|
@@ -321,13 +321,12 @@ export class GuessTheYear extends LitElement {
|
|
|
321
321
|
<div class="game-settings">
|
|
322
322
|
<p>
|
|
323
323
|
${this.i18n.translate("game-settings-p0")}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
</select>
|
|
327
|
-
${this.i18n.translate("game-settings-p1")}
|
|
324
|
+
|
|
325
|
+
${this.i18n.translate("game-settings-p1-1")}
|
|
328
326
|
<select @change="${this._setNumberOfQuestions}">
|
|
329
327
|
${selectQuestionOptions}
|
|
330
328
|
</select>
|
|
329
|
+
${this.i18n.translate("game-settings-p1-2")}
|
|
331
330
|
${this.i18n.translate("game-settings-p2")}
|
|
332
331
|
<select @change="${this._setFromDate}">
|
|
333
332
|
${this._renderYearStepXSelectOptions(MIN_YEAR, MAX_YEAR, 5, this.from.format("YYYY"))}
|
|
@@ -337,6 +336,11 @@ export class GuessTheYear extends LitElement {
|
|
|
337
336
|
${this._renderYearStepXSelectOptions(MIN_YEAR, MAX_YEAR, 5, this.to.format("YYYY"))}
|
|
338
337
|
</select>
|
|
339
338
|
${this.i18n.translate("game-settings-p4")}
|
|
339
|
+
${this.i18n.translate("game-settings-p5-1")}
|
|
340
|
+
<select @change="${this._setPlayerDob}">
|
|
341
|
+
${this._renderYearStepXSelectOptions(MAX_DOB, MIN_DOB, 1, this._playerDob + '')}
|
|
342
|
+
</select>
|
|
343
|
+
${this.i18n.translate("game-settings-p5-2")}
|
|
340
344
|
</p>
|
|
341
345
|
</div>
|
|
342
346
|
|
|
@@ -632,12 +636,21 @@ export class GuessTheYear extends LitElement {
|
|
|
632
636
|
|
|
633
637
|
private renderGameEnd(): TemplateResult {
|
|
634
638
|
console.debug("renderGameEnd");
|
|
639
|
+
const maxScore: number = this.numberOfQuestions * this._score;
|
|
640
|
+
const scoreRatio = Math.round((this.totalScore / maxScore) * 100);
|
|
635
641
|
return html`
|
|
636
642
|
${this._renderHeader("The end!")}
|
|
637
|
-
<div class="guess-the-year-game-end"
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
643
|
+
<div class="guess-the-year-game-end">
|
|
644
|
+
<p>
|
|
645
|
+
${this.i18n.translate("end").replace(/__SCORE__/, this.totalScore + '').replace(/__MAX_SCORE__/, maxScore + '').replace(/__PERCENT__/, scoreRatio + '')}
|
|
646
|
+
</p>
|
|
647
|
+
<p>
|
|
648
|
+
${this.i18n.translate(Util.scoreToValueJudgement(scoreRatio))}
|
|
649
|
+
</p>
|
|
650
|
+
</div>
|
|
651
|
+
<button @click="${() => (this._renderState = GameState.SPLASH)}" >
|
|
652
|
+
${this.i18n.translate("new-game")}
|
|
653
|
+
</button>
|
|
641
654
|
${this._renderFooter()}
|
|
642
655
|
`;
|
|
643
656
|
}
|
|
@@ -814,16 +827,16 @@ export class GuessTheYear extends LitElement {
|
|
|
814
827
|
}
|
|
815
828
|
// deduplicate array via [...new Set(this.sources)]
|
|
816
829
|
return html`
|
|
817
|
-
<div class="guess-the-year-sources">
|
|
830
|
+
<div class="guess-the-year-sources" >
|
|
818
831
|
Source: ${[...new Set(this.sources)].join(", ")}
|
|
819
|
-
|
|
820
|
-
|
|
832
|
+
</div>
|
|
833
|
+
`;
|
|
821
834
|
}
|
|
822
835
|
|
|
823
836
|
_handleImageLoadError = (evt: Event, incident: Incident) => {
|
|
824
837
|
// grab the image element that triggered the error
|
|
825
838
|
const targetImage = evt.target as HTMLImageElement;
|
|
826
|
-
console.debug(`Error loading image: ${targetImage.src}`);
|
|
839
|
+
console.debug(`Error loading image: ${targetImage.src} `);
|
|
827
840
|
|
|
828
841
|
// find out which no image source needs to be used
|
|
829
842
|
const noImageSrc = this.noImageSrc || NoImageImg;
|
package/src/lib/ApiService.ts
CHANGED
|
@@ -58,18 +58,23 @@ export class ApiService {
|
|
|
58
58
|
|
|
59
59
|
urls.push(url);
|
|
60
60
|
} else if (fromString && toString) {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
try {
|
|
62
|
+
const from = new Date(fromString).toISOString().substring(0, 10);
|
|
63
|
+
const to = new Date(toString).toISOString().substring(0, 10);
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// add from and to date to search
|
|
66
|
+
urlSearch.set("from", from);
|
|
67
|
+
urlSearch.set("to", to);
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// setup url
|
|
70
|
+
const url = new URL(this.teeeApiUrl);
|
|
71
|
+
url.search = urlSearch.toString();
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
urls.push(url);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.error(e, fromString, toString);
|
|
77
|
+
}
|
|
73
78
|
} else {
|
|
74
79
|
throw "No correct date or period specified.";
|
|
75
80
|
}
|
package/src/lib/Util.ts
CHANGED
|
@@ -47,6 +47,18 @@ export class Util {
|
|
|
47
47
|
// generationalpha: 2013-2028
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
|
|
51
|
+
public static scoreToValueJudgement(scoreAsPercent: number): string {
|
|
52
|
+
if (scoreAsPercent >= 90) return 'excellent';
|
|
53
|
+
if (scoreAsPercent >= 80) return 'very-good';
|
|
54
|
+
if (scoreAsPercent >= 70) return 'good';
|
|
55
|
+
if (scoreAsPercent >= 60) return 'reasonable-good';
|
|
56
|
+
if (scoreAsPercent >= 50) return 'reasonable';
|
|
57
|
+
if (scoreAsPercent >= 40) return 'not-so-good';
|
|
58
|
+
if (scoreAsPercent >= 20) return 'not-good';
|
|
59
|
+
if (scoreAsPercent >= 0) return 'bad';
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
export interface IHash {
|
package/src/lib/i18n/EN.ts
CHANGED
|
@@ -57,9 +57,25 @@ export class EN implements i18n {
|
|
|
57
57
|
case "start":
|
|
58
58
|
return "start";
|
|
59
59
|
case "new-game":
|
|
60
|
-
return "
|
|
60
|
+
return "Try again";
|
|
61
61
|
case "end":
|
|
62
|
-
return "You
|
|
62
|
+
return "You scored __SCORE__ of the __MAX_SCORE__ points. That is a score of __PERCENT__%";
|
|
63
|
+
case "excellent":
|
|
64
|
+
return "That is excellent!";
|
|
65
|
+
case "very-good":
|
|
66
|
+
return "That is very good!";
|
|
67
|
+
case "good":
|
|
68
|
+
return "That is good!";
|
|
69
|
+
case "reasonable-good":
|
|
70
|
+
return "That is reasonably good";
|
|
71
|
+
case "reasonable":
|
|
72
|
+
return "That is reasonable!";
|
|
73
|
+
case "not-so-good":
|
|
74
|
+
return "That is ok";
|
|
75
|
+
case "not-good":
|
|
76
|
+
return "That is not so good";
|
|
77
|
+
case "bad":
|
|
78
|
+
return "That is really bad :)";
|
|
63
79
|
case "next-question":
|
|
64
80
|
return "Next question";
|
|
65
81
|
case "quit":
|
|
@@ -105,21 +121,27 @@ export class EN implements i18n {
|
|
|
105
121
|
case "in-x-seconds":
|
|
106
122
|
return "In __SECONDS__ seconds";
|
|
107
123
|
case "game-settings-p0":
|
|
108
|
-
return "
|
|
109
|
-
case "game-settings-
|
|
110
|
-
return "
|
|
124
|
+
return "This is how I want to play: "
|
|
125
|
+
case "game-settings-p5-1":
|
|
126
|
+
return "Take my birth year into account ("
|
|
127
|
+
case "game-settings-p5-2":
|
|
128
|
+
return ") when selecting events."
|
|
129
|
+
case "game-settings-p1-1":
|
|
130
|
+
return "give me a maximum of"
|
|
131
|
+
case "game-settings-p1-2":
|
|
132
|
+
return "events."
|
|
111
133
|
case "game-settings-p2":
|
|
112
|
-
return "
|
|
134
|
+
return "Limit yourself to the period from "
|
|
113
135
|
case "game-settings-p3":
|
|
114
|
-
return "
|
|
136
|
+
return " to "
|
|
115
137
|
case "game-settings-p4":
|
|
116
|
-
return "
|
|
138
|
+
return "."
|
|
117
139
|
case "game-introduction-p1":
|
|
118
|
-
return "
|
|
140
|
+
return "Welcome to the ultimate test of your historical knowledge!"
|
|
119
141
|
case "game-introduction-p2":
|
|
120
|
-
return "
|
|
142
|
+
return "Dive into history and challenge yourself and your friends to guess the years of fascinating events. From groundbreaking inventions to memorable moments, this game takes you on a journey through time."
|
|
121
143
|
case "game-introduction-p3":
|
|
122
|
-
return "
|
|
144
|
+
return "Are you the master of chronology? Find out now!"
|
|
123
145
|
case "game-introduction-welcome":
|
|
124
146
|
return `Welcome to Guess The Year!`
|
|
125
147
|
}
|
package/src/lib/i18n/NL.ts
CHANGED
|
@@ -61,9 +61,25 @@ export class NL implements i18n {
|
|
|
61
61
|
case "start":
|
|
62
62
|
return "start";
|
|
63
63
|
case "new-game":
|
|
64
|
-
return "
|
|
64
|
+
return "Probeer opnieuw";
|
|
65
65
|
case "end":
|
|
66
|
-
return "
|
|
66
|
+
return "Je haalde __SCORE__ van de mogelijke __MAX_SCORE__ punten. Dat komt overeen met __PERCENT__%";
|
|
67
|
+
case "excellent":
|
|
68
|
+
return "Dat is echt ongelooflijk goed!";
|
|
69
|
+
case "very-good":
|
|
70
|
+
return "Dat is heel goed!";
|
|
71
|
+
case "good":
|
|
72
|
+
return "Dat is goed!";
|
|
73
|
+
case "reasonable-good":
|
|
74
|
+
return "Dat is best goed";
|
|
75
|
+
case "reasonable":
|
|
76
|
+
return "Dat is best redelijk!";
|
|
77
|
+
case "not-so-good":
|
|
78
|
+
return "Dat is redelijk";
|
|
79
|
+
case "not-good":
|
|
80
|
+
return "Dat is niet zo goed";
|
|
81
|
+
case "bad":
|
|
82
|
+
return "Dat is ronduit slecht :)";
|
|
67
83
|
case "next-question":
|
|
68
84
|
return "Volgende vraag";
|
|
69
85
|
case "quit":
|
|
@@ -109,21 +125,27 @@ export class NL implements i18n {
|
|
|
109
125
|
case "in-x-seconds":
|
|
110
126
|
return "In __SECONDS__ seconden";
|
|
111
127
|
case "game-settings-p0":
|
|
112
|
-
return "
|
|
113
|
-
case "game-settings-
|
|
114
|
-
return "
|
|
128
|
+
return "Zo wil ik het spelen: "
|
|
129
|
+
case "game-settings-p5-1":
|
|
130
|
+
return "Houd rekening met mijn geboortejaar ("
|
|
131
|
+
case "game-settings-p5-2":
|
|
132
|
+
return ") bij de selectie van de gebeurenissen."
|
|
133
|
+
case "game-settings-p1-1":
|
|
134
|
+
return "geef me maximaal"
|
|
135
|
+
case "game-settings-p1-2":
|
|
136
|
+
return "gebeurtenissen."
|
|
115
137
|
case "game-settings-p2":
|
|
116
|
-
return "
|
|
138
|
+
return "Beperk je tot de periode van "
|
|
117
139
|
case "game-settings-p3":
|
|
118
|
-
return "
|
|
140
|
+
return " tot "
|
|
119
141
|
case "game-settings-p4":
|
|
120
|
-
return "
|
|
142
|
+
return "."
|
|
121
143
|
case "game-introduction-p1":
|
|
122
|
-
return "
|
|
144
|
+
return "Welkom bij de ultieme test van je historische kennis!"
|
|
123
145
|
case "game-introduction-p2":
|
|
124
|
-
return "
|
|
146
|
+
return "Duik in de tijd en daag jezelf en je vrienden uit om de jaartallen van fascinerende gebeurtenissen te raden. Van baanbrekende uitvindingen tot memorabele momenten, dit spel neemt je mee op een reis door de geschiedenis."
|
|
125
147
|
case "game-introduction-p3":
|
|
126
|
-
return "
|
|
148
|
+
return "Ben jij de meester van de chronologie? Ontdek het nu!"
|
|
127
149
|
case "game-introduction-welcome":
|
|
128
150
|
return `Welkom bij Guess The Year!`
|
|
129
151
|
}
|