Skip to content

Commit

Permalink
Merge pull request #21 from Dabendorf/eirik_nabovarsel
Browse files Browse the repository at this point in the history
Nabovarsel
  • Loading branch information
Dabendorf authored Jan 12, 2025
2 parents fa943c3 + 85e47b4 commit 49c5d85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/Game/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SubmitGuessForm } from "./SubmitGuessForm";
import { GameSettingButtons } from "./GameSettingButtons";
import { useTranslation } from "react-i18next";
import { DateTime, Interval } from "luxon";
import NeighbourAlert from "../NeighbourAlert";

export function Game() {

Expand Down Expand Up @@ -40,6 +41,7 @@ export function Game() {
<ShareGameResult />
<SubmitGuessForm />
</div>
<NeighbourAlert />
<div className={(guesses.length >= 3 && gameResult === "ONGOING") ? "p-4 text-center" : ""}>
{(guesses.length >= 3 && gameResult === "ONGOING") && t("mapHelperRecommendation")}
</div>
Expand Down
18 changes: 18 additions & 0 deletions src/components/NeighbourAlert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import { useSharedGameState } from '../shared/useGame';
import { countries } from '../domain/countries';

const NeighbourAlert = () => {
const {
state: { country, guesses },
} = useSharedGameState();
const neighboursCountries = countries.filter( it => country.neighbours.includes(it.code) ).map(it => it.name.toLowerCase())
const lastguess = guesses[guesses.length - 1].name.toLowerCase()
return (
<b>
{neighboursCountries.includes(lastguess) ? "Nå jetta du naboområdet, tjommi." : ""}
</b>
)
}

export default NeighbourAlert

0 comments on commit 49c5d85

Please sign in to comment.