buy/combine from vbox wip
This commit is contained in:
+7
-1
@@ -142,10 +142,16 @@ impl Vbox {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn combine(&mut self, mut inv_indices: Vec<usize>, mut vbox_indicies: Vec<Vec<usize>>) -> Result<&mut Vbox, Error> {
|
||||
pub fn combine(&mut self, mut inv_indices: Vec<usize>, vbox_indicies: Vec<Vec<usize>>) -> Result<&mut Vbox, Error> {
|
||||
if !inv_indices.iter().all(|i| self.bound.get(*i).is_some()) {
|
||||
return Err(err_msg("item missing index"));
|
||||
}
|
||||
// try to buy up the vbox indicies and add them to the inventory indicies for combining
|
||||
for vi in vbox_indicies.iter() {
|
||||
inv_indices.push(self.bound.len());
|
||||
self.accept(vi[0], vi[1], Some(Uuid::nil()))?;
|
||||
}
|
||||
|
||||
// have to sort the indices and keep track of the iteration
|
||||
// because when removing the elements the array shifts
|
||||
inv_indices.sort_unstable();
|
||||
|
||||
Reference in New Issue
Block a user