Skip to content

Commit

Permalink
Add options for flat counts, stack counts, road connections, and links
Browse files Browse the repository at this point in the history
  • Loading branch information
gruppler committed Jun 26, 2024
1 parent c8021bf commit 99379bf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
22 changes: 13 additions & 9 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

Use `/tak @opponent` to start a new game. You can specify any of the following:

- `size` _(optional, default `6`):_ Valid values are `3` through `8`.
- `komi` _(optional, default `0`):_ A flat-score bonus for the second player. Valid values are -`4.5` through `4.5`.
- `color` _(optional):_ Seats the message author as White (Player 1) or Black (Player 2).
- `tps` _(optional):_ Begins the game from the specified board state.
- `opening` _(optional, default `swap`):_ Specify an opening variation. Valid values are `swap` and `no-swap`.
- `caps` _(optional):_ Override the number of cap stones per player.
- `flats` _(optional):_ Override the number of flat stones per player.
- `theme` _(optional, default `discord`):_ Uses the specified theme.
- `blind` _(optional, boolean):_ Never show the board.
- `size` _(default `6`):_ Valid values are `3` through `8`.
- `komi` _(default `0`):_ A flat-score bonus for the second player. Valid values are -`4.5` through `4.5`.
- `color` Seats the message author as White (Player 1) or Black (Player 2).
- `tps`: Begins the game from the specified board state.
- `opening` _(default `swap`):_ Specify an opening variation. Valid values are `swap` and `no-swap`.
- `caps`: Override the number of cap stones per player.
- `flats`: Override the number of flat stones per player.
- `theme` _(default `discord`):_ Uses the specified theme.
- `flat-counts` _(default `true`)_: Show flat counts
- `stack-counts` _(default `true`)_: Show stack counts
- `road-connections` _(default `true`)_: Show road connections
- `allow-links` _(default `true`)_: Allow requests for ptn.ninja links
- `blind` _(boolean):_ Never show the board.

**Standalone commands:**

Expand Down
6 changes: 6 additions & 0 deletions commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ module.exports = {
"You must use the game ID to get a link for a completed game. See `/history` to get the game ID.",
true
);
} else if (gameData.allowLinks === false) {
return sendMessage(
interaction,
"Requests for links have been disallowed for this game.",
true
);
}
gameId = gameData.gameId;
}
Expand Down
26 changes: 25 additions & 1 deletion commands/tak.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ module.exports = {
.setDescription("Theme name or JSON")
.setAutocomplete(true)
)
.addBooleanOption((option) =>
option.setName("flat-counts").setDescription("Show flat counts (default)")
)
.addBooleanOption((option) =>
option
.setName("stack-counts")
.setDescription("Show stack counts (default)")
)
.addBooleanOption((option) =>
option
.setName("road-connections")
.setDescription("Show road connections (default)")
)
.addBooleanOption((option) =>
option.setName("allow-links").setDescription("Allow links (default)")
)
.addBooleanOption((option) =>
option.setName("blind").setDescription("Never show the board")
),
Expand Down Expand Up @@ -189,7 +205,11 @@ module.exports = {
theme = getTheme(interaction);
}

// Blind mode
// Toggles mode
const flatCounts = options.getBoolean("flat-counts");
const stackCounts = options.getBoolean("stack-counts");
const showRoads = options.getBoolean("road-connections");
const allowLinks = options.getBoolean("allow-links");
const blind = options.getBoolean("blind");

// Create game data
Expand All @@ -211,6 +231,10 @@ module.exports = {

if (caps !== null) gameData.caps = caps;
if (flats !== null) gameData.flats = flats;
if (flatCounts === false) gameData.flatCounts = false;
if (stackCounts === false) gameData.stackCounts = false;
if (showRoads === false) gameData.showRoads = false;
if (allowLinks === false) gameData.allowLinks = false;
if (blind) gameData.blind = true;

let destination = interaction;
Expand Down

0 comments on commit 99379bf

Please sign in to comment.