|
@ -358,7 +358,7 @@ impl BankItem { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
pub enum FloorItemDetail {
|
|
|
pub enum FloorItemDetail {
|
|
|
Individual(IndividualItemDetail),
|
|
|
Individual(IndividualItemDetail),
|
|
|
Stacked(StackedItemDetail),
|
|
|
Stacked(StackedItemDetail),
|
|
@ -374,7 +374,7 @@ impl FloorItemDetail { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
pub struct FloorItem {
|
|
|
pub struct FloorItem {
|
|
|
pub item_id: ClientItemId,
|
|
|
pub item_id: ClientItemId,
|
|
|
pub item: FloorItemDetail,
|
|
|
pub item: FloorItemDetail,
|
|
@ -465,12 +465,10 @@ pub enum AddItemResult { |
|
|
Meseta,
|
|
|
Meseta,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Clone, Default)]
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
|
pub struct LocalFloor(Vec<FloorItem>);
|
|
|
pub struct LocalFloor(Vec<FloorItem>);
|
|
|
#[derive(Clone, Default)]
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
|
pub struct SharedFloor(Vec<FloorItem>);
|
|
|
pub struct SharedFloor(Vec<FloorItem>);
|
|
|
#[derive(Clone)]
|
|
|
|
|
|
pub struct RoomFloorItems(Vec<FloorItem>);
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
#[derive(Clone)]
|
|
|
pub struct InventoryState {
|
|
|
pub struct InventoryState {
|
|
@ -549,7 +547,7 @@ impl InventoryState { |
|
|
Err(InventoryError::MesetaFull)
|
|
|
Err(InventoryError::MesetaFull)
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
else {
|
|
|
self.meseta.0 = std::cmp::min(self.meseta.0 + meseta.0 ,999999);
|
|
|
|
|
|
|
|
|
self.meseta.0 = std::cmp::min(self.meseta.0 + meseta.0, 999999);
|
|
|
Ok(AddItemResult::Meseta)
|
|
|
Ok(AddItemResult::Meseta)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@ -607,7 +605,7 @@ impl InventoryState { |
|
|
Some(self.inventory.0.remove(idx))
|
|
|
Some(self.inventory.0.remove(idx))
|
|
|
},
|
|
|
},
|
|
|
InventoryItemDetail::Stacked(stacked_item) => {
|
|
|
InventoryItemDetail::Stacked(stacked_item) => {
|
|
|
let remove_all = match stacked_item.entity_ids.len().cmp(&(amount as usize)) {
|
|
|
|
|
|
|
|
|
let remove_all = (amount == 0) || match stacked_item.entity_ids.len().cmp(&(amount as usize)) {
|
|
|
Ordering::Equal => true,
|
|
|
Ordering::Equal => true,
|
|
|
Ordering::Greater => false,
|
|
|
Ordering::Greater => false,
|
|
|
Ordering::Less => return None,
|
|
|
Ordering::Less => return None,
|
|
@ -708,7 +706,6 @@ impl InventoryState { |
|
|
|
|
|
|
|
|
match (a_index, b_index) {
|
|
|
match (a_index, b_index) {
|
|
|
(Some(a_index), Some(b_index)) => {
|
|
|
(Some(a_index), Some(b_index)) => {
|
|
|
dbg!("sort!", a.item_id, a_index, b.item_id, b_index);
|
|
|
|
|
|
a_index.cmp(&b_index)
|
|
|
a_index.cmp(&b_index)
|
|
|
},
|
|
|
},
|
|
|
_ => Ordering::Equal
|
|
|
_ => Ordering::Equal
|
|
@ -1025,6 +1022,7 @@ impl std::cmp::Ord for BankItem { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
pub struct FloorState {
|
|
|
pub struct FloorState {
|
|
|
character_id: CharacterEntityId,
|
|
|
character_id: CharacterEntityId,
|
|
|
local: LocalFloor,
|
|
|
local: LocalFloor,
|
|
@ -1123,7 +1121,7 @@ impl ItemState { |
|
|
Ok(match item {
|
|
|
Ok(match item {
|
|
|
InventoryItemEntity::Individual(item) => {
|
|
|
InventoryItemEntity::Individual(item) => {
|
|
|
InventoryItem {
|
|
|
InventoryItem {
|
|
|
item_id: self.new_item_id()?,
|
|
|
|
|
|
|
|
|
item_id: ClientItemId(0),
|
|
|
item: InventoryItemDetail::Individual(IndividualItemDetail {
|
|
|
item: InventoryItemDetail::Individual(IndividualItemDetail {
|
|
|
entity_id: item.id,
|
|
|
entity_id: item.id,
|
|
|
item: item.item,
|
|
|
item: item.item,
|
|
@ -1132,7 +1130,7 @@ impl ItemState { |
|
|
},
|
|
|
},
|
|
|
InventoryItemEntity::Stacked(items) => {
|
|
|
InventoryItemEntity::Stacked(items) => {
|
|
|
InventoryItem {
|
|
|
InventoryItem {
|
|
|
item_id: self.new_item_id()?,
|
|
|
|
|
|
|
|
|
item_id: ClientItemId(0),
|
|
|
item: InventoryItemDetail::Stacked(StackedItemDetail {
|
|
|
item: InventoryItemDetail::Stacked(StackedItemDetail {
|
|
|
entity_ids: items.iter().map(|i| i.id).collect(),
|
|
|
entity_ids: items.iter().map(|i| i.id).collect(),
|
|
|
tool: items.get(0)
|
|
|
tool: items.get(0)
|
|
|