diff --git a/src/App.css b/src/App.css index 2999903..eeb0283 100644 --- a/src/App.css +++ b/src/App.css @@ -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; } diff --git a/src/App.tsx b/src/App.tsx index 5eed5d8..3303798 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 diff --git a/src/Game.tsx b/src/Game.tsx index 11f294a..6e17621 100644 --- a/src/Game.tsx +++ b/src/Game.tsx @@ -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 { diff --git a/src/clue.ts b/src/clue.ts index d68bf1e..eeaa94e 100644 --- a/src/clue.ts +++ b/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 };