diff --git a/src/entity/character.rs b/src/entity/character.rs index 6014515..f035a4a 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -127,7 +127,7 @@ pub struct CharacterAppearance { #[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub enum Techniques { +pub enum Technique { Foie, Gifoie, Rafoie, @@ -150,11 +150,11 @@ pub enum Techniques { } #[derive(Clone, Debug)] -pub struct TechLevel(u8); +pub struct TechLevel(pub u8); #[derive(Clone, Debug)] pub struct CharacterTechniques { - techs: HashMap + techs: HashMap } impl CharacterTechniques { @@ -164,38 +164,38 @@ impl CharacterTechniques { } } - fn set_tech(&mut self, tech: Techniques, level: TechLevel) { + pub fn set_tech(&mut self, tech: Technique, level: TechLevel) { self.techs.insert(tech, level); } // from_bytes - fn as_bytes(&self) -> [u8; 20] { + pub fn as_bytes(&self) -> [u8; 20] { self.techs.iter() .fold([0xFF; 20], |mut techlist, (tech, level)| { let index = match tech { - Techniques::Foie => 0, - Techniques::Gifoie => 1, - Techniques::Rafoie => 2, - Techniques::Zonde => 3, - Techniques::Gizonde => 4, - Techniques::Razonde => 5, - Techniques::Barta => 6, - Techniques::Gibarta => 7, - Techniques::Rabarta => 8, - Techniques::Grants => 9, - Techniques::Megid => 10, - Techniques::Shifta => 11, - Techniques::Deband => 12, - Techniques::Jellen => 13, - Techniques::Zalure => 14, - Techniques::Resta => 15, - Techniques::Anti => 16, - Techniques::Reverser => 17, - Techniques::Ryuker => 18, + Technique::Foie => 0, + Technique::Gifoie => 1, + Technique::Rafoie => 2, + Technique::Barta => 3, + Technique::Gibarta => 4, + Technique::Rabarta => 5, + Technique::Zonde => 6, + Technique::Gizonde => 7, + Technique::Razonde => 8, + Technique::Grants => 9, + Technique::Deband => 10, + Technique::Jellen => 11, + Technique::Zalure => 12, + Technique::Shifta => 13, + Technique::Ryuker => 14, + Technique::Resta => 15, + Technique::Anti => 16, + Technique::Reverser => 17, + Technique::Megid => 18, }; - techlist[index] = level.0; + techlist[index] = level.0 - 1; techlist }) } diff --git a/src/login/character.rs b/src/login/character.rs index 555807f..63285ef 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -18,7 +18,7 @@ use libpso::{utf8_to_array, utf8_to_utf16_array}; use crate::entity::gateway::EntityGateway; use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; use crate::entity::item::{ItemDetail, ItemLocation, Weapon, Armor, Shield, Tool}; -use crate::entity::character::{Character, CharacterClass}; +use crate::entity::character::{Character, CharacterClass, Technique, TechLevel}; use crate::login::login::get_login_status; @@ -187,12 +187,17 @@ pub struct CharacterServerState { fn new_character(entity_gateway: &mut EG, user: &UserAccount, preview: &CharacterPreview) { let mut char = entity_gateway.new_character_by_user(&user); new_character_from_preview(&mut char, preview); + match char.char_class { + CharacterClass::FOmar | CharacterClass::FOmarl| CharacterClass::FOnewm | CharacterClass::FOnewearl => char.techs.set_tech(Technique::Foie, TechLevel(1)), + _ => {} + } + entity_gateway.set_character(&char); let new_weapon = match char.char_class { CharacterClass::HUmar | CharacterClass::HUnewearl | CharacterClass::HUcast | CharacterClass::HUcaseal => item::weapon::WeaponType::Saber, CharacterClass::RAmar | CharacterClass::RAmarl | CharacterClass::RAcast | CharacterClass::RAcaseal => item::weapon::WeaponType::Handgun, - CharacterClass::FOmar| CharacterClass::FOmarl| CharacterClass::FOnewm | CharacterClass::FOnewearl => item::weapon::WeaponType::Cane, + CharacterClass::FOmar | CharacterClass::FOmarl| CharacterClass::FOnewm | CharacterClass::FOnewearl => item::weapon::WeaponType::Cane, }; entity_gateway.new_item( diff --git a/src/ship/character.rs b/src/ship/character.rs index 784d1ef..ceb0894 100644 --- a/src/ship/character.rs +++ b/src/ship/character.rs @@ -67,6 +67,7 @@ impl<'a> CharacterBytesBuilder<'a> { hair_b: character.appearance.hair_b, prop_x: character.appearance.prop_x, prop_y: character.appearance.prop_y, + techniques: character.techs.as_bytes(), ..character::Character::default() } }