Browse Source

hide mag struct internals

pbs
jake 4 years ago
parent
commit
f583b25176
  1. 29
      src/entity/item/mag.rs
  2. 14
      src/login/character.rs
  3. 13
      src/ship/drops/rare_drop_table.rs

29
src/entity/item/mag.rs

@ -326,19 +326,34 @@ pub enum PhotonBlast {
#[derive(Debug, Clone, PartialEq)]
pub struct Mag {
pub mag: MagType,
pub def: u16,
pub pow: u16,
pub dex: u16,
pub mnd: u16,
def: u16,
pow: u16,
dex: u16,
mnd: u16,
pub synchro: u8,
pub iq: u8,
pub photon_blast: [Option<PhotonBlast>; 3],
iq: u8,
photon_blast: [Option<PhotonBlast>; 3],
pub color: u8,
pub modifiers: Vec<MagModifier>,
modifiers: Vec<MagModifier>,
}
impl Mag {
pub fn baby_mag(skin: u16) -> Mag {
Mag {
mag: MagType::Mag,
def: 500,
pow: 0,
dex: 0,
mnd: 0,
synchro: 20,
iq: 0,
photon_blast: [None; 3],
color: (skin % 18) as u8,
modifiers: Vec::new(),
}
}
pub fn as_bytes(&self) -> [u8; 16] {
let mut result = [0; 16];
result[0..3].copy_from_slice(&self.mag.value());

14
src/login/character.rs

@ -226,19 +226,7 @@ async fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAc
entity_gateway.create_item(
NewItemEntity {
item: ItemDetail::Mag(
Mag {
mag: MagType::Mag,
def: 500,
pow: 0,
dex: 0,
mnd: 0,
synchro: 20,
iq: 0,
photon_blast: [None; 3],
color: (character.appearance.skin % 18) as u8,
modifiers: Vec::new(),
}),
item: ItemDetail::Mag(Mag::baby_mag(character.appearance.skin)),
location: ItemLocation::Inventory {
character_id: character.id,
slot: 2,

13
src/ship/drops/rare_drop_table.rs

@ -136,18 +136,7 @@ impl RareDropTable {
})
},
RareDropItem::Mag(mag) => {
ItemDropType::Mag(Mag {
mag: mag,
def: 500,
pow: 0,
dex: 0,
mnd: 0,
iq: 0,
synchro: 20,
photon_blast: [None; 3],
color: rng.gen_range(0, 18),
modifiers: Vec::new(),
})
ItemDropType::Mag(Mag::baby_mag(rng.gen_range(0, 18)))
}
}
}

Loading…
Cancel
Save