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

49 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-05-29 20:47:19 -04:00
class HiddenStats {
get Luck() {
return this._data.getUint8(0, true);
}
set Luck(v) {
return this._data.setUint8(0, v, true);
}
get Stealth() {
return this._data.getUint8(1, true);
}
set Stealth(v) {
return this._data.setUint8(1, v, true);
}
get Attractiveness() {
return this._data.getUint8(2, true);
}
set Attractiveness(v) {
return this._data.setUint8(2, v, true);
}
get Affluence() {
return this._data.getUint8(3, true);
}
set Affluence(v) {
return this._data.setUint8(3, v, true);
}
get Notoriety() {
return this._data.getUint8(4, true);
}
set Notoriety(v) {
return this._data.setUint8(4, v, true);
}
sql_insert(Luck, Stealth, Attractiveness, Affluence, Notoriety) {
return `INSERT INTO HiddenStats (Luck, Stealth, Attractiveness, Affluence, Notoriety) VALUES (${Luck}, ${Stealth}, ${Attractiveness}, ${Affluence}, ${Notoriety}) RETURNING id;`
}
get bytes() {
return new Uint8Array(this._ptr);
}
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 HiddenStats