Skip to content

Commit

Permalink
Merge pull request #284 from TruncateGame/feat/delta-one
Browse files Browse the repository at this point in the history
New rules, new art, Sunday release 👀
  • Loading branch information
bglw authored Nov 15, 2024
2 parents 90d42e7 + 403d377 commit 0ef788a
Show file tree
Hide file tree
Showing 64 changed files with 3,252 additions and 2,838 deletions.
110 changes: 56 additions & 54 deletions .backstage/build-tile-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,76 @@ const fs = require("fs");
const path = require("path");

const INPUT_FILE = path.join(__dirname, "../truncate_client/img/tile_order");
const OUTPUT_RUST = path.join(__dirname, "../truncate_client/src/utils/tex/tiles.rs");
const OUTPUT_RUST = path.join(
__dirname,
"../truncate_client/src/utils/tex/tiles.rs",
);
const OUTPUT_JS = path.join(__dirname, "../web_client/src/_data/tiles.js");

const raw_tiles = fs
.readFileSync(INPUT_FILE, { encoding: "utf8" })
.split("\n");
.readFileSync(INPUT_FILE, { encoding: "utf8" })
.split("\n")
.filter((t) => /\w/.test(t));

const quad_tiles = {};
for (const tile of raw_tiles) {
if (/_(nw|ne|se|sw)$/i.test(tile)) {
const tile_base = tile.replace(/_(nw|ne|se|sw)$/i, '');
const tile_corner = tile.match(/_(nw|ne|se|sw)$/i)?.[1];
quad_tiles[tile_base] = quad_tiles[tile_base] || {};
quad_tiles[tile_base][tile_corner?.toLowerCase() || "??"] = true
}
if (/_(nw|ne|se|sw)$/i.test(tile)) {
const tile_base = tile.replace(/_(nw|ne|se|sw)$/i, "");
const tile_corner = tile.match(/_(nw|ne|se|sw)$/i)?.[1];
quad_tiles[tile_base] = quad_tiles[tile_base] || {};
quad_tiles[tile_base][tile_corner?.toLowerCase() || "??"] = true;
}
}

const rs_map = [
`#![cfg_attr(rustfmt, rustfmt_skip)]\n`,
`#![allow(dead_code)]\n`,
`use super::{Tex, TexQuad};\n`,
`const fn t(tile: usize) -> Tex {`,
` Tex { tile, tint: None }`,
`}\n`,
`pub const MAX_TILE: usize = ${raw_tiles.length};`,
...raw_tiles.map((tile, i) =>
`pub const ${tile}: Tex = t(${i});`
),
`\npub mod quad {`,
` use super::*;\n`,
...Object.entries(quad_tiles).map(([tile, quadrants]) =>
` pub const ${tile}: TexQuad = [${[
quadrants.nw ? `${tile}_NW` : `NONE`,
quadrants.ne ? `${tile}_NE` : `NONE`,
quadrants.se ? `${tile}_SE` : `NONE`,
quadrants.sw ? `${tile}_SW` : `NONE`,
].join(', ')}];`
),
`}`
`#![cfg_attr(rustfmt, rustfmt_skip)]\n`,
`#![allow(dead_code)]\n`,
`use super::{Tex, TexQuad};\n`,
`const fn t(tile: usize) -> Tex {`,
` Tex { tile, tint: None }`,
`}\n`,
`pub const MAX_TILE: usize = ${raw_tiles.length};`,
...raw_tiles.map((tile, i) => `pub const ${tile}: Tex = t(${i});`),
`\npub mod quad {`,
` use super::*;\n`,
...Object.entries(quad_tiles).map(
([tile, quadrants]) =>
` pub const ${tile}: TexQuad = [${[
quadrants.nw ? `${tile}_NW` : `NONE`,
quadrants.ne ? `${tile}_NE` : `NONE`,
quadrants.se ? `${tile}_SE` : `NONE`,
quadrants.sw ? `${tile}_SW` : `NONE`,
].join(", ")}];`,
),
`}`,
].join("\n");

fs.writeFileSync(OUTPUT_RUST, rs_map);

const js_map = [
`const tiles = {`,
...raw_tiles.map((tile, i) =>
` ${tile}: ${i},`
),
`};\n`,
`const quads = {`,
...Object.entries(quad_tiles).map(([tile, quadrants]) =>
` ${tile}: [[${[
quadrants.nw ? `tiles.${tile}_NW` : `tiles.NONE`,
quadrants.ne ? `tiles.${tile}_NE` : `tiles.NONE`,
].join(', ')}],[${[
quadrants.sw ? `tiles.${tile}_SW` : `tiles.NONE`,
quadrants.se ? `tiles.${tile}_SE` : `tiles.NONE`,
].join(', ')}]],`
),
`};\n`,
`module.exports = async function () {`,
` return {`,
` ...tiles,`,
` QUAD: {`,
` ...quads,`,
` }`,
` }`,
`}`,
`const tiles = {`,
...raw_tiles.map((tile, i) => ` ${tile}: ${i},`),
`};\n`,
`const quads = {`,
...Object.entries(quad_tiles).map(
([tile, quadrants]) =>
` ${tile}: [[${[
quadrants.nw ? `tiles.${tile}_NW` : `tiles.NONE`,
quadrants.ne ? `tiles.${tile}_NE` : `tiles.NONE`,
].join(", ")}],[${[
quadrants.sw ? `tiles.${tile}_SW` : `tiles.NONE`,
quadrants.se ? `tiles.${tile}_SE` : `tiles.NONE`,
].join(", ")}]],`,
),
`};\n`,
`module.exports = async function () {`,
` return {`,
` ...tiles,`,
` QUAD: {`,
` ...quads,`,
` }`,
` }`,
`}`,
].join("\n");

fs.writeFileSync(OUTPUT_JS, js_map);
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
default: true
components: rustfmt, clippy
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
default: true
components: rustfmt, clippy

- name: Install wasm-pack
uses: jetli/wasm-pack-action@v0.4.0
with:
version: ${{env.WASM_PACK_VERSION}}

- name: Install Rust components
if: matrix.workspace == 'truncate_client'
run: |-
cargo install -f wasm-bindgen-cli --version 0.2.92
cargo install -f wasm-bindgen-cli --version 0.2.93
rustup target add wasm32-unknown-unknown
- name: Test
Expand Down
21 changes: 11 additions & 10 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN apt-get install -y nodejs

RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# Keep this wasm-bindgen-cli version aligned with the latest egui release's dependency
RUN cargo install -f wasm-bindgen-cli --version 0.2.92
RUN cargo install -f wasm-bindgen-cli --version 0.2.93
RUN rustup target add wasm32-unknown-unknown

RUN mkdir /app
Expand Down
89 changes: 18 additions & 71 deletions truncate_client/img/tile_order
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CHECKERBOARD_NW
CHECKERBOARD_NE
CHECKERBOARD_SW
CHECKERBOARD_SE
BASE_WATER_WAVES
BASE_WATER
WATER_WITH_LAND_SE
WATER_WITH_LAND_S
Expand Down Expand Up @@ -55,76 +56,20 @@ HOUSE_2
ROOF_2
HOUSE_3
ROOF_3
SMOKE_0
SMOKE_1
SMOKE_2
SMOKE_3
SMOKE_4
BUSH_0
BUSH_FLOWERS_0
BUSH_1
BUSH_FLOWERS_1
BUSH_2
BUSH_FLOWERS_2
WHEAT_WIND_0
WHEAT_WIND_1
WELL
NORTH_DOCK_NW
NORTH_DOCK_NE
NORTH_DOCK_SW
NORTH_DOCK_SE
NORTH_DOCK_SAIL_WIND_0_NW
NORTH_DOCK_SAIL_WIND_0_NE
NORTH_DOCK_SAIL_WIND_1_NW
NORTH_DOCK_SAIL_WIND_1_NE
NORTH_DOCK_SAIL_WIND_2_NW
NORTH_DOCK_SAIL_WIND_2_NE
SOUTH_DOCK_NW
SOUTH_DOCK_NE
SOUTH_DOCK_SW
SOUTH_DOCK_SE
SOUTH_DOCK_SAIL_WIND_0_NW
SOUTH_DOCK_SAIL_WIND_0_SW
SOUTH_DOCK_SAIL_WIND_1_NW
SOUTH_DOCK_SAIL_WIND_1_SW
SOUTH_DOCK_SAIL_WIND_2_NW
SOUTH_DOCK_SAIL_WIND_2_SW
EAST_DOCK_NW
EAST_DOCK_NE
EAST_DOCK_SW
EAST_DOCK_SE
EAST_DOCK_SAIL_WIND_0_NW
EAST_DOCK_SAIL_WIND_0_NE
EAST_DOCK_SAIL_WIND_0_SW
EAST_DOCK_SAIL_WIND_0_SE
EAST_DOCK_SAIL_WIND_1_NW
EAST_DOCK_SAIL_WIND_1_NE
EAST_DOCK_SAIL_WIND_1_SW
EAST_DOCK_SAIL_WIND_1_SE
EAST_DOCK_SAIL_WIND_2_NW
EAST_DOCK_SAIL_WIND_2_NE
EAST_DOCK_SAIL_WIND_2_SW
EAST_DOCK_SAIL_WIND_2_SE
WEST_DOCK_NW
WEST_DOCK_NE
WEST_DOCK_SW
WEST_DOCK_SE
WEST_DOCK_SAIL_WIND_0_NW
WEST_DOCK_SAIL_WIND_0_NE
WEST_DOCK_SAIL_WIND_1_NW
WEST_DOCK_SAIL_WIND_1_NE
WEST_DOCK_SAIL_WIND_2_NW
WEST_DOCK_SAIL_WIND_2_NE
FLOATING_DOCK_NW
FLOATING_DOCK_NE
FLOATING_DOCK_SW
FLOATING_DOCK_SE
FLOATING_DOCK_SAIL_WIND_0_NW
FLOATING_DOCK_SAIL_WIND_0_NE
FLOATING_DOCK_SAIL_WIND_1_NW
FLOATING_DOCK_SAIL_WIND_1_NE
FLOATING_DOCK_SAIL_WIND_2_NW
FLOATING_DOCK_SAIL_WIND_2_NE
ARTIFACT_NW
ARTIFACT_NE
ARTIFACT_SW
ARTIFACT_SE
ARTIFACT_GLYPH_NW
ARTIFACT_GLYPH_NE
ARTIFACT_GLYPH_SW
ARTIFACT_GLYPH_SE
GAME_PIECE_NW
GAME_PIECE_NE
GAME_PIECE_SW
Expand Down Expand Up @@ -237,13 +182,15 @@ TOWN_BUTTON_SW
TOWN_BUTTON_SE
TOWN_BUTTON_ROOF_NW
TOWN_BUTTON_ROOF_NE
DOCK_BUTTON_NW
DOCK_BUTTON_NE
DOCK_BUTTON_SW
DOCK_BUTTON_SE
DOCK_BUTTON_SAIL_NW
DOCK_BUTTON_SAIL_NE
ARTIFACT_BUTTON_NW
ARTIFACT_BUTTON_NE
ARTIFACT_BUTTON_SW
ARTIFACT_BUTTON_SE
ARTIFACT_BUTTON_GLYPH_NW
ARTIFACT_BUTTON_GLYPH_NE
ARTIFACT_BUTTON_GLYPH_SW
ARTIFACT_BUTTON_GLYPH_SE
TERRAIN_BUTTON_NW
TERRAIN_BUTTON_NE
TERRAIN_BUTTON_SW
TERRAIN_BUTTON_SE
TERRAIN_BUTTON_SE
Binary file modified truncate_client/img/truncate.aseprite
Binary file not shown.
Binary file modified truncate_client/img/truncate_packed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added truncate_client/img/truncate_packed_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0ef788a

Please sign in to comment.