Skip to content

Commit f2e1f57

Browse files
authored
Merge pull request #11 from EGAMAGZ/development
Improved validations, error handling and code redability
2 parents 2e794ab + 8c6653a commit f2e1f57

11 files changed

+1526
-2282
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Check the [JSR page for more details](https://jsr.io/@egamagz/paska-ovo).
3939
import { HistoricalCodes, PaskaOvo } from "@egamagz/paska-ovo";
4040

4141
const paskaOvo = new PaskaOvo()
42-
.addCode({
42+
.addEasterEgg({
4343
code: HistoricalCodes.BarrelRoll,
4444
onFound: () => {
4545
//...
@@ -50,14 +50,14 @@ const paskaOvo = new PaskaOvo()
5050
duration: 1000,
5151
tag: "Barrel Roll"
5252
})
53-
.addCode({
53+
.addEasterEgg({
5454
code: HistoricalCodes.Konami,
5555
onFound: () => {
5656
// ...
5757
},
5858
tag: "Konami"
5959
})
60-
.addCode({
60+
.addEasterEgg({
6161
code: ["a", "w", "e", "s", "o", "m", "e"],
6262
onFound: () => {
6363
// ...

deno.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@egamagz/paska-ovo",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"exports": "./mod.ts",
55
"lock": false,
66
"compilerOptions": {

example/package-lock.json

+1,211-1,983
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/components/Badge.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export default function Badge({ text, url, children }: Props) {
1212
{children} <span>{text}</span>
1313
</a>
1414
);
15-
}
15+
}

example/src/components/EasterEgg.tsx

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useSignal, useSignalEffect } from "@preact/signals";
2-
import { PaskaOvo, HistoricalCodes } from "@/../../mod";
2+
import { PaskaOvo, HistoricalCodes, type EasterEgg } from "@/../../mod";
33
import Title from "./Title";
44

55
enum EasterEggStatus {
@@ -14,7 +14,14 @@ export default function EasterEgg() {
1414

1515
useSignalEffect(() => {
1616
const paskaOvo = new PaskaOvo()
17-
.addCode({
17+
.addEasterEgg({
18+
code: ["4", "1", "8"],
19+
onFound: () => {
20+
throw new Error("418 - I'm a teapot")
21+
},
22+
tag: "Example"
23+
})
24+
.addEasterEgg({
1825
code: HistoricalCodes.BarrelRoll,
1926
onFound: () => {
2027
easterEggStatus.value = EasterEggStatus.BarrelRoll
@@ -25,28 +32,28 @@ export default function EasterEgg() {
2532
duration: 1000,
2633
tag: "Barrel Roll"
2734
})
28-
.addCode({
35+
.addEasterEgg({
2936
code: HistoricalCodes.Konami,
3037
onFound: () => {
3138
easterEggStatus.value = easterEggStatus.peek() === EasterEggStatus.Konami ? EasterEggStatus.None : EasterEggStatus.Konami
3239
},
3340
tag: "Konami"
3441
})
35-
.addCode({
42+
.addEasterEgg({
3643
code: ["up", "up", "down", "down", "left", "right", "left", "right", "b", "a", "c"],
3744
onFound: () => {
3845
alert("Nothing to show here... Sorry :(")
3946
},
4047
tag: "Konami+C"
4148
})
42-
.addCode({
49+
.addEasterEgg({
4350
code: ["a", "w", "e", "s", "o", "m", "e"],
4451
onFound: () => {
4552
easterEggStatus.value = easterEggStatus.peek() === EasterEggStatus.Awesome ? EasterEggStatus.None : EasterEggStatus.Awesome
4653
},
4754
tag: "Awesome"
4855
})
49-
.addCallback((easterEgg) => {
56+
.addCallback((easterEgg: EasterEgg) => {
5057
alert(`You found the easter egg: ${easterEgg.tag}`)
5158
});
5259

@@ -62,4 +69,4 @@ export default function EasterEgg() {
6269
<Title showKonami={easterEggStatus.value === EasterEggStatus.Konami} />
6370
</div>
6471
);
65-
}
72+
}

src/historical-codes.ts

+25-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
/**
22
* @module
33
* This module contains historical codes used in the project.
4-
*
54
*/
65

76
/**
87
* List of historical and important codes in video games.
9-
* */
8+
*/
109
export const HistoricalCodes = {
11-
/**
12-
* Konami code. No one knows what it is.
13-
*
14-
* */
15-
Konami: ["Up", "Up", "Down", "Down", "Left", "Right", "Left", "Right", "b", "a"],
16-
/**
17-
* Iddqd code. Reference to the command used in Doom.
18-
*/
19-
Iddqd: ["i", "d", "d", "q", "d"],
20-
/**
21-
* Barrel roll code. Reference to the phrase from Star Fox 64.
22-
* */
23-
BarrelRoll: ["Up", "Right", "Down", "Left"]
24-
};
10+
/**
11+
* Konami code. No one knows what it is.
12+
*/
13+
Konami: [
14+
"Up",
15+
"Up",
16+
"Down",
17+
"Down",
18+
"Left",
19+
"Right",
20+
"Left",
21+
"Right",
22+
"b",
23+
"a",
24+
],
25+
/**
26+
* Iddqd code. Reference to the command used in Doom.
27+
*/
28+
Iddqd: ["i", "d", "d", "q", "d"],
29+
/**
30+
* Barrel roll code. Reference to the phrase from Star Fox 64.
31+
*/
32+
BarrelRoll: ["Up", "Right", "Down", "Left"],
33+
};

0 commit comments

Comments
 (0)