flatland-client-lib 0.2.3

Flatland3 remote game client library (TCP session, bots, game state)
Documentation
//! Client-side session events (decoded from server messages).

use flatland_protocol::{
    ChatMessage, EntityId, HarvestResult, Intent, Seq, SessionId, Snapshot, Tick, TickDelta,
};

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum SessionEvent {
    Welcome {
        session_id: SessionId,
        entity_id: EntityId,
        snapshot: Snapshot,
    },
    /// Map/recipe/catalog reload — apply snapshot static layers in place.
    ContentUpdated {
        snapshot: Snapshot,
    },
    Tick(TickDelta),
    IntentAck {
        entity_id: EntityId,
        seq: Seq,
        tick: Tick,
    },
    Chat(ChatMessage),
    HarvestResult(HarvestResult),
    CraftResult(flatland_protocol::CraftResult),
    Death(flatland_protocol::DeathNotice),
    Interaction(flatland_protocol::InteractionNotice),
    ShopOpened(flatland_protocol::ShopCatalog),
    UseResult(flatland_protocol::UseResult),
    Disconnected {
        reason: Option<String>,
    },
}

/// Gameplay session handle (remote TCP or in-process worker).
#[async_trait::async_trait]
pub trait PlayConnection: Send {
    fn session_id(&self) -> SessionId;
    fn entity_id(&self) -> EntityId;
    async fn submit_intent(&self, intent: Intent) -> anyhow::Result<()>;
    fn try_next_event(&mut self) -> Option<SessionEvent>;
    async fn next_event(&mut self) -> Option<SessionEvent>;
    fn disconnect(&self);
}