-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from TruncateGame/feat/rendering-and-generation
💯 commits of rendering, generation, and daily puzzle features
- Loading branch information
Showing
90 changed files
with
8,933 additions
and
4,925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env node | ||
|
||
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_JS = path.join(__dirname, "../web_client/src/_data/tiles.js"); | ||
|
||
const raw_tiles = fs | ||
.readFileSync(INPUT_FILE, { encoding: "utf8" }) | ||
.split("\n"); | ||
|
||
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 | ||
} | ||
} | ||
|
||
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(', ')}];` | ||
), | ||
`}` | ||
].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,`, | ||
` }`, | ||
` }`, | ||
`}`, | ||
].join("\n"); | ||
|
||
fs.writeFileSync(OUTPUT_JS, js_map); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# migrations | ||
sqlx migrate add -r some_migration_name | ||
sqlx migrate revert | ||
sqlx migrate run | ||
|
||
# create staging db | ||
fly postgres create | ||
|
||
# prod | ||
flyctl secrets set -a truncate-citadel "DATABASE_URL=..." | ||
# staging | ||
flyctl secrets set -a truncate-coup "DATABASE_URL=..." | ||
|
||
# Remember ?sslmode=disable on the database url | ||
|
||
# to access postgresql://localhost:15432 | ||
fly proxy 15432:5432 -a truncate-staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.