Code Monkey home page Code Monkey logo

perion's Introduction

@perion/perion Travis CI Build Status Code coverage

A library of Node.js modules that help bring MapleStory private server development to the npm ecosystem.

npm i --save @perion/perion
  • Note this project is in early development, use with caution

Overview

Core Packages

  • calc

A calculator library that implements standard MapleStory specific calculations such as damage, stat modifiers, experience, and levels.

const calc = require('@perion/calc');

/** Example player stats object */
const playerStats = {base: {str: 4, ...}, hyper: {str: 1, ...}};

/** crypto.calc example */
const modifiedStats = calc.HyperStats(playerStats).applyAll().get();

/** Returns {str: 34, ...} */
  • crypto

A cryptography library that exposes everything you need to encrypt/decrypt data for MapleStory.

const crypto = require('@perion/crypto');

/** Example data */
const payload = Buffer.from([0x1]);
const sendIv = Buffer.from([0x0, 0x2, 0x3, 0x4]);
const recvIv = Buffer.from([0x4, 0x2, 0x1, 0x0]);

/** crypto.Shanda example */
const encrypted = crypto.Shanda.encrypt(payload);
const decrypted = crypto.Shanda.decrypt(payload);

/** Returns the input buffer with the payload encrypted/decrypted using Maple Custom Shanda */

/** crypto.AES example */
/**
  * You must initialize the AES class with:
  * - an IV (Initialization Vector)
  * - a MapleStory version number
  *
  * The IV must have a length of 4
  * As the server, you must send the IV for both send and recv to the client
  */
const sendAES = new crypto.AES(sendIv, 83);
const recvAES = new crypto.AES(recvIv, 83);

const encryptedOut = sendAES.transform(payload);
const decryptedIn = recvAES.transform(payload);

/** Returns the input buffer with the payload encrypted/decryped using Maple AES */
  • net

A packet parser using method-chaining syntax for compact and efficient parsing/writing of packet structures.

const net = require('@perion/net');

/** Example buffer */
const data = Buffer.from([1, 2]);

/** net.Packet.Parser example */
const packet = new net.Packet.Parser(data);
const fields = ['id', 'name', 'hp'];
const unpacked = packet.int().mapleascii().int().collect(fields);

/** Returns {id: <number>, name: <string>, hp: <number>} */

/** net.Packet.Writer example */

/** Initialize with length */
let packet = new net.Packet.Writer(5);
packet = packet.byte(0x0).int(9).buffer();

/** Returns the buffer with data */
  • script

A generic scripting engine for NPCs, events, maps, etc.

  • wz

A WZ library that can read and write to the WZ file format.

Neat Features

  • Uses Google's recommended JS style guidelines, fully documented code including full JSDoc comments
  • Modular packages, so use what you want
  • Full test coverage, with a minimum coverage threshold of 90%
  • Zero dependencies

Project Goals

In Progress

  • Networking protocol
  • Damage calculations
  • Event timers
  • WZ and NX file format
  • Generic MapleStory abstractions
  • Multiple MapleStory versions

Project Overview

Linter

npm run lint

Test

npm run test
npm run lcov

Documentation

Click here for the code documentation!

Contributing

For now, there are no contribution guidelines. I only ask that you follow the eslint rules when contributing a pull request. Thanks!

ForTheBadge built-with-love

perion's People

Contributors

jonnylin13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

perion's Issues

Evaluate the performance of FFI

It might make sense to pull some of the code out of Node.js and into a faster language like Rust, especially for the compute-heavy calls like AES encryption and WZ parsing (texture decompression). We need to evaluate the performance of the current implementation against a Rust implementation.

  • Implement Maple Shanda and AES in Rust
  • Add node bindings
  • Create a macro benchmark and run both of them with the same inputs (one in Node.js, one in Rust with FFI)
  • Report the results
  • Do the same for DXT decompression

If the overhead of FFI + running Rust code is far less costly than doing everything in Node.js, we should switch to this method.

Keep in mind this is probably only useful with DXT, because the native crypto module is probably already pretty fast. And it might also be worth it to just install node-dxt, or create another binding for libsquish if I can't get that to work

Asynchronous API

Especially useful in crypto, but expose a set of functions that will defer the CPU-intensive tasks to the event loop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.