-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Welcome to the webnoth wiki!
The root directory contains Node.js server code, responsible for validating input, maintaining game states in MongoDB, and pushing updates to clients.
-
/server.js
- the main server code, runnable withnode server.js
-
/auth.js
- creates user accounts, logs in users, validates user sessions (i.e., when a socket connection asks to perform a move on a unit, is it the owner of that unit?) -
/createUnit.js
- creates units -
/executePath.js
- validates and executes unit moves -
/loadUtils.js
- module for loading data about maps and units -
/lobby.js
- currently unused lobby code -
/init.mongo.js
- a run-once setup script to initialize the MongoDb store -
/manifest.json
- installation information about the server used by npm (mostly dependencies, installable withnpm install
)
The /static
folder contains code that is accessible by both the client and the server. When accessing files from the browser client, the /static
directory serves as the web root, so /static/foo
is accessible in the browser with the URL http://hostname/foo
.
The /static/client
folder holds the client-side JavaScript and HTML.
-
grid.html
- the HTML scaffolding of the browser client -
grid.js
- defines theWorld
object type (and theSpace
type), which maintains map and unit data, draws the map, and listens for mouse input events -
boot.js
- loads unit and map data, and listens for socket events (e.g., unit movements, turn endings) -
ui.js
- includes fuctions for drawing paths, updating unit info displays, moving units, and animating attacks (these are the functions used by the socket-event listeners when they hear about units moves, attacks, etc) -
astar.js
- generates unit pathing suggestions -
scroll.js
- map scrolling logic
The folders in /static/data
hold non-code data assets like images, units and race stats, and map files. These are used by both the client and server.
The /static/shared
folder has code used on both the client and server. For example, both client and server need to parse map files (for client-side rendering and pathing suggestions, and server-side pathing validation).
-
castlePathExists.js
- used to validate the existence of an unbroken path of castle tiles between two tiles. Used on the client to decide when to show the "Recruit" menu option and on server to validate unit-creation requests -
terrain.js
- parses Wesnoth map data files and contains information about which terrain properties (e.g., forest, snow) apply to which tile types (e.g. Winter Forest) -
unit.js
- loads unit data and includes aUnit
constructor that prototype-ifies an object of unit properties (e.g., the usage looks likenew Unit({ type: "grunt", hp: 12, xp: 7, moveLeft: 2 })
, and the resulting constructed object hashp
,xp
, andmoveLeft
properties as specified, but also hasmaxHp
,maxXp
, andmove
properties supplied by the Grunt unit prototype)