rainet
RaiNet Access Battlers Javascript implementation
Example usage
Creating game instances
// Create a game.let game =
The game will be created with some initial state, provided at game.state
. This object can be read to query the state of the game at any time.
Starting a game
Terminology: Here "team" is used to indicate the playing sides of the game, even if there is only one player in each.
Enums are provided by the rainet
module.
To start the game, pass an object to game.start()
:
startingTeam
: Starting team. Can be unspecified, in which case any player can make the first move.arrangement
: Map. Arrangement for each team.
Arrangement array format
The arrangement array is an array of numbers which is simply the number of link cards to put before each virus card.
Examples:
- LVLVLVLV = [1, 1, 1, 1]
- VLVLVLVL = [0, 1, 1, 1] : the remaining card is inferred
- LLLLVVVV = [4, 0, 0, 0] = [4] : remaining cards are inferred
- LLVVVVLL = [2, 0, 0, 0] = [2]
- VVVVLLLL = [0, 0, 0, 0] = [] : there are no link cards before any virus card
Example
gamestart startingTeam: Teambottom arrangement: Teamtop 1 2 0 1 Teambottom 4
Querying game state
Terminal card state
Example:
gamestateterminalCardState // boolean let sq = gamestateterminalCardState // Square if installed sqlocation // Location sqcard // Card if there's a card here sqfirewall // Team if there's a firewall here
Winner
Example:
gamestatewinner // undefined or Team
Grid
The grid is the main playing area consisting of 8 rows and 8 columns. These are indexed from 0 to 7 from top to bottom and left to right. That is, lower-indexed rows are closer to the team labeled "top".
let grid = gamestateboardgridgridrows // array of rows, each row is an array of squaresgridcolumns // array of columns, each column is an array of squaresgridsquares // all squaresgrid // Squaregridcolumns63 // Squaregridrows36 // Square
Making a move
Players take turns to submit moves to the game via game.submitMove
. An InvalidMoveError
will be thrown if the move submitted is invalid.
Move an online card
game
Move an online card with line boost / to the server area
gamegamestateboardstackArea0cause // 'infiltrated'gamestateboardstackArea0cardrevealed // true
Install / uninstall a line boost / firewall card
game game
Use a virus check card
gamegamestateboardgridcolumns56cardrevealed // true
Use a 404 Not Found card
gamegamestateboardgridcolumns46cardrevealed // falsegamestateboardgridcolumns56cardrevealed // false
Surrender
game
Wrap-up
This is pretty much what's needed to interact with the module. Feel free to consult the full documentation / source code.
Docs
Simply run npm run jsdoc
to generate documentation.
License
MIT