Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
268 commits
Select commit Hold shift + click to select a range
d131ce4
client model changes
mpalmerlee Nov 27, 2022
1b15e77
found bug in populate planets
mpalmerlee Nov 27, 2022
71f9741
fixed re-starting game every render
mpalmerlee Nov 27, 2022
1755bba
set owned planet for player in populate planets
mpalmerlee Nov 27, 2022
5a94c2f
generate tax revenue / credits
mpalmerlee Nov 27, 2022
ae874ae
more research work and events pub/sub
mpalmerlee Nov 28, 2022
06b6d87
minor changes to show research, added jest
mpalmerlee Dec 15, 2022
778eccf
first tests for trading center now passing!
mpalmerlee Dec 27, 2022
7958ea5
formatting
mpalmerlee Dec 27, 2022
ac6d443
finished tradingCenter tests
mpalmerlee Dec 28, 2022
3db3325
added call to executeCurrentTrades
mpalmerlee Dec 28, 2022
986bcae
added AI (computerPlayer.ts)
mpalmerlee Dec 31, 2022
32693bf
formatting
mpalmerlee Dec 31, 2022
7ea0bfc
Added battleSimulator and tests
mpalmerlee Jan 1, 2023
c2432dc
formatting
mpalmerlee Jan 1, 2023
e8f044d
added resolvePlanetaryConflicts function
mpalmerlee Jan 1, 2023
8dd1c6b
formatting
mpalmerlee Jan 1, 2023
f369c75
added eatAndStarve
mpalmerlee Jan 2, 2023
f6b7f80
formatting
mpalmerlee Jan 2, 2023
930742b
finished the rest of the player turn methods
mpalmerlee Jan 4, 2023
d7848c5
repair planetary fleets
mpalmerlee Jan 5, 2023
190248e
move fleets
mpalmerlee Jan 7, 2023
edb6405
task notifications for build queue empty instead of events
mpalmerlee Jan 9, 2023
b898525
added addLastStarShipToQueueOnPlanets
mpalmerlee Jan 9, 2023
b72088e
added fleet.spec.ts
mpalmerlee Jan 10, 2023
2bb9cfc
fixed bug in rect contains, added points calc and tests
mpalmerlee Jan 12, 2023
0595153
fixed calculated points tests
mpalmerlee Jan 13, 2023
6e3fdcc
adding storybook and chakra to ui lib
mpalmerlee Apr 26, 2023
5cb7319
have POC chakra button with svg background
mpalmerlee Oct 8, 2023
522b625
more button with svg background
mpalmerlee Oct 8, 2023
c7a57c5
formatting
mpalmerlee Oct 8, 2023
0935213
experimenting with different button sizes
mpalmerlee Oct 8, 2023
acff7be
added explicit svgs for different button sizes
mpalmerlee Oct 8, 2023
5426649
added explicit svgs for different button sizes
mpalmerlee Oct 8, 2023
7230f1c
now have secondary buttons
mpalmerlee Oct 8, 2023
ebb7b26
fixed bug with global var
mpalmerlee Oct 8, 2023
555197c
proper bolding, download additional weights
mpalmerlee Oct 8, 2023
49d0d1e
started adding notification
mpalmerlee Oct 9, 2023
e7919c1
notification component sizes
mpalmerlee Oct 9, 2023
cc5ada1
added card component
mpalmerlee Oct 9, 2023
316d48c
created custom Tab control
mpalmerlee Mar 29, 2024
7cbf7fd
navigation tab controller component
mpalmerlee Mar 29, 2024
2c22e70
uncommitted changes
mpalmerlee Jul 1, 2025
0b444c8
uncommitted changes
mpalmerlee Jul 1, 2025
330a291
minor type tweak in engine
mpalmerlee Jul 6, 2025
1676d08
lots of changes, ditched remix, upgraded libraries
mpalmerlee Jul 6, 2025
2b5b53c
Crazy changes with svelte & sveltekit pocs
mpalmerlee Jul 11, 2025
c1b99cc
orbiton font
mpalmerlee Jul 11, 2025
f9af2e0
proper svg for navigation tabs
mpalmerlee Jul 11, 2025
bae6cc1
now bot started making game for me
mpalmerlee Jul 12, 2025
3600fe6
avancing game loop
mpalmerlee Jul 12, 2025
c4d882a
turn -> cycle
mpalmerlee Jul 12, 2025
3a79088
toFixed(1) for resources
mpalmerlee Jul 12, 2025
437b6da
galaxy canvas and konva.js lib
mpalmerlee Jul 12, 2025
443393a
fixed bug with ssr
mpalmerlee Jul 12, 2025
4e0e7c9
drawing hexes
mpalmerlee Jul 12, 2025
8a9fea6
simplified dynamic imports
mpalmerlee Jul 12, 2025
4432934
planet owner rendering changes
mpalmerlee Jul 13, 2025
238bd1e
planet view changes
mpalmerlee Jul 13, 2025
7d902d8
started defining design system
mpalmerlee Jul 13, 2025
33403fc
had bot define rest of design system
mpalmerlee Jul 13, 2025
788f0b3
Typography for design system
mpalmerlee Jul 13, 2025
67833a5
moved astriarch css to own file
mpalmerlee Jul 13, 2025
0153016
logo
mpalmerlee Jul 13, 2025
7eab6d5
logo
mpalmerlee Jul 13, 2025
20a61cd
starting to add window frame
mpalmerlee Jul 13, 2025
4128ce1
responsive svg window frame
mpalmerlee Jul 13, 2025
684bd3b
removed unused svgs
mpalmerlee Jul 13, 2025
7ba5a8d
updated svg icons
mpalmerlee Jul 13, 2025
bdbcf33
Planet Production Item control
mpalmerlee Jul 14, 2025
d3ac63f
fixed layering with card component
mpalmerlee Jul 14, 2025
18cd015
tooltip for ppi
mpalmerlee Jul 14, 2025
e687172
DRY up component
mpalmerlee Jul 14, 2025
e151b7c
Planet view improvements
mpalmerlee Jul 15, 2025
bca596c
Planet view improvements
mpalmerlee Jul 15, 2025
ffc961e
Added astriarch-backend starting point
mpalmerlee Jul 15, 2025
f1879db
claude code flow instruction: This is the codebase for Astriarch: Rul…
mpalmerlee Jul 24, 2025
95b720f
claude code flow frontend work
mpalmerlee Jul 24, 2025
aa0eb0b
re-arranging docker
mpalmerlee Jul 24, 2025
9ae0ecf
undid some stuff the bot did to the frontend
mpalmerlee Jul 25, 2025
3c0eb8c
had bot refactor backend to be message driven
mpalmerlee Jul 28, 2025
bb5774f
fixed ts errors, moved ws test
mpalmerlee Jul 28, 2025
57c72f7
improved client websocket
mpalmerlee Jul 29, 2025
f6aad6c
null handling
mpalmerlee Jul 31, 2025
e839b7a
create game in test page
mpalmerlee Jul 31, 2025
63114e2
opponent list
mpalmerlee Jul 31, 2025
2014f9f
new message type payload typescript types
mpalmerlee Aug 1, 2025
0fdf735
using type safe engine payloads in client websocket
mpalmerlee Aug 1, 2025
f9f4911
formatting
mpalmerlee Aug 1, 2025
d71fb0a
lint fixes
mpalmerlee Aug 1, 2025
9bf9148
proper fix for lint in engine
mpalmerlee Aug 1, 2025
7209ccd
improved message handling typing in server
mpalmerlee Aug 6, 2025
bdca576
default / null check fixes
mpalmerlee Aug 6, 2025
1b08e62
update main game stores from web socket
mpalmerlee Aug 6, 2025
e42b058
minor changes to bottom tab buttons
mpalmerlee Aug 9, 2025
18866c8
AI did some stuff
mpalmerlee Aug 10, 2025
9535047
AI did more stuff
mpalmerlee Aug 10, 2025
76d6a4f
AI styling new GameOptionsView
mpalmerlee Aug 10, 2025
dfd99dc
moar ai styling, can not scroll
mpalmerlee Aug 10, 2025
b58f234
formatting
mpalmerlee Aug 10, 2025
5547671
scrollable content in create game view
mpalmerlee Aug 10, 2025
ac7043f
show lobby list on first load
mpalmerlee Aug 10, 2025
8f67964
remove overflow-hidden in main
mpalmerlee Aug 10, 2025
d810cc6
logo svg
mpalmerlee Aug 10, 2025
240c10a
formatting and proper logo
mpalmerlee Aug 10, 2025
d993e02
engine cleanup remove startGame test function
mpalmerlee Aug 10, 2025
7c7eea0
cleanup and logo
mpalmerlee Aug 21, 2025
ae6a693
temporarily added back startGame method in engine
mpalmerlee Aug 21, 2025
c6c7ffc
create game now works in ui
mpalmerlee Aug 21, 2025
bcc5832
fixed error with start new game
mpalmerlee Aug 21, 2025
f8a93fc
now getting through game options to game
mpalmerlee Aug 21, 2025
7359f38
broadcast client game model to players
mpalmerlee Aug 21, 2025
12597c3
cleanup old realtimegamecontroller.ts file and related tests
mpalmerlee Aug 22, 2025
51c1276
server side advance game model time on ws action
mpalmerlee Aug 24, 2025
da0f888
client side game state update on START_GAME and GAME_STATE_UPDATE mes…
mpalmerlee Aug 24, 2025
02d20cf
fix bug that was causing empty objects to be minimized to undefineds …
mpalmerlee Aug 25, 2025
d3ad04e
potentially problematic adding players based on game options code
mpalmerlee Aug 25, 2025
224362c
fixed logger
mpalmerlee Aug 25, 2025
0fcff8b
enable source maps
mpalmerlee Aug 25, 2025
25b24f0
proper exports from engine
mpalmerlee Aug 25, 2025
9cace4d
computer players do not have session ids
mpalmerlee Aug 25, 2025
8a140e4
send build queue message to server
mpalmerlee Aug 27, 2025
200a19d
cleanup with claude code
mpalmerlee Aug 27, 2025
4cf2ad7
major cleanup of the test server route and depentent components
mpalmerlee Aug 27, 2025
a6b4691
construct grid as necessary client side
mpalmerlee Aug 27, 2025
bcac322
only create grid if not exists
mpalmerlee Aug 28, 2025
e53a171
fixed planet ownership check and started optimistic build queue updates
mpalmerlee Aug 29, 2025
174d438
Document persistence layer to handle mixed field marking
mpalmerlee Aug 29, 2025
069cc75
fixed duplicate index warning
mpalmerlee Aug 29, 2025
42d7344
new engine method for enqueue and spend resources if possible
mpalmerlee Aug 29, 2025
49d961c
use engine method for build queue updates
mpalmerlee Aug 29, 2025
08d4b04
show proper pop worker assignments
mpalmerlee Aug 30, 2025
53304bd
frontend update population worker assignments
mpalmerlee Aug 30, 2025
301b7fc
server side updatePlanetOptions implementation
mpalmerlee Aug 30, 2025
8bb6fb6
server side formatting with prettier
mpalmerlee Aug 30, 2025
c84d567
updatePopulationWorkerTypes function in engine
mpalmerlee Aug 30, 2025
d4e9465
new tests for update population worker types
mpalmerlee Aug 30, 2025
9a95cbb
ping interval in client
mpalmerlee Aug 30, 2025
321b375
start owned planets with two pop by default
mpalmerlee Aug 30, 2025
a74aa91
ping response now sends client model
mpalmerlee Aug 30, 2025
06c3406
show planetary improvements and compact height
mpalmerlee Aug 30, 2025
fadcb73
fixed bug in engine with constructing starships
mpalmerlee Aug 30, 2025
bdc3db2
found issue in engine with build queue, should not have been accounti…
mpalmerlee Aug 31, 2025
36eaf9f
fleet command screen building
mpalmerlee Sep 1, 2025
b0e0a30
Fleet sending with backend server implementation
mpalmerlee Sep 1, 2025
c1cd5f9
updated planet selection logic
mpalmerlee Sep 1, 2025
a405f9d
added info panel
mpalmerlee Sep 1, 2025
1ab50fb
select planetdata or clientplanet
mpalmerlee Sep 1, 2025
62e91d0
fixed planet selection
mpalmerlee Sep 1, 2025
03a0f5c
use planetTypeToFriendlyName in planet panel
mpalmerlee Sep 1, 2025
b386641
now drawn fleets rendering
mpalmerlee Sep 1, 2025
ca148bd
streamlined ux a bit
mpalmerlee Sep 1, 2025
69f853b
update game state on send ships
mpalmerlee Sep 1, 2025
f60d3f1
try to fix header resources movement
mpalmerlee Sep 1, 2025
8be3464
Working on notifications system
mpalmerlee Sep 1, 2025
428f6c0
Fixed duplicate multiplayer state code in websocket.ts and multiplaye…
mpalmerlee Sep 1, 2025
f3ef88c
Added getDefaultGameOptions to engine
mpalmerlee Sep 2, 2025
13775d3
Lobby and new game options cleanup
mpalmerlee Sep 2, 2025
a679f0f
auto-timeout for notifications
mpalmerlee Sep 3, 2025
bd3246a
improved notification style
mpalmerlee Sep 3, 2025
640c1a5
fix bug with sorting by built improvement count
mpalmerlee Sep 3, 2025
631d466
enhanced build validation
mpalmerlee Sep 3, 2025
9c70cbb
little bit of cleanup
mpalmerlee Sep 3, 2025
ffc0c6f
use new can build on FE
mpalmerlee Sep 3, 2025
8d2fd44
unused gameState variable cleanup
mpalmerlee Sep 4, 2025
dbeba97
fallback state handle cleanup
mpalmerlee Sep 4, 2025
bfa5c06
cleanup and start SYNC_STATE message impl
mpalmerlee Sep 4, 2025
348d2aa
starting state sync from the client
mpalmerlee Sep 4, 2025
a54706b
gameId state fetch cleanup and state sync request
mpalmerlee Sep 4, 2025
479652a
no need to log all client side events
mpalmerlee Sep 5, 2025
ccbbe94
Messy code to resume games
mpalmerlee Sep 6, 2025
0aa90e8
set game id when joining
mpalmerlee Sep 6, 2025
d047d96
only return games the user can join from the backend, do not return s…
mpalmerlee Sep 6, 2025
b0e0e85
figured out why quickstart was not setting planets in quad explored
mpalmerlee Sep 6, 2025
b2d34e1
use fleets arriving on unowned planets to control state sync
mpalmerlee Sep 6, 2025
4f87321
remove legacy astriarch-frontend (React) and astriarch-frontend-svelte
mpalmerlee Sep 6, 2025
30ee6a2
formatting
mpalmerlee Sep 6, 2025
3d8782e
fix fleet animation by clearing each time
mpalmerlee Sep 6, 2025
771e0d7
research view and design system updates for REM units
mpalmerlee Sep 7, 2025
135d049
new icons for research view
mpalmerlee Sep 7, 2025
470c68c
improved icons
mpalmerlee Sep 7, 2025
1f11ffa
more research improvements
mpalmerlee Sep 7, 2025
002326d
start making research view functional
mpalmerlee Sep 7, 2025
ecdb208
removed duplicate state and now research working a bit
mpalmerlee Sep 7, 2025
9618832
estimate turns to complete
mpalmerlee Sep 8, 2025
d9b075f
estimate turns to complete
mpalmerlee Sep 8, 2025
a19cf1c
pan and zoom for galaxy
mpalmerlee Sep 8, 2025
861f322
fix engine bug with parsecs to destination
mpalmerlee Sep 8, 2025
3fbe5c2
change drawn planet to show strength, not length
mpalmerlee Sep 8, 2025
05ebb54
making progress towards better fleet control
mpalmerlee Sep 8, 2025
bc15a00
new ship card component
mpalmerlee Sep 8, 2025
ead51be
Dropdown component
mpalmerlee Sep 9, 2025
7436e9f
Dropdown component
mpalmerlee Sep 9, 2025
ed5c660
starting to use dropdown in research view
mpalmerlee Sep 9, 2025
c502869
DropdownSelect using Shadcn
mpalmerlee Sep 9, 2025
f656941
change to new dropdown select as default
mpalmerlee Sep 9, 2025
084c27c
Research improvements
mpalmerlee Sep 9, 2025
c1a7c8f
Research progress now reactive
mpalmerlee Sep 10, 2025
d88e640
add research level indicators on icons
mpalmerlee Sep 11, 2025
94c72e7
Fixed engine bug spending off-planet resources
mpalmerlee Sep 11, 2025
9d79a60
Had bot review engine code and fix more bugs, array bounds checking, …
mpalmerlee Sep 11, 2025
b8b2608
formatting
mpalmerlee Sep 11, 2025
d227389
added player.spec.ts for engine
mpalmerlee Sep 12, 2025
465c4c9
Started adding activity view
mpalmerlee Sep 12, 2025
5685985
improved activity view with combat details and zoom to planet
mpalmerlee Sep 12, 2025
31feb10
DRY up activity view
mpalmerlee Sep 12, 2025
eb8daa7
change to activity tabs
mpalmerlee Sep 12, 2025
1c4faff
custom design system tabs
mpalmerlee Sep 12, 2025
4075817
in the middle of trading center ai vibe coding checkpoint
mpalmerlee Sep 14, 2025
94b721f
updating trade data model for five second timeout, server side trade …
mpalmerlee Sep 14, 2025
1db872d
trading now working
mpalmerlee Sep 14, 2025
80c6d51
fix selecting planet after send fleet
mpalmerlee Sep 14, 2025
9ccecfc
improved fleet command view
mpalmerlee Sep 14, 2025
909f708
starting to work on multiplayer join game
mpalmerlee Sep 14, 2025
0541959
starting to work on multiplayer join game
mpalmerlee Sep 15, 2025
ae9b946
fix collisions between connect sessions and game_sessions collections
mpalmerlee Sep 16, 2025
f475c27
improved join multiplayer game
mpalmerlee Sep 16, 2025
a1b5ff7
Change player name functionality
mpalmerlee Sep 16, 2025
c329818
send player connected in game summary
mpalmerlee Sep 16, 2025
546026d
change name on blur rather than on input
mpalmerlee Sep 16, 2025
521d9fb
fixed showing joining player position in lobby
mpalmerlee Sep 16, 2025
b187c9b
fix host re-joins game
mpalmerlee Sep 16, 2025
51ab85c
using local storage to save player name
mpalmerlee Sep 16, 2025
2dbd14a
Now showing images for planet types
mpalmerlee Sep 17, 2025
df9f674
Planet selection rings
mpalmerlee Sep 17, 2025
c3399dd
Planet selection ring complex middle
mpalmerlee Sep 17, 2025
e456655
Better planet ring and remove planetCircle
mpalmerlee Sep 17, 2025
9372e2b
better metallic planet rings
mpalmerlee Sep 17, 2025
294d282
planet rings on top and new fleet strength indicators
mpalmerlee Sep 17, 2025
085f00d
better strength indicators
mpalmerlee Sep 17, 2025
b63c79a
DrawnPlanet -> Hex based click detection
mpalmerlee Sep 17, 2025
cba4360
DrawnPlanet now reacts to changes in the model
mpalmerlee Sep 17, 2025
cb01e9e
remove debugging and try to optimize planet selection
mpalmerlee Sep 17, 2025
c380e87
change grid size to match hex ratio (wider) and externalize grid size…
mpalmerlee Sep 18, 2025
aa34daa
Audio functionality
mpalmerlee Sep 18, 2025
1101410
still working on audio UI
mpalmerlee Sep 18, 2025
24d2f0b
fix top overview a bit by formatting numbers shorter
mpalmerlee Sep 18, 2025
d597b40
move volume control up a bit
mpalmerlee Sep 18, 2025
055213e
When human player disconnects pause game and resume when they rejoin
mpalmerlee Sep 18, 2025
22ea135
getting closer to new pause/resume
mpalmerlee Sep 18, 2025
cc9c695
remove unnecessary handlePotentialReconnection method
mpalmerlee Sep 18, 2025
8d5936f
proper game resume logic when another player is disconnected
mpalmerlee Sep 18, 2025
30506bb
do not set game resumed on pong messages
mpalmerlee Sep 19, 2025
8987c64
we do not have a sepectate feature (yet)
mpalmerlee Sep 19, 2025
e3655ab
game sync updates SYNC_STATE message
mpalmerlee Sep 19, 2025
24403d2
client side game state sync interval for the host
mpalmerlee Sep 19, 2025
bf3267f
queue up food amount shipped till cycle advancement for message
mpalmerlee Sep 19, 2025
4189558
formatting
mpalmerlee Sep 19, 2025
74567b2
do not deselect planet click in grid
mpalmerlee Sep 19, 2025
f8a54da
bot performance improvements, should be more event driven yet it seem…
mpalmerlee Sep 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ Thumbs.db

node_modules
.sass-cache
.idea
.idea

dist
build
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
old

# Ignore artifacts:
build
coverage

pnpm-lock.yaml
73 changes: 73 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview
Astriarch is a space strategy game built as a TypeScript monorepo using pnpm workspaces. The game features real-time multiplayer gameplay with a Node.js backend and multiple frontend implementations.

## Architecture
The project follows a monorepo structure with clear separation of concerns:

- **packages/astriarch-engine**: Core game engine with business logic, game state management, and turn-based mechanics. Provides TypeScript types and game controllers used across all applications.
- **apps/astriarch-backend**: Express.js server with WebSocket support, MongoDB integration, and session management. Handles multiplayer game state and real-time communication.
- **apps/astriarch-frontend-sveltekit**: Primary SvelteKit frontend with component library, game canvas using Konva, and real-time multiplayer UI.
- **packages/astriarch-ui**: Shared React component library using Chakra UI for consistent styling across frontends.

The engine exports game models, controllers, and messaging types that are consumed by both frontend and backend applications. The backend maintains authoritative game state while clients receive filtered views through the ClientGameModel.

## Development Commands

### Root Level (run from project root)
- `pnpm build` - Build all packages and apps
- `pnpm test` - Run tests across all workspaces
- `pnpm lint` - Lint all packages
- `pnpm format` - Format code across all packages
- `docker-compose up -d mongodb` - Start local MongoDB for development

### Backend Development
- `pnpm --filter astriarch-backend dev` - Start backend in development mode with hot reload
- `pnpm --filter astriarch-backend build` - Build backend TypeScript to JavaScript
- `pnpm --filter astriarch-backend test` - Run backend tests
- `pnpm --filter astriarch-backend lint` - Lint backend code
- `pnpm --filter astriarch-backend type-check` - Run TypeScript type checking

### SvelteKit Frontend Development
- `pnpm --filter astriarch-frontend-sveltekit dev` - Start SvelteKit dev server
- `pnpm --filter astriarch-frontend-sveltekit build` - Build SvelteKit app
- `pnpm --filter astriarch-frontend-sveltekit test` - Run Vitest unit tests
- `pnpm --filter astriarch-frontend-sveltekit lint` - Lint and format check
- `pnpm --filter astriarch-frontend-sveltekit storybook` - Start Storybook component development

### Engine Package Development
- `pnpm --filter astriarch-engine build` - Build engine package
- `pnpm --filter astriarch-engine test` - Run engine unit tests
- `pnpm --filter astriarch-engine lint` - Lint engine code

## Key Technical Details

### Game State Management
- Game state is managed centrally in the astriarch-engine package
- Backend maintains authoritative GameModel, clients receive filtered ClientGameModel
- Real-time updates flow through WebSocket connections managed by the backend
- Game timing: MS_PER_TICK (200ms) for client updates, MS_PER_CYCLE (30s) for game turns

### Database
- MongoDB is used for persistent game state and session management
- Start local MongoDB with `docker-compose up -d mongodb` for development
- Connection configuration in backend's config/ directory

### WebSocket Communication
- Real-time multiplayer uses WebSocket connections through the backend's WebSocketServer
- Message types are defined in packages/astriarch-engine/src/messaging/MessageTypes
- Frontend websocket service handles connection management and message routing

### Testing
- Backend uses Jest for unit testing
- SvelteKit frontend uses Vitest for component and unit testing
- Engine package has comprehensive Jest test suite
- Run individual package tests with `pnpm --filter <package-name> test`

## Current Branch Status
- Working on v2.x-svelte branch (SvelteKit migration)
- Main branch for PRs: master
- Recent development focuses on WebSocket multiplayer implementation and SvelteKit frontend
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:18-alpine AS build

WORKDIR /usr/src/app

# Install pnpm globally
RUN npm install -g pnpm

# Copy source code
COPY . .

RUN pnpm install --frozen-lockfile

RUN pnpm run --filter=astriarch-backend... build

RUN pnpm deploy --filter=astriarch-backend --prod /prod/astriarch-backend

FROM node:18-alpine AS backend

COPY --from=build /prod/astriarch-backend /prod/astriarch-backend
WORKDIR /prod/astriarch-backend

# Expose port
EXPOSE 8001

# Start the application
CMD ["pnpm", "start"]
53 changes: 10 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,22 @@
Astriarch
=========
# Astriarch - Ruler of the stars

Astriarch Ruler of the Stars, Space Strategy Game
http://www.astriarch.com/
## Quickstart

This is the Open Source Multiplayer version of Astriarch.
`docker-compose up -d mongodb`

It uses NodeJS and MongoDB on the server and leverages WebSockets for communication to the client

Running the Server
==================
You'll need to install Node.js 0.10+ and MongoDB
Run `npm install` then `npm start` and then visit `http://localhost:8000`

Or the easiest way to get started is to use [Docker](https://www.docker.com/):
create a file `./config/local.json`:
https://blog.nrwl.io/setup-a-monorepo-with-pnpm-workspaces-and-speed-it-up-with-nx-bc5d97258a7e

```
{
"mongodb":{
"host":"astriarch_mongo"
}
}
npx nx run-many --target=build --all
```
Run `docker-compose build` then `docker-compose up` and then visit `http://localhost:8000`

Overview
========
Astriarch - Ruler of the Stars is a Turn-based, Single Player Space Strategy Game.
Build planetary improvements and star ships to capture planets and defeat your enemies.
Your ultimate goal is to become the master of the known universe, and earn the title of Astriarch!

Background
==========
Developed in 2010 by <a href="http://www.masteredsoftware.com/" target="_blank">Mastered Software</a>, Astriarch combines aspects of other classic space strategy games such as <a href="http://en.wikipedia.org/wiki/Master_of_Orion_II:_Battle_at_Antares" target="_blank" rel="nofollow">Master of Orion 2</a> (MOO2), <a href="http://hol.abime.net/3427" target="_blank" rel="nofollow">Stellar Conflict</a> (1987 Amiga), and <a href="http://en.wikipedia.org/wiki/Star_Control" target="_blank" rel="nofollow">Star Control</a>.
<br /><br />
Currently Astriarch is realeased as a free casual web game.&nbsp; Planned future enhancements include the ability to research and develop improvements, as well as galaxy special items and events.
<br /><br />
The name Astriarch comes from the Ancient Greek words for star (<a href="http://en.wiktionary.org/wiki/%E1%BC%84%CF%83%CF%84%CF%81%CE%BF%CE%BD#Ancient_Greek" target="_blank" rel="nofollow">�stron</a>) and ruler (<a href="http://en.wiktionary.org/wiki/%E1%BC%80%CF%81%CF%87%CF%8C%CF%82" target="_blank" rel="nofollow">arkhos</a>)

Other Versions
==============
Single Player Open Source Versions:
```
pnpm --filter astriarch-frontend dev
```

HTML5: https://github.com/mpalmerlee/Astriarch/tree/HTML5
https://chakra-ui.com/getting-started/remix-guide

Silverlight: https://github.com/mpalmerlee/Astriarch/tree/Silverlight

Credits
=======
Astriarch - Ruler of the Stars, space strategy game designed and developed by <a href="http://www.masteredsoftware.com/" target="_blank">Mastered Software</a>, music by Resonant. Astriarch HTML 5/JavaScript version uses <a href="https://github.com/mpalmerlee/Stratiscape" target="_blank">Stratiscape</a> JavaScript Canvas Library and the <a href="https://github.com/mpalmerlee/jQuery-UI-Listbox" target="_blank">jQuery Listbox plugin</a>.

License
=======
This version of Astriarch - Ruler of the Stars is released under the MIT License.
20 changes: 20 additions & 0 deletions apps/astriarch-backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# MongoDB Configuration
MONGODB_CONNECTION_STRING=mongodb://astriarch:astriarch_password@localhost:27017/astriarch_v2
MONGODB_HOST=localhost
MONGODB_PORT=27017
MONGODB_USERNAME=astriarch
MONGODB_PASSWORD=astriarch_password
MONGODB_DATABASE=astriarch_v2

# Server Configuration
NODE_ENV=development
HOST=localhost
PORT=8001
WS_PORT=8001
WS_PROTOCOL=ws

# Session Configuration
SESSION_SECRET=astriarch-v2-development-secret

# CORS Configuration
CORS_ORIGIN=http://localhost:5173,http://localhost:3000
34 changes: 34 additions & 0 deletions apps/astriarch-backend/config/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"loglevel": "INFO",
"mongodb": {
"gamedb_name": "astriarch_v2",
"sessiondb_name": "astriarch_v2",
"host": "127.0.0.1",
"port": "27017",
"username": null,
"password": null
},
"cookie": {
"secret": "astriarch-v2-node-secret"
},
"server": {
"port": 8001,
"host": "localhost"
},
"websocket": {
"port": 8001,
"protocol": "ws",
"ping_frequency": 30000
},
"game": {
"client_timeout": 120000,
"cleanup_old_games": {
"enabled": true,
"check_interval_seconds": 7200
}
},
"cors": {
"origin": ["http://localhost:5173", "http://localhost:3000"],
"credentials": true
}
}
10 changes: 10 additions & 0 deletions apps/astriarch-backend/config/development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"loglevel": "DEBUG",
"mongodb": {
"gamedb_name": "astriarch_v2_dev",
"sessiondb_name": "astriarch_v2_dev"
},
"server": {
"port": 8001
}
}
17 changes: 17 additions & 0 deletions apps/astriarch-backend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'@typescript-eslint/recommended',
],
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
};
56 changes: 56 additions & 0 deletions apps/astriarch-backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "astriarch-backend",
"version": "2.0.0",
"description": "Astriarch game server backend with TypeScript, Express, MongoDB, and WebSockets",
"main": "dist/app.js",
"scripts": {
"build": "tsc",
"dev": "tsx watch src/app.ts",
"start": "node --enable-source-maps dist/app.js",
"format": "prettier --write \"src/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\"",
"lint": "eslint src/**/*.ts",
"type-check": "tsc --noEmit",
"test": "jest",
"test:watch": "jest --watch"
},
"dependencies": {
"astriarch-engine": "workspace:*",
"async": "^3.2.4",
"config": "^3.3.9",
"connect-mongo": "^5.1.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"express": "^4.18.2",
"express-session": "^1.17.3",
"helmet": "^7.1.0",
"mongoose": "^8.0.3",
"morgan": "^1.10.0",
"uuid": "^11.1.0",
"ws": "^8.14.2"
},
"devDependencies": {
"@types/async": "^3.2.24",
"@types/config": "^3.3.3",
"@types/cookie-parser": "^1.4.6",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/express-session": "^1.17.10",
"@types/morgan": "^1.9.9",
"@types/node": "^20.10.4",
"@types/uuid": "^10.0.0",
"@types/ws": "^8.5.9",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@types/jest": "^29.5.8",
"eslint": "^8.55.0",
"jest": "^29.7.0",
"prettier": "^3.6.2",
"ts-jest": "^29.1.1",
"tsx": "^4.6.2",
"typescript": "^5.3.3"
},
"engines": {
"node": ">=18.0.0"
}
}
Loading