Skip to main content

weiss_core/state/
cards.rs

1use serde::{Deserialize, Serialize};
2
3use crate::db::CardId;
4
5/// Unique identifier for a card instance within a game.
6pub type CardInstanceId = u32;
7
8/// Concrete card instance with ownership and controller.
9#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
10pub struct CardInstance {
11    /// Static card identifier in the card database.
12    pub id: CardId,
13    /// Stable per-game identifier for this physical card instance.
14    pub instance_id: CardInstanceId,
15    /// Owning seat (0 or 1).
16    pub owner: u8,
17    /// Current controlling seat (0 or 1).
18    pub controller: u8,
19}
20
21impl CardInstance {
22    /// Create a new card instance owned by `owner`.
23    pub fn new(id: CardId, owner: u8, instance_id: CardInstanceId) -> Self {
24        Self {
25            id,
26            instance_id,
27            owner,
28            controller: owner,
29        }
30    }
31}