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

67 lines
1.6 KiB
JavaScript

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