Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Ferentz committed Jan 23, 2024
1 parent 9025877 commit 4fbca01
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 40 deletions.
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="theme-color" content="#ffad06" />
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.ico" />
<title>Solidoku - A Sudoku game in Solid.js</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<script src="/src/index.tsx" type="module"></script>
</body>
</html>
Empty file removed src/App.module.css
Empty file.
5 changes: 2 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createSignal, type Component, Show, onMount } from 'solid-js'
import styles from './App.module.css'
import { GameContainer } from './GameContainer'
import { GameMenu } from './GameMenu'
import { gameController } from './stores/GameStore'
Expand All @@ -13,7 +12,7 @@ const App: Component = () => {
const [showGame, setShowGame] = createSignal(false)

return (
<div class={styles.App}>
<>
<Header />
<Show when={!showGame()}>
<GameMenu
Expand All @@ -25,7 +24,7 @@ const App: Component = () => {
<Show when={showGame()}>
<GameContainer />
</Show>
</div>
</>
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/GameMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { For, Show } from 'solid-js'
import { Difficulty } from './game/generate'
import { Difficulties, Difficulty } from './game/types'
import styles from './GameMenu.module.css'
import { gameController } from './stores/GameStore'

Expand All @@ -9,7 +9,7 @@ type GameMenuProps = {
onResumeGame: () => void
}
export const GameMenu = (props: GameMenuProps) => {
const levels = ['Easy', 'Medium', 'Hard'] as const
const levels = Object.keys(Difficulties) as Difficulty[]
const handleNewGame = (difficulty: Difficulty) => {
gameController.createGame(difficulty)
props.onNewGame()
Expand Down
5 changes: 2 additions & 3 deletions src/Header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
background-color: var(--flame-orange);
color: #fff;
padding: 15px;
box-shadow: 0 0 3px 5px rgba(0, 0, 0, 0.2);
box-shadow: -5px 0 3px 5px rgba(0, 0, 0, 0.2);
background: linear-gradient(to right, var(--fromColor), var(--toColor));
}

.appName {
display: inline-block;
text-align: center;
font-size: 2rem;
font-family: Impact, sans-serif;
font-size: 2rem;
text-shadow: 2px 2px 4px #111;
margin:0;
letter-spacing: 0.6rem;
Expand Down
5 changes: 3 additions & 2 deletions src/NumberSquare.module.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.square {
--sqw: min(calc((99vw - 1rem) / 9), 50px);
border: 1px solid #999;
display: flex;
align-items: center;
justify-content: center;
height: 50px;
width: 50px;
height: var(--sqw);
width: var(--sqw);
font-size: 1.2rem;
}

Expand Down
26 changes: 3 additions & 23 deletions src/game/generate.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import { Difficulties, Difficulty, Game } from "./types"
const br = [1, 2, 3, 4, 5, 6, 7, 8, 9]
export type Difficulty = 'Easy' | 'Medium' | 'Hard'

function getNumberToRemove(difficulty: Difficulty): number {
let min = 34,
max = 41
switch (difficulty) {
case 'Hard':
min = 58
max = 64
break
case 'Medium':
min = 42
max = 57
break
case 'Easy':
default:
break
}
const { min, max } = Difficulties[difficulty]
return Math.floor(Math.random() * (max - min)) + min
}

export type Game = {
solution: number[][]
puzzle: number[][]
current: number[][]
mistakes: number
difficulty: Difficulty
}
function shuffle(input: number[]) {
// Shuffle the array using Fisher-Yates algorithm
const row = [...input]
Expand Down
32 changes: 32 additions & 0 deletions src/game/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

export const Difficulties = {
Easy: {
min: 36,
max: 40
},
Medium: {
min: 40,
max: 47
},
Hard: {
min: 48,
max:54
},
Expert: {
min: 55,
max: 59
},
Insane: {
min: 60,
max: 64
}
} as const;
export type Difficulty = keyof typeof Difficulties

export type Game = {
solution: number[][]
puzzle: number[][]
current: number[][]
mistakes: number
difficulty: Difficulty
}
12 changes: 7 additions & 5 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
box-sizing: border-box;
}
body {
width: 100vw;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family: Impact, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
--flame-red: #ff105f;
--flame-orange: #ffad06;
}

#root {
width: 100vw;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

@property --fromColor {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"target": "ESNext",
"module": "ESNext",
Expand Down

0 comments on commit 4fbca01

Please sign in to comment.