diff --git a/common/src/bin/csv_export/main.rs b/common/src/bin/csv_export/main.rs index 79b2bfee2a..8ec6daf421 100644 --- a/common/src/bin/csv_export/main.rs +++ b/common/src/bin/csv_export/main.rs @@ -13,7 +13,7 @@ use veloren_common::{ self, item::{ armor::{ArmorKind, Protection}, - tool::{Hands, HandsKind, MaterialStatManifest, Tool, ToolKind}, + tool::{Hands, Tool, ToolKind}, Item, ItemKind, }, }, @@ -49,7 +49,7 @@ fn armor_stats() -> Result<(), Box> { for item in comp::item::Item::new_from_asset_glob("common.items.armor.*") .expect("Failed to iterate over item folders!") { - match item.kind() { + match &*item.kind() { comp::item::ItemKind::Armor(armor) => { let kind = get_armor_kind(&armor.kind); if kind == "Bag" { @@ -72,7 +72,7 @@ fn armor_stats() -> Result<(), Box> { let stealth = armor.stealth().unwrap_or(0.0).to_string(); wtr.write_record(&[ - item.item_definition_id(), + item.item_definition_id().raw().expect("All items from asset glob should be simple items"), &kind, &item.name(), &format!("{:?}", item.quality()), @@ -112,28 +112,26 @@ fn weapon_stats() -> Result<(), Box> { "Description", ])?; - let msm = MaterialStatManifest::default(); - // Does all items even outside weapon folder since we check if itemkind was a // tool anyways let items: Vec = comp::Item::new_from_asset_glob("common.items.*") .expect("Failed to iterate over item folders!"); for item in items.iter() { - if let comp::item::ItemKind::Tool(tool) = item.kind() { - let power = tool.base_power(&msm, &[]).to_string(); - let effect_power = tool.base_effect_power(&msm, &[]).to_string(); - let speed = tool.base_speed(&msm, &[]).to_string(); - let crit_chance = tool.base_crit_chance(&msm, &[]).to_string(); - let range = tool.base_range(&msm, &[]).to_string(); - let energy_efficiency = tool.base_energy_efficiency(&msm, &[]).to_string(); - let buff_strength = tool.base_buff_strength(&msm, &[]).to_string(); - let equip_time = tool.equip_time(&msm, &[]).as_secs_f32().to_string(); + if let comp::item::ItemKind::Tool(tool) = &*item.kind() { + let power = tool.base_power().to_string(); + let effect_power = tool.base_effect_power().to_string(); + let speed = tool.base_speed().to_string(); + let crit_chance = tool.base_crit_chance().to_string(); + let range = tool.base_range().to_string(); + let energy_efficiency = tool.base_energy_efficiency().to_string(); + let buff_strength = tool.base_buff_strength().to_string(); + let equip_time = tool.equip_time().as_secs_f32().to_string(); let kind = get_tool_kind(&tool.kind); let hands = get_tool_hands(tool); wtr.write_record(&[ - item.item_definition_id(), + item.item_definition_id().raw().expect("All items from asset glob should be simple items"), &kind, &item.name(), &hands, @@ -223,13 +221,13 @@ fn all_items() -> Result<(), Box> { for item in comp::item::Item::new_from_asset_glob("common.items.*") .expect("Failed to iterate over item folders!") { - let kind = match item.kind() { + let kind = match &*item.kind() { ItemKind::Armor(armor) => get_armor_kind_kind(&armor.kind), ItemKind::Lantern(lantern) => lantern.kind.clone(), _ => "".to_owned(), }; - wtr.write_record(&[item.item_definition_id(), &item.name(), &kind])?; + wtr.write_record(&[item.item_definition_id().raw().expect("All items in asset glob should be simple items"), &item.name(), &kind])?; } wtr.flush()?; @@ -395,6 +393,10 @@ fn entity_drops(entity_config: &str) -> Result<(), Box> { // Tab needed so excel doesn't think it is a date... (Some(item), format!("{}-{}\t", lower, upper)) }, + LootSpec::ModularWeapon { .. } => { + // TODO: Figure out how modular weapons should work here + (None, String::from("1")) + }, LootSpec::LootTable(_) => panic!("Shouldn't exist"), LootSpec::Nothing => (None, "-".to_string()), }; @@ -402,9 +404,9 @@ fn entity_drops(entity_config: &str) -> Result<(), Box> { let item = item_asset.map(|asset| Item::new_from_asset_expect(asset)); let item_name = if let Some(item) = &item { - item.name() + item.name().into_owned() } else { - "Nothing" + String::from("Nothing") }; wtr.write_record(&[ diff --git a/common/src/bin/csv_import/main.rs b/common/src/bin/csv_import/main.rs index 447c8fdc71..2d5ab8ba03 100644 --- a/common/src/bin/csv_import/main.rs +++ b/common/src/bin/csv_import/main.rs @@ -14,7 +14,7 @@ use veloren_common::{ item::{ armor::{ArmorKind, Protection}, tool::{AbilitySpec, Hands, Stats, ToolKind}, - ItemDesc, ItemKind, ItemTag, Material, Quality, + ItemKind, ItemTag, Material, Quality, ItemDefinitionId, }, }, lottery::LootSpec, @@ -71,7 +71,7 @@ fn armor_stats() -> Result<(), Box> { for item in comp::item::Item::new_from_asset_glob("common.items.armor.*") .expect("Failed to iterate over item folders!") { - match item.kind() { + match &*item.kind() { comp::item::ItemKind::Armor(armor) => { if let ArmorKind::Bag(_) = armor.kind { continue; @@ -79,7 +79,7 @@ fn armor_stats() -> Result<(), Box> { if let Ok(ref record) = record { if item.item_definition_id() - == record.get(headers["Path"]).expect("No file path in csv?") + == ItemDefinitionId::Simple(record.get(headers["Path"]).expect("No file path in csv?")) { let protection = if let Some(protection_raw) = record.get(headers["Protection"]) { @@ -222,7 +222,7 @@ fn armor_stats() -> Result<(), Box> { ItemKind::Armor(armor), quality, item.tags().to_vec(), - item.ability_spec.clone(), + item.ability_spec().map(|spec| spec.into_owned()), ); let pretty_config = PrettyConfig::new() @@ -232,7 +232,7 @@ fn armor_stats() -> Result<(), Box> { .enumerate_arrays(true); let mut path = ASSETS_PATH.clone(); - for part in item.item_definition_id().split('.') { + for part in item.item_definition_id().raw().expect("Csv import only works on simple items, not modular items").split('.') { path.push(part); } path.set_extension("ron"); @@ -273,10 +273,10 @@ fn weapon_stats() -> Result<(), Box> { .expect("Failed to iterate over item folders!"); for item in items.iter() { - if let comp::item::ItemKind::Tool(tool) = item.kind() { + if let comp::item::ItemKind::Tool(tool) = &*item.kind() { if let Ok(ref record) = record { if item.item_definition_id() - == record.get(headers["Path"]).expect("No file path in csv?") + == ItemDefinitionId::Simple(record.get(headers["Path"]).expect("No file path in csv?")) { let kind = tool.kind; let equip_time_secs: f32 = record @@ -414,7 +414,7 @@ fn weapon_stats() -> Result<(), Box> { ItemKind::Tool(tool), quality, item.tags().to_vec(), - item.ability_spec.clone(), + item.ability_spec().map(|spec| spec.into_owned()), ); let pretty_config = PrettyConfig::new() @@ -424,7 +424,7 @@ fn weapon_stats() -> Result<(), Box> { .enumerate_arrays(true); let mut path = ASSETS_PATH.clone(); - for part in item.item_definition_id().split('.') { + for part in item.item_definition_id().raw().expect("Csv import only works on simple items, not modular items").split('.') { path.push(part); } path.set_extension("ron"); @@ -513,10 +513,9 @@ fn loot_table(loot_table: &str) -> Result<(), Box> { tool: get_tool_kind(record.get(headers["Item"]).expect("No tool").to_string()) .expect("Invalid tool kind"), material: Material::from_str( - &record + record .get(headers["Lower Amount or Material"]) - .expect("No material") - .to_string(), + .expect("No material"), ) .expect("Invalid material type"), hands: get_tool_hands( diff --git a/common/src/bin/recipe_graphviz.rs b/common/src/bin/recipe_graphviz.rs index b7fb176207..a7e6abaa20 100644 --- a/common/src/bin/recipe_graphviz.rs +++ b/common/src/bin/recipe_graphviz.rs @@ -20,20 +20,20 @@ fn main() { .or_insert_with(|| graph.add_node(node.to_owned())) }; for (_, recipe) in recipes.iter() { - let output = recipe.output.0.item_definition_id(); + let output = String::from(recipe.output.0.item_definition_id().raw().expect("Recipe book can only create simple items (probably)")); let inputs = recipe .inputs .iter() - .map(|(i, _)| i) + .map(|(i, _, _)| i) .filter_map(|input| { if let RecipeInput::Item(item) = input { - Some(item.item_definition_id()) + item.item_definition_id().raw().map(String::from) } else { None } }) .collect::>(); - let out_node = add_node(&mut graph, output); + let out_node = add_node(&mut graph, &output); for input in inputs.iter() { let in_node = add_node(&mut graph, input); graph.add_edge(in_node, out_node, ()); diff --git a/common/src/comp/inventory/test.rs b/common/src/comp/inventory/test.rs index fbbc5e1454..e65d9748ec 100644 --- a/common/src/comp/inventory/test.rs +++ b/common/src/comp/inventory/test.rs @@ -1,7 +1,8 @@ use super::*; use crate::comp::{ inventory::{slot::ArmorSlot, test_helpers::get_test_bag}, - Item, item::ItemDefinitionId, + item::ItemDefinitionId, + Item, }; use lazy_static::lazy_static; lazy_static! {