Giter Club home page Giter Club logo

sanctum-map-system's Introduction

Sanctum-Map-System

Map system for the Discord game Sanctum. Although it is currently not in use, it is a fully functional Node.JS, image generated map with item, movement, session systems, and more built in. Feel free to use it for whatever you need.

img

Usage:

First, require the dungeonmaker.js script via import:

const map = require('./dungeonmaker.js');

Preperation:

Next, you must prepare to use Async, as much of the map gen API requires awaiting. To start generating the map, create a new session:

map.session(mode);
// "mode" can be left out or set to "auto". If left out, the map will not generate any tiles or starting pos. If set to "auto", it will do just that as well as place items, doors, and the end point.

Now, before generating tiles, disable/enable any settings you'd like:

map.session.disableAutoStashing(); // Don't place stashes automatically
map.session.disableAutoEnd(); // Don't place the exit automatically
map.session.disableAutoHide(); // Don't hide tiles that we haven't explored

Generation:

Place tiles willy-nilly. The map generator will warn you if you go out of bounds or etc.

map.session.placeCorridor([0, 8], [10, 8]);
map.session.placeCorridor([0, 8], "East");

// The second parameter ("to") can be *alternatively* submitted as a compass direction in string format for staggered placement, at the cost of an accurate stopping point.

Set any tile data that you wish. This can be especially handy for creating text-based adventures with quests and etc.

map.session.setTileData([2, 3], {stash: "key", status: "unexplored"});

// You can add more to this list. "stash" and "status" are values that are planned for us in Sanctum.
// Stash can be set to "end". This can be moved past, but also will act as an exit when movement comes around.
// Status can be set to "unexplored", "explored", "current", and "door". "current" is highly discouraged, as it WILL screw with the movement system.
//Setting status to "door" will make this tile a discoverable door. Keys are needed to get past these.

Set the player pos (if you wish to do so manually. Defaults to first tile placed. It will only check to see if you placed within map boundaries).

map.session.setPlayerPos([1, 3]);

Completion:

Once you're all done, complete the map. Make sure to grab the session that is returned. This is required to retrieve the map and minimap image.

var our_session = await map.session.complete();

Get Images:

The map is completed! Congrats. Now pay $2.99 for rights to the generated images! Just kidding, I'm not EA. Here's how you do it:

// As is, these supply discord embeds. I didn't set this up for non-discord use, so you will have to adjust the API get...Image() functions to return the actual images for the time being. I should update this eventually.

var map_img = await map.session.getMapImage(our_session));
var minimap_img = msg_channel.send(await map.session.getMinimapImage(our_session));

// map.session.getMapData(our_session); <- Use this function to print the map to console. Obviously it won't look great, but it allows for some quick testing! It also returns all the map data, so set it to a variable if you need the info!

Movement:

Now to the juicy part: Movement...

await map.session.update(our_session);
await map.session.update.leap("east", our_session);

// Yup, that's it. There's so much you dont see...
// Anyway, make sure to update the session before actually leaping. It is neccessito!

Ending Session:

Once you've used the map to your hearts content, ERASE IT FROM THE FACE OF THE EARTH.

map.session.end(our_session);
// This deletes the associated images and session data.

Conclusion:

And that concludes the map generation and movement. You can use this to host multiple galliant text adventures at the same time, or even use it for epic overkill to generate a tile-based word. I dunno, your choice.

img

img

sanctum-map-system's People

Contributors

gmanicus avatar

Watchers

 avatar

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.