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

142 lines
4.8 KiB
JavaScript

/**
* @typedef {Object} DerivedStats Derived user stats
* @property {Uint8} u8 how many hits you can take, if it reaches 0 you ded!
* @property {Uint8} u8 How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc.
* @property {Uint8} u8 being able to observe some objects
* @property {Uint8} u8 Get better probability rolls for things that matter for rolls
* @property {Uint8} u8 Probability of being discovered when hiding
* @property {Uint8} u8 based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class.
* @property {Uint8} u8 same as attractiveness but can change with money
* @property {Int8} i8 how attuned to the vision of Eru
*/
class DerivedStats {
/**
* how many hits you can take, if it reaches 0 you ded!
* @return {Uint8} gets the value of Hitpoints
*/
get Hitpoints() {
return this._data.getUint8(0, true);
}
/**
* how many hits you can take, if it reaches 0 you ded!
* @param {Uint8} sets the value of Hitpoints
*/
set Hitpoints(v) {
return this._data.setUint8(0, v, true);
}
/**
* How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc.
* @return {Uint8} gets the value of Stamina
*/
get Stamina() {
return this._data.getUint8(1, true);
}
/**
* How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc.
* @param {Uint8} sets the value of Stamina
*/
set Stamina(v) {
return this._data.setUint8(1, v, true);
}
/**
* being able to observe some objects
* @return {Uint8} gets the value of Perception
*/
get Perception() {
return this._data.getUint8(2, true);
}
/**
* being able to observe some objects
* @param {Uint8} sets the value of Perception
*/
set Perception(v) {
return this._data.setUint8(2, v, true);
}
/**
* Get better probability rolls for things that matter for rolls
* @return {Uint8} gets the value of Luck
*/
get Luck() {
return this._data.getUint8(3, true);
}
/**
* Get better probability rolls for things that matter for rolls
* @param {Uint8} sets the value of Luck
*/
set Luck(v) {
return this._data.setUint8(3, v, true);
}
/**
* Probability of being discovered when hiding
* @return {Uint8} gets the value of Stealth
*/
get Stealth() {
return this._data.getUint8(4, true);
}
/**
* Probability of being discovered when hiding
* @param {Uint8} sets the value of Stealth
*/
set Stealth(v) {
return this._data.setUint8(4, v, true);
}
/**
* based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class.
* @return {Uint8} gets the value of Attractiveness
*/
get Attractiveness() {
return this._data.getUint8(5, true);
}
/**
* based on your character you make in the creator. more attractive will have better outcomes with aristocracy and more 'ugly' will have better outcomes with working class.
* @param {Uint8} sets the value of Attractiveness
*/
set Attractiveness(v) {
return this._data.setUint8(5, v, true);
}
/**
* same as attractiveness but can change with money
* @return {Uint8} gets the value of Affluence
*/
get Affluence() {
return this._data.getUint8(6, true);
}
/**
* same as attractiveness but can change with money
* @param {Uint8} sets the value of Affluence
*/
set Affluence(v) {
return this._data.setUint8(6, v, true);
}
/**
* how attuned to the vision of Eru
* @return {Int8} gets the value of Holyness
*/
get Holyness() {
return this._data.getInt8(7, true);
}
/**
* how attuned to the vision of Eru
* @param {Int8} sets the value of Holyness
*/
set Holyness(v) {
return this._data.setInt8(7, v, true);
}
/**
* Constructs a new DerivedStats
*
* @param {{Hitpoints: Uint8, Stamina: Uint8, Perception: Uint8, Luck: Uint8, Stealth: Uint8, Attractiveness: Uint8, Affluence: Uint8, Holyness: Int8, }} init The arguments to construct the object.
* @param {Uint8Array} ptr The pointer to the C struct.
*/
constructor(init = {}, ptr = undefined) {
this._size = 8;
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 DerivedStats