You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
941 B
38 lines
941 B
use crate::ClientItemId;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum TradeItem {
|
|
Individual(ClientItemId),
|
|
Stacked(ClientItemId, usize),
|
|
}
|
|
|
|
impl TradeItem {
|
|
pub fn stacked(&self) -> Option<(ClientItemId, usize)> {
|
|
match self {
|
|
TradeItem::Stacked(item_id, amount) => Some((*item_id, *amount)),
|
|
_ => None
|
|
}
|
|
}
|
|
|
|
pub fn stacked_mut(&mut self) -> Option<(ClientItemId, &mut usize)> {
|
|
match self {
|
|
TradeItem::Stacked(item_id, ref mut amount) => Some((*item_id, amount)),
|
|
_ => None
|
|
}
|
|
}
|
|
|
|
pub fn item_id(&self) -> ClientItemId {
|
|
match self {
|
|
TradeItem::Individual(item_id) => *item_id,
|
|
TradeItem::Stacked(item_id, _) => *item_id,
|
|
}
|
|
}
|
|
|
|
pub fn amount(&self) -> usize {
|
|
match self {
|
|
TradeItem::Individual(_) => 1,
|
|
TradeItem::Stacked(_, amount) => *amount,
|
|
}
|
|
}
|
|
}
|
|
|