lint, make it colorblind friendly

This commit is contained in:
Lynn
2022-01-01 19:35:03 +01:00
parent 053242dc0b
commit 50ecda06c9
4 changed files with 12 additions and 20 deletions

View File

@@ -63,7 +63,7 @@ body {
font-size: 20px; font-size: 20px;
color: inherit; color: inherit;
text-decoration: inherit; text-decoration: inherit;
border: inherit; border: 2px solid transparent;
cursor: pointer; cursor: pointer;
} }
@@ -76,19 +76,19 @@ body {
} }
.letter-correct { .letter-correct {
border: none; border: 2px solid rgba(0, 0, 0, 0.3);
background-color: rgb(87, 172, 87); background-color: rgb(87, 172, 87);
color: white; color: white;
} }
.letter-elsewhere { .letter-elsewhere {
border: none; border: 2px dotted rgba(0, 0, 0, 0.3);
background-color: #e9c601; background-color: #e9c601;
color: white; color: white;
} }
.letter-absent { .letter-absent {
border: none; border: 2px solid transparent;
background-color: rgb(162, 162, 162); background-color: rgb(162, 162, 162);
color: white; color: white;
} }

View File

@@ -3,7 +3,7 @@ import common from "./common.json";
import { dictionarySet, pick } from "./util"; import { dictionarySet, pick } from "./util";
import Game from "./Game"; import Game from "./Game";
import { names } from "./names"; import { names } from "./names";
import { useEffect, useState } from "react"; import { useState } from "react";
const targets = common const targets = common
.slice(0, 20000) // adjust for max target freakiness .slice(0, 20000) // adjust for max target freakiness

View File

@@ -1,7 +1,7 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Row, RowState } from "./Row"; import { Row, RowState } from "./Row";
import dictionary from "./dictionary.json"; import dictionary from "./dictionary.json";
import { Clue, clue, clueClass } from "./clue"; import { Clue, clue } from "./clue";
import { Keyboard } from "./Keyboard"; import { Keyboard } from "./Keyboard";
enum GameState { enum GameState {

View File

@@ -9,28 +9,20 @@ export interface CluedLetter {
letter: string; 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[] { export function clue(word: string, target: string): CluedLetter[] {
let notFound: string[] = []; let elusive: string[] = [];
target.split("").map((letter, i) => { target.split("").forEach((letter, i) => {
if (word[i] !== letter) { if (word[i] !== letter) {
notFound.push(letter); elusive.push(letter);
} }
}); });
return word.split("").map((letter, i) => { return word.split("").map((letter, i) => {
let j: number; let j: number;
if (target[i] === letter) { if (target[i] === letter) {
return { clue: Clue.Correct, letter }; return { clue: Clue.Correct, letter };
} else if ((j = notFound.indexOf(letter)) > -1) { } else if ((j = elusive.indexOf(letter)) > -1) {
notFound[j] = ""; // "use it up" so we don't clue at it twice
elusive[j] = "";
return { clue: Clue.Elsewhere, letter }; return { clue: Clue.Elsewhere, letter };
} else { } else {
return { clue: Clue.Absent, letter }; return { clue: Clue.Absent, letter };