Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

areaspawnr

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

areaspawnr - npm Package Compare versions

Comparing version 0.7.5 to 0.8.0-beta0

lib/types.d.ts

8

lib/AreaSpawnr.d.ts
import { IArea, ILocation, IMap, IPreThingsContainers, IPreThingSettings } from "mapscreatr";
import { IAreaSpawnr, IAreaSpawnrSettings } from "./IAreaSpawnr";
import { IAreaSpawnrSettings } from "./types";
/**
* Loads GameStartr maps to spawn and unspawn areas on demand.
* Loads EightBittr maps to spawn and unspawn areas on demand.
*/
export declare class AreaSpawnr implements IAreaSpawnr {
export declare class AreaSpawnr {
/**
* Storage container and lazy loader for GameStartr maps.
* Storage container and lazy loader for EightBittr maps.
*/

@@ -10,0 +10,0 @@ private readonly mapsCreator;

@@ -8,3 +8,3 @@ define(["require", "exports"], function (require, exports) {

*/
var directionKeys = {
const directionKeys = {
xDec: "right",

@@ -18,3 +18,3 @@ xInc: "left",

*/
var directionOpposites = {
const directionOpposites = {
xDec: "xInc",

@@ -38,3 +38,3 @@ xInc: "xDec",

*/
var getDirectionEnd = function (directionKey, top, right, bottom, left) {
const getDirectionEnd = (directionKey, top, right, bottom, left) => {
switch (directionKey) {

@@ -50,3 +50,3 @@ case "top":

default:
throw new Error("Unknown directionKey: '" + directionKey + "'.");
throw new Error(`Unknown directionKey: '${directionKey}'.`);
}

@@ -69,6 +69,6 @@ };

*/
var findPreThingsSpawnStart = function (direction, group, top, right, bottom, left) {
var directionKey = directionKeys[direction];
var directionEnd = getDirectionEnd(directionKey, top, right, bottom, left);
for (var i = 0; i < group.length; i += 1) {
const findPreThingsSpawnStart = (direction, group, top, right, bottom, left) => {
const directionKey = directionKeys[direction];
const directionEnd = getDirectionEnd(directionKey, top, right, bottom, left);
for (let i = 0; i < group.length; i += 1) {
if (group[i][directionKey] >= directionEnd) {

@@ -95,7 +95,7 @@ return i;

*/
var findPreThingsSpawnEnd = function (direction, group, top, right, bottom, left) {
var directionKey = directionKeys[direction];
var directionKeyOpposite = directionKeys[directionOpposites[direction]];
var directionEnd = getDirectionEnd(directionKeyOpposite, top, right, bottom, left);
for (var i = group.length - 1; i >= 0; i -= 1) {
const findPreThingsSpawnEnd = (direction, group, top, right, bottom, left) => {
const directionKey = directionKeys[direction];
const directionKeyOpposite = directionKeys[directionOpposites[direction]];
const directionEnd = getDirectionEnd(directionKeyOpposite, top, right, bottom, left);
for (let i = group.length - 1; i >= 0; i -= 1) {
if (group[i][directionKey] <= directionEnd) {

@@ -108,5 +108,5 @@ return i;

/**
* Loads GameStartr maps to spawn and unspawn areas on demand.
* Loads EightBittr maps to spawn and unspawn areas on demand.
*/
var AreaSpawnr = /** @class */ (function () {
class AreaSpawnr {
/**

@@ -117,12 +117,3 @@ * Initializes a new instance of the AreaSpawnr class.

*/
function AreaSpawnr(settings) {
if (!settings) {
throw new Error("No settings given to AreaSpawnr.");
}
if (!settings.mapsCreatr) {
throw new Error("No mapsCreatr provided to AreaSpawnr.");
}
if (!settings.mapScreenr) {
throw new Error("No mapsCreatr provided to AreaSpawnr.");
}
constructor(settings) {
this.mapsCreator = settings.mapsCreatr;

@@ -139,11 +130,11 @@ this.mapScreenr = settings.mapScreenr;

*/
AreaSpawnr.prototype.getScreenAttributes = function () {
getScreenAttributes() {
return this.screenAttributes;
};
}
/**
* @returns The key by which the current Map is indexed.
*/
AreaSpawnr.prototype.getMapName = function () {
getMapName() {
return this.mapName;
};
}
/**

@@ -156,7 +147,5 @@ * Gets the map listed under the given name. If no name is provided, the

*/
AreaSpawnr.prototype.getMap = function (name) {
return typeof name === "undefined"
? this.mapCurrent
: this.mapsCreator.getMap(name);
};
getMap(name) {
return typeof name === "undefined" ? this.mapCurrent : this.mapsCreator.getMap(name);
}
/**

@@ -167,17 +156,17 @@ * Simple getter pipe to the internal MapsCreator.getMaps() function.

*/
AreaSpawnr.prototype.getMaps = function () {
getMaps() {
return this.mapsCreator.getMaps();
};
}
/**
* @returns The current Area.
*/
AreaSpawnr.prototype.getArea = function () {
getArea() {
return this.areaCurrent;
};
}
/**
* @returns The name of the current Area.
*/
AreaSpawnr.prototype.getAreaName = function () {
getAreaName() {
return this.areaCurrent.name;
};
}
/**

@@ -187,11 +176,11 @@ * @param location The key of the Location to return.

*/
AreaSpawnr.prototype.getLocation = function (location) {
getLocation(location) {
return this.areaCurrent.map.locations[location];
};
}
/**
* @returns The most recently entered Location in the current Area.
*/
AreaSpawnr.prototype.getLocationEntered = function () {
getLocationEntered() {
return this.locationEntered;
};
}
/**

@@ -203,5 +192,5 @@ * Simple getter function for the internal prethings object. This will be

*/
AreaSpawnr.prototype.getPreThings = function () {
getPreThings() {
return this.prethings;
};
}
/**

@@ -217,7 +206,7 @@ * Sets the currently manipulated Map in the handler to be the one under a

*/
AreaSpawnr.prototype.setMap = function (name, location) {
setMap(name, location) {
// Get the newly current map from this.getMap normally
this.mapCurrent = this.getMap(name);
if (!this.mapCurrent) {
throw new Error("Unknown Map in setMap: '" + name + "'.");
throw new Error(`Unknown Map in setMap: '${name}'.`);
}

@@ -230,3 +219,3 @@ this.mapName = name;

return this.mapCurrent;
};
}
/**

@@ -240,6 +229,6 @@ * Goes to a particular location in the given map. Area attributes are

*/
AreaSpawnr.prototype.setLocation = function (name) {
var location = this.mapCurrent.locations[name];
setLocation(name) {
const location = this.mapCurrent.locations[name];
if (!location) {
throw new Error("Unknown location in setLocation: '" + name + "'.");
throw new Error(`Unknown location in setLocation: '${name}'.`);
}

@@ -255,4 +244,3 @@ this.locationEntered = location;

// Copy all the settings from that area into the MapScreenr container
for (var _i = 0, _a = this.screenAttributes; _i < _a.length; _i++) {
var attribute = _a[_i];
for (const attribute of this.screenAttributes) {
this.mapScreenr.variables[attribute] = this.areaCurrent[attribute];

@@ -272,3 +260,3 @@ }

return location;
};
}
/**

@@ -280,10 +268,10 @@ * Applies the stretchAdd Function to each given "stretch" command and

*/
AreaSpawnr.prototype.setStretches = function (stretchesRaw) {
setStretches(stretchesRaw) {
if (!this.stretchAdd) {
throw new Error("Cannot call setStretches without a stretchAdd.");
}
for (var i = 0; i < stretchesRaw.length; i += 1) {
for (let i = 0; i < stretchesRaw.length; i += 1) {
this.stretchAdd(stretchesRaw[i], i, stretchesRaw);
}
};
}
/**

@@ -295,10 +283,10 @@ * Applies the afterAdd Function to each given "after" command and stores

*/
AreaSpawnr.prototype.setAfters = function (aftersRaw) {
setAfters(aftersRaw) {
if (!this.afterAdd) {
throw new Error("Cannot call setAfters without an afterAdd.");
}
for (var i = 0; i < aftersRaw.length; i += 1) {
for (let i = 0; i < aftersRaw.length; i += 1) {
this.afterAdd(aftersRaw[i], i, aftersRaw);
}
};
}
/**

@@ -316,7 +304,7 @@ * Calls onSpawn on every PreThing touched by the given bounding box,

*/
AreaSpawnr.prototype.spawnArea = function (direction, top, right, bottom, left) {
spawnArea(direction, top, right, bottom, left) {
if (this.onSpawn) {
this.applySpawnAction(this.onSpawn, true, direction, top, right, bottom, left);
}
};
}
/**

@@ -334,7 +322,7 @@ * Calls onUnspawn on every PreThing touched by the given bounding box,

*/
AreaSpawnr.prototype.unspawnArea = function (direction, top, right, bottom, left) {
unspawnArea(direction, top, right, bottom, left) {
if (this.onUnspawn) {
this.applySpawnAction(this.onUnspawn, false, direction, top, right, bottom, left);
}
};
}
/**

@@ -359,10 +347,10 @@ * Calls onUnspawn on every PreThing touched by the given bounding box,

*/
AreaSpawnr.prototype.applySpawnAction = function (callback, status, direction, top, right, bottom, left) {
applySpawnAction(callback, status, direction, top, right, bottom, left) {
// For each group of PreThings currently able to spawn...
for (var name_1 in this.prethings) {
if (!{}.hasOwnProperty.call(this.prethings, name_1)) {
for (const name in this.prethings) {
if (!{}.hasOwnProperty.call(this.prethings, name)) {
continue;
}
// Don't bother trying to spawn the group if it has no members
var group = this.prethings[name_1][direction];
const group = this.prethings[name][direction];
if (group.length === 0) {

@@ -373,8 +361,8 @@ continue;

// Ex. if direction="xInc", go from .left >= left to .left <= right
var start = findPreThingsSpawnStart(direction, group, top, right, bottom, left);
var end = findPreThingsSpawnEnd(direction, group, top, right, bottom, left);
const start = findPreThingsSpawnStart(direction, group, top, right, bottom, left);
const end = findPreThingsSpawnEnd(direction, group, top, right, bottom, left);
// Loop through all the directionally valid PreThings, spawning if
// They're within the bounding box
for (var i = start; i <= end; i += 1) {
var prething = group[i];
for (let i = start; i <= end; i += 1) {
const prething = group[i];
// For example: if status is true (spawned), don't spawn again

@@ -387,7 +375,6 @@ if (prething.spawned !== status) {

}
};
return AreaSpawnr;
}());
}
}
exports.AreaSpawnr = AreaSpawnr;
});
//# sourceMappingURL=AreaSpawnr.js.map
export * from "./AreaSpawnr";
export * from "./IAreaSpawnr";
export * from "./types";
//# sourceMappingURL=index.d.ts.map

@@ -11,8 +11,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

};
define(["require", "exports", "./AreaSpawnr", "./IAreaSpawnr"], function (require, exports, AreaSpawnr_1, IAreaSpawnr_1) {
define(["require", "exports", "./AreaSpawnr", "./types"], function (require, exports, AreaSpawnr_1, types_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(AreaSpawnr_1, exports);
__exportStar(IAreaSpawnr_1, exports);
__exportStar(types_1, exports);
});
//# sourceMappingURL=index.js.map

@@ -12,6 +12,5 @@ {

"mapscreatr": "^0.7.9",
"mapscreenr": "^0.7.6",
"shenanigans-manager": "^0.3.2"
"mapscreenr": "^0.7.6"
},
"description": "Loads GameStartr maps to spawn and unspawn areas on demand.",
"description": "Loads EightBittr maps to spawn and unspawn areas on demand.",
"devDependencies": {

@@ -27,8 +26,10 @@ "shenanigans-manager": "^0.3.0"

"scripts": {
"clean": "rm -rf lib *.tsbuildinfo",
"compile": "tsc -b",
"hydrate": "node ../shenanigans-manager/bin/shenanigans-manager hydrate-package-json && yarn run test:setup",
"hydrate": "yarn shenanigans-manager hydrate",
"link": "yarn link",
"publish:ci": "yarn shenanigans-manager publish-if-updated",
"test": "yarn run test:setup && yarn run test:run",
"test:run": "mocha-headless-chrome --file test/index.html",
"test:setup": "node ../shenanigans-manager/bin/shenanigans-manager generate-tests"
"test:setup": "yarn shenanigans-manager generate-tests"
},

@@ -39,4 +40,3 @@ "shenanigans": {

"types": "./lib/index.d.ts",
"version": "0.7.5",
"gitHead": "6379309b5ea381578fd84b96778fde081a937209"
}
"version": "0.8.0-beta0"
}

@@ -5,7 +5,8 @@ <!-- Top -->

[![Greenkeeper badge](https://badges.greenkeeper.io/FullScreenShenanigans/AreaSpawnr.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/FullScreenShenanigans/AreaSpawnr.svg?branch=master)](https://travis-ci.org/FullScreenShenanigans/AreaSpawnr)
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)
![TypeScript: Strict](https://img.shields.io/badge/typescript-strict-brightgreen.svg)
[![NPM version](https://badge.fury.io/js/areaspawnr.svg)](http://badge.fury.io/js/areaspawnr)
[![Join the chat at https://gitter.im/FullScreenShenanigans/community](https://badges.gitter.im/FullScreenShenanigans/community.svg)](https://gitter.im/FullScreenShenanigans/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Loads GameStartr maps to spawn and unspawn areas on demand.
Loads EightBittr maps to spawn and unspawn areas on demand.

@@ -18,28 +19,8 @@ <!-- /Top -->

After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo/):
This repository is a portion of the [EightBittr monorepo](https://raw.githubusercontent.com/FullScreenShenanigans/EightBittr).
See its [docs/Development.md](../../docs/Development.md) for details on how to get started. 💖
```
git clone https://github.com/<your-name-here>/AreaSpawnr
cd AreaSpawnr
npm install
yarn run setup
yarn run verify
```
### Running Tests
- `yarn run setup` creates a few auto-generated setup files locally.
- `yarn run verify` builds, lints, and runs tests.
### Building
```shell
yarn run watch
```
Source files are written under `src/` in TypeScript and compile in-place to JavaScript files.
`yarn run watch` will directly run the TypeScript compiler on source files in watch mode.
Use it in the background while developing to keep the compiled files up-to-date.
#### Running Tests
```shell
yarn run test

@@ -51,6 +32,7 @@ ```

Whenever you add, remove, or rename a `*.test.t*` file under `src/`, `watch` will re-run `yarn run test:setup` to regenerate the list of static test files in `test/index.html`.
You can open that file in a browser to debug through the tests.
You can open that file in a browser to debug through the tests, or run `yarn test:run` to run them in headless Chrome.
<!-- Maps -->
<!-- /Maps -->
<!-- /Development -->

@@ -0,0 +0,0 @@ {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc