Browse Source

tech table load config

pbs
jake 5 years ago
parent
commit
afbd63ff6a
  1. 24
      src/entity/character.rs
  2. 3
      src/entity/item/mod.rs
  3. 3
      src/login/character.rs
  4. 70
      src/ship/drops/tech_table.rs
  5. 6
      src/ship/drops/tool_table.rs
  6. 1
      src/ship/items.rs

24
src/entity/character.rs

@ -3,6 +3,7 @@ use std::collections::HashMap;
use libpso::character::character; use libpso::character::character;
use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; use libpso::packet::ship::{UpdateConfig, WriteInfoboard};
use crate::entity::item::tech::Technique;
#[derive(Copy, Clone, Hash, PartialEq, Eq)] #[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub enum CharacterClass { pub enum CharacterClass {
@ -127,29 +128,6 @@ pub struct CharacterAppearance {
} }
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Technique {
Foie,
Gifoie,
Rafoie,
Zonde,
Gizonde,
Razonde,
Barta,
Gibarta,
Rabarta,
Grants,
Megid,
Shifta,
Deband,
Jellen,
Zalure,
Resta,
Anti,
Reverser,
Ryuker,
}
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct TechLevel(pub u8); pub struct TechLevel(pub u8);

3
src/entity/item/mod.rs

@ -2,6 +2,7 @@ pub mod weapon;
pub mod armor; pub mod armor;
pub mod shield; pub mod shield;
pub mod tool; pub mod tool;
pub mod tech;
pub mod unit; pub mod unit;
pub mod mag; pub mod mag;
@ -55,6 +56,7 @@ pub enum ItemDetail {
Shield(shield::Shield), Shield(shield::Shield),
Unit(unit::Unit), Unit(unit::Unit),
Tool(Tool), Tool(Tool),
TechniqueDisk(tech::TechniqueDisk)
} }
impl ItemDetail { impl ItemDetail {
@ -72,6 +74,7 @@ impl ItemDetail {
ItemDetail::Shield(shield) => shield.as_bytes(), ItemDetail::Shield(shield) => shield.as_bytes(),
ItemDetail::Unit(unit) => unit.as_bytes(), ItemDetail::Unit(unit) => unit.as_bytes(),
ItemDetail::Tool(tool) => tool.as_bytes(), ItemDetail::Tool(tool) => tool.as_bytes(),
ItemDetail::TechniqueDisk(tech) => tech.as_bytes(),
} }
} }
} }

3
src/login/character.rs

@ -20,7 +20,8 @@ use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROO
use crate::entity::item::{ItemDetail, ItemLocation, Tool}; use crate::entity::item::{ItemDetail, ItemLocation, Tool};
use crate::entity::item::weapon::Weapon; use crate::entity::item::weapon::Weapon;
use crate::entity::item::armor::Armor; use crate::entity::item::armor::Armor;
use crate::entity::character::{Character, CharacterClass, Technique, TechLevel};
use crate::entity::item::tech::Technique;
use crate::entity::character::{Character, CharacterClass, TechLevel};
use crate::login::login::get_login_status; use crate::login::login::get_login_status;

70
src/ship/drops/tech_table.rs

@ -4,8 +4,8 @@ use serde::{Serialize, Deserialize};
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use rand::distributions::{WeightedIndex, Distribution}; use rand::distributions::{WeightedIndex, Distribution};
use crate::entity::item::{ItemDetail, Tool as ToolDetail};
use crate::entity::item::tool::{StackedTool, ToolType};
use crate::entity::item::ItemDetail;
use crate::entity::item::tech::{Technique, TechniqueDisk};
use crate::ship::room::{Difficulty, Episode}; use crate::ship::room::{Difficulty, Episode};
use crate::ship::map::MapVariantType; use crate::ship::map::MapVariantType;
use crate::entity::character::SectionID; use crate::entity::character::SectionID;
@ -13,23 +13,81 @@ use crate::ship::drops::load_data_file;
#[derive(Debug, Serialize, Deserialize)]
struct TechniqueRateStat {
rate: u32,
min: i32,
max: i32,
}
#[derive(Debug, Serialize, Deserialize)]
struct TechniqueRate {
#[serde(rename = "Foie")]
foie: TechniqueRateStat,
#[serde(rename = "Gifoie")]
gifoie: TechniqueRateStat,
#[serde(rename = "Rafoie")]
rafoie: TechniqueRateStat,
#[serde(rename = "Zonde")]
zonde: TechniqueRateStat,
#[serde(rename = "Gizonde")]
gizonde: TechniqueRateStat,
#[serde(rename = "Razonde")]
razonde: TechniqueRateStat,
#[serde(rename = "Barta")]
barta: TechniqueRateStat,
#[serde(rename = "Gibarta")]
gibarta: TechniqueRateStat,
#[serde(rename = "Rabarta")]
rabarta: TechniqueRateStat,
#[serde(rename = "Grants")]
grants: TechniqueRateStat,
#[serde(rename = "Deband")]
deband: TechniqueRateStat,
#[serde(rename = "Jellen")]
jellen: TechniqueRateStat,
#[serde(rename = "Zalure")]
zalure: TechniqueRateStat,
#[serde(rename = "Shifta")]
shifta: TechniqueRateStat,
#[serde(rename = "Ryuker")]
ryuker: TechniqueRateStat,
#[serde(rename = "Resta")]
resta: TechniqueRateStat,
#[serde(rename = "Anti")]
anti: TechniqueRateStat,
#[serde(rename = "Reverser")]
reverser: TechniqueRateStat,
#[serde(rename = "Megid")]
megid: TechniqueRateStat,
}
#[derive(Debug, Serialize, Deserialize)]
struct TechniqueRates {
area1: TechniqueRate,
area2: TechniqueRate,
area3: TechniqueRate,
area4: TechniqueRate,
area5: TechniqueRate,
area6: TechniqueRate,
area7: TechniqueRate,
area8: TechniqueRate,
area9: TechniqueRate,
area10: TechniqueRate,
}
pub struct TechniqueTable { pub struct TechniqueTable {
rates: TechniqueRates
} }
impl TechniqueTable { impl TechniqueTable {
pub fn new(episode: Episode, difficulty: Difficulty, section_id: SectionID) -> TechniqueTable { pub fn new(episode: Episode, difficulty: Difficulty, section_id: SectionID) -> TechniqueTable {
TechniqueTable { TechniqueTable {
rates: load_data_file(episode, difficulty, section_id, "tech_rate.toml")
} }
} }

6
src/ship/drops/tool_table.rs

@ -97,7 +97,8 @@ impl ToolTable {
let tool_rates = self.rates.get_by_area(map_area).iter(); let tool_rates = self.rates.get_by_area(map_area).iter();
let tool_weights = WeightedIndex::new(tool_rates.clone().map(|(_, weights)| weights)).unwrap(); let tool_weights = WeightedIndex::new(tool_rates.clone().map(|(_, weights)| weights)).unwrap();
match tool_rates.map(|(ttype, _)| ttype).nth(tool_weights.sample(rng)).unwrap() {
let tool = tool_rates.map(|(ttype, _)| ttype).nth(tool_weights.sample(rng)).unwrap();
match tool {
ToolRateType::Monomate => ToolType::Monomate, ToolRateType::Monomate => ToolType::Monomate,
ToolRateType::Dimate => ToolType::Dimate, ToolRateType::Dimate => ToolType::Dimate,
ToolRateType::Trimate => ToolType::Trimate, ToolRateType::Trimate => ToolType::Trimate,
@ -124,9 +125,8 @@ impl ToolTable {
ToolRateType::ScapeDoll => ToolType::ScapeDoll, ToolRateType::ScapeDoll => ToolType::ScapeDoll,
ToolRateType::PhotonDrop => ToolType::PhotonDrop, ToolRateType::PhotonDrop => ToolType::PhotonDrop,
ToolRateType::Technique => todo!(), ToolRateType::Technique => todo!(),
//ToolRateType::Technique => self.tech_table.get_drop(area, rng),
//ToolRateType::Technique => self.tech_table.get_drop(map_area, rng),
} }
//let attribute_weights = WeightedIndex::new(&[rates.none, rates.native, rates.abeast, rates.machine, rates.dark, rates.hit]).unwrap();
} }
pub fn get_drop<R: Rng>(&self, map_area: &MapVariantType, rng: &mut R) -> Option<ItemDetail> { pub fn get_drop<R: Rng>(&self, map_area: &MapVariantType, rng: &mut R) -> Option<ItemDetail> {

1
src/ship/items.rs

@ -115,6 +115,7 @@ impl Hash for StackedItemKey {
ItemDetail::Shield(s) => s.shield.value().hash(hasher), ItemDetail::Shield(s) => s.shield.value().hash(hasher),
ItemDetail::Unit(u) => u.unit.value().hash(hasher), ItemDetail::Unit(u) => u.unit.value().hash(hasher),
ItemDetail::Tool(t) => t.tool.value().hash(hasher), ItemDetail::Tool(t) => t.tool.value().hash(hasher),
ItemDetail::TechniqueDisk(t) => t.tech.hash(hasher),
} }
} }
} }

Loading…
Cancel
Save