Skip to content

Commit

Permalink
Add squares-diamonds board
Browse files Browse the repository at this point in the history
  • Loading branch information
Perlkonig committed Sep 10, 2024
1 parent ce236ba commit a2cb58d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.1] - 2024-09-10

### Added

- Added support for the new `squares-diamonds` board. Flood-fill only.

## [1.4.0] - 2024-08-18

### Added
Expand Down
39 changes: 14 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "abstractplay-designer",
"private": true,
"version": "1.4.0",
"version": "1.4.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down Expand Up @@ -29,7 +29,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"@abstractplay/renderer": "latest",
"@abstractplay/renderer": "^1.0.0-ci-10801591922.0",
"nanoid": "^4.0.2",
"peerjs": "^1.4.7",
"rfdc": "^1.3.0"
Expand Down
15 changes: 12 additions & 3 deletions src/components/Annotate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
const boardClick = (row: number, col: number, piece: string) => {
console.log(`Row: ${row}, Col: ${col}, Piece: ${piece}`);
const idx = currentTargets.findIndex(t => t[0] === col && t[1] === row);
const idx = currentTargets.findIndex(
(t) => t[0] === col && t[1] === row
);
if (idx === -1) {
currentTargets = [...currentTargets, [col, row]];
} else {
currentTargets = [...currentTargets.slice(0, idx), ...currentTargets.slice(idx+1)];
currentTargets = [
...currentTargets.slice(0, idx),
...currentTargets.slice(idx + 1),
];
}
return false;
};
Expand Down Expand Up @@ -217,7 +222,11 @@
{/if}
<div class="field">
<div class="content">
<p>Targets <span style="font-size: smaller">(click to add/remove)</span>:</p>
<p>
Targets <span style="font-size: smaller"
>(click to add/remove)</span
>:
</p>
<ul>
{#each currentTargets as target}
<li>{target[0]}, {target[1]}</li>
Expand Down
27 changes: 27 additions & 0 deletions src/components/Board.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"snubsquare",
"A unique combination of squares and triangles where most cells have five connections; pieces are placed on the vertices",
],
[
"squares-diamonds",
"A square board where the vertices are also spaces. In the designer, pieces cannot be placed anywhere. You can only use flood fill.",
],
[
"vertex",
"A grid of squares, no shading, with pieces placed on the vertices of the lines",
Expand Down Expand Up @@ -96,6 +100,7 @@
let symmetryLocked = true;
let invertOrientation = false;
let canInvertOrientation = false;
let startDiamonds = false;
const initVars = () => {
canBlock = false;
canAlternate = false;
Expand Down Expand Up @@ -159,6 +164,16 @@
}
};
const handleSDChange = () => {
if ($state.board.style === "squares-diamonds") {
if (startDiamonds) {
$state.board.sdStart = "D";
} else {
$state.board.sdStart = "S";
}
}
};
const handleStyleChange = () => {
if ($state.board.style === undefined) {
$state.board = { style: undefined };
Expand Down Expand Up @@ -425,6 +440,18 @@
</div>
</div>
{/if}
{#if $state.board.style === "squares-diamonds"}
<div class="control">
<label class="checkbox">
<input
type="checkbox"
bind:checked="{startDiamonds}"
on:change="{handleSDChange}"
/>
Start with diamonds
</label>
</div>
{/if}
{#if canAlternate}
<div class="control">
<label class="checkbox">
Expand Down
4 changes: 4 additions & 0 deletions src/components/Play.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
let floodEnabled = false;
let floodSupported = true;
$: if (!floodEnabled && $state.board.style === "squares-diamonds") {
floodEnabled = true;
}
const onKeyDown = (event: KeyboardEvent) => {
if (event.repeat) return;
if (
Expand Down

0 comments on commit a2cb58d

Please sign in to comment.