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 Event

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

Overview

Concrete tool for representing and persisting game events with factual/story distinction, related entities, and render metadata, provided by the Cultivation World Simulator event system.

Description

The Event dataclass is the universal event record in the simulation. Every gameplay occurrence—combat, cultivation, social interaction, story expansion, world phenomenon—produces an `Event` instance.

Key fields:

  • is_major: True for major/long-term-memory events (milestones, deaths, breakthroughs); False for minor/short-term
  • is_story: True for LLM-expanded narrative text; story events are excluded from memory indexing and never use `is_major=True`
  • event_type: machine-readable type string for propagation and rendering (e.g., "battle_kill", "bond_lovers_formed")
  • render_key / render_params: for frontend-localized rendering
  • related_avatars / related_sects: ID lists for filtering
  • subject_snapshots: name snapshots for display after entity deletion
  • observations: runtime-mounted observation objects persisted by EventManager

The `NullEvent` singleton and `is_null_event` helper provide a falsy placeholder.

Usage

Import and use this class when:

  • Producing events: gameplay systems create `Event(month_stamp, content, related_avatars, is_major, is_story, event_type)`
  • Story events: `StoryEventService` creates events with `is_story=True`
  • Serialization: `Event.to_dict()` and `Event.from_dict()` for save/load
  • Display: `str(event)` returns `"{date}: {content}"`

Code Reference

Source Location

Signature

@dataclass
class Event:
    month_stamp: MonthStamp
    content: str
    related_avatars: Optional[List[str]] = None
    related_sects: Optional[List[int]] = None
    is_major: bool = False
    is_story: bool = False
    event_type: str = ""
    render_key: Optional[str] = None
    render_params: Optional[dict[str, Any]] = None
    subject_snapshots: dict[str, str] = field(default_factory=dict)
    id: str = field(default_factory=lambda: str(uuid.uuid4()))
    created_at: float = field(default_factory=time.time)
    observations: List["EventObservation"] = field(default_factory=list, repr=False, compare=False)

    def to_dict(self) -> dict: ...
    @classmethod
    def from_dict(cls, data: dict) -> "Event": ...

class NullEvent:
    """Falsy singleton placeholder for events."""
    ...

NULL_EVENT = NullEvent()
def is_null_event(event) -> bool: ...

Import

from src.classes.event import Event, NULL_EVENT, is_null_event

I/O Contract

Inputs (constructor)

Name Type Required Description
month_stamp MonthStamp Yes When the event occurred
content str Yes Event text (factual or story)
related_avatars None No Related avatar IDs
is_major bool No Long-term memory flag (default False)
is_story bool No LLM narrative flag (default False)
event_type str No Machine-readable type (default "")

Outputs

Name Type Description
to_dict return dict JSON-serializable dict
from_dict return Event Reconstructed event
str() str "{date}: {content}"

Usage Examples

Create Factual Event

from src.classes.event import Event

event = Event(
    month_stamp=world.month_stamp,
    content="张三 defeated 李四 in a cultivation duel.",
    related_avatars=[avatar_a.id, avatar_b.id],
    is_major=True,
    event_type="battle_kill",
)
world.event_manager.add_event(event)

Create Story Event

story_event = Event(
    month_stamp=world.month_stamp,
    content=llm_generated_story_text,
    related_avatars=[avatar_a.id],
    is_story=True,  # NOT is_major
)

Serialize and Deserialize

data = event.to_dict()
# ... save to JSON ...
restored = Event.from_dict(data)
assert restored.content == event.content

Related Pages

Implements Principle

Required Environments

Page Connections

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