Browse Source

drop techs

pbs
jake 5 years ago
parent
commit
02c9cdc276
  1. 25
      src/entity/character.rs
  2. 32
      src/entity/item/tech.rs
  3. 2
      src/ship/drops/tech_table.rs

25
src/entity/character.rs

@ -153,29 +153,8 @@ impl CharacterTechniques {
pub 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 {
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 - 1;
let index = tech.as_value();
techlist[index as usize] = level.0 - 1;
techlist techlist
}) })
} }

32
src/entity/item/tech.rs

@ -24,6 +24,31 @@ pub enum Technique {
Megid, Megid,
} }
impl Technique {
pub fn as_value(&self) -> u8 {
match self {
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,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TechniqueDisk { pub struct TechniqueDisk {
@ -33,6 +58,11 @@ pub struct TechniqueDisk {
impl TechniqueDisk { impl TechniqueDisk {
pub fn as_bytes(&self) -> [u8; 16] { pub fn as_bytes(&self) -> [u8; 16] {
[0; 16]
let mut result = [0; 16];
result[0] = 3;
result[1] = 2;
result[2] = self.level as u8 - 1;
result[4] = self.tech.as_value();
result
} }
} }

2
src/ship/drops/tech_table.rs

@ -100,7 +100,7 @@ impl TechniqueTable {
let tech_weights = WeightedIndex::new(tech_rates.clone().map(|(_, stat)| stat.rate)).unwrap(); let tech_weights = WeightedIndex::new(tech_rates.clone().map(|(_, stat)| stat.rate)).unwrap();
let (tech, stat) = tech_rates.nth(tech_weights.sample(rng)).unwrap(); let (tech, stat) = tech_rates.nth(tech_weights.sample(rng)).unwrap();
let level = rng.gen_range(stat.min, stat.max+1);
let level = rng.gen_range(stat.min, stat.max+1) + 1;
Some(ItemDropType::TechniqueDisk(TechniqueDisk { Some(ItemDropType::TechniqueDisk(TechniqueDisk {
tech: *tech, tech: *tech,

Loading…
Cancel
Save