npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rainet

v1.1.1

Published

A JavaScript implementation of 5pb.'s game RaiNet Access Battlers.

Downloads

8

Readme

rainet

RaiNet Access Battlers Javascript implementation

[npm] Dependency Status devDependency Status node

Example usage

Creating game instances

// Create a game.
let game = new 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

game.start({
  startingTeam: Team.bottom,
  arrangement: new Map([
    [Team.top, [1, 2, 0, 1]],
    [Team.bottom, [4]]
  ])
})

Querying game state

Terminal card state

Example:

game.state.terminalCardState.get(Team.bottom).get(TerminalCardType.virusCheck) // boolean
{
  let sq = game.state.terminalCardState.get(Team.bottom)
    .get(TerminalCardType.lineBoost) // Square if installed
  sq.location // Location
  sq.card // Card if there's a card here
  sq.firewall // Team if there's a firewall here
}

Winner

Example:

game.state.winner // 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 = game.state.board.grid
grid.rows // array of rows, each row is an array of squares
grid.columns // array of columns, each column is an array of squares
grid.squares // all squares
grid.lookup(new Location(6, 3)) // Square
grid.columns[6][3] // Square
grid.rows[3][6] // 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.submitMove(new OnlineCardMove({
  team: Team.bottom,
  square: game.state.board.grid.lookup(new Location(4, 6)),
  direction: Direction.up
}))

Move an online card with line boost / to the server area

game.submitMove(new OnlineCardMove({
  team: Team.bottom,
  square: game.state.board.grid.lookup(new Location(6, 0)),
  direction: Direction.left,
  direction2: Direction.up,
  revealCard: true
}))
game.state.board.stackArea.get(Team.top)[0].cause // 'infiltrated'
game.state.board.stackArea.get(Team.top)[0].card.revealed // true

Install / uninstall a line boost / firewall card

game.submitMove(new InstallableTerminalCardMove({
  team: Team.bottom,
  square: game.state.board.grid.lookup(new Location(4, 6)),
  cardType: TerminalCardType.lineBoost
}))

game.submitMove(new InstallableTerminalCardMove({
  team: Team.bottom,
  cardType: TerminalCardType.lineBoost,
  uninstall: true
}))

Use a virus check card

game.submitMove(new TerminalCardMove({
  team: Team.top,
  square: game.state.board.grid.lookup(new Location(5, 6)),
  cardType: TerminalCardType.virusCheck
}))
game.state.board.grid.columns[5][6].card.revealed // true

Use a 404 Not Found card

game.submitMove(new NotFoundTerminalCardMove({
  team: Team.bottom,
  square: game.state.board.grid.lookup(new Location(4, 6)),
  other: game.state.board.grid.lookup(new Location(5, 6)),
  swap: true
}))
game.state.board.grid.columns[4][6].card.revealed // false
game.state.board.grid.columns[5][6].card.revealed // false

Surrender

game.submitMove(new SurrenderMove({ team: Team.bottom }))

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