kopia lustrzana https://github.com/lynn/hello-wordl
lint, make it colorblind friendly
rodzic
053242dc0b
commit
50ecda06c9
|
@ -63,7 +63,7 @@ body {
|
|||
font-size: 20px;
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
border: inherit;
|
||||
border: 2px solid transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
@ -76,19 +76,19 @@ body {
|
|||
}
|
||||
|
||||
.letter-correct {
|
||||
border: none;
|
||||
border: 2px solid rgba(0, 0, 0, 0.3);
|
||||
background-color: rgb(87, 172, 87);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.letter-elsewhere {
|
||||
border: none;
|
||||
border: 2px dotted rgba(0, 0, 0, 0.3);
|
||||
background-color: #e9c601;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.letter-absent {
|
||||
border: none;
|
||||
border: 2px solid transparent;
|
||||
background-color: rgb(162, 162, 162);
|
||||
color: white;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import common from "./common.json";
|
|||
import { dictionarySet, pick } from "./util";
|
||||
import Game from "./Game";
|
||||
import { names } from "./names";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
|
||||
const targets = common
|
||||
.slice(0, 20000) // adjust for max target freakiness
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { Row, RowState } from "./Row";
|
||||
import dictionary from "./dictionary.json";
|
||||
import { Clue, clue, clueClass } from "./clue";
|
||||
import { Clue, clue } from "./clue";
|
||||
import { Keyboard } from "./Keyboard";
|
||||
|
||||
enum GameState {
|
||||
|
|
20
src/clue.ts
20
src/clue.ts
|
@ -9,28 +9,20 @@ export interface CluedLetter {
|
|||
letter: string;
|
||||
}
|
||||
|
||||
// clue("perks", "rebus")
|
||||
// [
|
||||
// { letter: "p", clue: Absent },
|
||||
// { letter: "e", clue: Correct },
|
||||
// { letter: "r", clue: Elsewhere },
|
||||
// { letter: "k", clue: Absent },
|
||||
// { letter: "s", clue: Correct },
|
||||
// ]
|
||||
|
||||
export function clue(word: string, target: string): CluedLetter[] {
|
||||
let notFound: string[] = [];
|
||||
target.split("").map((letter, i) => {
|
||||
let elusive: string[] = [];
|
||||
target.split("").forEach((letter, i) => {
|
||||
if (word[i] !== letter) {
|
||||
notFound.push(letter);
|
||||
elusive.push(letter);
|
||||
}
|
||||
});
|
||||
return word.split("").map((letter, i) => {
|
||||
let j: number;
|
||||
if (target[i] === letter) {
|
||||
return { clue: Clue.Correct, letter };
|
||||
} else if ((j = notFound.indexOf(letter)) > -1) {
|
||||
notFound[j] = "";
|
||||
} else if ((j = elusive.indexOf(letter)) > -1) {
|
||||
// "use it up" so we don't clue at it twice
|
||||
elusive[j] = "";
|
||||
return { clue: Clue.Elsewhere, letter };
|
||||
} else {
|
||||
return { clue: Clue.Absent, letter };
|
||||
|
|
Ładowanie…
Reference in New Issue