Skip to content

Commit

Permalink
Permit item entries to include crafting components.
Browse files Browse the repository at this point in the history
Currently doesn't factor their costs in.
  • Loading branch information
hyena committed Nov 6, 2017
1 parent f4a3d1e commit 6f5ac9b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
A World of Warcraft webapp that helps players determine the best value for their bloods of sargeras and primal saronite on their realm.
A World of Warcraft webapp that helps players determine the best value for their bloods of sargeras and primal sargerite on their realm.

Quickstart
----------
Expand Down
17 changes: 17 additions & 0 deletions catalog/items.json
Expand Up @@ -209,5 +209,22 @@
"name": "Lightsphene",
"quantity": 0.1,
"vendor_type": "sargerite"
},
{
"id": 152296,
"name": "Primal Obliterum",
"quantity": 1,
"subtext": "Traded in Dalaran",
"mats": [{
"id": 124125,
"quantity": 1
}],
"vendor_type": "sargerite"
},
{
"id": 124125,
"name": "Obliterum",
"quantity": 1,
"vendor_type": "reagent"
}
]
11 changes: 10 additions & 1 deletion src/main.rs
Expand Up @@ -37,6 +37,15 @@ struct VendorItem {
id: u64,
vendor_type: String, // TODO: This should really be an enum populated by a custom deserializer.
subtext: Option<String>,
mats: Option<Vec<CraftingComponent>>,
}

/// Some items we can 'buy' are actually crafted or traded with NPCs. This represents
/// an ingredient in the recipe.
#[derive(Debug, Deserialize)]
struct CraftingComponent {
id: u64,
quantity: u64,
}

/// Value of an item on a realm.
Expand Down Expand Up @@ -207,7 +216,7 @@ fn main() {
}).collect();
// NOTE: drain_filter() is a nightly only experimental API call that might break.
let blood_price_rows = price_rows.drain_filter(|x| x.vendor_type.eq("blood")).collect::<Vec<_>>();
let sargerite_price_rows = price_rows;
let sargerite_price_rows = price_rows.drain_filter(|x| x.vendor_type.eq("sargerite")).collect::<Vec<_>>();
context.add("realm_name", &realms.iter().find(|&realm_info| &realm_info.slug == realm).unwrap().name);
context.add("blood_price_rows", &blood_price_rows);
context.add("sargerite_price_rows", &sargerite_price_rows);
Expand Down

0 comments on commit 6f5ac9b

Please sign in to comment.