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

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-05-29 20:47:19 -04:00
class Stats {
/**
* Physical attack damage + Equipment Load
*/
2024-05-29 20:47:19 -04:00
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
*/
2024-05-29 20:47:19 -04:00
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
*/
2024-05-29 20:47:19 -04:00
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.
*/
2024-05-29 20:47:19 -04:00
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.
*/
2024-05-29 20:47:19 -04:00
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
*/
2024-05-29 20:47:19 -04:00
get bytes() {
return new Uint8Array(this._ptr);
}
/**
* constructor
*/
2024-05-29 20:47:19 -04:00
constructor(init = {}, ptr = undefined) {
this._size = 5;
2024-05-29 20:47:19 -04:00
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