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 World create with db

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

Overview

Concrete tool for creating a World domain instance with SQLite-backed event persistence, provided by the Cultivation World Simulator core domain model.

Description

The World.create_with_db classmethod is a factory that instantiates a `World` dataclass with all its sub-managers: `EventManager` (backed by SQLite), `AvatarManager`, `DeceasedManager`, `MortalManager`, `POIManager`, and `RankingManager`. It also initializes the tournament/ranking system time.

This is the primary way to create a new world during game initialization.

Usage

Import and call this classmethod when:

  • Game initialization: creating a new world from a loaded map and start time
  • Test setup: creating a minimal world for unit tests (with a temporary SQLite path)

Code Reference

Source Location

Signature

@classmethod
def create_with_db(
    cls,
    map: "Map",
    month_stamp: MonthStamp,
    events_db_path: Path,
    start_year: int = 0,
) -> "World":
    """
    工厂方法:创建使用 SQLite 持久化事件的 World 实例。

    Args:
        map: 地图对象。
        month_stamp: 时间戳。
        events_db_path: 事件数据库文件路径。
        start_year: 世界开始年份。

    Returns:
        配置好的 World 实例。
    """

Import

from src.classes.core.world import World

I/O Contract

Inputs

Name Type Required Description
map Map Yes Game map instance with regions and tiles
month_stamp MonthStamp Yes Starting time stamp (year + month)
events_db_path Path Yes SQLite database path for event persistence
start_year int No World start year (default 0)

Outputs

Name Type Description
return World Fully initialized World with event_manager, avatar_manager, deceased_manager, mortal_manager, poi_manager, ranking_manager

Usage Examples

Create World for New Game

from src.classes.core.world import World
from src.systems.time import MonthStamp, Year, Month

game_map = load_cultivation_world_map("classic")
events_db_path = save_path.with_name(save_path.stem + "_events.db")

world = World.create_with_db(
    map=game_map,
    month_stamp=MonthStamp(Year(100), Month.JANUARY),
    events_db_path=events_db_path,
    start_year=100,
)

Related Pages

Implements Principle

Required Environments

Page Connections

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