Browse Source

add materials

pbs
jake 4 years ago
parent
commit
4452b6d4d2
  1. 13
      src/entity/character.rs
  2. 1
      src/entity/gateway/inmemory.rs
  3. 24
      src/ship/character.rs

13
src/entity/character.rs

@ -225,6 +225,16 @@ impl CharacterTechMenu {
} }
} }
#[derive(Clone, Default)]
pub struct CharacterMaterials {
pub power: u32,
pub mind: u32,
pub def: u32,
pub evade: u32,
pub luck: u32,
pub hp: u32,
pub tp: u32,
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct CharacterEntityId(pub u32); pub struct CharacterEntityId(pub u32);
@ -245,6 +255,7 @@ pub struct NewCharacterEntity {
pub config: CharacterConfig, pub config: CharacterConfig,
pub info_board: CharacterInfoboard, pub info_board: CharacterInfoboard,
pub guildcard: CharacterGuildCard, pub guildcard: CharacterGuildCard,
pub materials: CharacterMaterials,
pub tech_menu: CharacterTechMenu, pub tech_menu: CharacterTechMenu,
pub meseta: u32, pub meseta: u32,
@ -264,6 +275,7 @@ impl NewCharacterEntity {
config: CharacterConfig::new(), config: CharacterConfig::new(),
info_board: CharacterInfoboard::new(), info_board: CharacterInfoboard::new(),
guildcard: CharacterGuildCard::default(), guildcard: CharacterGuildCard::default(),
materials: CharacterMaterials::default(),
tech_menu: CharacterTechMenu::new(), tech_menu: CharacterTechMenu::new(),
meseta: 0, meseta: 0,
} }
@ -287,6 +299,7 @@ pub struct CharacterEntity {
pub config: CharacterConfig, pub config: CharacterConfig,
pub info_board: CharacterInfoboard, pub info_board: CharacterInfoboard,
pub guildcard: CharacterGuildCard, pub guildcard: CharacterGuildCard,
pub materials: CharacterMaterials,
pub tech_menu: CharacterTechMenu, pub tech_menu: CharacterTechMenu,
pub meseta: u32, pub meseta: u32,

1
src/entity/gateway/inmemory.rs

@ -120,6 +120,7 @@ impl EntityGateway for InMemoryGateway {
config: character.config, config: character.config,
info_board: character.info_board, info_board: character.info_board,
guildcard: character.guildcard, guildcard: character.guildcard,
materials: character.materials,
tech_menu: character.tech_menu, tech_menu: character.tech_menu,
meseta: character.meseta, meseta: character.meseta,
}; };

24
src/ship/character.rs

@ -46,13 +46,13 @@ impl<'a> CharacterBytesBuilder<'a> {
let level = self.level.unwrap(); let level = self.level.unwrap();
character::Character { character::Character {
name: libpso::utf8_to_utf16_array!(character.name, 16), name: libpso::utf8_to_utf16_array!(character.name, 16),
hp: stats.hp,
atp: stats.atp,
mst: stats.mst,
evp: stats.evp,
dfp: stats.dfp,
hp: stats.hp + character.materials.hp as u16 * 2,
atp: stats.atp + character.materials.power as u16 * 2,
mst: stats.mst + character.materials.mind as u16 * 2,
evp: stats.evp + character.materials.evade as u16 * 2,
dfp: stats.dfp + character.materials.def as u16 * 2,
ata: stats.ata, ata: stats.ata,
lck: stats.lck,
lck: stats.lck + character.materials.luck as u16 * 2,
level: level, level: level,
section_id: character.section_id.into(), section_id: character.section_id.into(),
ch_class: character.char_class.into(), ch_class: character.char_class.into(),
@ -158,7 +158,6 @@ impl<'a> FullCharacterBytesBuilder<'a> {
} }
} }
pub fn build(self) -> character::FullCharacter { pub fn build(self) -> character::FullCharacter {
let character = self.character.unwrap(); let character = self.character.unwrap();
let stats = self.stats.unwrap(); let stats = self.stats.unwrap();
@ -169,6 +168,13 @@ impl<'a> FullCharacterBytesBuilder<'a> {
let symbol_chat = self.symbol_chat.unwrap(); let symbol_chat = self.symbol_chat.unwrap();
let tech_menu = self.tech_menu.unwrap(); let tech_menu = self.tech_menu.unwrap();
let mut inventory_items = inventory.as_client_inventory_items();
inventory_items[7].material_count = character.materials.power as u8;
inventory_items[8].material_count = character.materials.mind as u8;
inventory_items[9].material_count = character.materials.evade as u8;
inventory_items[10].material_count = character.materials.def as u8;
inventory_items[11].material_count = character.materials.luck as u8;
character::FullCharacter { character::FullCharacter {
character: CharacterBytesBuilder::new() character: CharacterBytesBuilder::new()
.character(&character) .character(&character)
@ -177,7 +183,9 @@ impl<'a> FullCharacterBytesBuilder<'a> {
.build(), .build(),
inventory: character::Inventory { inventory: character::Inventory {
item_count: inventory.count() as u8, item_count: inventory.count() as u8,
items: inventory.as_client_inventory_items(),
items: inventory_items,
hp_mats_used: character.materials.hp as u8 * 2,
tp_mats_used: character.materials.tp as u8 * 2,
..character::Inventory::default() ..character::Inventory::default()
}, },
key_team_config: character::KeyTeamConfig { key_team_config: character::KeyTeamConfig {

Loading…
Cancel
Save