magpie-digital-pet 1.1.1 → 1.2.1

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/README.md CHANGED
@@ -154,9 +154,9 @@ inMagpieOnly = 有 agent && 没有 main
154
154
 
155
155
  | 档位 | 时长 | 数据碎片 | 亲密 | 消耗精力 |
156
156
  |---|---|---|---|---|
157
- | 短巡逻 patrol | 5 分钟 | **4** | **+3** | 10(需要精力 ≥ 15) |
158
- | 数据原野 field | 15 分钟 | **10** | **+4** | 10(同上) |
159
- | 深夜远征 night | 30 分钟 | **18** | **+5** | 10(同上) |
157
+ | 短巡逻 patrol | 5 分钟 | **5** | **+3** | 10(需要精力 ≥ 15) |
158
+ | 数据原野 field | 15 分钟 | **11** | **+4** | 10(同上) |
159
+ | 深夜远征 night | 30 分钟 | **19** | **+5** | 10(同上) |
160
160
 
161
161
  一次只能进行一场探险;结算时随机附一句见闻,并计入「探险 1 次」的每日目标。
162
162
 
@@ -164,15 +164,15 @@ inMagpieOnly = 有 agent && 没有 main
164
164
 
165
165
  | 目标 | 条件 | 奖励 |
166
166
  |---|---|---|
167
- | 照顾 | 当天照顾 2 次 | **4 碎片** |
168
- | 探险 | 当天完成 1 次探险 | **6 碎片** |
169
- | 投喂 | 当天自动吃掉 10 个请求 | **4 碎片** |
167
+ | 照顾 | 当天照顾 2 次 | **5 碎片** |
168
+ | 探险 | 当天完成 1 次探险 | **7 碎片** |
169
+ | 投喂 | 当天自动吃掉 10 个请求 | **5 碎片** |
170
170
 
171
171
  ### 数据碎片
172
172
 
173
- - **每天最多赚 240 片**(探险 + 每日目标合计),北京时间 0 点按本地日期重置;花掉的碎片不占额度。
173
+ - **每天最多赚 260 片**(探险 + 每日目标合计),北京时间 0 点按本地日期重置;花掉的碎片不占额度。
174
174
  - 到顶后再结算探险,实发 0,提示里会写「今日碎片已达上限」。
175
- - 页面「收藏与装饰」里显示 `数据碎片:N(今日 X / 240)`。
175
+ - 页面「收藏与装饰」里显示 `数据碎片:N(今日 X / 260)`。
176
176
 
177
177
  ### 装饰背景(十五套)
178
178
 
@@ -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
- if (!row) return 1;
189
- const decayed = decayCareState(
190
- {
191
- partnerId: row.partner_id,
192
- satiety: row.satiety,
193
- mood: row.mood,
194
- energy: row.energy,
195
- hygiene: row.hygiene,
196
- bond: row.bond,
197
- cooldowns: {
198
- snack: row.cooldown_snack ?? 0,
199
- play: row.cooldown_play ?? 0,
200
- clean: row.cooldown_clean ?? 0,
201
- rest: row.cooldown_rest ?? 0,
202
- petEgg: row.cooldown_pet_egg ?? 0,
203
- pet: row.cooldown_pet ?? 0,
204
- },
205
- burstUses: {
206
- snack: row.snack_burst_used ?? 0,
207
- play: row.play_burst_used ?? 0,
208
- },
209
- lastDecayAt: row.last_decay_at,
210
- updatedAt: row.updated_at,
211
- },
212
- Date.now(),
213
- );
214
- return evaluatePetStatuses(decayed).xpMultiplier;
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
  }