buy/combine from vbox wip
This commit is contained in:
parent
f2add9a836
commit
2ba8a63d81
@ -33,7 +33,7 @@ const addState = connect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendVboxCombine() {
|
function sendVboxCombine() {
|
||||||
return ws.sendVboxCombine(instance.id, combiner);
|
return ws.sendVboxCombine(instance.id, combiner, vboxSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendVboxReclaim(i) {
|
function sendVboxReclaim(i) {
|
||||||
@ -382,7 +382,6 @@ class Vbox extends preact.Component {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
class='vbox-btn'
|
class='vbox-btn'
|
||||||
disabled={combiner.length !== 3}
|
|
||||||
onMouseOver={e => hoverInfo(e, comboItem)}
|
onMouseOver={e => hoverInfo(e, comboItem)}
|
||||||
onClick={e => e.stopPropagation()}
|
onClick={e => e.stopPropagation()}
|
||||||
onMouseDown={() => sendVboxCombine()}>
|
onMouseDown={() => sendVboxCombine()}>
|
||||||
|
|||||||
@ -107,8 +107,8 @@ function createSocket(events) {
|
|||||||
events.clearInstance();
|
events.clearInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendVboxCombine(instanceId, invIndicies) {
|
function sendVboxCombine(instanceId, invIndicies, vboxIndicies) {
|
||||||
send(['VboxCombine', { instance_id: instanceId, inv_indices: invIndicies, vbox_indices: [] }]);
|
send(['VboxCombine', { instance_id: instanceId, inv_indices: invIndicies, vbox_indices: vboxIndicies }]);
|
||||||
events.clearInstance();
|
events.clearInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,10 +142,16 @@ impl Vbox {
|
|||||||
Ok(self)
|
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()) {
|
if !inv_indices.iter().all(|i| self.bound.get(*i).is_some()) {
|
||||||
return Err(err_msg("item missing index"));
|
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
|
// have to sort the indices and keep track of the iteration
|
||||||
// because when removing the elements the array shifts
|
// because when removing the elements the array shifts
|
||||||
inv_indices.sort_unstable();
|
inv_indices.sort_unstable();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user