Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <<scriptwindow.Character = function(config) {
- this.name = '';
- this.running = 0;
- this.jumping = 0;
- this.climbing_trees = 0;
- this.skill_check = function(attr, dc) {
- if (attr in Object.keys(this) {
- const dieSize = 20; // change this for other kinds of dice
- // Add 1 because otherwise this rolls 0-19
- return (Math.floor(Math.random() * dieSize) + 1 + this[attr]) >= dc;
- } else {
- return this.name + " doesn't have the skill " + attr + '.';
- }
- };
- Object.keys(config).forEach(function(attr) {
- if (attr in Object.keys(this) {
- this[attr] = clone(config[attr]); // you have to do this so changing config[attr] doesn't change Character[attr]
- }
- }, this);
- }
- Character.prototype.clone = function() {
- return new Character(this);
- };
- Character.prototype.toJSON = function () {
- let ownData = {};
- Object.keys(this).forEach(function(attr) {
- ownData[attr] = clone(this[attr]);
- }, this);
- return JSON.reviveWrapper('new Character($ReviveData$)', ownData);
- };
- >>
- <<set $You to new Character({
- name: "My Character",
- running: 1,
- jumping: 2,
- climbing_trees: 3
- })>>
- <<if $You.skill_check("running", 5)>>...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement