Browse Source

properly show techs and new FOs start with foie 1

pbs
jake 5 years ago
parent
commit
28a30cb06f
  1. 50
      src/entity/character.rs
  2. 7
      src/login/character.rs
  3. 1
      src/ship/character.rs

50
src/entity/character.rs

@ -127,7 +127,7 @@ pub struct CharacterAppearance {
#[derive(Clone, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Techniques {
pub enum Technique {
Foie, Foie,
Gifoie, Gifoie,
Rafoie, Rafoie,
@ -150,11 +150,11 @@ pub enum Techniques {
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct TechLevel(u8);
pub struct TechLevel(pub u8);
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CharacterTechniques { pub struct CharacterTechniques {
techs: HashMap<Techniques, TechLevel>
techs: HashMap<Technique, TechLevel>
} }
impl CharacterTechniques { 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); self.techs.insert(tech, level);
} }
// from_bytes // from_bytes
fn as_bytes(&self) -> [u8; 20] {
pub fn as_bytes(&self) -> [u8; 20] {
self.techs.iter() self.techs.iter()
.fold([0xFF; 20], |mut techlist, (tech, level)| { .fold([0xFF; 20], |mut techlist, (tech, level)| {
let index = match tech { 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 techlist
}) })
} }

7
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::gateway::EntityGateway;
use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use crate::entity::item::{ItemDetail, ItemLocation, Weapon, Armor, Shield, Tool}; 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; use crate::login::login::get_login_status;
@ -187,6 +187,11 @@ pub struct CharacterServerState<EG: EntityGateway> {
fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount, preview: &CharacterPreview) { fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount, preview: &CharacterPreview) {
let mut char = entity_gateway.new_character_by_user(&user); let mut char = entity_gateway.new_character_by_user(&user);
new_character_from_preview(&mut char, preview); 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); entity_gateway.set_character(&char);
let new_weapon = match char.char_class { let new_weapon = match char.char_class {

1
src/ship/character.rs

@ -67,6 +67,7 @@ impl<'a> CharacterBytesBuilder<'a> {
hair_b: character.appearance.hair_b, hair_b: character.appearance.hair_b,
prop_x: character.appearance.prop_x, prop_x: character.appearance.prop_x,
prop_y: character.appearance.prop_y, prop_y: character.appearance.prop_y,
techniques: character.techs.as_bytes(),
..character::Character::default() ..character::Character::default()
} }
} }

Loading…
Cancel
Save