update schema

This commit is contained in:
zongor 2024-06-30 21:12:58 -04:00
parent 60a550834e
commit b1940f30df
9 changed files with 547 additions and 266 deletions

View File

@ -1,89 +1,137 @@
/**
* @typedef {Object} DerivedStats Derived user stats
* @property {Uint8} u8 how many hits you can take, if it reaches 0 you ded!
* @property {Uint8} u8 How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc.
* @property {Uint8} u8 being able to observe some objects
* @property {Uint8} u8 Get better probability rolls for things that matter for rolls
* @property {Uint8} u8 Probability of being discovered when hiding
* @property {Uint8} u8 based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class.
* @property {Uint8} u8 same as attractiveness but can change with money
* @property {Int8} i8 how attuned to the vision of Eru
*/
class DerivedStats { class DerivedStats {
/** /**
* how many hits you can take, if it reaches 0 you ded! * how many hits you can take, if it reaches 0 you ded!
* @return {Uint8} gets the value of Hitpoints
*/ */
get Hitpoints() { get Hitpoints() {
return this._data.getUint8(0, true); return this._data.getUint8(0, true);
} }
/**
* how many hits you can take, if it reaches 0 you ded!
* @param {Uint8} sets the value of Hitpoints
*/
set Hitpoints(v) { set Hitpoints(v) {
return this._data.setUint8(0, v, true); return this._data.setUint8(0, v, true);
} }
/** /**
* How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc. * How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc.
* @return {Uint8} gets the value of Stamina
*/ */
get Stamina() { get Stamina() {
return this._data.getUint8(1, true); return this._data.getUint8(1, true);
} }
/**
* How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc.
* @param {Uint8} sets the value of Stamina
*/
set Stamina(v) { set Stamina(v) {
return this._data.setUint8(1, v, true); return this._data.setUint8(1, v, true);
} }
/** /**
* being able to observe some objects * being able to observe some objects
* @return {Uint8} gets the value of Perception
*/ */
get Perception() { get Perception() {
return this._data.getUint8(2, true); return this._data.getUint8(2, true);
} }
/**
* being able to observe some objects
* @param {Uint8} sets the value of Perception
*/
set Perception(v) { set Perception(v) {
return this._data.setUint8(2, v, true); return this._data.setUint8(2, v, true);
} }
/** /**
* Get better probability rolls for things that matter for rolls * Get better probability rolls for things that matter for rolls
* @return {Uint8} gets the value of Luck
*/ */
get Luck() { get Luck() {
return this._data.getUint8(3, true); return this._data.getUint8(3, true);
} }
/**
* Get better probability rolls for things that matter for rolls
* @param {Uint8} sets the value of Luck
*/
set Luck(v) { set Luck(v) {
return this._data.setUint8(3, v, true); return this._data.setUint8(3, v, true);
} }
/** /**
* Probability of being discovered when hiding * Probability of being discovered when hiding
* @return {Uint8} gets the value of Stealth
*/ */
get Stealth() { get Stealth() {
return this._data.getUint8(4, true); return this._data.getUint8(4, true);
} }
/**
* Probability of being discovered when hiding
* @param {Uint8} sets the value of Stealth
*/
set Stealth(v) { set Stealth(v) {
return this._data.setUint8(4, v, true); return this._data.setUint8(4, v, true);
} }
/** /**
* based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class. * based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class.
* @return {Uint8} gets the value of Attractiveness
*/ */
get Attractiveness() { get Attractiveness() {
return this._data.getUint8(5, true); return this._data.getUint8(5, true);
} }
/**
* based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class.
* @param {Uint8} sets the value of Attractiveness
*/
set Attractiveness(v) { set Attractiveness(v) {
return this._data.setUint8(5, v, true); return this._data.setUint8(5, v, true);
} }
/** /**
* same as attractiveness but can change with money * same as attractiveness but can change with money
* @return {Uint8} gets the value of Affluence
*/ */
get Affluence() { get Affluence() {
return this._data.getUint8(6, true); return this._data.getUint8(6, true);
} }
/**
* same as attractiveness but can change with money
* @param {Uint8} sets the value of Affluence
*/
set Affluence(v) { set Affluence(v) {
return this._data.setUint8(6, v, true); return this._data.setUint8(6, v, true);
} }
/** /**
* how attuned to the vision of Eru * how attuned to the vision of Eru
* @return {Int8} gets the value of Holyness
*/ */
get Holyness() { get Holyness() {
return this._data.getInt8(7, true); return this._data.getInt8(7, true);
} }
/**
* how attuned to the vision of Eru
* @param {Int8} sets the value of Holyness
*/
set Holyness(v) { set Holyness(v) {
return this._data.setInt8(7, v, true); return this._data.setInt8(7, v, true);
} }
/**
* get the struct representation of the object
*/
get bytes() {
return new Uint8Array(this._ptr);
}
/** /**
* constructor * Constructs a new DerivedStats
*
* @param {{Hitpoints: Uint8, Stamina: Uint8, Perception: Uint8, Luck: Uint8, Stealth: Uint8, Attractiveness: Uint8, Affluence: Uint8, Holyness: Int8, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/ */
constructor(init = {}, ptr = undefined) { constructor(init = {}, ptr = undefined) {
this._size = 8; this._size = 8;
this._ptr = ptr.buffer || new ArrayBuffer(this._size); this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr); this._data = new DataView(this._ptr.buffer);
for (const key of Object.keys(init)) { for (const key of Object.keys(init)) {
this[key] = init[key]; this[key] = init[key];

View File

@ -2,65 +2,100 @@ import Vector3 from "./Vector3"
import Stats from "./Stats" import Stats from "./Stats"
import DerivedStats from "./DerivedStats" import DerivedStats from "./DerivedStats"
import Skills from "./Skills" import Skills from "./Skills"
/**
* @typedef {Object} Entity Something that can exist in 3D space
* @property {string} Name Name of the entity
* @property {Vector3} Vector3 Vector3 of the entity in space
* @property {Stats} Stats Base stats
* @property {DerivedStats} DerivedStats Stats that are derived from skills and base stats
* @property {Skills} Skills Stuff that your character can do
*/
class Entity { class Entity {
/** /**
* Name of the entity * Name of the entity
* @return {string} gets the value of Name
*/ */
get Name() { get Name() {
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24))); return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24)));
} }
/**
* Name of the entity
* @param {string} v sets the value of Name
*/
set Name(v) { set Name(v) {
this._data.set(this._encoder.encode(v), 0); if (v.length > 24) {
throw new Error("input is larger than buffer size of 24");
}
const tmp = new Uint8Array(new ArrayBuffer(24));
tmp.set(this._encoder.encode(v))
this._ptr.set(tmp.buffer, 0);
} }
/** /**
* Vector3 of the entity in space * Vector3 of the entity in space
* @return {Vector3} gets the value of Vector3
*/ */
get Vector3() { get Vector3() {
return new Vector3({}, new Uint8Array(this._ptr.slice(24, 36))); return new Vector3({}, new Uint8Array(this._ptr.slice(24, 36)));
} }
/**
* Vector3 of the entity in space
* @param {Vector3} sets the value of Vector3
*/
set Vector3(v) { set Vector3(v) {
this._data.set(v.bytes(), 24); this._ptr.set(v._ptr, 24);
} }
/** /**
* Base stats * Base stats
* @return {Stats} gets the value of Stats
*/ */
get Stats() { get Stats() {
return new Stats({}, new Uint8Array(this._ptr.slice(36, 41))); return new Stats({}, new Uint8Array(this._ptr.slice(36, 41)));
} }
/**
* Base stats
* @param {Stats} sets the value of Stats
*/
set Stats(v) { set Stats(v) {
this._data.set(v.bytes(), 36); this._ptr.set(v._ptr, 36);
} }
/** /**
* Stats that are derived from skills and base stats * Stats that are derived from skills and base stats
* @return {DerivedStats} gets the value of DerivedStats
*/ */
get DerivedStats() { get DerivedStats() {
return new DerivedStats({}, new Uint8Array(this._ptr.slice(41, 49))); return new DerivedStats({}, new Uint8Array(this._ptr.slice(41, 49)));
} }
/**
* Stats that are derived from skills and base stats
* @param {DerivedStats} sets the value of DerivedStats
*/
set DerivedStats(v) { set DerivedStats(v) {
this._data.set(v.bytes(), 41); this._ptr.set(v._ptr, 41);
} }
/** /**
* Stuff that your character can do * Stuff that your character can do
* @return {Skills} gets the value of Skills
*/ */
get Skills() { get Skills() {
return new Skills({}, new Uint8Array(this._ptr.slice(49, 65))); return new Skills({}, new Uint8Array(this._ptr.slice(49, 65)));
} }
set Skills(v) { /**
this._data.set(v.bytes(), 49); * Stuff that your character can do
} * @param {Skills} sets the value of Skills
/**
* get the struct representation of the object
*/ */
get bytes() { set Skills(v) {
return new Uint8Array(this._ptr); this._ptr.set(v._ptr, 49);
} }
/** /**
* constructor * Constructs a new Entity
*
* @param {{Name: string, Vector3: Vector3, Stats: Stats, DerivedStats: DerivedStats, Skills: Skills, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/ */
constructor(init = {}, ptr = undefined) { constructor(init = {}, ptr = undefined) {
this._size = 65; this._size = 65;
this._ptr = ptr.buffer || new ArrayBuffer(this._size); this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr); this._data = new DataView(this._ptr.buffer);
this._encoder = new TextEncoder(); this._encoder = new TextEncoder();
this._decoder = new TextDecoder(); this._decoder = new TextDecoder();

View File

@ -1,35 +1,52 @@
/**
* @typedef {Object} Item Item
* @property {string} Name Name of the item
* @property {Int32} i32 Default starting value of the item
*/
class Item { class Item {
/** /**
* Name of the item * Name of the item
* @return {string} gets the value of Name
*/ */
get Name() { get Name() {
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24))); return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24)));
} }
/**
* Name of the item
* @param {string} v sets the value of Name
*/
set Name(v) { set Name(v) {
this._data.set(this._encoder.encode(v), 0); if (v.length > 24) {
throw new Error("input is larger than buffer size of 24");
}
const tmp = new Uint8Array(new ArrayBuffer(24));
tmp.set(this._encoder.encode(v))
this._ptr.set(tmp.buffer, 0);
} }
/** /**
* Default starting value of the item * Default starting value of the item
* @return {Int32} gets the value of BaseValue
*/ */
get BaseValue() { get BaseValue() {
return this._data.getInt32(24, true); return this._data.getInt32(24, true);
} }
/**
* Default starting value of the item
* @param {Int32} sets the value of BaseValue
*/
set BaseValue(v) { set BaseValue(v) {
return this._data.setInt32(24, v, true); return this._data.setInt32(24, v, true);
} }
/**
* get the struct representation of the object
*/
get bytes() {
return new Uint8Array(this._ptr);
}
/** /**
* constructor * Constructs a new Item
*
* @param {{Name: string, BaseValue: Int32, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/ */
constructor(init = {}, ptr = undefined) { constructor(init = {}, ptr = undefined) {
this._size = 28; this._size = 28;
this._ptr = ptr.buffer || new ArrayBuffer(this._size); this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr); this._data = new DataView(this._ptr.buffer);
this._encoder = new TextEncoder(); this._encoder = new TextEncoder();
this._decoder = new TextDecoder(); this._decoder = new TextDecoder();

View File

@ -1,26 +1,37 @@
/**
* @typedef {Object} Phenomenon Kinda like an action, cant remember
* @property {string} Name Name of the phenomenon
*/
class Phenomenon { class Phenomenon {
/** /**
* Name of the phenomenon * Name of the phenomenon
* @return {string} gets the value of Name
*/ */
get Name() { get Name() {
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 64))); return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 64)));
} }
/**
* Name of the phenomenon
* @param {string} v sets the value of Name
*/
set Name(v) { set Name(v) {
this._data.set(this._encoder.encode(v), 0); if (v.length > 64) {
} throw new Error("input is larger than buffer size of 64");
/** }
* get the struct representation of the object const tmp = new Uint8Array(new ArrayBuffer(64));
*/ tmp.set(this._encoder.encode(v))
get bytes() { this._ptr.set(tmp.buffer, 0);
return new Uint8Array(this._ptr);
} }
/** /**
* constructor * Constructs a new Phenomenon
*
* @param {{Name: string, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/ */
constructor(init = {}, ptr = undefined) { constructor(init = {}, ptr = undefined) {
this._size = 64; this._size = 64;
this._ptr = ptr.buffer || new ArrayBuffer(this._size); this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr); this._data = new DataView(this._ptr.buffer);
this._encoder = new TextEncoder(); this._encoder = new TextEncoder();
this._decoder = new TextDecoder(); this._decoder = new TextDecoder();

View File

@ -1,161 +1,257 @@
/**
* @typedef {Object} Skills User skills
* @property {Uint8} u8 Crafting, visual arts, etc.
* @property {Uint8} u8 cooking, baking, brewing,
* @property {Uint8} u8 using guns/cannons, bows, etc.
* @property {Uint8} u8 using swords, hammers, pole-arms etc.
* @property {Uint8} u8 being able to contort, move, dodge, etc.
* @property {Uint8} u8 skullduggery, lock-picking, deceiving, slight of hand
* @property {Uint8} u8 creating and using contraptions, building houses
* @property {Uint8} u8 obvious, but in this you can also use automatic stuff
* @property {Uint8} u8 ability to read/write a specific language
* @property {Uint8} u8 healing hp, getting rid of diseases, etc.
* @property {Uint8} u8 Creating potions, creating alloys, creating chemicals, component based 'magic'
* @property {Uint8} u8 collecting fish
* @property {Uint8} u8 collecting ore
* @property {Uint8} u8 woodcutting, fire-making, hunting, collecting herbs, etc.
* @property {Uint8} u8 growing plants, herbs, etc.
* @property {Uint8} u8 will give more information when examining some objects
*/
class Skills { class Skills {
/** /**
* Crafting, visual arts, etc. * Crafting, visual arts, etc.
* @return {Uint8} gets the value of Artisan
*/ */
get Artisan() { get Artisan() {
return this._data.getUint8(0, true); return this._data.getUint8(0, true);
} }
/**
* Crafting, visual arts, etc.
* @param {Uint8} sets the value of Artisan
*/
set Artisan(v) { set Artisan(v) {
return this._data.setUint8(0, v, true); return this._data.setUint8(0, v, true);
} }
/** /**
* cooking, baking, brewing, * cooking, baking, brewing,
* @return {Uint8} gets the value of Culinary
*/ */
get Culinary() { get Culinary() {
return this._data.getUint8(1, true); return this._data.getUint8(1, true);
} }
/**
* cooking, baking, brewing,
* @param {Uint8} sets the value of Culinary
*/
set Culinary(v) { set Culinary(v) {
return this._data.setUint8(1, v, true); return this._data.setUint8(1, v, true);
} }
/** /**
* using guns/cannons, bows, etc. * using guns/cannons, bows, etc.
* @return {Uint8} gets the value of Ranged
*/ */
get Ranged() { get Ranged() {
return this._data.getUint8(2, true); return this._data.getUint8(2, true);
} }
/**
* using guns/cannons, bows, etc.
* @param {Uint8} sets the value of Ranged
*/
set Ranged(v) { set Ranged(v) {
return this._data.setUint8(2, v, true); return this._data.setUint8(2, v, true);
} }
/** /**
* using swords, hammers, pole-arms etc. * using swords, hammers, pole-arms etc.
* @return {Uint8} gets the value of Melee
*/ */
get Melee() { get Melee() {
return this._data.getUint8(3, true); return this._data.getUint8(3, true);
} }
/**
* using swords, hammers, pole-arms etc.
* @param {Uint8} sets the value of Melee
*/
set Melee(v) { set Melee(v) {
return this._data.setUint8(3, v, true); return this._data.setUint8(3, v, true);
} }
/** /**
* being able to contort, move, dodge, etc. * being able to contort, move, dodge, etc.
* @return {Uint8} gets the value of Acrobatics
*/ */
get Acrobatics() { get Acrobatics() {
return this._data.getUint8(4, true); return this._data.getUint8(4, true);
} }
/**
* being able to contort, move, dodge, etc.
* @param {Uint8} sets the value of Acrobatics
*/
set Acrobatics(v) { set Acrobatics(v) {
return this._data.setUint8(4, v, true); return this._data.setUint8(4, v, true);
} }
/** /**
* skullduggery, lock-picking, deceiving, slight of hand * skullduggery, lock-picking, deceiving, slight of hand
* @return {Uint8} gets the value of Prestidigitation
*/ */
get Prestidigitation() { get Prestidigitation() {
return this._data.getUint8(5, true); return this._data.getUint8(5, true);
} }
/**
* skullduggery, lock-picking, deceiving, slight of hand
* @param {Uint8} sets the value of Prestidigitation
*/
set Prestidigitation(v) { set Prestidigitation(v) {
return this._data.setUint8(5, v, true); return this._data.setUint8(5, v, true);
} }
/** /**
* creating and using contraptions, building houses * creating and using contraptions, building houses
* @return {Uint8} gets the value of Engineering
*/ */
get Engineering() { get Engineering() {
return this._data.getUint8(6, true); return this._data.getUint8(6, true);
} }
/**
* creating and using contraptions, building houses
* @param {Uint8} sets the value of Engineering
*/
set Engineering(v) { set Engineering(v) {
return this._data.setUint8(6, v, true); return this._data.setUint8(6, v, true);
} }
/** /**
* obvious, but in this you can also use automatic stuff * obvious, but in this you can also use automatic stuff
* @return {Uint8} gets the value of Metalworking
*/ */
get Metalworking() { get Metalworking() {
return this._data.getUint8(7, true); return this._data.getUint8(7, true);
} }
/**
* obvious, but in this you can also use automatic stuff
* @param {Uint8} sets the value of Metalworking
*/
set Metalworking(v) { set Metalworking(v) {
return this._data.setUint8(7, v, true); return this._data.setUint8(7, v, true);
} }
/** /**
* ability to read/write a specific language * ability to read/write a specific language
* @return {Uint8} gets the value of Language
*/ */
get Language() { get Language() {
return this._data.getUint8(8, true); return this._data.getUint8(8, true);
} }
/**
* ability to read/write a specific language
* @param {Uint8} sets the value of Language
*/
set Language(v) { set Language(v) {
return this._data.setUint8(8, v, true); return this._data.setUint8(8, v, true);
} }
/** /**
* healing hp, getting rid of diseases, etc. * healing hp, getting rid of diseases, etc.
* @return {Uint8} gets the value of Medicine
*/ */
get Medicine() { get Medicine() {
return this._data.getUint8(9, true); return this._data.getUint8(9, true);
} }
/**
* healing hp, getting rid of diseases, etc.
* @param {Uint8} sets the value of Medicine
*/
set Medicine(v) { set Medicine(v) {
return this._data.setUint8(9, v, true); return this._data.setUint8(9, v, true);
} }
/** /**
* Creating potions, creating alloys, creating chemicals, component based 'magic' * Creating potions, creating alloys, creating chemicals, component based 'magic'
* @return {Uint8} gets the value of Alchemy
*/ */
get Alchemy() { get Alchemy() {
return this._data.getUint8(10, true); return this._data.getUint8(10, true);
} }
/**
* Creating potions, creating alloys, creating chemicals, component based 'magic'
* @param {Uint8} sets the value of Alchemy
*/
set Alchemy(v) { set Alchemy(v) {
return this._data.setUint8(10, v, true); return this._data.setUint8(10, v, true);
} }
/** /**
* collecting fish * collecting fish
* @return {Uint8} gets the value of Fishing
*/ */
get Fishing() { get Fishing() {
return this._data.getUint8(11, true); return this._data.getUint8(11, true);
} }
/**
* collecting fish
* @param {Uint8} sets the value of Fishing
*/
set Fishing(v) { set Fishing(v) {
return this._data.setUint8(11, v, true); return this._data.setUint8(11, v, true);
} }
/** /**
* collecting ore * collecting ore
* @return {Uint8} gets the value of Mining
*/ */
get Mining() { get Mining() {
return this._data.getUint8(12, true); return this._data.getUint8(12, true);
} }
/**
* collecting ore
* @param {Uint8} sets the value of Mining
*/
set Mining(v) { set Mining(v) {
return this._data.setUint8(12, v, true); return this._data.setUint8(12, v, true);
} }
/** /**
* woodcutting, fire-making, hunting, collecting herbs, etc. * woodcutting, fire-making, hunting, collecting herbs, etc.
* @return {Uint8} gets the value of Survival
*/ */
get Survival() { get Survival() {
return this._data.getUint8(13, true); return this._data.getUint8(13, true);
} }
/**
* woodcutting, fire-making, hunting, collecting herbs, etc.
* @param {Uint8} sets the value of Survival
*/
set Survival(v) { set Survival(v) {
return this._data.setUint8(13, v, true); return this._data.setUint8(13, v, true);
} }
/** /**
* growing plants, herbs, etc. * growing plants, herbs, etc.
* @return {Uint8} gets the value of Gardening
*/ */
get Gardening() { get Gardening() {
return this._data.getUint8(14, true); return this._data.getUint8(14, true);
} }
/**
* growing plants, herbs, etc.
* @param {Uint8} sets the value of Gardening
*/
set Gardening(v) { set Gardening(v) {
return this._data.setUint8(14, v, true); return this._data.setUint8(14, v, true);
} }
/** /**
* will give more information when examining some objects * will give more information when examining some objects
* @return {Uint8} gets the value of History
*/ */
get History() { get History() {
return this._data.getUint8(15, true); return this._data.getUint8(15, true);
} }
/**
* will give more information when examining some objects
* @param {Uint8} sets the value of History
*/
set History(v) { set History(v) {
return this._data.setUint8(15, v, true); return this._data.setUint8(15, v, true);
} }
/**
* get the struct representation of the object
*/
get bytes() {
return new Uint8Array(this._ptr);
}
/** /**
* constructor * Constructs a new Skills
*
* @param {{Artisan: Uint8, Culinary: Uint8, Ranged: Uint8, Melee: Uint8, Acrobatics: Uint8, Prestidigitation: Uint8, Engineering: Uint8, Metalworking: Uint8, Language: Uint8, Medicine: Uint8, Alchemy: Uint8, Fishing: Uint8, Mining: Uint8, Survival: Uint8, Gardening: Uint8, History: Uint8, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/ */
constructor(init = {}, ptr = undefined) { constructor(init = {}, ptr = undefined) {
this._size = 16; this._size = 16;
this._ptr = ptr.buffer || new ArrayBuffer(this._size); this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr); this._data = new DataView(this._ptr.buffer);
for (const key of Object.keys(init)) { for (const key of Object.keys(init)) {
this[key] = init[key]; this[key] = init[key];

View File

@ -1,62 +1,92 @@
/**
* @typedef {Object} Stats User stats
* @property {Uint8} u8 Physical attack damage + Equipment Load
* @property {Uint8} u8 HP + Dmg mitigation for physical damage, how much stamina you have
* @property {Uint8} u8 Use/build steampunk gadgets + be able to read specific logical papers
* @property {Uint8} u8 Number of magic / special attack / skills you can remember at one time.
* @property {Uint8} u8 how good you can talk, persuade, etc.
*/
class Stats { class Stats {
/** /**
* Physical attack damage + Equipment Load * Physical attack damage + Equipment Load
* @return {Uint8} gets the value of Strength
*/ */
get Strength() { get Strength() {
return this._data.getUint8(0, true); return this._data.getUint8(0, true);
} }
/**
* Physical attack damage + Equipment Load
* @param {Uint8} sets the value of Strength
*/
set Strength(v) { set Strength(v) {
return this._data.setUint8(0, v, true); return this._data.setUint8(0, v, true);
} }
/** /**
* HP + Dmg mitigation for physical damage, how much stamina you have * HP + Dmg mitigation for physical damage, how much stamina you have
* @return {Uint8} gets the value of Endurance
*/ */
get Endurance() { get Endurance() {
return this._data.getUint8(1, true); return this._data.getUint8(1, true);
} }
/**
* HP + Dmg mitigation for physical damage, how much stamina you have
* @param {Uint8} sets the value of Endurance
*/
set Endurance(v) { set Endurance(v) {
return this._data.setUint8(1, v, true); return this._data.setUint8(1, v, true);
} }
/** /**
* Use/build steampunk gadgets + be able to read specific logical papers * Use/build steampunk gadgets + be able to read specific logical papers
* @return {Uint8} gets the value of Intelligence
*/ */
get Intelligence() { get Intelligence() {
return this._data.getUint8(2, true); return this._data.getUint8(2, true);
} }
/**
* Use/build steampunk gadgets + be able to read specific logical papers
* @param {Uint8} sets the value of Intelligence
*/
set Intelligence(v) { set Intelligence(v) {
return this._data.setUint8(2, v, true); return this._data.setUint8(2, v, true);
} }
/** /**
* Number of magic / special attack / skills you can remember at one time. * Number of magic / special attack / skills you can remember at one time.
* @return {Uint8} gets the value of Wisdom
*/ */
get Wisdom() { get Wisdom() {
return this._data.getUint8(3, true); return this._data.getUint8(3, true);
} }
/**
* Number of magic / special attack / skills you can remember at one time.
* @param {Uint8} sets the value of Wisdom
*/
set Wisdom(v) { set Wisdom(v) {
return this._data.setUint8(3, v, true); return this._data.setUint8(3, v, true);
} }
/** /**
* how good you can talk, persuade, etc. * how good you can talk, persuade, etc.
* @return {Uint8} gets the value of Charisma
*/ */
get Charisma() { get Charisma() {
return this._data.getUint8(4, true); return this._data.getUint8(4, true);
} }
/**
* how good you can talk, persuade, etc.
* @param {Uint8} sets the value of Charisma
*/
set Charisma(v) { set Charisma(v) {
return this._data.setUint8(4, v, true); return this._data.setUint8(4, v, true);
} }
/**
* get the struct representation of the object
*/
get bytes() {
return new Uint8Array(this._ptr);
}
/** /**
* constructor * Constructs a new Stats
*
* @param {{Strength: Uint8, Endurance: Uint8, Intelligence: Uint8, Wisdom: Uint8, Charisma: Uint8, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/ */
constructor(init = {}, ptr = undefined) { constructor(init = {}, ptr = undefined) {
this._size = 5; this._size = 5;
this._ptr = ptr.buffer || new ArrayBuffer(this._size); this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr); this._data = new DataView(this._ptr.buffer);
for (const key of Object.keys(init)) { for (const key of Object.keys(init)) {
this[key] = init[key]; this[key] = init[key];

View File

@ -1,44 +1,62 @@
/**
* @typedef {Object} Vector3 A representation of a position in 3D space
* @property {Float32} f32 x coordinate
* @property {Float32} f32 y coordinate
* @property {Float32} f32 z coordinate
*/
class Vector3 { class Vector3 {
/** /**
* x coordinate * x coordinate
* @return {Float32} gets the value of x
*/ */
get x() { get x() {
return this._data.getFloat32(0, true); return this._data.getFloat32(0, true);
} }
/**
* x coordinate
* @param {Float32} sets the value of x
*/
set x(v) { set x(v) {
return this._data.setFloat32(0, v, true); return this._data.setFloat32(0, v, true);
} }
/** /**
* y coordinate * y coordinate
* @return {Float32} gets the value of y
*/ */
get y() { get y() {
return this._data.getFloat32(4, true); return this._data.getFloat32(4, true);
} }
/**
* y coordinate
* @param {Float32} sets the value of y
*/
set y(v) { set y(v) {
return this._data.setFloat32(4, v, true); return this._data.setFloat32(4, v, true);
} }
/** /**
* z coordinate * z coordinate
* @return {Float32} gets the value of z
*/ */
get z() { get z() {
return this._data.getFloat32(8, true); return this._data.getFloat32(8, true);
} }
/**
* z coordinate
* @param {Float32} sets the value of z
*/
set z(v) { set z(v) {
return this._data.setFloat32(8, v, true); return this._data.setFloat32(8, v, true);
} }
/**
* get the struct representation of the object
*/
get bytes() {
return new Uint8Array(this._ptr);
}
/** /**
* constructor * Constructs a new Vector3
*
* @param {{x: Float32, y: Float32, z: Float32, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/ */
constructor(init = {}, ptr = undefined) { constructor(init = {}, ptr = undefined) {
this._size = 12; this._size = 12;
this._ptr = ptr.buffer || new ArrayBuffer(this._size); this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr); this._data = new DataView(this._ptr.buffer);
for (const key of Object.keys(init)) { for (const key of Object.keys(init)) {
this[key] = init[key]; this[key] = init[key];

View File

@ -1,219 +1,240 @@
{ {
"Vector3": { "Vector3": {
"x": { "comment": "A representation of a position in 3D space",
"type": "f32", "members": {
"kind": "scalar", "x": {
"comment": "x coordinate" "type": "f32",
}, "kind": "scalar",
"y": { "comment": "x coordinate"
"type": "f32", },
"kind": "scalar", "y": {
"comment": "y coordinate" "type": "f32",
}, "kind": "scalar",
"z": { "comment": "y coordinate"
"type": "f32", },
"kind": "scalar", "z": {
"comment": "z coordinate" "type": "f32",
"kind": "scalar",
"comment": "z coordinate"
}
} }
}, },
"Stats": { "Stats": {
"Strength": { "comment": "User stats",
"type": "u8", "members": {
"kind": "scalar", "Strength": {
"comment": "Physical attack damage + Equipment Load" "type": "u8",
}, "kind": "scalar",
"Endurance": { "comment": "Physical attack damage + Equipment Load"
"type": "u8", },
"kind": "scalar", "Endurance": {
"comment": "HP + Dmg mitigation for physical damage, how much stamina you have" "type": "u8",
}, "kind": "scalar",
"Intelligence": { "comment": "HP + Dmg mitigation for physical damage, how much stamina you have"
"type": "u8", },
"kind": "scalar", "Intelligence": {
"comment": "Use/build steampunk gadgets + be able to read specific logical papers" "type": "u8",
}, "kind": "scalar",
"Wisdom": { "comment": "Use/build steampunk gadgets + be able to read specific logical papers"
"type": "u8", },
"kind": "scalar", "Wisdom": {
"comment": "Number of magic / special attack / skills you can remember at one time." "type": "u8",
}, "kind": "scalar",
"Charisma": { "comment": "Number of magic / special attack / skills you can remember at one time."
"type": "u8", },
"kind": "scalar", "Charisma": {
"comment": "how good you can talk, persuade, etc." "type": "u8",
"kind": "scalar",
"comment": "how good you can talk, persuade, etc."
}
} }
}, },
"Skills": { "Skills": {
"Artisan": { "comment": "User skills",
"type": "u8", "members": {
"kind": "scalar", "Artisan": {
"comment": "Crafting, visual arts, etc." "type": "u8",
}, "kind": "scalar",
"Culinary": { "comment": "Crafting, visual arts, etc."
"type": "u8", },
"kind": "scalar", "Culinary": {
"comment": "cooking, baking, brewing, " "type": "u8",
}, "kind": "scalar",
"Ranged": { "comment": "cooking, baking, brewing, "
"type": "u8", },
"kind": "scalar", "Ranged": {
"comment": "using guns/cannons, bows, etc." "type": "u8",
}, "kind": "scalar",
"Melee": { "comment": "using guns/cannons, bows, etc."
"type": "u8", },
"kind": "scalar", "Melee": {
"comment": "using swords, hammers, pole-arms etc." "type": "u8",
}, "kind": "scalar",
"Acrobatics": { "comment": "using swords, hammers, pole-arms etc."
"type": "u8", },
"kind": "scalar", "Acrobatics": {
"comment": "being able to contort, move, dodge, etc." "type": "u8",
}, "kind": "scalar",
"Prestidigitation": { "comment": "being able to contort, move, dodge, etc."
"type": "u8", },
"kind": "scalar", "Prestidigitation": {
"comment": "skullduggery, lock-picking, deceiving, slight of hand" "type": "u8",
}, "kind": "scalar",
"Engineering": { "comment": "skullduggery, lock-picking, deceiving, slight of hand"
"type": "u8", },
"kind": "scalar", "Engineering": {
"comment": " creating and using contraptions, building houses" "type": "u8",
}, "kind": "scalar",
"Metalworking": { "comment": " creating and using contraptions, building houses"
"type": "u8", },
"kind": "scalar", "Metalworking": {
"comment": "obvious, but in this you can also use automatic stuff" "type": "u8",
}, "kind": "scalar",
"Language": { "comment": "obvious, but in this you can also use automatic stuff"
"type": "u8", },
"kind": "scalar", "Language": {
"comment": "ability to read/write a specific language" "type": "u8",
}, "kind": "scalar",
"Medicine": { "comment": "ability to read/write a specific language"
"type": "u8", },
"kind": "scalar", "Medicine": {
"comment": "healing hp, getting rid of diseases, etc." "type": "u8",
}, "kind": "scalar",
"Alchemy": { "comment": "healing hp, getting rid of diseases, etc."
"type": "u8", },
"kind": "scalar", "Alchemy": {
"comment": "Creating potions, creating alloys, creating chemicals, component based 'magic'" "type": "u8",
}, "kind": "scalar",
"Fishing": { "comment": "Creating potions, creating alloys, creating chemicals, component based 'magic'"
"type": "u8", },
"kind": "scalar", "Fishing": {
"comment": "collecting fish" "type": "u8",
}, "kind": "scalar",
"Mining": { "comment": "collecting fish"
"type": "u8", },
"kind": "scalar", "Mining": {
"comment": "collecting ore" "type": "u8",
}, "kind": "scalar",
"Survival": { "comment": "collecting ore"
"type": "u8", },
"kind": "scalar", "Survival": {
"comment": "woodcutting, fire-making, hunting, collecting herbs, etc." "type": "u8",
}, "kind": "scalar",
"Gardening": { "comment": "woodcutting, fire-making, hunting, collecting herbs, etc."
"type": "u8", },
"kind": "scalar", "Gardening": {
"comment": "growing plants, herbs, etc." "type": "u8",
}, "kind": "scalar",
"History": { "comment": "growing plants, herbs, etc."
"type": "u8", },
"kind": "scalar", "History": {
"comment": "will give more information when examining some objects" "type": "u8",
"kind": "scalar",
"comment": "will give more information when examining some objects"
}
} }
}, },
"DerivedStats": { "DerivedStats": {
"Hitpoints": { "comment": "Derived user stats",
"type": "u8", "members": {
"kind": "scalar", "Hitpoints": {
"comment": "how many hits you can take, if it reaches 0 you ded!" "type": "u8",
}, "kind": "scalar",
"Stamina": { "comment": "how many hits you can take, if it reaches 0 you ded!"
"type": "u8", },
"kind": "scalar", "Stamina": {
"comment": "How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc." "type": "u8",
}, "kind": "scalar",
"Perception": { "comment": "How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc."
"type": "u8", },
"kind": "scalar", "Perception": {
"comment": "being able to observe some objects" "type": "u8",
}, "kind": "scalar",
"Luck": { "comment": "being able to observe some objects"
"type": "u8", },
"kind": "scalar", "Luck": {
"comment": "Get better probability rolls for things that matter for rolls" "type": "u8",
}, "kind": "scalar",
"Stealth": { "comment": "Get better probability rolls for things that matter for rolls"
"type": "u8", },
"kind": "scalar", "Stealth": {
"comment": "Probability of being discovered when hiding" "type": "u8",
}, "kind": "scalar",
"Attractiveness": { "comment": "Probability of being discovered when hiding"
"type": "u8", },
"kind": "scalar", "Attractiveness": {
"comment": "based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class." "type": "u8",
}, "kind": "scalar",
"Affluence": { "comment": "based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class."
"type": "u8", },
"kind": "scalar", "Affluence": {
"comment": "same as attractiveness but can change with money" "type": "u8",
}, "kind": "scalar",
"Holyness": { "comment": "same as attractiveness but can change with money"
"type": "i8", },
"kind": "scalar", "Holyness": {
"comment": "how attuned to the vision of Eru" "type": "i8",
"kind": "scalar",
"comment": "how attuned to the vision of Eru"
}
} }
}, },
"Entity": { "Entity": {
"Name": { "comment": "Something that can exist in 3D space",
"type": "string", "members": {
"kind": "string", "Name": {
"size": "24", "type": "string",
"comment": "Name of the entity" "kind": "string",
}, "size": "24",
"Vector3": { "comment": "Name of the entity"
"type": "Vector3", },
"kind": "struct", "Vector3": {
"comment": "Vector3 of the entity in space" "type": "Vector3",
}, "kind": "struct",
"Stats": { "comment": "Vector3 of the entity in space"
"type": "Stats", },
"kind": "struct", "Stats": {
"comment": "Base stats" "type": "Stats",
}, "kind": "struct",
"DerivedStats": { "comment": "Base stats"
"type": "DerivedStats", },
"kind": "struct", "DerivedStats": {
"comment": "Stats that are derived from skills and base stats" "type": "DerivedStats",
}, "kind": "struct",
"Skills": { "comment": "Stats that are derived from skills and base stats"
"type": "Skills", },
"kind": "struct", "Skills": {
"comment": "Stuff that your character can do" "type": "Skills",
"kind": "struct",
"comment": "Stuff that your character can do"
}
} }
}, },
"Item": { "Item": {
"Name": { "comment": "Item",
"type": "string", "members": {
"kind": "string", "Name": {
"size": "24", "type": "string",
"comment": "Name of the item" "kind": "string",
}, "size": "24",
"BaseValue": { "comment": "Name of the item"
"type": "i32", },
"kind": "scalar", "BaseValue": {
"comment": "Default starting value of the item" "type": "i32",
"kind": "scalar",
"comment": "Default starting value of the item"
}
} }
}, },
"Phenomenon": { "Phenomenon": {
"Name": { "comment": "Kinda like an action, cant remember",
"type": "string", "members": {
"kind": "string", "Name": {
"size": "64", "type": "string",
"comment": "Name of the phenomenon" "kind": "string",
"size": "64",
"comment": "Name of the phenomenon"
}
} }
} }
} }

View File

@ -1,5 +1,6 @@
{ {
"Vector3": { "Vector3": {
"type": "struct",
"comment": "A representation of a position in 3D space", "comment": "A representation of a position in 3D space",
"members": { "members": {
"x": { "x": {
@ -20,6 +21,7 @@
} }
}, },
"Login": { "Login": {
"type": "struct",
"comment": "The login object", "comment": "The login object",
"members": { "members": {
"Email": { "Email": {
@ -37,6 +39,7 @@
} }
}, },
"User": { "User": {
"type": "struct",
"comment": "The user object", "comment": "The user object",
"members": { "members": {
"Name": { "Name": {
@ -58,6 +61,7 @@
} }
}, },
"LoginRequest": { "LoginRequest": {
"type": "request",
"comment": "a request for a login", "comment": "a request for a login",
"members": { "members": {
"Login": { "Login": {
@ -68,6 +72,7 @@
} }
}, },
"LoginResponse": { "LoginResponse": {
"type": "response",
"comment": "the response from a login request", "comment": "the response from a login request",
"members": { "members": {
"success": { "success": {