Skip to content

Commit

Permalink
Adding diacritics compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezo committed Feb 20, 2024
1 parent 7f60a21 commit b149f59
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
gtag('config', 'G-7SK998GPMX', { 'page_path': '/home' });
}
</script>
<style>*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}*,:before,:after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }html,body{height:100%}body{margin:0;font-family:Roboto,Helvetica Neue,sans-serif}</style><link rel="stylesheet" href="styles.67f3c5b222d19b51.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.67f3c5b222d19b51.css"></noscript></head>
<style>*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}*,:before,:after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(59 130 246 / .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }html,body{height:100%}body{margin:0;font-family:Roboto,Helvetica Neue,sans-serif}</style><link rel="stylesheet" href="styles.b50e63b31057d3aa.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.b50e63b31057d3aa.css"></noscript></head>
<body class="mat-typography">
<app-root></app-root>
<script src="runtime.c2d2548033d65b02.js" type="module"></script><script src="polyfills.75186c7b7fc1d123.js" type="module"></script><script src="scripts.a1e2309b4257c7b3.js" defer></script><script src="main.d7988242917a88dd.js" type="module"></script>
<script src="runtime.c2d2548033d65b02.js" type="module"></script><script src="polyfills.75186c7b7fc1d123.js" type="module"></script><script src="scripts.a1e2309b4257c7b3.js" defer></script><script src="main.52005c67eb771ab0.js" type="module"></script>

</body></html>
1 change: 1 addition & 0 deletions docs/main.52005c67eb771ab0.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/main.d7988242917a88dd.js

This file was deleted.

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/app/game/service/snoguess.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class SnoguessService {
return char; // Keep the semantic tag visible
}
// Use a regular expression to test if the character is a letter or a number
return /[a-zA-Z0-9]/.test(char) ? '_' : char;
return /[a-zA-Z0-9á-úñ]/.test(char) ? '_' : char;
}); // Do not join here to match the Game interface expectation

this.game.next({
Expand All @@ -255,27 +255,27 @@ export class SnoguessService {
}
}

removeAccents(str: string): string {
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
}

// Guess a single letter
guessLetter(letter: string): void {
let newState = { ...this.game.value };
let found = false;

// Determine the index where the semantic tag begins
const semanticTagIndex = newState.term.lastIndexOf('(');

newState.term.split('').forEach((char, index) => {
// Check if the index is within the range before the semantic tag
// and if the character at that position has not been guessed yet
if (index < semanticTagIndex && newState.displayTerm[index] === '_') {
if (char.toLowerCase() === letter.toLowerCase()) {
// Compare normalized versions of the characters
if (this.removeAccents(char.toLowerCase()) === this.removeAccents(letter.toLowerCase())) {
newState.displayTerm[index] = char; // Reveal the correctly guessed letter
found = true;
newState.score += this.rules.pointsPerGuessedLetter; // Increment the score
// check if won, score >= max goal score, but waiting until there are no more _ before semantic tag
const isTermGessed = newState.displayTerm.slice(0, semanticTagIndex).indexOf('_') === -1;
if (isTermGessed && newState.score >= this.rules.goals[this.rules.goals.length - 1].score) {
newState.state = 'won';
}
}
}
});
Expand Down

0 comments on commit b149f59

Please sign in to comment.