From 1ee895ab42a0418ce87d184526e7e7936e82ffe4 Mon Sep 17 00:00:00 2001 From: Peaceultime Date: Sat, 26 Apr 2025 15:49:52 +0200 Subject: [PATCH] Add Health, mana and armor editing --- db.sqlite | Bin 614400 -> 614400 bytes db.sqlite-shm | Bin 32768 -> 32768 bytes db.sqlite-wal | Bin 65952 -> 119512 bytes db/schema.ts | 1 + drizzle/0008_glorious_johnny_blaze.sql | 1 + drizzle/meta/0008_snapshot.json | 426 +++++++++++++++++++++++ drizzle/meta/_journal.json | 7 + pages/character/[id]/index.client.vue | 28 +- server/api/character/[id]/values.get.ts | 34 ++ server/api/character/[id]/values.post.ts | 42 +++ shared/character-config.json | 2 +- types/character.ts | 6 + 12 files changed, 544 insertions(+), 3 deletions(-) create mode 100644 drizzle/0008_glorious_johnny_blaze.sql create mode 100644 drizzle/meta/0008_snapshot.json create mode 100644 server/api/character/[id]/values.get.ts create mode 100644 server/api/character/[id]/values.post.ts diff --git a/db.sqlite b/db.sqlite index a54e85a647212879390aac2586e7de7c2f79f64d..4d0ba03a4585f085c155bb11bf12d20a7d328c15 100644 GIT binary patch delta 303 zcmZoTpxSUib%L~@G6Ms{G$1YqVs0Roo~UEYqs*Y!rpe2#${@(>F)>?-(PLxZE+(!f zHwkued3nZ`=*i{GN2C=J$`W%*Q;QQ6N>VFI6kJ^097BCV6x6G0)hBDSCv2X`Qp_#J z$?MI)znMRcUy|<(Up=1@?^E6xyxyA?1q^w8y*XJK8hKeQ%*`y*ER&4P5>3+#EKDrS zEX|E9QVbH)(u_^b%nVbKEzHxB6Ae-fOw&@*Ow7zvQxZ*543bikfQl21l2RC_6@|Tz z-aJD#he?c+{|W>DAO7$BpZMSMzutIF*6Xe05K~NvjH*t_W$)9j1K@@0A9HO delta 203 zcmZoTpxSUib%L~@5(5LnG$1YqVs0Rony6#Uqr{-srpe2#${@&`J26{{F?VC%E~d%u zERtePx)SW-+S-gQf+dMfia@r!Jdiy(i22B58)lx(?ksz`ML2k8Fz|2YPve*5JHuDc zXTS|H_-}3&EI7!&`KG>rJ~P)k pqs?#P1QbDx=KuBW|LYlnm diff --git a/db.sqlite-shm b/db.sqlite-shm index 8a02d293f75accd0aa5b4e2736b53e9042e50307..4d88cd7712a2b1c87f0f1de879e94159c845149c 100644 GIT binary patch delta 246 zcmZo@U}|V!s+V}A%K!qhK+MR%AONDL0kQPKZLelOt^fM5=yh4}Y3JHwPd^+tf2LPS zs(PSNU;r}rKN5fnPpp?@)STFBEvpF>U;|qepDaFEmg#6eg2=>+}W}{j>oG+OU)(D29T;A zXcQQL%>9o9pu!XDB`2=Yn7D>xfrEjIfro*QK>#Sor~v?9MKbRI diff --git a/db.sqlite-wal b/db.sqlite-wal index 41c926cc92212ef2e5cd6c5abcf8c17861c70c2d..ac14c9dd186ae4d88ee0a51e5cd2a30eb177f934 100644 GIT binary patch literal 119512 zcmeI5eT*Ds9mj`jdoR%5A^gLO#AUD^G&Aka?(ADZ4cADUmZXFp2tAH4JNxYJ^!8>h zGqY#wc>*=KV5HQfLI_l1gfylaVj!XkRw0Ijl0bw+6G0OZq5?)<;tR$Yf6p`fez&t{ z(!H|fd&%{==jrqO=6OE9-}ADQ-|yMf?Sls;_4NxR>0F8byyw0>zvqQ*i@RQ)Uwg-Y zFZd4?4bt!ZwemNQeEMr&mU7o`pu*wN!_wHxV~>u_kL?({X!M=Y!=opt7(XBY0w4ea zAOHd&00JNY0w4eaAkZ@c%JAA7M%Lz%sa!gl*41=^>8c*fYid?c#Z)6<#8@ty$Y%9; zap)(vDI>hLnMubrBcD>Wbe5^Qk;$tDGvjJB8cXI4GntC#^2POk+@}ok+R3<M9%_Q=sYU(M2#bWVTF3pPT{`S1Gj@M@Cys4R)q-v%TIaSxGVmfZ>YBZsx zVp=?wO{R0jb%Qr6YkBQ_IvQi~SX?zyDMQuMnYfzGYlfOMQrT>rMNJw>aow5|${Jof zYZ}>PJe5{s=}bb^vk5~@C-tbB&+7S1Je$oVbc1R?s0;|%(YQ_!GHNWT$7z&lre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AdaA896_a2iyhd5*a5^2Aa;O9FUmdtp6#CBB+!T*;NN3D z>$vh(EfGC);|MPPM*h}I?tAt%#1Zu5Ln?%V00@8p2!H?xfB*=900@8p2y`LP!#INL z5J%8Gj^M2yKXdWlZ-4V4#1V8cRQxvxfB*=900@8p2!H?xfB*=900{I0fzUXD>n{Hv D)A1a@ delta 559 zcmcbylzl-ni-mbTTN8usBMAlu0R|8_|IcjhY}p>iB00uK*%QAj0fpFrcp6NcGs|>m zYw8z<%^Lz<@-cI*3)ws;UWQQsCM}WPc}nF|Y3Swvfj|5*Kxqwh1Dx!RcDAii<%b!N zi)sL`)3heR_$3=)2IOKGu=s-C%A+q`p1};LL^VLfAdV|s`NwCN0hJgA+*D8C0Ypa;W%EldSB=V-dVff=v~)qvLi%&wewnT9X}HenbbcJAp* zp<9<`Lk(E3hHAjKZM;p_ezvcH8n9js!+^V7DV}<)RYEWWj8P4^+!y2Z&@_!7W`Hq< i0eTA6KbP0u6NDMyfocGET>T?!&LSzW0W4hWJv0D6xY?)x diff --git a/db/schema.ts b/db/schema.ts index 701220c..8ae7185 100644 --- a/db/schema.ts +++ b/db/schema.ts @@ -58,6 +58,7 @@ export const characterTable = sqliteTable("character", { name: text().notNull(), owner: int().notNull().references(() => usersTable.id, { onDelete: 'cascade', onUpdate: 'cascade' }), progress: text({ mode: 'json' }).notNull(), + values: text({ mode: 'json' }).notNull().default({}), thumbnail: blob(), }) diff --git a/drizzle/0008_glorious_johnny_blaze.sql b/drizzle/0008_glorious_johnny_blaze.sql new file mode 100644 index 0000000..a7d49af --- /dev/null +++ b/drizzle/0008_glorious_johnny_blaze.sql @@ -0,0 +1 @@ +ALTER TABLE `character` ADD `values` text DEFAULT '{}' NOT NULL; \ No newline at end of file diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json new file mode 100644 index 0000000..9701091 --- /dev/null +++ b/drizzle/meta/0008_snapshot.json @@ -0,0 +1,426 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "eb68cf2f-c7e2-4111-910d-a26b0fc438cc", + "prevId": "15ea15e0-3d44-4dff-a4cd-f8666c4aa5ed", + "tables": { + "character": { + "name": "character", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "progress": { + "name": "progress", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "values": { + "name": "values", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "thumbnail": { + "name": "thumbnail", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "character_owner_users_id_fk": { + "name": "character_owner_users_id_fk", + "tableFrom": "character", + "tableTo": "users", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "email_validation": { + "name": "email_validation", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "timestamp": { + "name": "timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "explorer_content": { + "name": "explorer_content", + "columns": { + "path": { + "name": "path", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "navigable": { + "name": "navigable", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "private": { + "name": "private", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visit": { + "name": "visit", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "timestamp": { + "name": "timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "explorer_content_owner_users_id_fk": { + "name": "explorer_content_owner_users_id_fk", + "tableFrom": "explorer_content", + "tableTo": "users", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_permissions": { + "name": "user_permissions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_permissions_id_users_id_fk": { + "name": "user_permissions_id_users_id_fk", + "tableFrom": "user_permissions", + "tableTo": "users", + "columnsFrom": [ + "id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": { + "user_permissions_id_permission_pk": { + "columns": [ + "id", + "permission" + ], + "name": "user_permissions_id_permission_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_sessions": { + "name": "user_sessions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timestamp": { + "name": "timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_sessions_user_id_users_id_fk": { + "name": "user_sessions_user_id_users_id_fk", + "tableFrom": "user_sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": { + "user_sessions_id_user_id_pk": { + "columns": [ + "id", + "user_id" + ], + "name": "user_sessions_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users_data": { + "name": "users_data", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "signin": { + "name": "signin", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "lastTimestamp": { + "name": "lastTimestamp", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "logCount": { + "name": "logCount", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "users_data_id_users_id_fk": { + "name": "users_data_id_users_id_fk", + "tableFrom": "users_data", + "tableTo": "users", + "columnsFrom": [ + "id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "users_username_unique": { + "name": "users_username_unique", + "columns": [ + "username" + ], + "isUnique": true + }, + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + }, + "users_hash_unique": { + "name": "users_hash_unique", + "columns": [ + "hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index a0f492a..9d1f110 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -57,6 +57,13 @@ "when": 1745074613379, "tag": "0007_tearful_true_believers", "breakpoints": true + }, + { + "idx": 8, + "version": "6", + "when": 1745675022171, + "tag": "0008_glorious_johnny_blaze", + "breakpoints": true } ] } \ No newline at end of file diff --git a/pages/character/[id]/index.client.vue b/pages/character/[id]/index.client.vue index b591e15..9eda723 100644 --- a/pages/character/[id]/index.client.vue +++ b/pages/character/[id]/index.client.vue @@ -9,7 +9,21 @@ const characterConfig = config as CharacterConfig; const id = useRouter().currentRoute.value.params.id; const { user } = useUserSession(); +const { add } = useToast(); + const { data: character, status, error } = await useAsyncData(() => useRequestFetch()(`/api/character/${id}/compiled`)); +const { data: values } = await useAsyncData(() => useRequestFetch()(`/api/character/${id}/values`)); + +async function updateValues() +{ + await useRequestFetch()(`/api/character/${id}/values`, { + method: "post", + body: values.value, + onResponseError: (e) => { + add({ duration: 25000, timer: true, type: "success", title: "Erreur", content: e.response.statusText }); + } + }); +}