Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ jobs:
run: util/checkconventionalcommit.py
working-directory: crawl-ref/source
continue-on-error: true
- name: Setup node.js
uses: actions/setup-node@v6
with:
node-version: 22.20.0
- name: Install node.js dependencies
run: npm ci
- name: JavaScript linting (biome)
run: npm run lint
- name: JavaScript formatting (biome)
run: npm run format

build_source:
permissions:
Expand Down Expand Up @@ -139,6 +149,10 @@ jobs:
- name: Install dependencies
run: ./deps.py --compiler ${{ matrix.compiler }} --build-opts "${{ matrix.build_opts }}" --debug-opts "${{ matrix.debug }}"
working-directory: .github/workflows
- name: Setup node.js
uses: actions/setup-node@v6
with:
node-version: 22.20.0
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.cquery_cache/
.DS_Store
.vscode/
node_modules/
.vs

*.sublime-workspace
Expand Down
3 changes: 3 additions & 0 deletions crawl-ref/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ chunk
/source/webserver/game_data/static/gui.png
/source/webserver/game_data/static/icons.png
/source/webserver/game_data/static/tileinfo-*.js
/source/webserver/game_data/static/game.js
/source/webserver/static/stone_soup_icon-32x32.png
/source/webserver/static/title_*.png
/source/webserver/static/index-*.js
/source/webserver/static/index-*.css

# Makefile-generated junk
makefile.dep
Expand Down
40 changes: 35 additions & 5 deletions crawl-ref/source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1326,20 +1326,50 @@ TITLEIMGS = denzi_dragon denzi_kitchen_duty denzi_summoner \
benadryl_antaeus king7artist_eustachio benadryl_oni \
ylam_formicid_shrikes lemurrobot_gozag_vaults

GENERATEDJS = $(TILEINFOJS:%=webserver/game_data/static/tileinfo-%.js)

WEBSERVERGAME = webserver/game_data/static/game.js

WEBSERVERLOBBY = webserver/static/index-*.js \
webserver/static/index-*.css \
webserver/templates/client.html

STATICFILES = $(TILEIMAGEFILES:%=webserver/game_data/static/%.png) \
webserver/static/stone_soup_icon-32x32.png \
$(TITLEIMGS:%=webserver/static/title_%.png) \
$(TILEINFOJS:%=webserver/game_data/static/tileinfo-%.js) \
webserver/webtiles/version.txt
webserver/static/stone_soup_icon-32x32.png \
$(TITLEIMGS:%=webserver/static/title_%.png) \
$(GENERATEDJS) \
$(WEBSERVERGAME) \
$(WEBSERVERLOBBY) \
webserver/webtiles/version.txt

$(TILEINFOJS:%=$(RLTILES)/tileinfo-%.js): build-rltiles

webserver/webtiles/version.txt: .ver
@git describe $(MERGE_BASE) > webserver/webtiles/version.txt

webserver/game_data/static/%.js: $(RLTILES)/%.js
webserver/game_data/static/tileinfo-%.js: $(RLTILES)/tileinfo-%.js
$(QUIET_COPY)$(COPY) $< webserver/game_data/static/

NPMPACKAGELOCKS = ../../package.json \
../../package-lock.json \
webserver/client/game/package.json \
webserver/client/lobby/package.json \

NPMNODEMODULES = ../../node_modules/.modified

$(NPMNODEMODULES): $(NPMPACKAGELOCKS)
npm ci
@rm -f ../../node_modules/.modified
@touch -m ../../node_modules/.modified

$(WEBSERVERGAME): $(GENERATEDJS) webserver/client/game/src/*.js $(NPMNODEMODULES)
npm run build --workspace=crawl-game

$(WEBSERVERLOBBY): webserver/client/lobby/src/*.js $(NPMNODEMODULES)
@rm -f webserver/static/index-*.js
@rm -f webserver/static/index-*.css
npm run build --workspace=crawl-lobby

clean-webserver:
$(RM) $(STATICFILES) webserver/*.pyc

Expand Down
31 changes: 12 additions & 19 deletions crawl-ref/source/rltiles/tool/tile_list_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1673,39 +1673,32 @@ bool tile_list_processor::write_data(bool image, bool code)

if (m_abstract.size() == 0)
{
fprintf(fp, "define([");
if (m_start_value_module.size() > 0)
fprintf(fp, "\"./tileinfo-%s\"", m_start_value_module.c_str());
fprintf(fp, "], function(m) {\n");
fprintf(fp, "import m from \"./tileinfo-%s\"\n", m_start_value_module.c_str());
}
else
{
fprintf(fp, "define([\"jquery\",");
for (const auto& abstract : m_abstract)
fprintf(fp, "\"./tileinfo-%s\", ", abstract.first.c_str());
fprintf(fp, "],\n function ($, ");
for (size_t i = 0; i < m_abstract.size(); ++i)
for (const auto &abstract : m_abstract)
{
if (i < m_abstract.size() - 1)
fprintf(fp, "%s, ", m_abstract[i].first.c_str());
else
fprintf(fp, "%s", m_abstract[i].first.c_str());
fprintf(fp, "import %s from \"./tileinfo-%s\"\n",
abstract.first.c_str(), abstract.first.c_str());
}
fprintf(fp, ") {\n");
}
fprintf(fp, "// This file has been automatically generated.\n\n");
fprintf(fp, "var exports = {};\n");
fprintf(fp, "const exports = { ");

if (m_abstract.size() > 0)
{
for (const auto& abstract : m_abstract)
fprintf(fp, "$.extend(exports, %s);\n", abstract.first.c_str());
for (const auto &abstract : m_abstract)
fprintf(fp, "...%s, ", abstract.first.c_str());
}

fprintf(fp, "};\n");

if (m_start_value_module.size() > 0)
fprintf(fp, "\nvar val = m.%s;\n", m_start_value.c_str());
fprintf(fp, "\nlet val = m.%s;\n", m_start_value.c_str());
else
fprintf(fp, "\nvar val = %s;\n", m_start_value.c_str());
fprintf(fp, "\nlet val = %s;\n", m_start_value.c_str());

string old_enum_name = "";
int count = 0;
Expand Down Expand Up @@ -1862,7 +1855,7 @@ bool tile_list_processor::write_data(bool image, bool code)
fprintf(fp, "};\n\n");
}

fprintf(fp, "return exports;\n});\n");
fprintf(fp, "export default exports\n");

fclose(fp);
}
Expand Down
1 change: 1 addition & 0 deletions crawl-ref/source/webserver/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ banned_players.txt
webtiles/version.txt
Pipfile
Pipfile.lock
templates/client.html
2 changes: 0 additions & 2 deletions crawl-ref/source/webserver/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
lint:
flake8 --mypy-config=mypy.ini *.py webtiles/*.py


format:
isort --check-only --recursive .


.PHONY: lint format
24 changes: 24 additions & 0 deletions crawl-ref/source/webserver/client/game/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
40 changes: 40 additions & 0 deletions crawl-ref/source/webserver/client/game/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"includes": ["*", "src/*", "!src/contrib"]

},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noVar": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
12 changes: 12 additions & 0 deletions crawl-ref/source/webserver/client/game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Crawl Game</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions crawl-ref/source/webserver/client/game/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "crawl-game",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "npm-run-all build:vite copy",
"build:vite": "vite build",
"lint": "biome lint ./src/*",
"lint:fix": "biome lint ./src/* --write --unsafe",
"format": "biome format ./src/*",
"preview": "vite preview",
"copy": "cp dist/static/* ../../game_data/static"
},
"devDependencies": {
"@biomejs/biome": "^2.2.6",
"typescript": "~5.9.3",
"vite": "^7.1.7"
},
"dependencies": {
"focus-trap": "^7.6.5",
"jquery": "^1.12.4"
}
}
Loading
Loading