update schema and add comments to generator
This commit is contained in:
parent
822a1e4c66
commit
5026958057
|
@ -30,14 +30,14 @@ EM_BOOL onmessage(int eventType,
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
InitWindow(screen_width, screen_height, "Project Verne");
|
InitWindow(screen_width, screen_height, "Project Verne");
|
||||||
|
|
||||||
camera.position = (Vector3){-9.0f, 9.0f, 4.0f};
|
camera.position = (Vector3){0.0f, 0.0f, 1.0f};
|
||||||
camera.target = (Vector3){9.0f, 9.0f, 0.0f};
|
camera.target = (Vector3){0.0f, 0.0f, 0.0f};
|
||||||
camera.up = (Vector3){0.0f, 1.0f, 0.0f};
|
camera.up = (Vector3){0.0f, 1.0f, 0.0f};
|
||||||
camera.fovy = 60.0f;
|
camera.fovy = 60.0f;
|
||||||
camera.projection = CAMERA_PERSPECTIVE;
|
camera.projection = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
parth = LoadModel("assets/parthanon.obj");
|
parth = LoadModel("assets/parthanon.obj");
|
||||||
texture = LoadTexture("assets/parthanon_8k.png");
|
texture = LoadTexture("assets/parthanon.png");
|
||||||
parth.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
parth.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
|
||||||
|
|
||||||
parth_bound_box = GetMeshBoundingBox(parth.meshes[0]);
|
parth_bound_box = GetMeshBoundingBox(parth.meshes[0]);
|
||||||
|
|
|
@ -1,46 +1,61 @@
|
||||||
|
typedef struct Vector3 {
|
||||||
|
float x; // x coordinate
|
||||||
|
float y; // y coordinate
|
||||||
|
float z; // z coordinate
|
||||||
|
} Vector3;
|
||||||
|
|
||||||
typedef struct Stats {
|
typedef struct Stats {
|
||||||
unsigned char Strength;
|
unsigned char Strength; // Physical attack damage + Equipment Load
|
||||||
unsigned char Endurance;
|
unsigned char Endurance; // HP + Dmg mitigation for physical damage, how much stamina you have
|
||||||
unsigned char Intelligence;
|
unsigned char Intelligence; // Use/build steampunk gadgets + be able to read specific logical papers
|
||||||
unsigned char Wisdom;
|
unsigned char Wisdom; // Number of magic / special attack / skills you can remember at one time.
|
||||||
unsigned char Charisma;
|
unsigned char Charisma; // how good you can talk, persuade, etc.
|
||||||
unsigned char Faith;
|
|
||||||
} Stats;
|
} Stats;
|
||||||
|
|
||||||
typedef struct HiddenStats {
|
|
||||||
unsigned char Luck;
|
|
||||||
unsigned char Stealth;
|
|
||||||
unsigned char Attractiveness;
|
|
||||||
unsigned char Affluence;
|
|
||||||
unsigned char Notoriety;
|
|
||||||
} HiddenStats;
|
|
||||||
|
|
||||||
typedef struct Skills {
|
typedef struct Skills {
|
||||||
unsigned char Artisan;
|
unsigned char Artisan; // Crafting, visual arts, etc.
|
||||||
unsigned char Metalworking;
|
unsigned char Culinary; // cooking, baking, brewing,
|
||||||
unsigned char Alchemy;
|
unsigned char Ranged; // using guns/cannons, bows, etc.
|
||||||
unsigned char Engineering;
|
unsigned char Melee; // using swords, hammers, pole-arms etc.
|
||||||
unsigned char Culinary;
|
unsigned char Acrobatics; // being able to contort, move, dodge, etc.
|
||||||
unsigned char Ranged;
|
unsigned char Prestidigitation; // skullduggery, lock-picking, deceiving, slight of hand
|
||||||
unsigned char Melee;
|
unsigned char Engineering; // creating and using contraptions, building houses
|
||||||
unsigned char Acrobatics;
|
unsigned char Metalworking; // obvious, but in this you can also use automatic stuff
|
||||||
unsigned char Prestidigitation;
|
unsigned char Language; // ability to read/write a specific language
|
||||||
unsigned char Language;
|
unsigned char Medicine; // healing hp, getting rid of diseases, etc.
|
||||||
unsigned char Medicine;
|
unsigned char Alchemy; // Creating potions, creating alloys, creating chemicals, component based 'magic'
|
||||||
unsigned char Thaumatology;
|
unsigned char Fishing; // collecting fish
|
||||||
unsigned char Theology;
|
unsigned char Mining; // collecting ore
|
||||||
unsigned char Fishing;
|
unsigned char Survival; // woodcutting, fire-making, hunting, collecting herbs, etc.
|
||||||
unsigned char Mining;
|
unsigned char Gardening; // growing plants, herbs, etc.
|
||||||
unsigned char Survival;
|
unsigned char History; // will give more information when examining some objects
|
||||||
unsigned char Gardening;
|
|
||||||
unsigned char History;
|
|
||||||
unsigned char Perception;
|
|
||||||
} Skills;
|
} Skills;
|
||||||
|
|
||||||
|
typedef struct DerivedStats {
|
||||||
|
unsigned char Hitpoints; // how many hits you can take, if it reaches 0 you ded!
|
||||||
|
unsigned char Stamina; // How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc.
|
||||||
|
unsigned char Perception; // being able to observe some objects
|
||||||
|
unsigned char Luck; // Get better probability rolls for things that matter for rolls
|
||||||
|
unsigned char Stealth; // Probability of being discovered when hiding
|
||||||
|
unsigned char Attractiveness; // 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.
|
||||||
|
unsigned char Affluence; // same as attractiveness but can change with money
|
||||||
|
char Holyness; // how attuned to the vision of Eru
|
||||||
|
} DerivedStats;
|
||||||
|
|
||||||
typedef struct Entity {
|
typedef struct Entity {
|
||||||
char Name[24];
|
char Name[24]; // Name of the entity
|
||||||
Stats Stats;
|
Vector3 Vector3; // Vector3 of the entity in space
|
||||||
HiddenStats HiddenStats;
|
Stats Stats; // Base stats
|
||||||
Skills Skills;
|
DerivedStats DerivedStats; // Stats that are derived from skills and base stats
|
||||||
|
Skills Skills; // Stuff that your character can do
|
||||||
} Entity;
|
} Entity;
|
||||||
|
|
||||||
|
typedef struct Item {
|
||||||
|
char Name[24]; // Name of the item
|
||||||
|
int BaseValue; // Default starting value of the item
|
||||||
|
} Item;
|
||||||
|
|
||||||
|
typedef struct Phenomenon {
|
||||||
|
char Name[64]; // Name of the phenomenon
|
||||||
|
} Phenomenon;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
class DerivedStats {
|
||||||
|
/**
|
||||||
|
* how many hits you can take, if it reaches 0 you ded!
|
||||||
|
*/
|
||||||
|
get Hitpoints() {
|
||||||
|
return this._data.getUint8(0, true);
|
||||||
|
}
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
get Stamina() {
|
||||||
|
return this._data.getUint8(1, true);
|
||||||
|
}
|
||||||
|
set Stamina(v) {
|
||||||
|
return this._data.setUint8(1, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* being able to observe some objects
|
||||||
|
*/
|
||||||
|
get Perception() {
|
||||||
|
return this._data.getUint8(2, true);
|
||||||
|
}
|
||||||
|
set Perception(v) {
|
||||||
|
return this._data.setUint8(2, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get better probability rolls for things that matter for rolls
|
||||||
|
*/
|
||||||
|
get Luck() {
|
||||||
|
return this._data.getUint8(3, true);
|
||||||
|
}
|
||||||
|
set Luck(v) {
|
||||||
|
return this._data.setUint8(3, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Probability of being discovered when hiding
|
||||||
|
*/
|
||||||
|
get Stealth() {
|
||||||
|
return this._data.getUint8(4, true);
|
||||||
|
}
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
get Attractiveness() {
|
||||||
|
return this._data.getUint8(5, true);
|
||||||
|
}
|
||||||
|
set Attractiveness(v) {
|
||||||
|
return this._data.setUint8(5, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* same as attractiveness but can change with money
|
||||||
|
*/
|
||||||
|
get Affluence() {
|
||||||
|
return this._data.getUint8(6, true);
|
||||||
|
}
|
||||||
|
set Affluence(v) {
|
||||||
|
return this._data.setUint8(6, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* how attuned to the vision of Eru
|
||||||
|
*/
|
||||||
|
get Holyness() {
|
||||||
|
return this._data.getInt8(7, true);
|
||||||
|
}
|
||||||
|
set Holyness(v) {
|
||||||
|
return this._data.setInt8(7, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 8;
|
||||||
|
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 DerivedStats
|
|
@ -1,39 +1,64 @@
|
||||||
|
import Vector3 from "./Vector3"
|
||||||
import Stats from "./Stats"
|
import Stats from "./Stats"
|
||||||
import HiddenStats from "./HiddenStats"
|
import DerivedStats from "./DerivedStats"
|
||||||
import Skills from "./Skills"
|
import Skills from "./Skills"
|
||||||
class Entity {
|
class Entity {
|
||||||
|
/**
|
||||||
|
* Name of the entity
|
||||||
|
*/
|
||||||
get Name() {
|
get Name() {
|
||||||
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24)));
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24)));
|
||||||
}
|
}
|
||||||
set Name(v) {
|
set Name(v) {
|
||||||
this._data.set(this._encoder.encode(v), 0);
|
this._data.set(this._encoder.encode(v), 0);
|
||||||
}
|
}
|
||||||
get Stats() {
|
/**
|
||||||
return new Stats({}, new Uint8Array(this._ptr.slice(24, 30)));
|
* Vector3 of the entity in space
|
||||||
|
*/
|
||||||
|
get Vector3() {
|
||||||
|
return new Vector3({}, new Uint8Array(this._ptr.slice(24, 36)));
|
||||||
}
|
}
|
||||||
set Stats(v) {
|
set Vector3(v) {
|
||||||
this._data.set(v.bytes(), 24);
|
this._data.set(v.bytes(), 24);
|
||||||
}
|
}
|
||||||
get HiddenStats() {
|
/**
|
||||||
return new HiddenStats({}, new Uint8Array(this._ptr.slice(30, 35)));
|
* Base stats
|
||||||
|
*/
|
||||||
|
get Stats() {
|
||||||
|
return new Stats({}, new Uint8Array(this._ptr.slice(36, 41)));
|
||||||
}
|
}
|
||||||
set HiddenStats(v) {
|
set Stats(v) {
|
||||||
this._data.set(v.bytes(), 30);
|
this._data.set(v.bytes(), 36);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Stats that are derived from skills and base stats
|
||||||
|
*/
|
||||||
|
get DerivedStats() {
|
||||||
|
return new DerivedStats({}, new Uint8Array(this._ptr.slice(41, 49)));
|
||||||
|
}
|
||||||
|
set DerivedStats(v) {
|
||||||
|
this._data.set(v.bytes(), 41);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Stuff that your character can do
|
||||||
|
*/
|
||||||
get Skills() {
|
get Skills() {
|
||||||
return new Skills({}, new Uint8Array(this._ptr.slice(35, 54)));
|
return new Skills({}, new Uint8Array(this._ptr.slice(49, 65)));
|
||||||
}
|
}
|
||||||
set Skills(v) {
|
set Skills(v) {
|
||||||
this._data.set(v.bytes(), 35);
|
this._data.set(v.bytes(), 49);
|
||||||
}
|
|
||||||
sql_insert(Name, Stats, HiddenStats, Skills) {
|
|
||||||
return `INSERT INTO Entity (Name, Stats, HiddenStats, Skills) VALUES (${Name}, ${Stats}, ${HiddenStats}, ${Skills}) RETURNING id;`
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
get bytes() {
|
get bytes() {
|
||||||
return new Uint8Array(this._ptr);
|
return new Uint8Array(this._ptr);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
constructor(init = {}, ptr = undefined) {
|
constructor(init = {}, ptr = undefined) {
|
||||||
this._size = 54;
|
this._size = 65;
|
||||||
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
this._data = new DataView(this._ptr);
|
this._data = new DataView(this._ptr);
|
||||||
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
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
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
class Item {
|
||||||
|
/**
|
||||||
|
* Name of the item
|
||||||
|
*/
|
||||||
|
get Name() {
|
||||||
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24)));
|
||||||
|
}
|
||||||
|
set Name(v) {
|
||||||
|
this._data.set(this._encoder.encode(v), 0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Default starting value of the item
|
||||||
|
*/
|
||||||
|
get BaseValue() {
|
||||||
|
return this._data.getInt32(24, true);
|
||||||
|
}
|
||||||
|
set BaseValue(v) {
|
||||||
|
return this._data.setInt32(24, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 28;
|
||||||
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
|
this._data = new DataView(this._ptr);
|
||||||
|
|
||||||
|
this._encoder = new TextEncoder();
|
||||||
|
this._decoder = new TextDecoder();
|
||||||
|
for (const key of Object.keys(init)) {
|
||||||
|
this[key] = init[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Item
|
|
@ -0,0 +1,33 @@
|
||||||
|
class Phenomenon {
|
||||||
|
/**
|
||||||
|
* Name of the phenomenon
|
||||||
|
*/
|
||||||
|
get Name() {
|
||||||
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 64)));
|
||||||
|
}
|
||||||
|
set Name(v) {
|
||||||
|
this._data.set(this._encoder.encode(v), 0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 64;
|
||||||
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
|
this._data = new DataView(this._ptr);
|
||||||
|
|
||||||
|
this._encoder = new TextEncoder();
|
||||||
|
this._decoder = new TextDecoder();
|
||||||
|
for (const key of Object.keys(init)) {
|
||||||
|
this[key] = init[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Phenomenon
|
|
@ -0,0 +1,49 @@
|
||||||
|
class Position {
|
||||||
|
/**
|
||||||
|
* x coordinate
|
||||||
|
*/
|
||||||
|
get x() {
|
||||||
|
return this._data.getFloat32(0, true);
|
||||||
|
}
|
||||||
|
set x(v) {
|
||||||
|
return this._data.setFloat32(0, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* y coordinate
|
||||||
|
*/
|
||||||
|
get y() {
|
||||||
|
return this._data.getFloat32(4, true);
|
||||||
|
}
|
||||||
|
set y(v) {
|
||||||
|
return this._data.setFloat32(4, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* z coordinate
|
||||||
|
*/
|
||||||
|
get z() {
|
||||||
|
return this._data.getFloat32(8, true);
|
||||||
|
}
|
||||||
|
set z(v) {
|
||||||
|
return this._data.setFloat32(8, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 12;
|
||||||
|
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 Position
|
|
@ -1,126 +1,159 @@
|
||||||
class Skills {
|
class Skills {
|
||||||
|
/**
|
||||||
|
* Crafting, visual arts, etc.
|
||||||
|
*/
|
||||||
get Artisan() {
|
get Artisan() {
|
||||||
return this._data.getUint8(0, true);
|
return this._data.getUint8(0, true);
|
||||||
}
|
}
|
||||||
set Artisan(v) {
|
set Artisan(v) {
|
||||||
return this._data.setUint8(0, v, true);
|
return this._data.setUint8(0, v, true);
|
||||||
}
|
}
|
||||||
get Metalworking() {
|
/**
|
||||||
|
* cooking, baking, brewing,
|
||||||
|
*/
|
||||||
|
get Culinary() {
|
||||||
return this._data.getUint8(1, true);
|
return this._data.getUint8(1, true);
|
||||||
}
|
}
|
||||||
set Metalworking(v) {
|
set Culinary(v) {
|
||||||
return this._data.setUint8(1, v, true);
|
return this._data.setUint8(1, v, true);
|
||||||
}
|
}
|
||||||
get Alchemy() {
|
/**
|
||||||
|
* using guns/cannons, bows, etc.
|
||||||
|
*/
|
||||||
|
get Ranged() {
|
||||||
return this._data.getUint8(2, true);
|
return this._data.getUint8(2, true);
|
||||||
}
|
}
|
||||||
set Alchemy(v) {
|
set Ranged(v) {
|
||||||
return this._data.setUint8(2, v, true);
|
return this._data.setUint8(2, v, true);
|
||||||
}
|
}
|
||||||
get Engineering() {
|
/**
|
||||||
|
* using swords, hammers, pole-arms etc.
|
||||||
|
*/
|
||||||
|
get Melee() {
|
||||||
return this._data.getUint8(3, true);
|
return this._data.getUint8(3, true);
|
||||||
}
|
}
|
||||||
set Engineering(v) {
|
set Melee(v) {
|
||||||
return this._data.setUint8(3, v, true);
|
return this._data.setUint8(3, v, true);
|
||||||
}
|
}
|
||||||
get Culinary() {
|
/**
|
||||||
|
* being able to contort, move, dodge, etc.
|
||||||
|
*/
|
||||||
|
get Acrobatics() {
|
||||||
return this._data.getUint8(4, true);
|
return this._data.getUint8(4, true);
|
||||||
}
|
}
|
||||||
set Culinary(v) {
|
set Acrobatics(v) {
|
||||||
return this._data.setUint8(4, v, true);
|
return this._data.setUint8(4, v, true);
|
||||||
}
|
}
|
||||||
get Ranged() {
|
/**
|
||||||
|
* skullduggery, lock-picking, deceiving, slight of hand
|
||||||
|
*/
|
||||||
|
get Prestidigitation() {
|
||||||
return this._data.getUint8(5, true);
|
return this._data.getUint8(5, true);
|
||||||
}
|
}
|
||||||
set Ranged(v) {
|
set Prestidigitation(v) {
|
||||||
return this._data.setUint8(5, v, true);
|
return this._data.setUint8(5, v, true);
|
||||||
}
|
}
|
||||||
get Melee() {
|
/**
|
||||||
|
* creating and using contraptions, building houses
|
||||||
|
*/
|
||||||
|
get Engineering() {
|
||||||
return this._data.getUint8(6, true);
|
return this._data.getUint8(6, true);
|
||||||
}
|
}
|
||||||
set Melee(v) {
|
set Engineering(v) {
|
||||||
return this._data.setUint8(6, v, true);
|
return this._data.setUint8(6, v, true);
|
||||||
}
|
}
|
||||||
get Acrobatics() {
|
/**
|
||||||
|
* obvious, but in this you can also use automatic stuff
|
||||||
|
*/
|
||||||
|
get Metalworking() {
|
||||||
return this._data.getUint8(7, true);
|
return this._data.getUint8(7, true);
|
||||||
}
|
}
|
||||||
set Acrobatics(v) {
|
set Metalworking(v) {
|
||||||
return this._data.setUint8(7, v, true);
|
return this._data.setUint8(7, v, true);
|
||||||
}
|
}
|
||||||
get Prestidigitation() {
|
/**
|
||||||
|
* ability to read/write a specific language
|
||||||
|
*/
|
||||||
|
get Language() {
|
||||||
return this._data.getUint8(8, true);
|
return this._data.getUint8(8, true);
|
||||||
}
|
}
|
||||||
set Prestidigitation(v) {
|
set Language(v) {
|
||||||
return this._data.setUint8(8, v, true);
|
return this._data.setUint8(8, v, true);
|
||||||
}
|
}
|
||||||
get Language() {
|
/**
|
||||||
|
* healing hp, getting rid of diseases, etc.
|
||||||
|
*/
|
||||||
|
get Medicine() {
|
||||||
return this._data.getUint8(9, true);
|
return this._data.getUint8(9, true);
|
||||||
}
|
}
|
||||||
set Language(v) {
|
set Medicine(v) {
|
||||||
return this._data.setUint8(9, v, true);
|
return this._data.setUint8(9, v, true);
|
||||||
}
|
}
|
||||||
get Medicine() {
|
/**
|
||||||
|
* Creating potions, creating alloys, creating chemicals, component based 'magic'
|
||||||
|
*/
|
||||||
|
get Alchemy() {
|
||||||
return this._data.getUint8(10, true);
|
return this._data.getUint8(10, true);
|
||||||
}
|
}
|
||||||
set Medicine(v) {
|
set Alchemy(v) {
|
||||||
return this._data.setUint8(10, v, true);
|
return this._data.setUint8(10, v, true);
|
||||||
}
|
}
|
||||||
get Thaumatology() {
|
/**
|
||||||
|
* collecting fish
|
||||||
|
*/
|
||||||
|
get Fishing() {
|
||||||
return this._data.getUint8(11, true);
|
return this._data.getUint8(11, true);
|
||||||
}
|
}
|
||||||
set Thaumatology(v) {
|
set Fishing(v) {
|
||||||
return this._data.setUint8(11, v, true);
|
return this._data.setUint8(11, v, true);
|
||||||
}
|
}
|
||||||
get Theology() {
|
/**
|
||||||
|
* collecting ore
|
||||||
|
*/
|
||||||
|
get Mining() {
|
||||||
return this._data.getUint8(12, true);
|
return this._data.getUint8(12, true);
|
||||||
}
|
}
|
||||||
set Theology(v) {
|
set Mining(v) {
|
||||||
return this._data.setUint8(12, v, true);
|
return this._data.setUint8(12, v, true);
|
||||||
}
|
}
|
||||||
get Fishing() {
|
/**
|
||||||
|
* woodcutting, fire-making, hunting, collecting herbs, etc.
|
||||||
|
*/
|
||||||
|
get Survival() {
|
||||||
return this._data.getUint8(13, true);
|
return this._data.getUint8(13, true);
|
||||||
}
|
}
|
||||||
set Fishing(v) {
|
set Survival(v) {
|
||||||
return this._data.setUint8(13, v, true);
|
return this._data.setUint8(13, v, true);
|
||||||
}
|
}
|
||||||
get Mining() {
|
/**
|
||||||
|
* growing plants, herbs, etc.
|
||||||
|
*/
|
||||||
|
get Gardening() {
|
||||||
return this._data.getUint8(14, true);
|
return this._data.getUint8(14, true);
|
||||||
}
|
}
|
||||||
set Mining(v) {
|
set Gardening(v) {
|
||||||
return this._data.setUint8(14, v, true);
|
return this._data.setUint8(14, v, true);
|
||||||
}
|
}
|
||||||
get Survival() {
|
/**
|
||||||
|
* will give more information when examining some objects
|
||||||
|
*/
|
||||||
|
get History() {
|
||||||
return this._data.getUint8(15, true);
|
return this._data.getUint8(15, true);
|
||||||
}
|
}
|
||||||
set Survival(v) {
|
set History(v) {
|
||||||
return this._data.setUint8(15, v, true);
|
return this._data.setUint8(15, v, true);
|
||||||
}
|
}
|
||||||
get Gardening() {
|
/**
|
||||||
return this._data.getUint8(16, true);
|
* get the struct representation of the object
|
||||||
}
|
*/
|
||||||
set Gardening(v) {
|
|
||||||
return this._data.setUint8(16, v, true);
|
|
||||||
}
|
|
||||||
get History() {
|
|
||||||
return this._data.getUint8(17, true);
|
|
||||||
}
|
|
||||||
set History(v) {
|
|
||||||
return this._data.setUint8(17, v, true);
|
|
||||||
}
|
|
||||||
get Perception() {
|
|
||||||
return this._data.getUint8(18, true);
|
|
||||||
}
|
|
||||||
set Perception(v) {
|
|
||||||
return this._data.setUint8(18, v, true);
|
|
||||||
}
|
|
||||||
sql_insert(Artisan, Metalworking, Alchemy, Engineering, Culinary, Ranged, Melee, Acrobatics, Prestidigitation, Language, Medicine, Thaumatology, Theology, Fishing, Mining, Survival, Gardening, History, Perception) {
|
|
||||||
return `INSERT INTO Skills (Artisan, Metalworking, Alchemy, Engineering, Culinary, Ranged, Melee, Acrobatics, Prestidigitation, Language, Medicine, Thaumatology, Theology, Fishing, Mining, Survival, Gardening, History, Perception) VALUES (${Artisan}, ${Metalworking}, ${Alchemy}, ${Engineering}, ${Culinary}, ${Ranged}, ${Melee}, ${Acrobatics}, ${Prestidigitation}, ${Language}, ${Medicine}, ${Thaumatology}, ${Theology}, ${Fishing}, ${Mining}, ${Survival}, ${Gardening}, ${History}, ${Perception}) RETURNING id;`
|
|
||||||
}
|
|
||||||
get bytes() {
|
get bytes() {
|
||||||
return new Uint8Array(this._ptr);
|
return new Uint8Array(this._ptr);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
constructor(init = {}, ptr = undefined) {
|
constructor(init = {}, ptr = undefined) {
|
||||||
this._size = 19;
|
this._size = 16;
|
||||||
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
this._data = new DataView(this._ptr);
|
this._data = new DataView(this._ptr);
|
||||||
|
|
||||||
|
|
|
@ -1,48 +1,60 @@
|
||||||
class Stats {
|
class Stats {
|
||||||
|
/**
|
||||||
|
* Physical attack damage + Equipment Load
|
||||||
|
*/
|
||||||
get Strength() {
|
get Strength() {
|
||||||
return this._data.getUint8(0, true);
|
return this._data.getUint8(0, true);
|
||||||
}
|
}
|
||||||
set Strength(v) {
|
set Strength(v) {
|
||||||
return this._data.setUint8(0, v, true);
|
return this._data.setUint8(0, v, true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* HP + Dmg mitigation for physical damage, how much stamina you have
|
||||||
|
*/
|
||||||
get Endurance() {
|
get Endurance() {
|
||||||
return this._data.getUint8(1, true);
|
return this._data.getUint8(1, true);
|
||||||
}
|
}
|
||||||
set Endurance(v) {
|
set Endurance(v) {
|
||||||
return this._data.setUint8(1, v, true);
|
return this._data.setUint8(1, v, true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Use/build steampunk gadgets + be able to read specific logical papers
|
||||||
|
*/
|
||||||
get Intelligence() {
|
get Intelligence() {
|
||||||
return this._data.getUint8(2, true);
|
return this._data.getUint8(2, true);
|
||||||
}
|
}
|
||||||
set Intelligence(v) {
|
set Intelligence(v) {
|
||||||
return this._data.setUint8(2, v, true);
|
return this._data.setUint8(2, v, true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Number of magic / special attack / skills you can remember at one time.
|
||||||
|
*/
|
||||||
get Wisdom() {
|
get Wisdom() {
|
||||||
return this._data.getUint8(3, true);
|
return this._data.getUint8(3, true);
|
||||||
}
|
}
|
||||||
set Wisdom(v) {
|
set Wisdom(v) {
|
||||||
return this._data.setUint8(3, v, true);
|
return this._data.setUint8(3, v, true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* how good you can talk, persuade, etc.
|
||||||
|
*/
|
||||||
get Charisma() {
|
get Charisma() {
|
||||||
return this._data.getUint8(4, true);
|
return this._data.getUint8(4, true);
|
||||||
}
|
}
|
||||||
set Charisma(v) {
|
set Charisma(v) {
|
||||||
return this._data.setUint8(4, v, true);
|
return this._data.setUint8(4, v, true);
|
||||||
}
|
}
|
||||||
get Faith() {
|
/**
|
||||||
return this._data.getUint8(5, true);
|
* get the struct representation of the object
|
||||||
}
|
*/
|
||||||
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() {
|
get bytes() {
|
||||||
return new Uint8Array(this._ptr);
|
return new Uint8Array(this._ptr);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
constructor(init = {}, ptr = undefined) {
|
constructor(init = {}, ptr = undefined) {
|
||||||
this._size = 6;
|
this._size = 5;
|
||||||
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
this._data = new DataView(this._ptr);
|
this._data = new DataView(this._ptr);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
class Vector3 {
|
||||||
|
/**
|
||||||
|
* x coordinate
|
||||||
|
*/
|
||||||
|
get x() {
|
||||||
|
return this._data.getFloat32(0, true);
|
||||||
|
}
|
||||||
|
set x(v) {
|
||||||
|
return this._data.setFloat32(0, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* y coordinate
|
||||||
|
*/
|
||||||
|
get y() {
|
||||||
|
return this._data.getFloat32(4, true);
|
||||||
|
}
|
||||||
|
set y(v) {
|
||||||
|
return this._data.setFloat32(4, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* z coordinate
|
||||||
|
*/
|
||||||
|
get z() {
|
||||||
|
return this._data.getFloat32(8, true);
|
||||||
|
}
|
||||||
|
set z(v) {
|
||||||
|
return this._data.setFloat32(8, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 12;
|
||||||
|
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 Vector3
|
|
@ -1,147 +1,219 @@
|
||||||
{
|
{
|
||||||
|
"Vector3": {
|
||||||
|
"x": {
|
||||||
|
"type": "f32",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "x coordinate"
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"type": "f32",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "y coordinate"
|
||||||
|
},
|
||||||
|
"z": {
|
||||||
|
"type": "f32",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "z coordinate"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Stats": {
|
"Stats": {
|
||||||
"Strength": {
|
"Strength": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "Physical attack damage + Equipment Load"
|
||||||
},
|
},
|
||||||
"Endurance": {
|
"Endurance": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "HP + Dmg mitigation for physical damage, how much stamina you have"
|
||||||
},
|
},
|
||||||
"Intelligence": {
|
"Intelligence": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "Use/build steampunk gadgets + be able to read specific logical papers"
|
||||||
},
|
},
|
||||||
"Wisdom": {
|
"Wisdom": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "Number of magic / special attack / skills you can remember at one time."
|
||||||
},
|
},
|
||||||
"Charisma": {
|
"Charisma": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
},
|
"comment": "how good you can talk, persuade, etc."
|
||||||
"Faith": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"HiddenStats": {
|
|
||||||
"Luck": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Stealth": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Attractiveness": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Affluence": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Notoriety": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Skills": {
|
"Skills": {
|
||||||
"Artisan": {
|
"Artisan": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
},
|
"comment": "Crafting, visual arts, etc."
|
||||||
"Metalworking": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Alchemy": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Engineering": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
},
|
||||||
"Culinary": {
|
"Culinary": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "cooking, baking, brewing, "
|
||||||
},
|
},
|
||||||
"Ranged": {
|
"Ranged": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "using guns/cannons, bows, etc."
|
||||||
},
|
},
|
||||||
"Melee": {
|
"Melee": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "using swords, hammers, pole-arms etc."
|
||||||
},
|
},
|
||||||
"Acrobatics": {
|
"Acrobatics": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "being able to contort, move, dodge, etc."
|
||||||
},
|
},
|
||||||
"Prestidigitation": {
|
"Prestidigitation": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "skullduggery, lock-picking, deceiving, slight of hand"
|
||||||
|
},
|
||||||
|
"Engineering": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": " creating and using contraptions, building houses"
|
||||||
|
},
|
||||||
|
"Metalworking": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "obvious, but in this you can also use automatic stuff"
|
||||||
},
|
},
|
||||||
"Language": {
|
"Language": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "ability to read/write a specific language"
|
||||||
},
|
},
|
||||||
"Medicine": {
|
"Medicine": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "healing hp, getting rid of diseases, etc."
|
||||||
},
|
},
|
||||||
"Thaumatology": {
|
"Alchemy": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
},
|
"comment": "Creating potions, creating alloys, creating chemicals, component based 'magic'"
|
||||||
"Theology": {
|
|
||||||
"type": "u8",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
},
|
||||||
"Fishing": {
|
"Fishing": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "collecting fish"
|
||||||
},
|
},
|
||||||
"Mining": {
|
"Mining": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "collecting ore"
|
||||||
},
|
},
|
||||||
"Survival": {
|
"Survival": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "woodcutting, fire-making, hunting, collecting herbs, etc."
|
||||||
},
|
},
|
||||||
"Gardening": {
|
"Gardening": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "growing plants, herbs, etc."
|
||||||
},
|
},
|
||||||
"History": {
|
"History": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "will give more information when examining some objects"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"DerivedStats": {
|
||||||
|
"Hitpoints": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "how many hits you can take, if it reaches 0 you ded!"
|
||||||
|
},
|
||||||
|
"Stamina": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "How many strenuous actions you can take, i.e. swinging a hammer, attacking, fishing, etc."
|
||||||
},
|
},
|
||||||
"Perception": {
|
"Perception": {
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "being able to observe some objects"
|
||||||
|
},
|
||||||
|
"Luck": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "Get better probability rolls for things that matter for rolls"
|
||||||
|
},
|
||||||
|
"Stealth": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "Probability of being discovered when hiding"
|
||||||
|
},
|
||||||
|
"Attractiveness": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "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."
|
||||||
|
},
|
||||||
|
"Affluence": {
|
||||||
|
"type": "u8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "same as attractiveness but can change with money"
|
||||||
|
},
|
||||||
|
"Holyness": {
|
||||||
|
"type": "i8",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "how attuned to the vision of Eru"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Entity": {
|
"Entity": {
|
||||||
"Name": {
|
"Name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"kind": "string",
|
"kind": "string",
|
||||||
"size": "24"
|
"size": "24",
|
||||||
|
"comment": "Name of the entity"
|
||||||
|
},
|
||||||
|
"Vector3": {
|
||||||
|
"type": "Vector3",
|
||||||
|
"kind": "struct",
|
||||||
|
"comment": "Vector3 of the entity in space"
|
||||||
},
|
},
|
||||||
"Stats": {
|
"Stats": {
|
||||||
"type": "Stats",
|
"type": "Stats",
|
||||||
"kind": "struct"
|
"kind": "struct",
|
||||||
|
"comment": "Base stats"
|
||||||
},
|
},
|
||||||
"HiddenStats": {
|
"DerivedStats": {
|
||||||
"type": "HiddenStats",
|
"type": "DerivedStats",
|
||||||
"kind": "struct"
|
"kind": "struct",
|
||||||
|
"comment": "Stats that are derived from skills and base stats"
|
||||||
},
|
},
|
||||||
"Skills": {
|
"Skills": {
|
||||||
"type": "Skills",
|
"type": "Skills",
|
||||||
"kind": "struct"
|
"kind": "struct",
|
||||||
|
"comment": "Stuff that your character can do"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Item": {
|
||||||
|
"Name": {
|
||||||
|
"type": "string",
|
||||||
|
"kind": "string",
|
||||||
|
"size": "24",
|
||||||
|
"comment": "Name of the item"
|
||||||
|
},
|
||||||
|
"BaseValue": {
|
||||||
|
"type": "i32",
|
||||||
|
"kind": "scalar",
|
||||||
|
"comment": "Default starting value of the item"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Phenomenon": {
|
||||||
|
"Name": {
|
||||||
|
"type": "string",
|
||||||
|
"kind": "string",
|
||||||
|
"size": "64",
|
||||||
|
"comment": "Name of the phenomenon"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
CREATE TABLE Stats (id INTEGER PRIMARY KEY AUTOINCREMENT, Strength INTEGER, Endurance INTEGER, Intelligence INTEGER, Wisdom INTEGER, Charisma INTEGER, Faith INTEGER);
|
CREATE TABLE Vector3 (id INTEGER PRIMARY KEY AUTOINCREMENT, x REAL, y REAL, z REAL);
|
||||||
|
|
||||||
CREATE TABLE HiddenStats (id INTEGER PRIMARY KEY AUTOINCREMENT, Luck INTEGER, Stealth INTEGER, Attractiveness INTEGER, Affluence INTEGER, Notoriety INTEGER);
|
CREATE TABLE Stats (id INTEGER PRIMARY KEY AUTOINCREMENT, Strength INTEGER, Endurance INTEGER, Intelligence INTEGER, Wisdom INTEGER, Charisma INTEGER);
|
||||||
|
|
||||||
CREATE TABLE Skills (id INTEGER PRIMARY KEY AUTOINCREMENT, Artisan INTEGER, Metalworking INTEGER, Alchemy INTEGER, Engineering INTEGER, Culinary INTEGER, Ranged INTEGER, Melee INTEGER, Acrobatics INTEGER, Prestidigitation INTEGER, Language INTEGER, Medicine INTEGER, Thaumatology INTEGER, Theology INTEGER, Fishing INTEGER, Mining INTEGER, Survival INTEGER, Gardening INTEGER, History INTEGER, Perception INTEGER);
|
CREATE TABLE Skills (id INTEGER PRIMARY KEY AUTOINCREMENT, Artisan INTEGER, Culinary INTEGER, Ranged INTEGER, Melee INTEGER, Acrobatics INTEGER, Prestidigitation INTEGER, Engineering INTEGER, Metalworking INTEGER, Language INTEGER, Medicine INTEGER, Alchemy INTEGER, Fishing INTEGER, Mining INTEGER, Survival INTEGER, Gardening INTEGER, History INTEGER);
|
||||||
|
|
||||||
CREATE TABLE Entity (id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, stats_id INTEGER, hiddenstats_id INTEGER, skills_id INTEGER
|
CREATE TABLE DerivedStats (id INTEGER PRIMARY KEY AUTOINCREMENT, Hitpoints INTEGER, Stamina INTEGER, Perception INTEGER, Luck INTEGER, Stealth INTEGER, Attractiveness INTEGER, Affluence INTEGER, Holyness INTEGER);
|
||||||
|
|
||||||
|
CREATE TABLE Entity (id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, vector3_id INTEGER, stats_id INTEGER, derivedstats_id INTEGER, skills_id INTEGER
|
||||||
|
, FOREIGN KEY(vector3_id) REFERENCES Vector3(id)
|
||||||
, FOREIGN KEY(stats_id) REFERENCES Stats(id)
|
, FOREIGN KEY(stats_id) REFERENCES Stats(id)
|
||||||
, FOREIGN KEY(hiddenstats_id) REFERENCES HiddenStats(id)
|
, FOREIGN KEY(derivedstats_id) REFERENCES DerivedStats(id)
|
||||||
, FOREIGN KEY(skills_id) REFERENCES Skills(id));
|
, FOREIGN KEY(skills_id) REFERENCES Skills(id));
|
||||||
|
|
||||||
|
CREATE TABLE Item (id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, BaseValue INTEGER);
|
||||||
|
|
||||||
|
CREATE TABLE Phenomenon (id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
class Login {
|
||||||
|
/**
|
||||||
|
* Email of the user
|
||||||
|
*/
|
||||||
|
get Email() {
|
||||||
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 256)));
|
||||||
|
}
|
||||||
|
set Email(v) {
|
||||||
|
this._data.set(this._encoder.encode(v), 0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Password of the user
|
||||||
|
*/
|
||||||
|
get Password() {
|
||||||
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(256, 320)));
|
||||||
|
}
|
||||||
|
set Password(v) {
|
||||||
|
this._data.set(this._encoder.encode(v), 256);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 320;
|
||||||
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
|
this._data = new DataView(this._ptr);
|
||||||
|
|
||||||
|
this._encoder = new TextEncoder();
|
||||||
|
this._decoder = new TextDecoder();
|
||||||
|
for (const key of Object.keys(init)) {
|
||||||
|
this[key] = init[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Login
|
|
@ -0,0 +1,32 @@
|
||||||
|
import Login from "./Login"
|
||||||
|
class LoginRequest {
|
||||||
|
/**
|
||||||
|
* user login info
|
||||||
|
*/
|
||||||
|
get Login() {
|
||||||
|
return new Login({}, new Uint8Array(this._ptr.slice(0, 320)));
|
||||||
|
}
|
||||||
|
set Login(v) {
|
||||||
|
this._data.set(v.bytes(), 0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 320;
|
||||||
|
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 LoginRequest
|
|
@ -0,0 +1,31 @@
|
||||||
|
class LoginResponse {
|
||||||
|
/**
|
||||||
|
* login was successful or not
|
||||||
|
*/
|
||||||
|
get success() {
|
||||||
|
return this._data.getInt8(0, true);
|
||||||
|
}
|
||||||
|
set success(v) {
|
||||||
|
return this._data.setInt8(0, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 1;
|
||||||
|
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 LoginResponse
|
|
@ -0,0 +1,53 @@
|
||||||
|
import Login from "./Login"
|
||||||
|
import Vector3 from "./Vector3"
|
||||||
|
class User {
|
||||||
|
/**
|
||||||
|
* Name of the user
|
||||||
|
*/
|
||||||
|
get Name() {
|
||||||
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 24)));
|
||||||
|
}
|
||||||
|
set Name(v) {
|
||||||
|
this._data.set(this._encoder.encode(v), 0);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* user login info
|
||||||
|
*/
|
||||||
|
get Login() {
|
||||||
|
return new Login({}, new Uint8Array(this._ptr.slice(24, 344)));
|
||||||
|
}
|
||||||
|
set Login(v) {
|
||||||
|
this._data.set(v.bytes(), 24);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* last logout position of user
|
||||||
|
*/
|
||||||
|
get Position() {
|
||||||
|
return new Vector3({}, new Uint8Array(this._ptr.slice(344, 356)));
|
||||||
|
}
|
||||||
|
set Position(v) {
|
||||||
|
this._data.set(v.bytes(), 344);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 356;
|
||||||
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
|
this._data = new DataView(this._ptr);
|
||||||
|
|
||||||
|
this._encoder = new TextEncoder();
|
||||||
|
this._decoder = new TextDecoder();
|
||||||
|
for (const key of Object.keys(init)) {
|
||||||
|
this[key] = init[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default User
|
|
@ -0,0 +1,49 @@
|
||||||
|
class Vector3 {
|
||||||
|
/**
|
||||||
|
* x coordinate
|
||||||
|
*/
|
||||||
|
get x() {
|
||||||
|
return this._data.getFloat32(0, true);
|
||||||
|
}
|
||||||
|
set x(v) {
|
||||||
|
return this._data.setFloat32(0, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* y coordinate
|
||||||
|
*/
|
||||||
|
get y() {
|
||||||
|
return this._data.getFloat32(4, true);
|
||||||
|
}
|
||||||
|
set y(v) {
|
||||||
|
return this._data.setFloat32(4, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* z coordinate
|
||||||
|
*/
|
||||||
|
get z() {
|
||||||
|
return this._data.getFloat32(8, true);
|
||||||
|
}
|
||||||
|
set z(v) {
|
||||||
|
return this._data.setFloat32(8, v, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
|
get bytes() {
|
||||||
|
return new Uint8Array(this._ptr);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(init = {}, ptr = undefined) {
|
||||||
|
this._size = 12;
|
||||||
|
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 Vector3
|
Binary file not shown.
|
@ -0,0 +1,25 @@
|
||||||
|
typedef struct Vector3 {
|
||||||
|
float x; // x coordinate
|
||||||
|
float y; // y coordinate
|
||||||
|
float z; // z coordinate
|
||||||
|
} Vector3;
|
||||||
|
|
||||||
|
typedef struct Login {
|
||||||
|
char Email[256]; // Email of the user
|
||||||
|
char Password[320]; // Password of the user
|
||||||
|
} Login;
|
||||||
|
|
||||||
|
typedef struct User {
|
||||||
|
char Name[24]; // Name of the user
|
||||||
|
Login Login; // user login info
|
||||||
|
Vector3 Position; // last logout position of user
|
||||||
|
} User;
|
||||||
|
|
||||||
|
typedef struct LoginRequest {
|
||||||
|
Login Login; // user login info
|
||||||
|
} LoginRequest;
|
||||||
|
|
||||||
|
typedef struct LoginResponse {
|
||||||
|
char success; // login was successful or not
|
||||||
|
} LoginResponse;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
CREATE TABLE Vector3 (id INTEGER PRIMARY KEY AUTOINCREMENT, x REAL, y REAL, z REAL);
|
||||||
|
|
||||||
|
CREATE TABLE Login (id INTEGER PRIMARY KEY AUTOINCREMENT, Email TEXT, Password TEXT);
|
||||||
|
|
||||||
|
CREATE TABLE User (id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, login_id INTEGER, position_id INTEGER
|
||||||
|
, FOREIGN KEY(login_id) REFERENCES Login(id)
|
||||||
|
, FOREIGN KEY(position_id) REFERENCES Vector3(id));
|
||||||
|
|
||||||
|
CREATE TABLE LoginRequest (id INTEGER PRIMARY KEY AUTOINCREMENT, login_id INTEGER
|
||||||
|
, FOREIGN KEY(login_id) REFERENCES Login(id));
|
||||||
|
|
||||||
|
CREATE TABLE LoginResponse (id INTEGER PRIMARY KEY AUTOINCREMENT, success INTEGER);
|
||||||
|
|
|
@ -2,168 +2,64 @@
|
||||||
"Vector3": {
|
"Vector3": {
|
||||||
"x": {
|
"x": {
|
||||||
"type": "f32",
|
"type": "f32",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "x coordinate"
|
||||||
},
|
},
|
||||||
"y": {
|
"y": {
|
||||||
"type": "f32",
|
"type": "f32",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "y coordinate"
|
||||||
},
|
},
|
||||||
"z": {
|
"z": {
|
||||||
"type": "f32",
|
"type": "f32",
|
||||||
"kind": "scalar"
|
"kind": "scalar",
|
||||||
|
"comment": "z coordinate"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Camera3D": {
|
"Login": {
|
||||||
"position": {
|
"Email": {
|
||||||
"type": "Vector3",
|
"type": "string",
|
||||||
"kind": "struct"
|
"kind": "string",
|
||||||
|
"size": "256",
|
||||||
|
"comment": "Email of the user"
|
||||||
},
|
},
|
||||||
"target": {
|
"Password": {
|
||||||
"type": "Vector3",
|
"type": "string",
|
||||||
"kind": "struct"
|
"kind": "string",
|
||||||
},
|
"size": "64",
|
||||||
"up": {
|
"comment": "Password of the user"
|
||||||
"type": "Vector3",
|
|
||||||
"kind": "struct"
|
|
||||||
},
|
|
||||||
"fovy": {
|
|
||||||
"type": "f32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"projection": {
|
|
||||||
"type": "f32",
|
|
||||||
"kind": "scalar"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Entity": {
|
"User": {
|
||||||
"Name": {
|
"Name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"kind": "string",
|
"kind": "string",
|
||||||
"size": "24"
|
"size": "24",
|
||||||
|
"comment": "Name of the user"
|
||||||
},
|
},
|
||||||
"Camera": {
|
"Login": {
|
||||||
"type": "Camera3D",
|
"type": "Login",
|
||||||
"kind": "struct"
|
"kind": "struct",
|
||||||
|
"comment": "user login info"
|
||||||
},
|
},
|
||||||
"Strength": {
|
"Position": {
|
||||||
"type": "i32",
|
"type": "Vector3",
|
||||||
"kind": "scalar"
|
"kind": "struct",
|
||||||
|
"comment": "last logout position of user"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Endurance": {
|
"LoginRequest": {
|
||||||
"type": "i32",
|
"Login": {
|
||||||
"kind": "scalar"
|
"type": "Login",
|
||||||
|
"kind": "struct",
|
||||||
|
"comment": "user login info"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"Intelligence": {
|
"LoginResponse": {
|
||||||
"type": "i32",
|
"success": {
|
||||||
"kind": "scalar"
|
"type": "i8",
|
||||||
},
|
"kind": "scalar",
|
||||||
"Wisdom": {
|
"comment": "login was successful or not"
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Charisma": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Faith": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Artisan": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Metalworking": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Alchemy": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Engineering": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Culinary": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Ranged": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Melee": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Acrobatics": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Prestidigitation": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Language": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Medicine": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Thaumatology": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Theology": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Fishing": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Mining": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Survival": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Gardening": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"History": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Perception": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Luck": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Stealth": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Attractiveness": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Affluence": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
},
|
|
||||||
"Notoriety": {
|
|
||||||
"type": "i32",
|
|
||||||
"kind": "scalar"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { $ } from "bun";
|
import { $ } from "bun";
|
||||||
|
|
||||||
await $`bun run ../transpile.js -S schema.json -j out/ -c out/ -s out/`;
|
await $`bun run ../transpile.js -S schema.json -j build/ -c build/ -s build/`;
|
||||||
await $`rm -rf out/test.db`;
|
await $`rm -rf build/test.db`;
|
||||||
await $`sqlite3 out/test.db < out/types.sql`;
|
await $`sqlite3 build/test.db < build/types.sql`;
|
||||||
const vid1 = await $`echo 'INSERT INTO Vector3 (x, y, z) VALUES (-9.0, 9.0, 4.0) RETURNING id;' | sqlite3 out/test.db`.text();
|
// const vid1 = await $`echo 'INSERT INTO Vector3 (x, y, z) VALUES (-9.0, 9.0, 4.0) RETURNING id;' | sqlite3 build/test.db`.text();
|
||||||
const vid2 = await $`echo 'INSERT INTO Vector3 (x, y, z) VALUES (9.0, 9.0, 0.0) RETURNING id;' | sqlite3 out/test.db`.text();
|
// const vid2 = await $`echo 'INSERT INTO Vector3 (x, y, z) VALUES (9.0, 9.0, 0.0) RETURNING id;' | sqlite3 build/test.db`.text();
|
||||||
const vid3 = await $`echo 'INSERT INTO Vector3 (x, y, z) VALUES (0.0, 1.0, 0.0) RETURNING id;' | sqlite3 out/test.db`.text();
|
// const vid3 = await $`echo 'INSERT INTO Vector3 (x, y, z) VALUES (0.0, 1.0, 0.0) RETURNING id;' | sqlite3 build/test.db`.text();
|
||||||
const cid = await $`echo 'INSERT INTO Camera3D (position_id, target_id, up_id, fovy, projection) VALUES (${vid1}, ${vid2}, ${vid3}, 60.0, 0) RETURNING id;' | sqlite3 out/test.db`.text();
|
// const cid = await $`echo 'INSERT INTO Camera3D (position_id, target_id, up_id, fovy, projection) VALUES (${vid1}, ${vid2}, ${vid3}, 60.0, 0) RETURNING id;' | sqlite3 build/test.db`.text();
|
||||||
const eid = await $`echo "INSERT INTO Entity (Name, camera_id, Strength, Endurance, Intelligence, Wisdom, Charisma, Faith, Artisan, Metalworking, Alchemy, Engineering, Culinary, Ranged, Melee, Acrobatics, Prestidigitation, Language, Medicine, Thaumatology, Theology, Fishing, Mining, Survival, Gardening, History, Perception, Luck, Stealth, Attractiveness, Affluence, Notoriety) VALUES ('Zongor',${cid},1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,42,1,1,1,1) RETURNING id;" | sqlite3 out/test.db`.text();
|
// const eid = await $`echo "INSERT INTO Entity (Name, camera_id, Strength, Endurance, Intelligence, Wisdom, Charisma, Faith, Artisan, Metalworking, Alchemy, Engineering, Culinary, Ranged, Melee, Acrobatics, Prestidigitation, Language, Medicine, Thaumatology, Theology, Fishing, Mining, Survival, Gardening, History, Perception, Luck, Stealth, Attractiveness, Affluence, Notoriety) VALUES ('Zongor',${cid},1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,42,1,1,1,1) RETURNING id;" | sqlite3 build/test.db`.text();
|
||||||
console.log(`generated Entity=${eid} Camera3D=${cid} Vector3=${vid1} Vector3=${vid2} Vector3=${vid3}`);
|
// console.log(`generated Entity=${eid} Camera3D=${cid} Vector3=${vid1} Vector3=${vid2} Vector3=${vid3}`);
|
||||||
|
|
|
@ -87,9 +87,15 @@ const { values } = parseArgs({
|
||||||
|
|
||||||
function jsStructConstructor(size, containsString) {
|
function jsStructConstructor(size, containsString) {
|
||||||
return `
|
return `
|
||||||
|
/**
|
||||||
|
* get the struct representation of the object
|
||||||
|
*/
|
||||||
get bytes() {
|
get bytes() {
|
||||||
return new Uint8Array(this._ptr);
|
return new Uint8Array(this._ptr);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
constructor(init = {}, ptr = undefined) {
|
constructor(init = {}, ptr = undefined) {
|
||||||
this._size = ${size};
|
this._size = ${size};
|
||||||
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||||||
|
@ -126,6 +132,7 @@ for (const type of Object.keys(schema)) {
|
||||||
for (const prop of Object.keys(props)) {
|
for (const prop of Object.keys(props)) {
|
||||||
const propType = props[prop].type;
|
const propType = props[prop].type;
|
||||||
const kind = props[prop].kind;
|
const kind = props[prop].kind;
|
||||||
|
const comment = props[prop].comment;
|
||||||
let typeSize = parseInt(types[propType]?.size);
|
let typeSize = parseInt(types[propType]?.size);
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
@ -134,6 +141,9 @@ for (const type of Object.keys(schema)) {
|
||||||
typeSize = props[prop].size;
|
typeSize = props[prop].size;
|
||||||
const iSize = parseInt(offset) + parseInt(typeSize);
|
const iSize = parseInt(offset) + parseInt(typeSize);
|
||||||
jsData += `
|
jsData += `
|
||||||
|
${(comment) ? `/**
|
||||||
|
* ${comment}
|
||||||
|
*/` : ""}
|
||||||
get ${prop}() {
|
get ${prop}() {
|
||||||
return this._decoder.decode(new Uint8Array(this._ptr.slice(${parseInt(
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(${parseInt(
|
||||||
offset
|
offset
|
||||||
|
@ -144,11 +154,14 @@ for (const type of Object.keys(schema)) {
|
||||||
}`;
|
}`;
|
||||||
sqlData += `, ${prop} TEXT`;
|
sqlData += `, ${prop} TEXT`;
|
||||||
cData += `
|
cData += `
|
||||||
char ${prop}[${iSize}];`;
|
char ${prop}[${iSize}]; // ${comment}`;
|
||||||
break;
|
break;
|
||||||
case "scalar":
|
case "scalar":
|
||||||
typeSize = types[propType].size;
|
typeSize = types[propType].size;
|
||||||
jsData += `
|
jsData += `
|
||||||
|
${(comment) ? `/**
|
||||||
|
* ${comment}
|
||||||
|
*/` : ""}
|
||||||
get ${prop}() {
|
get ${prop}() {
|
||||||
return this._data.get${types[propType].js}(${parseInt(offset)}, true);
|
return this._data.get${types[propType].js}(${parseInt(offset)}, true);
|
||||||
}
|
}
|
||||||
|
@ -159,19 +172,22 @@ for (const type of Object.keys(schema)) {
|
||||||
}`;
|
}`;
|
||||||
sqlData += `, ${prop} ${types[propType].sql}`;
|
sqlData += `, ${prop} ${types[propType].sql}`;
|
||||||
cData += `
|
cData += `
|
||||||
${types[propType].c} ${prop};`;
|
${types[propType].c} ${prop}; // ${comment}`;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "struct":
|
case "struct":
|
||||||
const jsSize = parseInt(offset) + parseInt(types[propType].size);
|
const jsSize = parseInt(offset) + parseInt(types[propType].size);
|
||||||
jsData += `
|
jsData += `
|
||||||
|
${(comment) ? `/**
|
||||||
|
* ${comment}
|
||||||
|
*/` : ""}
|
||||||
get ${prop}() {
|
get ${prop}() {
|
||||||
return new ${propType}({}, new Uint8Array(this._ptr.slice(${offset}, ${jsSize})));
|
return new ${propType}({}, new Uint8Array(this._ptr.slice(${offset}, ${jsSize})));
|
||||||
}
|
}
|
||||||
set ${prop}(v) {
|
set ${prop}(v) {
|
||||||
this._data.set(v.bytes(), ${offset});
|
this._data.set(v.bytes(), ${offset});
|
||||||
}`;
|
}`;
|
||||||
const importS = `import ${propType} from "./${propType}"\n\n`;
|
const importS = `import ${propType} from "./${propType}"\n`;
|
||||||
if (!importStatements.includes(importS)) {
|
if (!importStatements.includes(importS)) {
|
||||||
importStatements += importS;
|
importStatements += importS;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +195,7 @@ for (const type of Object.keys(schema)) {
|
||||||
|
|
||||||
sqlData += `, ${localKey} INTEGER`;
|
sqlData += `, ${localKey} INTEGER`;
|
||||||
foreignKeys += `\n, FOREIGN KEY(${localKey}) REFERENCES ${propType}(id)`
|
foreignKeys += `\n, FOREIGN KEY(${localKey}) REFERENCES ${propType}(id)`
|
||||||
cData += `\n\t\t${types[propType].c} ${prop};`;
|
cData += `\n\t\t${types[propType].c} ${prop}; // ${comment}`;
|
||||||
break;
|
break;
|
||||||
case "array":
|
case "array":
|
||||||
throw new Error("Not Implemented!");
|
throw new Error("Not Implemented!");
|
||||||
|
|
Loading…
Reference in New Issue