raylib-wasm-transpiler/server/components/Stats.js

97 lines
3.0 KiB
JavaScript

/**
* @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 {
/**
* Physical attack damage + Equipment Load
* @return {Uint8} gets the value of Strength
*/
get Strength() {
return this._data.getUint8(0, true);
}
/**
* Physical attack damage + Equipment Load
* @param {Uint8} sets the value of Strength
*/
set Strength(v) {
return this._data.setUint8(0, v, true);
}
/**
* HP + Dmg mitigation for physical damage, how much stamina you have
* @return {Uint8} gets the value of Endurance
*/
get Endurance() {
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) {
return this._data.setUint8(1, v, true);
}
/**
* Use/build steampunk gadgets + be able to read specific logical papers
* @return {Uint8} gets the value of Intelligence
*/
get Intelligence() {
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) {
return this._data.setUint8(2, v, true);
}
/**
* Number of magic / special attack / skills you can remember at one time.
* @return {Uint8} gets the value of Wisdom
*/
get Wisdom() {
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) {
return this._data.setUint8(3, v, true);
}
/**
* how good you can talk, persuade, etc.
* @return {Uint8} gets the value of Charisma
*/
get Charisma() {
return this._data.getUint8(4, true);
}
/**
* how good you can talk, persuade, etc.
* @param {Uint8} sets the value of Charisma
*/
set Charisma(v) {
return this._data.setUint8(4, v, true);
}
/**
* 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) {
this._size = 5;
this._ptr = ptr || new Uint8Array(this._size);
this._data = new DataView(this._ptr.buffer);
for (const key of Object.keys(init)) {
this[key] = init[key];
}
}
}
export default Stats