Skip to content

Commit

Permalink
fix played years
Browse files Browse the repository at this point in the history
  • Loading branch information
chocomega committed Jan 26, 2022
1 parent 14f9beb commit c6302b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions components/board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ export default function Board(props: Props) {
if (source.droppableId === "next" && destination.droppableId === "played") {
const newDeck = [...state.deck];
const newPlayed = [...state.played];
const newNext = state.nextButOne;
const newNextButOne = getRandomItem(newDeck, newPlayed);
const newImageCache = [preloadImage(newNextButOne.image)];

const { correct, delta } = checkCorrect(
newPlayed,
item,
Expand All @@ -58,6 +54,10 @@ export default function Board(props: Props) {
...state.next,
played: { correct },
});

const newNext = state.nextButOne;
const newNextButOne = getRandomItem(newDeck, newNext ? [...newPlayed, newNext] : newPlayed);
const newImageCache = [preloadImage(newNextButOne.image)];

setState({
...state,
Expand Down
6 changes: 3 additions & 3 deletions lib/create-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Item } from "../types/item";
import { getRandomItem, preloadImage } from "./items";

export default async function createState(deck: Item[]): Promise<GameState> {
const next = getRandomItem(deck, []);
const nextButOne = getRandomItem(deck, []);
const imageCache = [preloadImage(next.image), preloadImage(nextButOne.image)];
const played = [{ ...getRandomItem(deck, []), played: { correct: true } }];
const next = getRandomItem(deck, played);
const nextButOne = getRandomItem(deck, [...played, next]);
const imageCache = [preloadImage(next.image), preloadImage(nextButOne.image)];

return {
badlyPlaced: null,
Expand Down

0 comments on commit c6302b1

Please sign in to comment.