Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:4thfever Cultivation world simulator load game

From Leeroopedia
Knowledge Sources
Domains Persistence, Save_Load
Last Updated 2026-10-22 14:00 GMT

Overview

Concrete tool for loading game state from a JSON save file through section-based deserialization, provided by the Cultivation World Simulator load system.

Description

The load_game function reads a JSON save file, creates a `LoadContext`, and calls `restore_loaded_game(context)` which iterates 8 ordered load sections (RunConfig, WorldCore, SectRuntime, Avatars, RegionRuntime, Membership, Events, Simulator) to reconstruct the world, simulator, and existed sects.

Supporting functions: get_events_db_path (derives SQLite path from save path), check_save_compatibility (currently always returns True in dev phase).

Usage

Import and call this function when:

  • Load game: called by `load_game_into_runtime` in the control service
  • Testing: called directly with a save path to verify load logic

Code Reference

Source Location

Signature

def load_game(save_path: Optional[Path] = None) -> Tuple["World", "Simulator", List["Sect"]]:
    """Load game state from a JSON save file."""

def get_events_db_path(save_path: Path) -> Path:
    """Derive SQLite events DB path from save path (e.g., save.json -> save_events.db)."""

def check_save_compatibility(save_path: Path) -> Tuple[bool, str]:
    """Check save compatibility. Currently always True (dev phase)."""

Import

from src.sim.load.load_game import load_game, get_events_db_path, check_save_compatibility

I/O Contract

Inputs

Name Type Required Description
save_path None No Save file path (default: saves_dir / "save.json")

Outputs

Name Type Description
return tuple[World, Simulator, list[Sect]] Reconstructed game state

Usage Examples

Load a Save File

from src.sim.load.load_game import load_game
from pathlib import Path

world, sim, existed_sects = load_game(Path("saves/save_20260101_120000.json"))
print(f"Loaded {len(world.avatar_manager.avatars)} avatars")

Related Pages

Implements Principle

Required Environments

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment