magpie-digital-pet 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/pet.adapter.mjs +43 -28
- package/lib/pet.care-rules.mjs +714 -22
- package/lib/pet.care-store.mjs +363 -12
- package/lib/pet.server.mjs +106 -5
- package/package.json +1 -1
- package/page/app.css +289 -0
- package/page/app.html +7 -4
- package/page/app.js +512 -41
- package/page/props/brick-stand.png +0 -0
- package/page/props/charge-dock.png +0 -0
- package/page/props/digi-monument.png +0 -0
- package/page/props/gravity-chamber.png +0 -0
- package/page/props/training-bag.png +0 -0
package/lib/pet.adapter.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import { fileURLToPath } from "node:url";
|
|
|
24
24
|
import { Database } from "bun:sqlite";
|
|
25
25
|
import { plugin as createOpenCodePetPlugin, DIGIMON_DATA } from "@jcendal/opencode-digital-pet";
|
|
26
26
|
import { DIFFICULTY_KNOWN } from "./pet.care-store.mjs";
|
|
27
|
-
import { decayCareState, evaluatePetStatuses } from "./pet.care-rules.mjs";
|
|
27
|
+
import { createDefaultCareState, decayCareState, evaluatePetStatuses } from "./pet.care-rules.mjs";
|
|
28
28
|
|
|
29
29
|
export { DIGIMON_DATA };
|
|
30
30
|
|
|
@@ -185,33 +185,48 @@ export function createPetAdapter({ databasePath, dbPath, notifyGate } = {}) {
|
|
|
185
185
|
const row = roDb
|
|
186
186
|
.query("SELECT * FROM magpie_pet_care_state WHERE partner_id = ?")
|
|
187
187
|
.get(partner.partner_id);
|
|
188
|
-
|
|
189
|
-
const decayed =
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
188
|
+
const nowMs = Date.now();
|
|
189
|
+
const decayed = row
|
|
190
|
+
? decayCareState(
|
|
191
|
+
{
|
|
192
|
+
partnerId: row.partner_id,
|
|
193
|
+
satiety: row.satiety,
|
|
194
|
+
mood: row.mood,
|
|
195
|
+
energy: row.energy,
|
|
196
|
+
hygiene: row.hygiene,
|
|
197
|
+
bond: row.bond,
|
|
198
|
+
cooldowns: {
|
|
199
|
+
snack: row.cooldown_snack ?? 0,
|
|
200
|
+
play: row.cooldown_play ?? 0,
|
|
201
|
+
clean: row.cooldown_clean ?? 0,
|
|
202
|
+
rest: row.cooldown_rest ?? 0,
|
|
203
|
+
petEgg: row.cooldown_pet_egg ?? 0,
|
|
204
|
+
pet: row.cooldown_pet ?? 0,
|
|
205
|
+
},
|
|
206
|
+
burstUses: {
|
|
207
|
+
snack: row.snack_burst_used ?? 0,
|
|
208
|
+
play: row.play_burst_used ?? 0,
|
|
209
|
+
},
|
|
210
|
+
lastDecayAt: row.last_decay_at,
|
|
211
|
+
updatedAt: row.updated_at,
|
|
212
|
+
},
|
|
213
|
+
nowMs,
|
|
214
|
+
)
|
|
215
|
+
: createDefaultCareState(partner.partner_id, nowMs);
|
|
216
|
+
let activeBuffs = [];
|
|
217
|
+
try {
|
|
218
|
+
activeBuffs = roDb
|
|
219
|
+
.query(
|
|
220
|
+
`SELECT buff_id AS id, label, xp_multiplier AS xpMultiplier,
|
|
221
|
+
expedition_bonus AS expeditionBonus, tip, granted_at AS grantedAt, expires_at AS expiresAt
|
|
222
|
+
FROM magpie_pet_buffs
|
|
223
|
+
WHERE partner_id = ? AND expires_at > ?`,
|
|
224
|
+
)
|
|
225
|
+
.all(partner.partner_id, nowMs);
|
|
226
|
+
} catch {
|
|
227
|
+
activeBuffs = [];
|
|
228
|
+
}
|
|
229
|
+
return evaluatePetStatuses(decayed, activeBuffs, nowMs).xpMultiplier;
|
|
215
230
|
} catch {
|
|
216
231
|
return 1;
|
|
217
232
|
}
|