unequip specs

This commit is contained in:
ntr 2019-03-15 19:42:38 +11:00
parent 9df24a8f07
commit 0b21a5090d
4 changed files with 19 additions and 6 deletions

View File

@ -52,6 +52,12 @@ class StatSheet extends Phaser.Scene {
create(cryp) { create(cryp) {
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
const ws = this.registry.get('ws');
const player = this.registry.get('player');
if (!player) return false;
const { vbox } = player;
this.cryp = cryp; this.cryp = cryp;
const del = this.add.existing(new DeleteHitBox(this, X + WIDTH * 0.7, Y + HEIGHT * 0.6)); const del = this.add.existing(new DeleteHitBox(this, X + WIDTH * 0.7, Y + HEIGHT * 0.6));
@ -116,7 +122,7 @@ class StatSheet extends Phaser.Scene {
if (hitBox) { if (hitBox) {
hitBox.itemDeselect(); hitBox.itemDeselect();
// add socket function for unlearn here // add socket function for unlearn here
console.log(`delete: ${item.item}`); ws.sendVboxUnequip(vbox.instance, cryp.id, item.item);
} }
return true; return true;
}); });

View File

@ -101,6 +101,10 @@ function createSocket(events) {
send({ method: 'player_vbox_apply', params: { instance_id: instanceId, cryp_id: crypId, index } }); send({ method: 'player_vbox_apply', params: { instance_id: instanceId, cryp_id: crypId, index } });
} }
function sendVboxUnequip(instanceId, crypId, target) {
send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, cryp_id: crypId, target } });
}
function sendVboxDiscard(instanceId) { function sendVboxDiscard(instanceId) {
send({ method: 'player_vbox_discard', params: { instance_id: instanceId } }); send({ method: 'player_vbox_discard', params: { instance_id: instanceId } });
} }
@ -311,6 +315,7 @@ function createSocket(events) {
sendVboxReclaim, sendVboxReclaim,
sendVboxCombine, sendVboxCombine,
sendVboxDiscard, sendVboxDiscard,
sendVboxUnequip,
connect, connect,
}; };
} }

View File

@ -660,7 +660,7 @@ struct VboxUnequipMsg {
pub struct VboxUnequipParams { pub struct VboxUnequipParams {
pub instance_id: Uuid, pub instance_id: Uuid,
pub cryp_id: Uuid, pub cryp_id: Uuid,
pub var: Var, pub target: Var,
} }
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]

View File

@ -493,21 +493,23 @@ pub fn vbox_unequip(params: VboxUnequipParams, tx: &mut Transaction, account: &A
return Err(err_msg("too many vars bound")); return Err(err_msg("too many vars bound"));
} }
match params.var.effect() { println!("{:?}", params);
match params.target.effect() {
Some(VarEffect::Skill) => { Some(VarEffect::Skill) => {
let skill = params.var.into_skill().ok_or(format_err!("var {:?} has no associated skill", params.var))?; let skill = params.target.into_skill().ok_or(format_err!("var {:?} has no associated skill", params.target))?;
let cryp = player.cryp_get(params.cryp_id)?; let cryp = player.cryp_get(params.cryp_id)?;
cryp.forget(skill)?; cryp.forget(skill)?;
}, },
Some(VarEffect::Spec) => { Some(VarEffect::Spec) => {
let spec = params.var.into_spec().ok_or(format_err!("var {:?} has no associated spec", params.var))?; let spec = params.target.into_spec().ok_or(format_err!("var {:?} has no associated spec", params.target))?;
let cryp = player.cryp_get(params.cryp_id)?; let cryp = player.cryp_get(params.cryp_id)?;
cryp.spec_remove(spec)?; cryp.spec_remove(spec)?;
}, },
None => return Err(err_msg("var has no effect on cryps")), None => return Err(err_msg("var has no effect on cryps")),
} }
player.vbox.bound.push(params.var); player.vbox.bound.push(params.target);
return player_update(tx, player, false); return player_update(tx, player, false);
} }