Skip to main content

manabrew_engine/cost/
individual_cost_payment_instance.rs

1//! Mirrors Java `IndividualCostPaymentInstance`.
2
3use std::sync::atomic::{AtomicU64, Ordering};
4
5use crate::cost::CostPart;
6use crate::ids::CardId;
7
8static NEXT_ID: AtomicU64 = AtomicU64::new(1);
9
10#[derive(Debug, Clone)]
11pub struct IndividualCostPaymentInstance {
12    id: u64,
13    cost: CostPart,
14    payment_source: CardId,
15}
16
17impl IndividualCostPaymentInstance {
18    pub fn new(cost: CostPart, payment_source: CardId) -> Self {
19        let id = NEXT_ID.fetch_add(1, Ordering::Relaxed);
20        Self {
21            id,
22            cost,
23            payment_source,
24        }
25    }
26
27    pub fn get_id(&self) -> u64 {
28        self.id
29    }
30
31    pub fn get_cost(&self) -> &CostPart {
32        &self.cost
33    }
34
35    pub fn get_payment_source(&self) -> CardId {
36        self.payment_source
37    }
38}