move elseware characterclas/sectionid logic into libpso
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
c309e51f02
commit
240ddc7e84
@ -5,6 +5,8 @@ authors = ["Jake Probst <jake.probst@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
psopacket = { path = "psopacket" }
|
||||
rand = "0.6.5"
|
||||
chrono = "*"
|
||||
psopacket = { path = "psopacket" }
|
||||
serde = { version = "1.0", features = ["derive"]}
|
||||
strum = { version = "0.25.0", features = ["derive"] }
|
||||
|
@ -1,9 +1,11 @@
|
||||
// TODO: techniques to enum
|
||||
use psopacket::PSOPacketData;
|
||||
use crate::{PSOPacketData, PacketParseError};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(PSOPacketData, Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(PSOPacketData, Debug, Copy, Clone, Hash, PartialEq, Eq, strum::Display, strum::EnumString, Serialize, Deserialize)]
|
||||
pub enum CharacterClass {
|
||||
HUmar,
|
||||
HUnewearl,
|
||||
@ -25,6 +27,7 @@ impl Default for CharacterClass {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: TryFrom
|
||||
impl std::convert::From<u8> for CharacterClass {
|
||||
fn from(f: u8) -> CharacterClass {
|
||||
match f {
|
||||
@ -46,8 +49,54 @@ impl std::convert::From<u8> for CharacterClass {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CharacterClass> for u8 {
|
||||
fn from(other: CharacterClass) -> u8 {
|
||||
match other {
|
||||
CharacterClass::HUmar => 0,
|
||||
CharacterClass::HUnewearl => 1,
|
||||
CharacterClass::HUcast => 2,
|
||||
CharacterClass::RAmar => 3,
|
||||
CharacterClass::RAcast => 4,
|
||||
CharacterClass::RAcaseal => 5,
|
||||
CharacterClass::FOmarl => 6,
|
||||
CharacterClass::FOnewm => 7,
|
||||
CharacterClass::FOnewearl => 8,
|
||||
CharacterClass::HUcaseal => 9,
|
||||
CharacterClass::FOmar => 10,
|
||||
CharacterClass::RAmarl => 11,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CharacterClass {
|
||||
pub fn is_human(&self) -> bool {
|
||||
matches!(self,
|
||||
CharacterClass::HUmar |
|
||||
CharacterClass::RAmar |
|
||||
CharacterClass::RAmarl |
|
||||
CharacterClass::FOmar |
|
||||
CharacterClass::FOmarl)
|
||||
}
|
||||
|
||||
pub fn is_newman(&self) -> bool {
|
||||
matches!(self,
|
||||
CharacterClass::HUnewearl |
|
||||
CharacterClass::FOnewm |
|
||||
CharacterClass::FOnewearl)
|
||||
}
|
||||
|
||||
pub fn is_android(&self) -> bool {
|
||||
matches!(self,
|
||||
CharacterClass::HUcast |
|
||||
CharacterClass::HUcaseal |
|
||||
CharacterClass::RAcast |
|
||||
CharacterClass::RAcaseal)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(PSOPacketData, Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(PSOPacketData, Debug, Copy, Clone, Hash, PartialEq, Eq, strum::Display, strum::EnumString, Serialize, Deserialize)]
|
||||
pub enum SectionID {
|
||||
Viridia,
|
||||
Greenill,
|
||||
@ -67,6 +116,43 @@ impl Default for SectionID {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: TryFrom
|
||||
impl From<u8> for SectionID {
|
||||
fn from(id: u8) -> SectionID {
|
||||
match id {
|
||||
0 => SectionID::Viridia,
|
||||
1 => SectionID::Greenill,
|
||||
2 => SectionID::Skyly,
|
||||
3 => SectionID::Bluefull,
|
||||
4 => SectionID::Purplenum,
|
||||
5 => SectionID::Pinkal,
|
||||
6 => SectionID::Redria,
|
||||
7 => SectionID::Oran,
|
||||
8 => SectionID::Yellowboze,
|
||||
9 => SectionID::Whitill,
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SectionID> for u8 {
|
||||
fn from(other: SectionID) -> u8 {
|
||||
match other {
|
||||
SectionID::Viridia => 0,
|
||||
SectionID::Greenill => 1,
|
||||
SectionID::Skyly => 2,
|
||||
SectionID::Bluefull => 3,
|
||||
SectionID::Purplenum => 4,
|
||||
SectionID::Pinkal => 5,
|
||||
SectionID::Redria => 6,
|
||||
SectionID::Oran => 7,
|
||||
SectionID::Yellowboze => 8,
|
||||
SectionID::Whitill => 9,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(PSOPacketData, Copy, Clone)]
|
||||
#[repr(C)]
|
||||
|
@ -2,3 +2,5 @@
|
||||
pub mod settings;
|
||||
pub mod character;
|
||||
pub mod guildcard;
|
||||
|
||||
pub use character::{SectionID, CharacterClass};
|
||||
|
Loading…
x
Reference in New Issue
Block a user