lint, make it colorblind friendly
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
20
src/clue.ts
20
src/clue.ts
@@ -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 };
|
||||||
|
|||||||
Reference in New Issue
Block a user