Browse Source

Merge pull request 'get_the_web_ui_working' (#251) from get_the_web_ui_working into master

pbs
jake 4 years ago
parent
commit
82c4c2a445
  1. 2
      Cargo.toml
  2. 24
      src/entity/gateway/postgres/migrations/V0001__initial.sql
  3. 23
      src/entity/gateway/postgres/migrations/V0002__equips.sql
  4. 8
      src/entity/item/mod.rs
  5. 6
      src/login/character.rs
  6. 5
      src/ship/items/mod.rs

2
Cargo.toml

@ -28,7 +28,7 @@ async-trait = "0.1.41"
lazy_static = "1.4.0"
barrel = { version = "0.6.5", features = ["pg"] }
refinery = { version = "0.3.0", features = ["postgres"] }
sqlx = { version = "0.4.0-beta.1", features = ["postgres", "json", "chrono"] }
sqlx = { version = "0.4.0", features = ["runtime-async-std-native-tls", "postgres", "json", "chrono"] }
strum = "0.19.5"
strum_macros = "0.19"
anyhow = "1.0.33"

24
src/entity/gateway/postgres/migrations/V0001__initial.sql

@ -122,27 +122,3 @@ create table mag_modifier (
modifier jsonb not null,
created_at timestamptz default current_timestamp not null
);
create table equipped (
pchar integer references player_character (id) unique not null,
weapon integer references item (id),
armor integer references item (id),
shield integer references item (id),
unit0 integer references item (id),
unit1 integer references item (id),
unit2 integer references item (id),
unit3 integer references item (id),
mag integer references item (id)
);
create table inventory (
pchar integer references player_character (id) unique not null,
items jsonb not null
);
create table bank (
pchar integer references player_character (id) not null,
items jsonb not null,
name varchar(128) not null,
unique (pchar, name)
);

23
src/entity/gateway/postgres/migrations/V0002__equips.sql

@ -0,0 +1,23 @@
create table equipped (
pchar integer references player_character (id) unique not null,
weapon integer references item (id),
armor integer references item (id),
shield integer references item (id),
unit0 integer references item (id),
unit1 integer references item (id),
unit2 integer references item (id),
unit3 integer references item (id),
mag integer references item (id)
);
create table inventory (
pchar integer references player_character (id) unique not null,
items jsonb not null
);
create table bank (
pchar integer references player_character (id) not null,
items jsonb not null,
name varchar(128) not null,
unique (pchar, name)
);

8
src/entity/item/mod.rs

@ -17,10 +17,10 @@ use crate::ship::drops::ItemDropType;
pub struct ItemEntityId(pub u32);
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
pub struct ItemId(u32);
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
pub struct BankName(pub String);
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum ItemLocation {
Inventory {
character_id: CharacterEntityId,
@ -167,7 +167,7 @@ pub struct NewItemEntity {
pub item: ItemDetail,
}
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ItemEntity {
pub id: ItemEntityId,
pub location: ItemLocation,
@ -175,7 +175,7 @@ pub struct ItemEntity {
}
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum InventoryItemEntity {
Individual(ItemEntity),
Stacked(Vec<ItemEntity>),

6
src/login/character.rs

@ -266,13 +266,13 @@ async fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAc
items: vec![InventoryItemEntity::Individual(weapon.clone()), InventoryItemEntity::Individual(armor.clone()), InventoryItemEntity::Individual(mag.clone()),
InventoryItemEntity::Stacked(monomates), InventoryItemEntity::Stacked(monofluids)],
};
entity_gateway.set_character_inventory(&character.id, &inventory);
entity_gateway.set_character_bank(&character.id, &BankEntity::default(), BankName("".into()));
entity_gateway.set_character_inventory(&character.id, &inventory).await;
entity_gateway.set_character_bank(&character.id, &BankEntity::default(), BankName("".into())).await;
let mut equipped = EquippedEntity::default();
equipped.weapon = Some(weapon.id);
equipped.armor = Some(armor.id);
equipped.mag = Some(mag.id);
entity_gateway.set_character_equips(&character.id, &equipped);
entity_gateway.set_character_equips(&character.id, &equipped).await;
}

5
src/ship/items/mod.rs

@ -1,10 +1,11 @@
mod bank;
mod floor;
mod inventory;
pub mod inventory;
mod manager;
pub mod use_tool;
use serde::{Serialize, Deserialize};
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct ClientItemId(pub u32);
// TODO: remove these and fix use statements in the rest of the codebase

Loading…
Cancel
Save