mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Repair costs scale based on how damaged the item is.
This commit is contained in:
parent
85ceae3354
commit
536d88a2c7
@ -186,7 +186,7 @@ recipes: {
|
|||||||
// ARMOR/HIDE/CARAPACE
|
// ARMOR/HIDE/CARAPACE
|
||||||
ItemDefId("common.items.armor.hide.carapace.back"): (
|
ItemDefId("common.items.armor.hide.carapace.back"): (
|
||||||
inputs: [
|
inputs: [
|
||||||
(Item("common.items.crafting_ing.lhide.carapace"), 1),
|
(Item("common.items.crafting_ing.hide.carapace"), 1),
|
||||||
(Item("common.items.mineral.ore.veloritefrag"), 2),
|
(Item("common.items.mineral.ore.veloritefrag"), 2),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -832,20 +832,20 @@ recipes: {
|
|||||||
ItemDefId("common.items.armor.misc.head.crown"): (
|
ItemDefId("common.items.armor.misc.head.crown"): (
|
||||||
inputs: [
|
inputs: [
|
||||||
(Item("common.items.crafting_ing.cloth.linen_red"), 3),
|
(Item("common.items.crafting_ing.cloth.linen_red"), 3),
|
||||||
(item("common.items.mineral.ingot.gold"), 1),
|
(Item("common.items.mineral.ingot.gold"), 1),
|
||||||
(Item("common.items.mineral.ore.veloritefrag"), 3),
|
(Item("common.items.mineral.ore.veloritefrag"), 3),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ItemDefId("common.items.armor.pirate.hat"): (
|
ItemDefId("common.items.armor.pirate.hat"): (
|
||||||
inputs: [
|
inputs: [
|
||||||
(Item("common.items.crafting_ing.hide.rigid_leather"), 1),
|
(Item("common.items.crafting_ing.leather.rigid_leather"), 1),
|
||||||
(Item("common.items.mineral.ore.veloritefrag"), 3),
|
(Item("common.items.mineral.ore.veloritefrag"), 3),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ItemDefId("common.items.armor.witch.hat"): (
|
ItemDefId("common.items.armor.witch.hat"): (
|
||||||
inputs: [
|
inputs: [
|
||||||
(Item("common.items.crafting_ing.hide.rigid_leather"), 1),
|
(Item("common.items.crafting_ing.leather.rigid_leather"), 1),
|
||||||
(Item("common.items.crafting_ing.animal_misc.grim_eyeball"), 1)
|
(Item("common.items.crafting_ing.animal_misc.grim_eyeball"), 1),
|
||||||
(Item("common.items.mineral.ore.veloritefrag"), 3),
|
(Item("common.items.mineral.ore.veloritefrag"), 3),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -859,7 +859,7 @@ recipes: {
|
|||||||
},
|
},
|
||||||
fallback: (
|
fallback: (
|
||||||
inputs: [
|
inputs: [
|
||||||
(Item("common.items.utility.coins"), 1000),
|
(Item("common.items.mineral.ore.veloritefrag"), 25),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
@ -11,7 +11,8 @@
|
|||||||
trait_alias,
|
trait_alias,
|
||||||
type_alias_impl_trait,
|
type_alias_impl_trait,
|
||||||
extend_one,
|
extend_one,
|
||||||
arbitrary_self_types
|
arbitrary_self_types,
|
||||||
|
int_roundings
|
||||||
)]
|
)]
|
||||||
#![feature(hash_drain_filter)]
|
#![feature(hash_drain_filter)]
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{borrow::Cow, sync::Arc};
|
use std::{borrow::Cow, ops::Mul, sync::Arc};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub enum RecipeInput {
|
pub enum RecipeInput {
|
||||||
@ -973,13 +973,18 @@ impl RepairRecipe {
|
|||||||
/// are missing.
|
/// are missing.
|
||||||
pub fn inventory_contains_ingredients(
|
pub fn inventory_contains_ingredients(
|
||||||
&self,
|
&self,
|
||||||
|
item: &Item,
|
||||||
inv: &Inventory,
|
inv: &Inventory,
|
||||||
) -> Result<Vec<(u32, InvSlotId)>, Vec<(&RecipeInput, u32)>> {
|
) -> Result<Vec<(u32, InvSlotId)>, Vec<(&RecipeInput, u32)>> {
|
||||||
inventory_contains_ingredients(self.inputs(), inv, 1)
|
inventory_contains_ingredients(self.inputs(item), inv, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inputs(&self) -> impl ExactSizeIterator<Item = (&RecipeInput, u32)> {
|
pub fn inputs(&self, item: &Item) -> impl ExactSizeIterator<Item = (&RecipeInput, u32)> {
|
||||||
self.inputs.iter().map(|(input, amount)| (input, *amount))
|
let item_durability = item.durability().unwrap_or(0);
|
||||||
|
self.inputs.iter().map(move |(input, amount)| {
|
||||||
|
let amount = amount.mul(item_durability).div_ceil(Item::MAX_DURABILITY);
|
||||||
|
(input, amount)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1014,8 +1019,7 @@ impl RepairRecipeBook {
|
|||||||
} {
|
} {
|
||||||
if let Some(repair_recipe) = self.repair_recipe(item) {
|
if let Some(repair_recipe) = self.repair_recipe(item) {
|
||||||
repair_recipe
|
repair_recipe
|
||||||
.inputs
|
.inputs(item)
|
||||||
.iter()
|
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.for_each(|(i, (input, amount))| {
|
.for_each(|(i, (input, amount))| {
|
||||||
// Gets all slots provided for this input by the frontend
|
// Gets all slots provided for this input by the frontend
|
||||||
@ -1025,7 +1029,7 @@ impl RepairRecipeBook {
|
|||||||
.copied();
|
.copied();
|
||||||
// Checks if requirement is met, and if not marks it as unsatisfied
|
// Checks if requirement is met, and if not marks it as unsatisfied
|
||||||
input.handle_requirement(
|
input.handle_requirement(
|
||||||
*amount,
|
amount,
|
||||||
&mut slot_claims,
|
&mut slot_claims,
|
||||||
&mut unsatisfied_requirements,
|
&mut unsatisfied_requirements,
|
||||||
inv,
|
inv,
|
||||||
|
@ -1788,7 +1788,9 @@ impl PlayState for SessionState {
|
|||||||
}?;
|
}?;
|
||||||
let repair_recipe =
|
let repair_recipe =
|
||||||
client.repair_recipe_book().repair_recipe(item)?;
|
client.repair_recipe_book().repair_recipe(item)?;
|
||||||
repair_recipe.inventory_contains_ingredients(inventory).ok()
|
repair_recipe
|
||||||
|
.inventory_contains_ingredients(item, inventory)
|
||||||
|
.ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -669,22 +669,17 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
6,
|
6,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Durability
|
if item.has_durability() {
|
||||||
if let Some(durability) = item.durability() {
|
let durability = Item::MAX_DURABILITY - item.durability().unwrap_or(0);
|
||||||
const MAX_DURABILITY: u32 = 8;
|
stat_text(
|
||||||
let durability = MAX_DURABILITY - durability.min(MAX_DURABILITY);
|
format!(
|
||||||
widget::Text::new(&format!(
|
"{} : {}/{}",
|
||||||
"{} : {}/{}",
|
i18n.get_msg("common-stats-durability"),
|
||||||
i18n.get_msg("common-stats-durability"),
|
durability,
|
||||||
durability,
|
Item::MAX_DURABILITY
|
||||||
MAX_DURABILITY
|
),
|
||||||
))
|
7,
|
||||||
.graphics_for(id)
|
)
|
||||||
.parent(id)
|
|
||||||
.with_style(self.style.desc)
|
|
||||||
.color(text_color)
|
|
||||||
.down_from(state.ids.stats[6], V_PAD_STATS)
|
|
||||||
.set(state.ids.stats[7], ui);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(equipped_item) = equipped_item {
|
if let Some(equipped_item) = equipped_item {
|
||||||
|
Loading…
Reference in New Issue
Block a user