Authenticate a user.
In general, you will want to create a session for a user upon authentication;
therefore you will generally want to use login
instead.
Ban the user
Change a user's password.
User login
Login a user as an anonymous user
This allows for user-to-user events to be emitted, even if a given user does not exist.
Register a new user
Unban the user
Command-line interface API
The cli property is a library that lets you extend and boot up the command-line argument parser.
Commander object which allows you to extend the provided CLI
var cli = require('mage').cli;
cli.program.option('--clown', 'Enables clown mode');
cli.run();
With the previous code, you should obtain the following:
$ ./game --verbose --help
Usage: game [options] [command]
...
Options:
...
--clown Enables clown mode
Parse the process arguments obtained via process.argv
Core modules
Logger module
The logger module should be used to capture log entries; it can be configured to send logs to one or multiple logging backend (syslog, file, etc).
See https://mage.github.io/mage/#logging for more details.
Contains information from MAGE’s package.json
file:
Contains information from your project's package.json
file:
Session module
The session module can be used to create a session
object, which will then normally be accessible through
the state.session
key on the state object received
through user commands.
Transfer a session and its content to another user
Mostly used for testing purposes.
Register a new session
The current task to execute. Internal value.
The name of the task to execute
Options passed to the task
Time module
The time module can be used to affect how time is perceived from the MAGE process' perspective. This is mostly useful when either writing tests (like unit tests) or simulations (run an instance of your game server faster to, for instance, play a full week of your game within a few hours).
See https://mage.github.io/mage/#time-manipulation for more details.
Change the current time, and how quickly time advances
You may use the offset to specify how far back or forward in time you wish to go, and the acceleration factor to decide how fast (or slow) should time pass.
The startAt
attribute might be a bit confusing; in essence, the only time you should
need to set it is when you wish to specify from which time in the past timestamps should be
translated based on the acceleration factor. Therefore, unless you use an acceleration factor
other than 1, setting this will have no effect.
In short, you should almost never have to use the startAt
attribute.
See https://github.com/Wizcorp/timer.js/blob/master/index.js#L37 for more details.
in milliseconds (default: 0)
How fast should time move forward. (default: 1)
From which point in time do we consider time to be accelerated (default: Date.now())
Return the current time configuration (offset, acceleration factor and acceleration start time)
Get the current time according to MAGE, in milliseconds
You can use this to instanciate Date objects:
var date = Date(mage.time.msec());
Get the current time according to MAGE, in seconds
Translate a given timestamp
Sometimes, you will need to take a given timestamp and calculate
its relative representation according to MAGE time settings. In general,
you will only need to use this when using mage.time.bend
; however,
using it when time is not bent will simply have no effect on the passed value.
The timestamp to translate
The translated timestamp according to the current time rules enforced by mage.time.bend
Remove the effect of mage.time.bend
This effectively resets the clock to the current time.
The current version of MAGE
The worker ID of the currently worker process
Will return false if the process is the master process, or if MAGE is running in single mode.
This differs from cluster.worker.id because it will remain consistent if restarted or reloaded.
Add a new lookup path when attempting to load modules
Boot the MAGE server
You normally will not have to call this manually; the
mage
binary referred to in your project's package.json
will
call this for you.
However, you will need to call this in cases where you wish to create your own binary entry point (when creating a debug console to run MAGE under special conditions, for instance).
Shut down MAGE
When setting hard
to true, MAGE will not try to complete current I/O
operations and exit immediately; you should avoid using hard
unless there
are no other options available to you.
Note that this will behave similarly to process.exit
; only the current
process will be stopped, not the entire server. To stop the entire server,
see mage.quit
Retrieve a given app's configuration
Return the path from which a given module was loaded from
Return MAGE's current run state
Get the task to be executed
Check if a file is considered like a source code file in MAGE
Example:
mage.isCodeFileExtension('.js');
File extension
True if the extension is for a source code file
Verify if development mode is currently activated, or if a given development mode feature is activated
List all loaded modules
Quit MAGE
This will stop ALL MAGE processes regardless of where it
is called from. To stop only the local process (similarly
to what process.exit
would do, please see mage.exit
)
Requiring MAGE's dependencies into games
This should only be used to load the tomes module (when used).
Set MAGE's current run state
Set which MAGE task to execute.
Setup MAGE
You should not need to call this manually unless you are trying to manually set up MAGE for some special use case.
Setup MAGE modules.
You should not need to call this manually unless you are trying to manually set up MAGE for some special use case.
Start MAGE
You should not need to call this manually unless you are trying to manually set up MAGE for some special use case.
Tell MAGE to load all your application's modules
MAGE will then load all modules found under your project's
./lib/modules
folder.
Define which modules to load at runtime
auth module
The auth module can be used to register and authenticate users
Mage