Fixed csv tools

This commit is contained in:
Sam 2021-05-20 21:34:06 -05:00 committed by Marcel Märtens
parent 855384fbeb
commit fa0fe38699
4 changed files with 74 additions and 8 deletions

1
Cargo.lock generated
View File

@ -5776,6 +5776,7 @@ dependencies = [
"ordered-float 2.5.1",
"rand 0.8.3",
"rayon",
"ron",
"roots",
"serde",
"serde_repr",

View File

@ -19,6 +19,7 @@ common-base = { package = "veloren-common-base", path = "base" }
# Serde
serde = { version = "1.0.110", features = ["derive", "rc"] }
ron = { version = "0.6", default-features = false }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
approx = "0.4.0"

View File

@ -36,6 +36,10 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
"Quality",
"Protection",
"Poise Resilience",
"Max Energy",
"Energy Recovery",
"Crit Power",
"Stealth",
"Description",
])?;
@ -57,6 +61,10 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
Protection::Invincible => "Invincible".to_string(),
Protection::Normal(value) => value.to_string(),
};
let max_energy = armor.get_energy_max().to_string();
let energy_recovery = armor.get_energy_recovery().to_string();
let crit_power = armor.get_crit_power().to_string();
let stealth = armor.get_stealth().to_string();
wtr.write_record(&[
item.item_definition_id(),
@ -65,6 +73,10 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
&format!("{:?}", item.quality()),
&protection,
&poise_resilience,
&max_energy,
&energy_recovery,
&crit_power,
&stealth,
item.description(),
])?;
},
@ -139,19 +151,19 @@ fn weapon_stats() -> Result<(), Box<dyn Error>> {
fn get_tool_kind(kind: &ToolKind) -> String {
match kind {
ToolKind::Sword | ToolKind::SwordSimple => "Sword".to_string(),
ToolKind::Axe | ToolKind::AxeSimple => "Axe".to_string(),
ToolKind::Hammer | ToolKind::HammerSimple => "Hammer".to_string(),
ToolKind::Bow | ToolKind::BowSimple => "Bow".to_string(),
ToolKind::Sword => "Sword".to_string(),
ToolKind::Axe => "Axe".to_string(),
ToolKind::Hammer => "Hammer".to_string(),
ToolKind::Bow => "Bow".to_string(),
ToolKind::Dagger => "Dagger".to_string(),
ToolKind::Staff | ToolKind::StaffSimple => "Staff".to_string(),
ToolKind::Staff => "Staff".to_string(),
ToolKind::Sceptre => "Sceptre".to_string(),
ToolKind::Shield => "Shield".to_string(),
ToolKind::Spear => "Spear".to_string(),
ToolKind::Debug => "Debug".to_string(),
ToolKind::Farming => "Farming".to_string(),
ToolKind::Pick => "Pick".to_string(),
ToolKind::Unique(_) => "Unique".to_string(),
ToolKind::Natural => "Natural".to_string(),
ToolKind::Empty => "Empty".to_string(),
}
}

View File

@ -112,9 +112,61 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
Protection::Normal(0.0)
};
let max_energy =
if let Some(max_energy_raw) = record.get(headers["Max Energy"]) {
max_energy_raw.parse().unwrap()
} else {
eprintln!(
"Could not unwrap max energy value for {:?}",
item.item_definition_id()
);
0
};
let energy_recovery = if let Some(energy_recovery_raw) =
record.get(headers["Energy Recovery"])
{
energy_recovery_raw.parse().unwrap()
} else {
eprintln!(
"Could not unwrap energy recovery value for {:?}",
item.item_definition_id()
);
0.0
};
let crit_power =
if let Some(crit_power_raw) = record.get(headers["Crit Power"]) {
crit_power_raw.parse().unwrap()
} else {
eprintln!(
"Could not unwrap crit power value for {:?}",
item.item_definition_id()
);
0.0
};
let stealth = if let Some(stealth_raw) = record.get(headers["Stealth"])
{
stealth_raw.parse().unwrap()
} else {
eprintln!(
"Could not unwrap stealth value for {:?}",
item.item_definition_id()
);
0.0
};
let kind = armor.kind.clone();
let armor =
comp::item::armor::Armor::new(kind, protection, poise_resilience);
let armor_stats = comp::item::armor::Stats::new(
protection,
poise_resilience,
max_energy,
energy_recovery,
crit_power,
stealth,
);
let armor = comp::item::armor::Armor::new(kind, armor_stats);
let quality = if let Some(quality_raw) = record.get(headers["Quality"])
{
match quality_raw {