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

55 lines
1.5 KiB
JavaScript

class Stats {
get Strength() {
return this._data.getUint8(0, true);
}
set Strength(v) {
return this._data.setUint8(0, v, true);
}
get Endurance() {
return this._data.getUint8(1, true);
}
set Endurance(v) {
return this._data.setUint8(1, v, true);
}
get Intelligence() {
return this._data.getUint8(2, true);
}
set Intelligence(v) {
return this._data.setUint8(2, v, true);
}
get Wisdom() {
return this._data.getUint8(3, true);
}
set Wisdom(v) {
return this._data.setUint8(3, v, true);
}
get Charisma() {
return this._data.getUint8(4, true);
}
set Charisma(v) {
return this._data.setUint8(4, v, true);
}
get Faith() {
return this._data.getUint8(5, true);
}
set Faith(v) {
return this._data.setUint8(5, v, true);
}
sql_insert(Strength, Endurance, Intelligence, Wisdom, Charisma, Faith) {
return `INSERT INTO Stats (Strength, Endurance, Intelligence, Wisdom, Charisma, Faith) VALUES (${Strength}, ${Endurance}, ${Intelligence}, ${Wisdom}, ${Charisma}, ${Faith}) RETURNING id;`
}
get bytes() {
return new Uint8Array(this._ptr);
}
constructor(init = {}, ptr = undefined) {
this._size = 6;
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