appease clippy, the tyrant
This commit is contained in:
parent
5976030970
commit
fae1ffe55b
@ -3,7 +3,7 @@ use std::fs::File;
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use crate::entity::character::CharacterClass;
|
use crate::entity::character::CharacterClass;
|
||||||
|
|
||||||
#[derive(Default, Copy, Clone, Debug, PartialEq)]
|
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CharacterStats {
|
pub struct CharacterStats {
|
||||||
pub hp: u16,
|
pub hp: u16,
|
||||||
pub atp: u16,
|
pub atp: u16,
|
||||||
|
@ -51,11 +51,9 @@ impl PostgresGateway {
|
|||||||
embedded::migrations::runner().run(&mut conn).unwrap();
|
embedded::migrations::runner().run(&mut conn).unwrap();
|
||||||
|
|
||||||
let pool = async_std::task::block_on(async move {
|
let pool = async_std::task::block_on(async move {
|
||||||
let pool = PgPoolOptions::new()
|
PgPoolOptions::new()
|
||||||
.max_connections(5)
|
.max_connections(5)
|
||||||
.connect(&format!("postgresql://{}:{}@{}:5432/{}", username, password, host, dbname)).await.unwrap();
|
.connect(&format!("postgresql://{}:{}@{}:5432/{}", username, password, host, dbname)).await.unwrap()
|
||||||
|
|
||||||
pool
|
|
||||||
});
|
});
|
||||||
|
|
||||||
PostgresGateway {
|
PostgresGateway {
|
||||||
|
@ -289,7 +289,7 @@ impl ArmorType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum ArmorModifier {
|
pub enum ArmorModifier {
|
||||||
AddSlot {
|
AddSlot {
|
||||||
addslot: ItemEntityId,
|
addslot: ItemEntityId,
|
||||||
@ -297,7 +297,7 @@ pub enum ArmorModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Armor {
|
pub struct Armor {
|
||||||
pub armor: ArmorType,
|
pub armor: ArmorType,
|
||||||
pub dfp: u8,
|
pub dfp: u8,
|
||||||
|
@ -121,7 +121,7 @@ impl ESWeaponType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, strum_macros::EnumIter)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, strum_macros::EnumIter)]
|
||||||
pub enum ESWeaponSpecial {
|
pub enum ESWeaponSpecial {
|
||||||
Jellen = 1,
|
Jellen = 1,
|
||||||
Zalure,
|
Zalure,
|
||||||
@ -169,7 +169,7 @@ impl ESWeaponSpecial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ESWeapon {
|
pub struct ESWeapon {
|
||||||
pub esweapon: ESWeaponType,
|
pub esweapon: ESWeaponType,
|
||||||
pub special: Option<ESWeaponSpecial>,
|
pub special: Option<ESWeaponSpecial>,
|
||||||
|
@ -519,7 +519,7 @@ pub enum MagCellError {
|
|||||||
IsRareMag,
|
IsRareMag,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum MagModifier {
|
pub enum MagModifier {
|
||||||
FeedMag{
|
FeedMag{
|
||||||
food: ItemEntityId,
|
food: ItemEntityId,
|
||||||
@ -529,7 +529,7 @@ pub enum MagModifier {
|
|||||||
OwnerChange(CharacterClass, SectionID)
|
OwnerChange(CharacterClass, SectionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, enum_utils::FromStr)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, enum_utils::FromStr)]
|
||||||
pub enum PhotonBlast {
|
pub enum PhotonBlast {
|
||||||
Farlla,
|
Farlla,
|
||||||
Estlla,
|
Estlla,
|
||||||
@ -539,7 +539,7 @@ pub enum PhotonBlast {
|
|||||||
MyllaYoulla,
|
MyllaYoulla,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Mag {
|
pub struct Mag {
|
||||||
pub mag: MagType,
|
pub mag: MagType,
|
||||||
def: u16,
|
def: u16,
|
||||||
|
@ -13,7 +13,7 @@ use crate::entity::character::CharacterEntityId;
|
|||||||
use crate::ship::map::MapArea;
|
use crate::ship::map::MapArea;
|
||||||
use crate::ship::drops::ItemDropType;
|
use crate::ship::drops::ItemDropType;
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone, Debug, Hash, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
pub struct ItemEntityId(pub u32);
|
pub struct ItemEntityId(pub u32);
|
||||||
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
|
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct ItemId(u32);
|
pub struct ItemId(u32);
|
||||||
@ -70,7 +70,7 @@ pub enum ItemNote {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct Meseta(pub u32);
|
pub struct Meseta(pub u32);
|
||||||
|
|
||||||
impl Meseta {
|
impl Meseta {
|
||||||
@ -95,12 +95,12 @@ pub enum ItemType {
|
|||||||
ESWeapon(esweapon::ESWeaponType),
|
ESWeapon(esweapon::ESWeaponType),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ItemParseError {
|
pub enum ItemParseError {
|
||||||
InvalidBytes
|
InvalidBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum ItemDetail {
|
pub enum ItemDetail {
|
||||||
Weapon(weapon::Weapon),
|
Weapon(weapon::Weapon),
|
||||||
Armor(armor::Armor),
|
Armor(armor::Armor),
|
||||||
@ -186,7 +186,7 @@ pub struct NewItemEntity {
|
|||||||
pub item: ItemDetail,
|
pub item: ItemDetail,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ItemEntity {
|
pub struct ItemEntity {
|
||||||
pub id: ItemEntityId,
|
pub id: ItemEntityId,
|
||||||
pub item: ItemDetail,
|
pub item: ItemDetail,
|
||||||
|
@ -519,7 +519,7 @@ impl ShieldType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Shield {
|
pub struct Shield {
|
||||||
pub shield: ShieldType,
|
pub shield: ShieldType,
|
||||||
pub dfp: u8,
|
pub dfp: u8,
|
||||||
|
@ -642,7 +642,7 @@ impl ToolType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Tool {
|
pub struct Tool {
|
||||||
pub tool: ToolType,
|
pub tool: ToolType,
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ impl UnitType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum UnitModifier {
|
pub enum UnitModifier {
|
||||||
PlusPlus,
|
PlusPlus,
|
||||||
Plus,
|
Plus,
|
||||||
@ -331,7 +331,7 @@ pub enum UnitModifier {
|
|||||||
MinusMinus,
|
MinusMinus,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Unit {
|
pub struct Unit {
|
||||||
pub unit: UnitType,
|
pub unit: UnitType,
|
||||||
pub modifier: Option<UnitModifier>,
|
pub modifier: Option<UnitModifier>,
|
||||||
|
@ -10,7 +10,7 @@ pub enum ItemParseError {
|
|||||||
InvalidWeaponAttribute,
|
InvalidWeaponAttribute,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Hash, Eq, Ord, PartialOrd, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
pub enum Attribute {
|
pub enum Attribute {
|
||||||
Native = 1,
|
Native = 1,
|
||||||
ABeast,
|
ABeast,
|
||||||
@ -32,7 +32,7 @@ impl Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct WeaponAttribute {
|
pub struct WeaponAttribute {
|
||||||
pub attr: Attribute,
|
pub attr: Attribute,
|
||||||
pub value: i8,
|
pub value: i8,
|
||||||
@ -45,7 +45,7 @@ impl WeaponAttribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, strum_macros::EnumIter)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, strum_macros::EnumIter)]
|
||||||
pub enum WeaponSpecial {
|
pub enum WeaponSpecial {
|
||||||
Draw = 1,
|
Draw = 1,
|
||||||
Drain,
|
Drain,
|
||||||
@ -1424,14 +1424,14 @@ impl WeaponType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum TekSpecialModifier {
|
pub enum TekSpecialModifier {
|
||||||
Plus,
|
Plus,
|
||||||
Neutral,
|
Neutral,
|
||||||
Minus,
|
Minus,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum TekPercentModifier {
|
pub enum TekPercentModifier {
|
||||||
PlusPlus,
|
PlusPlus,
|
||||||
Plus,
|
Plus,
|
||||||
@ -1440,7 +1440,7 @@ pub enum TekPercentModifier {
|
|||||||
MinusMinus,
|
MinusMinus,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum WeaponModifier {
|
pub enum WeaponModifier {
|
||||||
AddPercents {
|
AddPercents {
|
||||||
attr: WeaponAttribute,
|
attr: WeaponAttribute,
|
||||||
@ -1457,7 +1457,7 @@ pub enum WeaponModifier {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Weapon {
|
pub struct Weapon {
|
||||||
pub weapon: WeaponType,
|
pub weapon: WeaponType,
|
||||||
pub special: Option<WeaponSpecial>,
|
pub special: Option<WeaponSpecial>,
|
||||||
|
@ -89,7 +89,7 @@ pub struct MonsterDropStats {
|
|||||||
pub max_meseta: u32,
|
pub max_meseta: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ItemDropType {
|
pub enum ItemDropType {
|
||||||
Weapon(weapon::Weapon),
|
Weapon(weapon::Weapon),
|
||||||
Armor(armor::Armor),
|
Armor(armor::Armor),
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// TODO: replace various u32s and usizes denoting item amounts for ItemAmount(u32) for consistency
|
||||||
|
|
||||||
use crate::ship::items::ClientItemId;
|
use crate::ship::items::ClientItemId;
|
||||||
use crate::entity::item::{Meseta, ItemNote};
|
use crate::entity::item::{Meseta, ItemNote};
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
@ -14,7 +16,7 @@ use crate::entity::item::tool::Tool;
|
|||||||
use crate::entity::item::ItemModifier;
|
use crate::entity::item::ItemModifier;
|
||||||
use crate::ship::shops::ShopItem;
|
use crate::ship::shops::ShopItem;
|
||||||
use crate::ship::trade::TradeItem;
|
use crate::ship::trade::TradeItem;
|
||||||
use crate::ship::location::{AreaClient, RoomId};
|
use crate::ship::location::AreaClient;
|
||||||
use crate::ship::drops::{ItemDrop, ItemDropType};
|
use crate::ship::drops::{ItemDrop, ItemDropType};
|
||||||
|
|
||||||
pub enum TriggerCreateItem {
|
pub enum TriggerCreateItem {
|
||||||
@ -107,7 +109,7 @@ fn take_item_from_inventory(character_id: CharacterEntityId, item_id: ClientItem
|
|||||||
move |(mut item_state, mut transaction), _| {
|
move |(mut item_state, mut transaction), _| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let mut inventory = item_state.inventory(&character_id)?;
|
let mut inventory = item_state.inventory(&character_id)?;
|
||||||
let item = inventory.take_item(&item_id, amount).ok_or_else (|| ItemStateError::NoFloorItem(item_id))?;
|
let item = inventory.take_item(&item_id, amount).ok_or (ItemStateError::NoFloorItem(item_id))?;
|
||||||
|
|
||||||
transaction.gateway().set_character_inventory(&character_id, &inventory.as_inventory_entity(&character_id)).await?;
|
transaction.gateway().set_character_inventory(&character_id, &inventory.as_inventory_entity(&character_id)).await?;
|
||||||
item_state.set_inventory(inventory);
|
item_state.set_inventory(inventory);
|
||||||
@ -235,7 +237,7 @@ fn add_meseta_to_shared_floor(character_id: CharacterEntityId, amount: u32, map_
|
|||||||
let floor_item = FloorItem {
|
let floor_item = FloorItem {
|
||||||
item_id: item_state.new_item_id()?,
|
item_id: item_state.new_item_id()?,
|
||||||
item: FloorItemDetail::Meseta(Meseta(amount)),
|
item: FloorItemDetail::Meseta(Meseta(amount)),
|
||||||
map_area: map_area,
|
map_area,
|
||||||
x: drop_position.0,
|
x: drop_position.0,
|
||||||
y: 0.0,
|
y: 0.0,
|
||||||
z: drop_position.1,
|
z: drop_position.1,
|
||||||
@ -352,7 +354,7 @@ where
|
|||||||
{
|
{
|
||||||
entity_gateway.with_transaction(|transaction| async move {
|
entity_gateway.with_transaction(|transaction| async move {
|
||||||
let item_state_proxy = ItemStateProxy::new(item_state);
|
let item_state_proxy = ItemStateProxy::new(item_state);
|
||||||
let ((item_state_proxy, transaction), result) = ItemStateAction::default()
|
let ((item_state_proxy, transaction), _) = ItemStateAction::default()
|
||||||
.act(take_meseta_from_inventory(character.id, amount))
|
.act(take_meseta_from_inventory(character.id, amount))
|
||||||
.act(add_meseta_to_bank(character.id, amount))
|
.act(add_meseta_to_bank(character.id, amount))
|
||||||
.commit((item_state_proxy, transaction))
|
.commit((item_state_proxy, transaction))
|
||||||
@ -369,7 +371,7 @@ fn take_item_from_bank(character_id: CharacterEntityId, item_id: ClientItemId, a
|
|||||||
move |(mut item_state, mut transaction), _| {
|
move |(mut item_state, mut transaction), _| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let mut bank = item_state.bank(&character_id)?;
|
let mut bank = item_state.bank(&character_id)?;
|
||||||
let item = bank.take_item(&item_id, amount).ok_or_else(|| ItemStateError::NoBankItem(item_id))?;
|
let item = bank.take_item(&item_id, amount).ok_or(ItemStateError::NoBankItem(item_id))?;
|
||||||
transaction.gateway().set_character_bank(&character_id, &bank.as_bank_entity(), &bank.name).await?;
|
transaction.gateway().set_character_bank(&character_id, &bank.as_bank_entity(), &bank.name).await?;
|
||||||
item_state.set_bank(bank);
|
item_state.set_bank(bank);
|
||||||
|
|
||||||
@ -440,7 +442,7 @@ where
|
|||||||
.act(take_item_from_bank(character.id, *item_id, amount))
|
.act(take_item_from_bank(character.id, *item_id, amount))
|
||||||
//.act(bank_item_to_inventory_item)
|
//.act(bank_item_to_inventory_item)
|
||||||
//.act(add_item_to_inventory)
|
//.act(add_item_to_inventory)
|
||||||
.act(add_bank_item_to_inventory(&character))
|
.act(add_bank_item_to_inventory(character))
|
||||||
.commit((item_state_proxy, transaction))
|
.commit((item_state_proxy, transaction))
|
||||||
.await?;
|
.await?;
|
||||||
item_state_proxy.commit();
|
item_state_proxy.commit();
|
||||||
@ -664,10 +666,10 @@ fn feed_mag_item(character: CharacterEntity, mag_item_id: ClientItemId)
|
|||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let mut inventory = item_state.inventory(&character.id)?;
|
let mut inventory = item_state.inventory(&character.id)?;
|
||||||
let mag_entity = inventory.get_by_client_id_mut(&mag_item_id)
|
let mag_entity = inventory.get_by_client_id_mut(&mag_item_id)
|
||||||
.ok_or_else(|| ItemStateError::InvalidItemId(mag_item_id))?
|
.ok_or(ItemStateError::InvalidItemId(mag_item_id))?
|
||||||
.item
|
.item
|
||||||
.as_individual_mut()
|
.as_individual_mut()
|
||||||
.ok_or_else(|| ItemStateError::NotAMag(mag_item_id))?;
|
.ok_or(ItemStateError::NotAMag(mag_item_id))?;
|
||||||
let mag_entity_id = mag_entity.entity_id;
|
let mag_entity_id = mag_entity.entity_id;
|
||||||
|
|
||||||
let mut transaction = tool.with_entity_id(transaction, |mut transaction, entity_id| {
|
let mut transaction = tool.with_entity_id(transaction, |mut transaction, entity_id| {
|
||||||
@ -683,13 +685,13 @@ fn feed_mag_item(character: CharacterEntity, mag_item_id: ClientItemId)
|
|||||||
let food_tool = tool
|
let food_tool = tool
|
||||||
.item
|
.item
|
||||||
.stacked()
|
.stacked()
|
||||||
.ok_or_else(|| ItemStateError::NotMagFood(tool.item_id))?
|
.ok_or(ItemStateError::NotMagFood(tool.item_id))?
|
||||||
.tool
|
.tool
|
||||||
.tool;
|
.tool;
|
||||||
|
|
||||||
let mag_entity = mag_entity
|
let mag_entity = mag_entity
|
||||||
.as_mag_mut()
|
.as_mag_mut()
|
||||||
.ok_or_else(|| ItemStateError::NotAMag(mag_item_id))?;
|
.ok_or(ItemStateError::NotAMag(mag_item_id))?;
|
||||||
|
|
||||||
mag_entity.feed(food_tool);
|
mag_entity.feed(food_tool);
|
||||||
|
|
||||||
@ -745,7 +747,7 @@ fn add_bought_item_to_inventory<'a>(character_id: CharacterEntityId,
|
|||||||
item: ItemDetail::Tool(tool),
|
item: ItemDetail::Tool(tool),
|
||||||
}).await?;
|
}).await?;
|
||||||
transaction.gateway().add_item_note(&item_entity.id, ItemNote::BoughtAtShop {
|
transaction.gateway().add_item_note(&item_entity.id, ItemNote::BoughtAtShop {
|
||||||
character_id: character_id,
|
character_id,
|
||||||
}).await?;
|
}).await?;
|
||||||
item_entities.push(item_entity);
|
item_entities.push(item_entity);
|
||||||
}
|
}
|
||||||
@ -754,7 +756,7 @@ fn add_bought_item_to_inventory<'a>(character_id: CharacterEntityId,
|
|||||||
item_id,
|
item_id,
|
||||||
item: InventoryItemDetail::Stacked(StackedItemDetail {
|
item: InventoryItemDetail::Stacked(StackedItemDetail {
|
||||||
entity_ids: item_entities.into_iter().map(|i| i.id).collect(),
|
entity_ids: item_entities.into_iter().map(|i| i.id).collect(),
|
||||||
tool: tool,
|
tool,
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
inventory.add_item(inventory_item)?.1
|
inventory.add_item(inventory_item)?.1
|
||||||
@ -764,7 +766,7 @@ fn add_bought_item_to_inventory<'a>(character_id: CharacterEntityId,
|
|||||||
item: item_detail.clone(),
|
item: item_detail.clone(),
|
||||||
}).await?;
|
}).await?;
|
||||||
transaction.gateway().add_item_note(&item_entity.id, ItemNote::BoughtAtShop {
|
transaction.gateway().add_item_note(&item_entity.id, ItemNote::BoughtAtShop {
|
||||||
character_id: character_id,
|
character_id,
|
||||||
}).await?;
|
}).await?;
|
||||||
|
|
||||||
let inventory_item = InventoryItem {
|
let inventory_item = InventoryItem {
|
||||||
@ -816,7 +818,7 @@ fn sell_inventory_item<'a>(character_id: CharacterEntityId)
|
|||||||
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
||||||
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
||||||
{
|
{
|
||||||
move |(mut item_state, mut transaction), inventory_item| {
|
move |(mut item_state, transaction), inventory_item| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let mut inventory = item_state.inventory(&character_id)?;
|
let mut inventory = item_state.inventory(&character_id)?;
|
||||||
let price = inventory_item.item.sell_price()?;
|
let price = inventory_item.item.sell_price()?;
|
||||||
@ -899,7 +901,7 @@ where
|
|||||||
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), O), ItemStateError>> + Send + 'a>> + Send + Sync,
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), O), ItemStateError>> + Send + 'a>> + Send + Sync,
|
||||||
T: Clone + Send + Sync,
|
T: Clone + Send + Sync,
|
||||||
{
|
{
|
||||||
move |(mut item_state, mut transaction), arg| {
|
move |(item_state, transaction), arg| {
|
||||||
let input = input.clone();
|
let input = input.clone();
|
||||||
let func = func.clone();
|
let func = func.clone();
|
||||||
println!("i {:?} {:?}", input, arg);
|
println!("i {:?} {:?}", input, arg);
|
||||||
@ -958,18 +960,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn clear<'a, T: Send + Clone + 'a>()
|
|
||||||
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T)
|
|
||||||
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ()), ItemStateError>> + Send + 'a>>
|
|
||||||
{
|
|
||||||
move |state, _| {
|
|
||||||
Box::pin(async move {
|
|
||||||
Ok((state, ()))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert<'a, T: Send + Clone + 'a>(element: T)
|
fn insert<'a, T: Send + Clone + 'a>(element: T)
|
||||||
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
-> impl Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), ())
|
||||||
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T), ItemStateError>> + Send + 'a>>
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), T), ItemStateError>> + Send + 'a>>
|
||||||
@ -986,26 +976,10 @@ fn add_item_to_inventory(character: CharacterEntity)
|
|||||||
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
||||||
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>> + Clone
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>> + Clone
|
||||||
{
|
{
|
||||||
let character = character.clone();
|
|
||||||
move |(mut item_state, transaction), inventory_item| {
|
move |(mut item_state, transaction), inventory_item| {
|
||||||
let character = character.clone();
|
let character = character.clone();
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
//let bank_name = item_state.bank(&character.id)?.name;
|
|
||||||
let mut inventory = item_state.inventory(&character.id)?;
|
let mut inventory = item_state.inventory(&character.id)?;
|
||||||
|
|
||||||
let character_id = character.id;
|
|
||||||
/*
|
|
||||||
let transaction = bank_item.with_entity_id(transaction, |mut transaction, entity_id| {
|
|
||||||
let bank_name = bank_name.clone();
|
|
||||||
async move {
|
|
||||||
transaction.gateway().add_item_note(&entity_id, ItemNote::Withdraw {
|
|
||||||
character_id,
|
|
||||||
bank: bank_name,
|
|
||||||
}).await?;
|
|
||||||
Ok(transaction)
|
|
||||||
}}).await?;
|
|
||||||
*/
|
|
||||||
|
|
||||||
let mut transaction = inventory_item.with_mag(transaction, |mut transaction, entity_id, _mag| {
|
let mut transaction = inventory_item.with_mag(transaction, |mut transaction, entity_id, _mag| {
|
||||||
let character = character.clone();
|
let character = character.clone();
|
||||||
async move {
|
async move {
|
||||||
@ -1060,7 +1034,6 @@ fn assign_new_item_id()
|
|||||||
pub async fn trade_items<'a, EG> (
|
pub async fn trade_items<'a, EG> (
|
||||||
item_state: &'a mut ItemState,
|
item_state: &'a mut ItemState,
|
||||||
entity_gateway: &mut EG,
|
entity_gateway: &mut EG,
|
||||||
room_id: RoomId,
|
|
||||||
p1: (&AreaClient, &CharacterEntity, &Vec<TradeItem>, Meseta),
|
p1: (&AreaClient, &CharacterEntity, &Vec<TradeItem>, Meseta),
|
||||||
p2: (&AreaClient, &CharacterEntity, &Vec<TradeItem>, Meseta))
|
p2: (&AreaClient, &CharacterEntity, &Vec<TradeItem>, Meseta))
|
||||||
-> Result<(Vec<InventoryItem>, Vec<InventoryItem>), ItemStateError>
|
-> Result<(Vec<InventoryItem>, Vec<InventoryItem>), ItemStateError>
|
||||||
@ -1137,9 +1110,9 @@ pub async fn take_meseta<'a, EG> (
|
|||||||
where
|
where
|
||||||
EG: EntityGateway,
|
EG: EntityGateway,
|
||||||
{
|
{
|
||||||
entity_gateway.with_transaction(|mut transaction| async move {
|
entity_gateway.with_transaction(|transaction| async move {
|
||||||
let item_state_proxy = ItemStateProxy::new(item_state);
|
let item_state_proxy = ItemStateProxy::new(item_state);
|
||||||
let ((item_state_proxy, transaction), p1_removed_items) = ItemStateAction::default()
|
let ((item_state_proxy, transaction), _) = ItemStateAction::default()
|
||||||
.act(take_meseta_from_inventory(*character_id, meseta.0))
|
.act(take_meseta_from_inventory(*character_id, meseta.0))
|
||||||
.commit((item_state_proxy, transaction))
|
.commit((item_state_proxy, transaction))
|
||||||
.await?;
|
.await?;
|
||||||
@ -1270,7 +1243,7 @@ pub async fn enemy_drops_item<'a, EG> (
|
|||||||
where
|
where
|
||||||
EG: EntityGateway,
|
EG: EntityGateway,
|
||||||
{
|
{
|
||||||
entity_gateway.with_transaction(|mut transaction| async move {
|
entity_gateway.with_transaction(|transaction| async move {
|
||||||
let item_state_proxy = ItemStateProxy::new(item_state);
|
let item_state_proxy = ItemStateProxy::new(item_state);
|
||||||
let ((item_state_proxy, transaction), floor_item) = ItemStateAction::default()
|
let ((item_state_proxy, transaction), floor_item) = ItemStateAction::default()
|
||||||
.act(convert_item_drop_to_floor_item(character_id, item_drop))
|
.act(convert_item_drop_to_floor_item(character_id, item_drop))
|
||||||
@ -1283,17 +1256,17 @@ where
|
|||||||
}).await
|
}).await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_modifier_to_inventory_item(character_id: CharacterEntityId, modifier: ItemModifier)
|
fn apply_modifier_to_inventory_item(modifier: ItemModifier)
|
||||||
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
-> impl for<'a> Fn((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem)
|
||||||
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
-> Pin<Box<dyn Future<Output=Result<((ItemStateProxy<'a>, Box<dyn EntityGatewayTransaction + 'a>), InventoryItem), ItemStateError>> + Send + 'a>>
|
||||||
{
|
{
|
||||||
move |(item_state, mut transaction), mut inventory_item| {
|
move |(item_state, mut transaction), mut inventory_item| {
|
||||||
let modifier = modifier.clone();
|
let modifier = modifier.clone();
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
match (&inventory_item.item, modifier) {
|
match (&mut inventory_item.item, modifier) {
|
||||||
(InventoryItemDetail::Individual(IndividualItemDetail{entity_id, item: ItemDetail::Weapon(mut weapon), ..}), ItemModifier::WeaponModifier(modifier)) => {
|
(InventoryItemDetail::Individual(IndividualItemDetail{entity_id, item: ItemDetail::Weapon(ref mut weapon), ..}), ItemModifier::WeaponModifier(modifier)) => {
|
||||||
weapon.apply_modifier(&modifier);
|
weapon.apply_modifier(&modifier);
|
||||||
transaction.gateway().add_weapon_modifier(&entity_id, modifier).await?;
|
transaction.gateway().add_weapon_modifier(entity_id, modifier).await?;
|
||||||
},
|
},
|
||||||
_ => return Err(ItemStateError::InvalidModifier)
|
_ => return Err(ItemStateError::InvalidModifier)
|
||||||
}
|
}
|
||||||
@ -1334,7 +1307,7 @@ where
|
|||||||
let item_state_proxy = ItemStateProxy::new(item_state);
|
let item_state_proxy = ItemStateProxy::new(item_state);
|
||||||
let ((item_state_proxy, transaction), item) = ItemStateAction::default()
|
let ((item_state_proxy, transaction), item) = ItemStateAction::default()
|
||||||
.act(take_item_from_inventory(character.id, item_id, 1))
|
.act(take_item_from_inventory(character.id, item_id, 1))
|
||||||
.act(apply_modifier_to_inventory_item(character.id, modifier))
|
.act(apply_modifier_to_inventory_item(modifier))
|
||||||
.act(add_item_to_inventory(character.clone()))
|
.act(add_item_to_inventory(character.clone()))
|
||||||
.act(as_individual_item())
|
.act(as_individual_item())
|
||||||
.commit((item_state_proxy, transaction))
|
.commit((item_state_proxy, transaction))
|
||||||
|
@ -109,7 +109,7 @@ where
|
|||||||
let mut inventory = item_state.inventory(&character.id)?;
|
let mut inventory = item_state.inventory(&character.id)?;
|
||||||
|
|
||||||
let (mag_entity_id, mag) = inventory.equipped_mag_mut()
|
let (mag_entity_id, mag) = inventory.equipped_mag_mut()
|
||||||
.ok_or_else(|| ApplyItemError::ItemNotEquipped)?;
|
.ok_or(ApplyItemError::ItemNotEquipped)?;
|
||||||
mag.apply_mag_cell(mag_cell_type)?;
|
mag.apply_mag_cell(mag_cell_type)?;
|
||||||
|
|
||||||
entity_gateway.use_mag_cell(&mag_entity_id, &cell_entity_id).await?;
|
entity_gateway.use_mag_cell(&mag_entity_id, &cell_entity_id).await?;
|
||||||
|
@ -492,15 +492,6 @@ pub enum FloorItemDetail {
|
|||||||
Meseta(Meseta),
|
Meseta(Meseta),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FloorItemDetail {
|
|
||||||
fn stacked(&self) -> Option<&StackedItemDetail> {
|
|
||||||
match self {
|
|
||||||
FloorItemDetail::Stacked(sitem) => Some(sitem),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FloorItem {
|
pub struct FloorItem {
|
||||||
pub item_id: ClientItemId,
|
pub item_id: ClientItemId,
|
||||||
@ -767,7 +758,7 @@ impl InventoryState {
|
|||||||
Some(InventoryItem {
|
Some(InventoryItem {
|
||||||
item_id: ClientItemId(self.item_id_counter),
|
item_id: ClientItemId(self.item_id_counter),
|
||||||
item: InventoryItemDetail::Stacked(StackedItemDetail {
|
item: InventoryItemDetail::Stacked(StackedItemDetail {
|
||||||
entity_ids: entity_ids,
|
entity_ids,
|
||||||
tool: stacked_item.tool,
|
tool: stacked_item.tool,
|
||||||
})})
|
})})
|
||||||
}
|
}
|
||||||
@ -870,7 +861,7 @@ impl InventoryState {
|
|||||||
.find(|(entity_id, _)| *entity_id == mag_id)
|
.find(|(entity_id, _)| *entity_id == mag_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sort(&mut self, item_ids: &Vec<ClientItemId>) {
|
pub fn sort(&mut self, item_ids: &[ClientItemId]) {
|
||||||
self.inventory.0.sort_by(|a, b| {
|
self.inventory.0.sort_by(|a, b| {
|
||||||
let a_index = item_ids.iter().position(|item_id| *item_id == a.item_id);
|
let a_index = item_ids.iter().position(|item_id| *item_id == a.item_id);
|
||||||
let b_index = item_ids.iter().position(|item_id| *item_id == b.item_id);
|
let b_index = item_ids.iter().position(|item_id| *item_id == b.item_id);
|
||||||
@ -984,7 +975,7 @@ impl BankState {
|
|||||||
if self.meseta.0 + amount > 999999 {
|
if self.meseta.0 + amount > 999999 {
|
||||||
return Err(ItemStateError::FullOfMeseta)
|
return Err(ItemStateError::FullOfMeseta)
|
||||||
}
|
}
|
||||||
self.meseta.0 += self.meseta.0 + amount;
|
self.meseta.0 += amount;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1070,7 +1061,7 @@ impl BankState {
|
|||||||
Some(BankItem {
|
Some(BankItem {
|
||||||
item_id: ClientItemId(self.item_id_counter),
|
item_id: ClientItemId(self.item_id_counter),
|
||||||
item: BankItemDetail::Stacked(StackedItemDetail {
|
item: BankItemDetail::Stacked(StackedItemDetail {
|
||||||
entity_ids: entity_ids,
|
entity_ids,
|
||||||
tool: stacked_item.tool,
|
tool: stacked_item.tool,
|
||||||
})})
|
})})
|
||||||
}
|
}
|
||||||
@ -1223,7 +1214,7 @@ impl FloorState {
|
|||||||
InventoryItemDetail::Individual(individual_item) => FloorItemDetail::Individual(individual_item),
|
InventoryItemDetail::Individual(individual_item) => FloorItemDetail::Individual(individual_item),
|
||||||
InventoryItemDetail::Stacked(stacked_item) => FloorItemDetail::Stacked(stacked_item),
|
InventoryItemDetail::Stacked(stacked_item) => FloorItemDetail::Stacked(stacked_item),
|
||||||
},
|
},
|
||||||
map_area: map_area,
|
map_area,
|
||||||
x: position.0,
|
x: position.0,
|
||||||
y: position.1,
|
y: position.1,
|
||||||
z: position.2,
|
z: position.2,
|
||||||
@ -1271,13 +1262,13 @@ impl Default for ItemState {
|
|||||||
|
|
||||||
impl ItemState {
|
impl ItemState {
|
||||||
pub fn get_character_inventory(&self, character: &CharacterEntity) -> Result<&InventoryState, ItemStateError> {
|
pub fn get_character_inventory(&self, character: &CharacterEntity) -> Result<&InventoryState, ItemStateError> {
|
||||||
Ok(self.character_inventory.get(&character.id)
|
self.character_inventory.get(&character.id)
|
||||||
.ok_or(ItemStateError::NoCharacter(character.id))?)
|
.ok_or(ItemStateError::NoCharacter(character.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_character_bank(&self, character: &CharacterEntity) -> Result<&BankState, ItemStateError> {
|
pub fn get_character_bank(&self, character: &CharacterEntity) -> Result<&BankState, ItemStateError> {
|
||||||
Ok(self.character_bank.get(&character.id)
|
self.character_bank.get(&character.id)
|
||||||
.ok_or(ItemStateError::NoCharacter(character.id))?)
|
.ok_or(ItemStateError::NoCharacter(character.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1327,7 +1318,7 @@ impl ItemState {
|
|||||||
character_id: character.id,
|
character_id: character.id,
|
||||||
item_id_counter: 0,
|
item_id_counter: 0,
|
||||||
inventory: Inventory(inventory_items),
|
inventory: Inventory(inventory_items),
|
||||||
equipped: equipped,
|
equipped,
|
||||||
meseta: character_meseta,
|
meseta: character_meseta,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1408,7 +1399,7 @@ impl ItemState {
|
|||||||
.find(|item| item.item_id == *item_id)
|
.find(|item| item.item_id == *item_id)
|
||||||
.map(|item| (item, FloorType::Shared))
|
.map(|item| (item, FloorType::Shared))
|
||||||
})
|
})
|
||||||
.ok_or_else(|| ItemStateError::NoFloorItem(*item_id))
|
.ok_or(ItemStateError::NoFloorItem(*item_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ pub enum AreaType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct LobbyId(pub usize);
|
pub struct LobbyId(pub usize);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, derive_more::Display)]
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, derive_more::Display)]
|
||||||
@ -25,7 +25,7 @@ impl LobbyId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("create room")]
|
#[error("create room")]
|
||||||
pub enum CreateRoomError {
|
pub enum CreateRoomError {
|
||||||
NoOpenSlots,
|
NoOpenSlots,
|
||||||
@ -33,7 +33,7 @@ pub enum CreateRoomError {
|
|||||||
JoinError,
|
JoinError,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("join room")]
|
#[error("join room")]
|
||||||
pub enum JoinRoomError {
|
pub enum JoinRoomError {
|
||||||
RoomDoesNotExist,
|
RoomDoesNotExist,
|
||||||
@ -41,7 +41,7 @@ pub enum JoinRoomError {
|
|||||||
ClientInAreaAlready,
|
ClientInAreaAlready,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("join lobby")]
|
#[error("join lobby")]
|
||||||
pub enum JoinLobbyError {
|
pub enum JoinLobbyError {
|
||||||
LobbyDoesNotExist,
|
LobbyDoesNotExist,
|
||||||
@ -49,7 +49,7 @@ pub enum JoinLobbyError {
|
|||||||
ClientInAreaAlready,
|
ClientInAreaAlready,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("get area")]
|
#[error("get area")]
|
||||||
pub enum GetAreaError {
|
pub enum GetAreaError {
|
||||||
NotInRoom,
|
NotInRoom,
|
||||||
@ -57,28 +57,28 @@ pub enum GetAreaError {
|
|||||||
InvalidClient,
|
InvalidClient,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("client removal")]
|
#[error("client removal")]
|
||||||
pub enum ClientRemovalError {
|
pub enum ClientRemovalError {
|
||||||
ClientNotInArea,
|
ClientNotInArea,
|
||||||
InvalidArea,
|
InvalidArea,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("get clients")]
|
#[error("get clients")]
|
||||||
pub enum GetClientsError {
|
pub enum GetClientsError {
|
||||||
InvalidClient,
|
InvalidClient,
|
||||||
InvalidArea,
|
InvalidArea,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("get neighbor")]
|
#[error("get neighbor")]
|
||||||
pub enum GetNeighborError {
|
pub enum GetNeighborError {
|
||||||
InvalidClient,
|
InvalidClient,
|
||||||
InvalidArea,
|
InvalidArea,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("get leader")]
|
#[error("get leader")]
|
||||||
pub enum GetLeaderError {
|
pub enum GetLeaderError {
|
||||||
InvalidClient,
|
InvalidClient,
|
||||||
@ -86,7 +86,7 @@ pub enum GetLeaderError {
|
|||||||
NoClientInArea,
|
NoClientInArea,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq, Eq)]
|
||||||
#[error("clientlocation")]
|
#[error("clientlocation")]
|
||||||
pub enum ClientLocationError {
|
pub enum ClientLocationError {
|
||||||
CreateRoomError(#[from] CreateRoomError),
|
CreateRoomError(#[from] CreateRoomError),
|
||||||
@ -100,7 +100,7 @@ pub enum ClientLocationError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct LocalClientId(usize);
|
pub struct LocalClientId(usize);
|
||||||
|
|
||||||
impl LocalClientId {
|
impl LocalClientId {
|
||||||
@ -115,19 +115,19 @@ impl PartialEq<u8> for LocalClientId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct AreaClient {
|
pub struct AreaClient {
|
||||||
pub client: ClientId,
|
pub client: ClientId,
|
||||||
pub local_client: LocalClientId,
|
pub local_client: LocalClientId,
|
||||||
time_join: SystemTime,
|
time_join: SystemTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
struct Lobby([Option<AreaClient>; 12]);
|
struct Lobby([Option<AreaClient>; 12]);
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
struct Room([Option<AreaClient>; 4]);
|
struct Room([Option<AreaClient>; 4]);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum RoomLobby {
|
pub enum RoomLobby {
|
||||||
Room(RoomId),
|
Room(RoomId),
|
||||||
Lobby(LobbyId),
|
Lobby(LobbyId),
|
||||||
|
@ -5,7 +5,7 @@ use thiserror::Error;
|
|||||||
use crate::ship::room::Episode;
|
use crate::ship::room::Episode;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum MapArea {
|
pub enum MapArea {
|
||||||
Pioneer2Ep1,
|
Pioneer2Ep1,
|
||||||
Forest1,
|
Forest1,
|
||||||
|
@ -5,7 +5,7 @@ use rand::Rng;
|
|||||||
// TODO: don't use *
|
// TODO: don't use *
|
||||||
use crate::ship::map::*;
|
use crate::ship::map::*;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum MapVariantMode {
|
pub enum MapVariantMode {
|
||||||
Online,
|
Online,
|
||||||
Offline,
|
Offline,
|
||||||
|
@ -24,15 +24,11 @@ const SHOP_OPTION_TOOL: u8 = 0;
|
|||||||
const SHOP_OPTION_WEAPON: u8 = 1;
|
const SHOP_OPTION_WEAPON: u8 = 1;
|
||||||
const SHOP_OPTION_ARMOR: u8 = 2;
|
const SHOP_OPTION_ARMOR: u8 = 2;
|
||||||
|
|
||||||
const INVENTORY_MESETA_CAPACITY: u32 = 999999;
|
|
||||||
const BANK_MESETA_CAPACITY: u32 = 999999;
|
|
||||||
|
|
||||||
//const BANK_ACTION_: u8 = 1;
|
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
#[error("")]
|
|
||||||
pub enum MessageError {
|
pub enum MessageError {
|
||||||
|
#[error("invalid tek {0}")]
|
||||||
InvalidTek(ClientItemId),
|
InvalidTek(ClientItemId),
|
||||||
|
#[error("mismatched tek {0} {1}")]
|
||||||
MismatchedTekIds(ClientItemId, ClientItemId),
|
MismatchedTekIds(ClientItemId, ClientItemId),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +154,7 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
//match item_manager.character_picks_up_item(entity_gateway, &mut client.character, ClientItemId(pickup_item.item_id)).await {
|
//match item_manager.character_picks_up_item(entity_gateway, &mut client.character, ClientItemId(pickup_item.item_id)).await {
|
||||||
match pick_up_item(item_state, entity_gateway, &mut client.character, &ClientItemId(pickup_item.item_id)).await {
|
match pick_up_item(item_state, entity_gateway, &client.character, &ClientItemId(pickup_item.item_id)).await {
|
||||||
Ok(trigger_create_item) => {
|
Ok(trigger_create_item) => {
|
||||||
let remove_packets: Box<dyn Iterator<Item=(ClientId, SendShipPacket)> + Send> = match floor_type {
|
let remove_packets: Box<dyn Iterator<Item=(ClientId, SendShipPacket)> + Send> = match floor_type {
|
||||||
FloorType::Local => {
|
FloorType::Local => {
|
||||||
@ -374,7 +370,7 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let inventory_item = buy_shop_item(item_state, entity_gateway, &mut client.character, item, ClientItemId(buy_item.item_id), buy_item.amount as u32).await?;
|
let inventory_item = buy_shop_item(item_state, entity_gateway, &client.character, item, ClientItemId(buy_item.item_id), buy_item.amount as u32).await?;
|
||||||
let create = builder::message::create_withdrawn_inventory_item(area_client, &inventory_item)?;
|
let create = builder::message::create_withdrawn_inventory_item(area_client, &inventory_item)?;
|
||||||
|
|
||||||
if remove {
|
if remove {
|
||||||
@ -432,11 +428,10 @@ where
|
|||||||
let inventory = item_state.get_character_inventory(&client.character)?;
|
let inventory = item_state.get_character_inventory(&client.character)?;
|
||||||
let item = inventory.get_by_client_id(&ClientItemId(tek_request.item_id))
|
let item = inventory.get_by_client_id(&ClientItemId(tek_request.item_id))
|
||||||
.ok_or(ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?;
|
.ok_or(ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?;
|
||||||
let mut weapon = item.item.as_individual()
|
let mut weapon = *item.item.as_individual()
|
||||||
.ok_or(ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?
|
.ok_or(ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?
|
||||||
.as_weapon()
|
.as_weapon()
|
||||||
.ok_or(ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?
|
.ok_or(ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?;
|
||||||
.clone();
|
|
||||||
|
|
||||||
weapon.apply_modifier(&item::weapon::WeaponModifier::Tekked {
|
weapon.apply_modifier(&item::weapon::WeaponModifier::Tekked {
|
||||||
special: special_mod,
|
special: special_mod,
|
||||||
|
@ -10,10 +10,8 @@ use crate::ship::trade::{TradeItem, TradeState, TradeStatus};
|
|||||||
use crate::entity::gateway::EntityGateway;
|
use crate::entity::gateway::EntityGateway;
|
||||||
use crate::ship::packet::builder;
|
use crate::ship::packet::builder;
|
||||||
use crate::ship::items::actions::trade_items;
|
use crate::ship::items::actions::trade_items;
|
||||||
use crate::entity::item::ItemDetail;
|
use crate::ship::location::{AreaClient, RoomId};
|
||||||
use crate::entity::item::tool::Tool;
|
use crate::entity::item::Meseta;
|
||||||
use crate::ship::location::AreaClient;
|
|
||||||
use crate::entity::item::{Meseta, ItemNote};
|
|
||||||
|
|
||||||
pub const MESETA_ITEM_ID: ClientItemId = ClientItemId(0xFFFFFF01);
|
pub const MESETA_ITEM_ID: ClientItemId = ClientItemId(0xFFFFFF01);
|
||||||
pub const OTHER_MESETA_ITEM_ID: ClientItemId = ClientItemId(0xFFFFFFFF);
|
pub const OTHER_MESETA_ITEM_ID: ClientItemId = ClientItemId(0xFFFFFFFF);
|
||||||
@ -441,9 +439,9 @@ where
|
|||||||
{
|
{
|
||||||
enum TradeReady<'a> {
|
enum TradeReady<'a> {
|
||||||
OnePlayer,
|
OnePlayer,
|
||||||
BothPlayers(crate::ship::location::RoomId,
|
BothPlayers(RoomId,
|
||||||
(crate::ship::location::AreaClient, &'a crate::ship::ship::ClientState, crate::ship::trade::ClientTradeState),
|
(AreaClient, &'a crate::ship::ship::ClientState, crate::ship::trade::ClientTradeState),
|
||||||
(crate::ship::location::AreaClient, &'a crate::ship::ship::ClientState, crate::ship::trade::ClientTradeState)),
|
(AreaClient, &'a crate::ship::ship::ClientState, crate::ship::trade::ClientTradeState)),
|
||||||
}
|
}
|
||||||
|
|
||||||
let trade_instructions = trades
|
let trade_instructions = trades
|
||||||
@ -476,7 +474,7 @@ where
|
|||||||
TradeReady::OnePlayer => {
|
TradeReady::OnePlayer => {
|
||||||
Ok(Box::new(None.into_iter()) as Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>)
|
Ok(Box::new(None.into_iter()) as Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>)
|
||||||
},
|
},
|
||||||
TradeReady::BothPlayers(room_id, (this_local_client, this_client, this), (other_local_client, other_client, other)) => {
|
TradeReady::BothPlayers(_room_id, (this_local_client, this_client, this), (other_local_client, other_client, other)) => {
|
||||||
let remove_item_packets = this.items
|
let remove_item_packets = this.items
|
||||||
.clone()
|
.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -495,7 +493,6 @@ where
|
|||||||
|
|
||||||
let (this_new_items, other_new_items) = trade_items(item_state,
|
let (this_new_items, other_new_items) = trade_items(item_state,
|
||||||
entity_gateway,
|
entity_gateway,
|
||||||
room_id,
|
|
||||||
(&this_local_client, &this_client.character, &this.items, Meseta(this.meseta as u32)),
|
(&this_local_client, &this_client.character, &this.items, Meseta(this.meseta as u32)),
|
||||||
(&other_local_client, &other_client.character, &other.items, Meseta(other.meseta as u32))).await?;
|
(&other_local_client, &other_client.character, &other.items, Meseta(other.meseta as u32))).await?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user