lint, make it colorblind friendly

pull/1/head
Lynn 2022-01-01 19:35:03 +01:00
rodzic 053242dc0b
commit 50ecda06c9
4 zmienionych plików z 12 dodań i 20 usunięć

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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

Wyświetl plik

@ -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 {

Wyświetl plik

@ -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 };