character-sheet
Version:
CharacterSheet library for assembling relationships between stats and modifiers.
143 lines (105 loc) • 3.02 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: Modifier.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: Modifier.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import Op from './operations';
/**
* Modifier
*
* A modifier modifies one or many stat definitions post-calculation.
*/
class Modifier {
_description = 'This modifier has no descrition.';
_operations = [];
_active = true;
currentlyModifying = null;
get operations() {
return this._operations;
}
describe(description) {
this._description = description;
return this;
}
get description() {
return this._description;
}
modifies(target) {
this._operations.push(new Op.Modifies(target));
return this;
}
add(value) {
this._operations.push(new Op.Add({ value }));
return this;
}
subtract(value) {
this._operations.push(new Op.Subtract({ value }));
return this;
}
divideBy(value) {
this._operations.push(new Op.DivideBy({ value }));
return this;
}
roundUp() {
this._operations.push(new Op.RoundUp());
return this;
}
roundDown() {
this._operations.push(new Op.RoundDown());
return this;
}
calculate({ selectors = [], fn }) {
this._operations.push(new Op.Calculate({ selectors, fn }));
return this;
}
static from(modifier) {
// make a new modifier
let m = new Modifier();
// import modifier from object
m.import(modifier);
// return modifier
return m;
}
import(modifier) {
this._description = modifier.description;
this._operations = modifier.operations;
this._active = modifier.active;
return this;
}
export() {
return {
description: this._description,
operations: this._operations,
active: this._active
};
}
}
export default Modifier;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Add.html">Add</a></li><li><a href="Modifier.html">Modifier</a></li><li><a href="Operation.html">Operation</a></li><li><a href="Using.html">Using</a></li></ul><h3>Global</h3><ul><li><a href="global.html#RegisterWith">RegisterWith</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Dec 25 2018 11:17:38 GMT-0800 (Pacific Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>