summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Kernel/WorldSave.fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Kernel/WorldSave.fs')
-rw-r--r--src/LivingVillage.Kernel/WorldSave.fs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/LivingVillage.Kernel/WorldSave.fs b/src/LivingVillage.Kernel/WorldSave.fs
index 3e11810..29c8d18 100644
--- a/src/LivingVillage.Kernel/WorldSave.fs
+++ b/src/LivingVillage.Kernel/WorldSave.fs
@@ -617,6 +617,11 @@ module WorldSave =
| Some task -> writeDailyTask tokens task
| None -> ()
writeBackpack tokens state.Backpack
+ // P55:连续完成天数仅在 > 0 时写入尾段,旧 v3(无此段)读回默认 0,
+ // 且缺省(无 streak)存档的文本布局与 P51/P52 完全一致。
+ if state.Streak > 0 then
+ add tokens "streak"
+ addInt tokens state.Streak
| None -> ()
String.Join("|", tokens)
@@ -660,7 +665,8 @@ module WorldSave =
TaskToken = task
Today = None
StoryStage = stage
- Backpack = (Occupation.profileOf kind).InitialInventory })
+ Backpack = (Occupation.profileOf kind).InitialInventory
+ Streak = 0 })
| _ -> ()
let tick = readInt64 reader "tick"
let time = readFloat reader "time"
@@ -679,20 +685,24 @@ module WorldSave =
let tail =
let mutable task : Occupation.DailyTask option = None
let mutable backpack : (ItemKind * int) list option = None
+ let mutable streak = 0
while reader.Remaining > 0 do
match reader.Take("occupation.tail") with
| "task-today" -> task <- Some(readDailyTask reader)
| "backpack" -> backpack <- Some(readBackpack reader)
+ | "streak" -> streak <- readInt reader "occupation.streak"
| _ -> invalid "trailing save data"
- task, backpack
+ task, backpack, streak
+ let tailTask, tailBackpack, tailStreak = tail
if reader.Remaining <> 0 then
invalid "trailing save data"
let occupation =
occupationOption
|> Option.map (fun state ->
{ state with
- Today = fst tail
- Backpack = snd tail |> Option.defaultValue state.Backpack })
+ Today = tailTask
+ Backpack = tailBackpack |> Option.defaultValue state.Backpack
+ Streak = tailStreak })
Ok
({ Tick = tick
Time = time