can't make it

This commit is contained in:
ntr 2019-02-19 23:14:39 +11:00
commit 8a06c8b976
7 changed files with 64 additions and 47 deletions

View File

@ -175,8 +175,8 @@ module.exports = {
{ name: 'Decay', { name: 'Decay',
description: description:
'afflict a cryp with a blue damage based damage over time debuff' }, 'afflict a cryp with a blue damage based damage over time debuff' },
{ name: 'Drain', { name: 'Siphon',
description: 'drain hp from target cryp with a blue damage based debuff' }, description: 'siphon hp from target cryp with a blue damage based debuff' },
{ name: 'Empower', { name: 'Empower',
description: 'increase the red damage dealt by a cryp' }, description: 'increase the red damage dealt by a cryp' },
{ name: 'Haste', { name: 'Haste',

View File

@ -41,7 +41,7 @@ class Item extends Phaser.GameObjects.Container {
clickHandler() { clickHandler() {
this.scene.activeItem = this; this.scene.activeItem = this;
// Set the main context to display the item info // Set the main context to display the item info
this.scene.registry.set('itemInfo', this.action); this.scene.registry.set('itemInfo', this.item);
this.select(); this.select();
} }

View File

@ -89,7 +89,7 @@ class CombinerHitBox extends Phaser.GameObjects.Rectangle {
} }
deallocate() { deallocate() {
this.item.setPosition(this.item.origX, this.item.origY); if (this.item) this.item.setPosition(this.item.origX, this.item.origY);
this.item = false; this.item = false;
} }
} }
@ -137,33 +137,35 @@ class ItemList extends Phaser.Scene {
create(vbox) { create(vbox) {
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.registry.events.on('setdata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this);
if (!vbox.bound) return false;
this.combinerItems = this.registry.get('combinerItems');
if (!this.combinerItems || vbox.bound.length < this.registry.get('boundLength')) {
this.combinerItems = [-1, -1, -1]; this.combinerItems = [-1, -1, -1];
if (!vbox.free) return false;
this.addStatic(vbox);
this.addItems(vbox);
this.addClickHandlers(vbox);
return this;
} }
this.registry.set('boundLength', vbox.bound.length);
addStatic(vbox) {
const ws = this.registry.get('ws'); const ws = this.registry.get('ws');
// Static Elements
const graphics = this.add.graphics(); const graphics = this.add.graphics();
graphics.lineStyle(5, 0x808080, 1.0); graphics.lineStyle(5, 0x808080, 1.0);
drawCombiner(graphics); drawCombiner(graphics);
drawInventory(graphics); drawInventory(graphics);
drawVbox(graphics); drawVbox(graphics);
this.add.text(X + WIDTH * 0.1, Y, 'Inventory', TEXT.HEADER); this.add.text(X + WIDTH * 0.1, Y, 'Inventory', TEXT.HEADER);
this.add.text(X + WIDTH * 0.47, Y, 'Combiner', TEXT.HEADER); this.add.text(X + WIDTH * 0.47, Y, 'Combiner', TEXT.HEADER);
this.add.text(X + WIDTH * 0.35, Y + HEIGHT / 2, 'Varibox', TEXT.HEADER); this.add.text(X + WIDTH * 0.35, Y + HEIGHT / 2, 'Varibox', TEXT.HEADER);
const reroll = this.add.rectangle(WIDTH * 0.01, Y + HEIGHT * 0.775, ITEM_WIDTH * 1.25, ITEM_HEIGHT * 1.25, 0x222222) const reroll = this.add
.rectangle(WIDTH * 0.01, Y + HEIGHT * 0.775, ITEM_WIDTH * 1.25, ITEM_HEIGHT * 1.25, 0x222222)
.setInteractive() .setInteractive()
.setOrigin(0) .setOrigin(0)
.on('pointerdown', () => this.registry.get('ws').sendVboxDiscard(vbox.game)); .on('pointerdown', () => this.registry.get('ws').sendVboxDiscard(vbox.game));
this.add.text(reroll.getCenter().x, reroll.getCenter().y, 'Reroll', TEXT.HEADER) this.add.text(reroll.getCenter().x, reroll.getCenter().y, 'Reroll', TEXT.HEADER)
.setOrigin(0.5, 0.5); .setOrigin(0.5, 0.5);
const combine = this.add.rectangle(ITEM_WIDTH * 1.1 + COMB_X, ITEM_HEIGHT * 1.1 + COMB_Y, ITEM_WIDTH, ITEM_HEIGHT, 0x222222) const combine = this.add
.rectangle(ITEM_WIDTH * 1.1 + COMB_X, ITEM_HEIGHT * 1.1 + COMB_Y, ITEM_WIDTH, ITEM_HEIGHT, 0x222222)
.setInteractive() .setInteractive()
.setOrigin(0) .setOrigin(0)
.on('pointerdown', () => { .on('pointerdown', () => {
@ -182,11 +184,8 @@ class ItemList extends Phaser.Scene {
const del = this.add.existing(new DeleteHitBox(this, WIDTH * 0.01, Y + HEIGHT * 0.6)); const del = this.add.existing(new DeleteHitBox(this, WIDTH * 0.01, Y + HEIGHT * 0.6));
this.add.text(del.getCenter().x, del.getCenter().y, 'Del', TEXT.HEADER) this.add.text(del.getCenter().x, del.getCenter().y, 'Del', TEXT.HEADER)
.setOrigin(0.5, 0.5); .setOrigin(0.5, 0.5);
}
addItems(vbox) {
const ws = this.registry.get('ws');
// Generate Items
vbox.bound.forEach((action, i) => { vbox.bound.forEach((action, i) => {
const ITEM_X = ITEM_WIDTH * 1.1 * (i % INV_COLUMNS) + INV_X + ITEM_WIDTH * 0.5; const ITEM_X = ITEM_WIDTH * 1.1 * (i % INV_COLUMNS) + INV_X + ITEM_WIDTH * 0.5;
const ITEM_Y = ITEM_HEIGHT * 1.1 * Math.floor(i / INV_COLUMNS) + INV_Y + ITEM_HEIGHT * 0.5; const ITEM_Y = ITEM_HEIGHT * 1.1 * Math.floor(i / INV_COLUMNS) + INV_Y + ITEM_HEIGHT * 0.5;
@ -206,10 +205,22 @@ class ItemList extends Phaser.Scene {
}); });
this.add.existing(itemBox); this.add.existing(itemBox);
}); });
}
addClickHandlers(vbox) { // Restore previous combiner item slots
const ws = this.registry.get('ws'); this.combinerItems.forEach((index, i) => {
if (index === -1) return false;
const item = this.children.list.filter(obj => obj instanceof Item).find(it => it.index === index);
const hitBox = this.children.list.filter(obj => obj instanceof CombinerHitBox).find(hb => hb.slot === i);
hitBox.allocate(item);
return true;
});
// allocation functions
const allocate = (item, hitBox) => {
hitBox.allocate(item);
this.combinerItems[hitBox.slot] = item.index;
this.registry.set('combinerItems', this.combinerItems);
};
const deallocate = (item) => { const deallocate = (item) => {
const clearIndex = this.combinerItems.indexOf(item.index); const clearIndex = this.combinerItems.indexOf(item.index);
@ -231,11 +242,7 @@ class ItemList extends Phaser.Scene {
} return false; } return false;
}; };
const allocate = (item, hitBox) => { // Add Handlers
hitBox.allocate(item);
this.combinerItems[hitBox.slot] = item.index;
};
this.input.on('dragstart', (pointer, item) => { this.input.on('dragstart', (pointer, item) => {
if (!(item instanceof Item)) return false; if (!(item instanceof Item)) return false;
item.clickHandler(); item.clickHandler();
@ -278,6 +285,7 @@ class ItemList extends Phaser.Scene {
deallocate(item); deallocate(item);
return true; return true;
}); });
return this;
} }
cleanUp() { cleanUp() {

View File

@ -847,7 +847,7 @@ mod tests {
.learn(Skill::TestTouch) .learn(Skill::TestTouch)
.learn(Skill::TestBlock) .learn(Skill::TestBlock)
.learn(Skill::TestParry) .learn(Skill::TestParry)
.learn(Skill::TestDrain) .learn(Skill::TestSiphon)
.learn(Skill::Empower) .learn(Skill::Empower)
.learn(Skill::Stun) .learn(Skill::Stun)
.learn(Skill::Block) .learn(Skill::Block)
@ -861,7 +861,7 @@ mod tests {
.learn(Skill::TestTouch) .learn(Skill::TestTouch)
.learn(Skill::TestBlock) .learn(Skill::TestBlock)
.learn(Skill::TestParry) .learn(Skill::TestParry)
.learn(Skill::TestDrain) .learn(Skill::TestSiphon)
.learn(Skill::Empower) .learn(Skill::Empower)
.learn(Skill::Stun) .learn(Skill::Stun)
.learn(Skill::Block) .learn(Skill::Block)
@ -1081,7 +1081,7 @@ mod tests {
} }
#[test] #[test]
fn drain_test() { fn siphon_test() {
let mut game = create_test_game(); let mut game = create_test_game();
let x_team = game.teams[0].clone(); let x_team = game.teams[0].clone();
@ -1090,7 +1090,7 @@ mod tests {
let x_cryp = x_team.cryps[0].clone(); let x_cryp = x_team.cryps[0].clone();
let y_cryp = y_team.cryps[0].clone(); let y_cryp = y_team.cryps[0].clone();
let _x_drain_id = game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestDrain).unwrap(); let _x_siphon_id = game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestSiphon).unwrap();
let _y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); let _y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
game.resolve_phase_start(); game.resolve_phase_start();
@ -1100,7 +1100,7 @@ mod tests {
game.resolve_phase_start(); game.resolve_phase_start();
assert!(game.resolved.iter().any(|r| r.skill == Skill::DrainTick)); assert!(game.resolved.iter().any(|r| r.skill == Skill::SiphonTick));
} }
#[test] #[test]

View File

@ -938,7 +938,7 @@ mod tests {
.learn(Skill::TestTouch) .learn(Skill::TestTouch)
.learn(Skill::TestBlock) .learn(Skill::TestBlock)
.learn(Skill::TestParry) .learn(Skill::TestParry)
.learn(Skill::TestDrain) .learn(Skill::TestSiphon)
.learn(Skill::Empower) .learn(Skill::Empower)
.learn(Skill::Block) .learn(Skill::Block)
.create(); .create();
@ -950,7 +950,7 @@ mod tests {
.learn(Skill::TestTouch) .learn(Skill::TestTouch)
.learn(Skill::TestBlock) .learn(Skill::TestBlock)
.learn(Skill::TestParry) .learn(Skill::TestParry)
.learn(Skill::TestDrain) .learn(Skill::TestSiphon)
.learn(Skill::Empower) .learn(Skill::Empower)
.learn(Skill::Block) .learn(Skill::Block)
.create(); .create();
@ -1194,7 +1194,7 @@ mod tests {
} }
#[test] #[test]
fn drain_test() { fn siphon_test() {
let mut game = create_test_game(); let mut game = create_test_game();
let x_team = game.teams[0].clone(); let x_team = game.teams[0].clone();
@ -1203,13 +1203,13 @@ mod tests {
let x_cryp = x_team.cryps[0].clone(); let x_cryp = x_team.cryps[0].clone();
let y_cryp = y_team.cryps[0].clone(); let y_cryp = y_team.cryps[0].clone();
let x_drain_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestDrain).unwrap(); let x_siphon_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestSiphon).unwrap();
let y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap(); let y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap();
game.target_phase_start(); game.target_phase_start();
game.add_target(x_team.id, x_cryp.id, y_touch_id).unwrap(); game.add_target(x_team.id, x_cryp.id, y_touch_id).unwrap();
game.add_target(y_team.id, y_cryp.id, x_drain_id).unwrap(); game.add_target(y_team.id, y_cryp.id, x_siphon_id).unwrap();
game.resolve_phase_start(); game.resolve_phase_start();
@ -1218,7 +1218,7 @@ mod tests {
game.target_phase_start(); game.target_phase_start();
assert!(game.resolved.iter().any(|r| r.skill == Skill::DrainTick)); assert!(game.resolved.iter().any(|r| r.skill == Skill::SiphonTick));
} }
#[test] #[test]

View File

@ -291,7 +291,7 @@ impl Rpc {
let cryp = cryp_spawn(CrypSpawnParams { name }, tx, &account)?; let cryp = cryp_spawn(CrypSpawnParams { name }, tx, &account)?;
cryp_learn(CrypLearnParams { id: cryp.id, skill: Skill::Decay }, tx, &account)?; cryp_learn(CrypLearnParams { id: cryp.id, skill: Skill::Decay }, tx, &account)?;
cryp_learn(CrypLearnParams { id: cryp.id, skill: Skill::Blast }, tx, &account)?; cryp_learn(CrypLearnParams { id: cryp.id, skill: Skill::Blast }, tx, &account)?;
cryp_learn(CrypLearnParams { id: cryp.id, skill: Skill::Drain }, tx, &account)?; cryp_learn(CrypLearnParams { id: cryp.id, skill: Skill::Siphon }, tx, &account)?;
let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect();
let cryp = cryp_spawn(CrypSpawnParams { name }, tx, &account)?; let cryp = cryp_spawn(CrypSpawnParams { name }, tx, &account)?;

View File

@ -44,10 +44,14 @@ pub enum Var {
Reflect, Reflect,
Ruin, Ruin,
Shield, Shield,
Silence,
Slay,
Slow,
Snare, Snare,
Strangle, Strangle,
Strike, Strike,
Siphon, Siphon,
Survival,
Taunt, Taunt,
Throw, Throw,
Toxic, Toxic,
@ -81,10 +85,15 @@ impl Var {
Var::Purify => Ok(Skill::Purify), Var::Purify => Ok(Skill::Purify),
// Var::Reflect => Ok(Skill::Reflect), // Var::Reflect => Ok(Skill::Reflect),
Var::Ruin => Ok(Skill::Ruin), Var::Ruin => Ok(Skill::Ruin),
Var::Shield => Ok(Skill::Shield),
Var::Shield => Ok(Skill::Shield),
Var::Silence => Ok(Skill::Silence),
Var::Slay => Ok(Skill::Slay),
Var::Slow => Ok(Skill::Slow),
Var::Snare => Ok(Skill::Snare), Var::Snare => Ok(Skill::Snare),
Var::Strangle => Ok(Skill::Strangle), Var::Strangle => Ok(Skill::Strangle),
Var::Shield => Ok(Skill::Shield),
// Var::Strike => Ok(Skill::Strike), // Var::Strike => Ok(Skill::Strike),
// Var::Survival => Ok(Skill::Survival),
// Var::Taunt => Ok(Skill::Taunt), // Var::Taunt => Ok(Skill::Taunt),
Var::Throw => Ok(Skill::Throw), Var::Throw => Ok(Skill::Throw),
// Var::Toxic => Ok(Skill::Toxic), // Var::Toxic => Ok(Skill::Toxic),
@ -224,9 +233,9 @@ impl Vbox {
ColourCode::RR => Var::Strike, ColourCode::RR => Var::Strike,
ColourCode::GG => Var::Heal, ColourCode::GG => Var::Heal,
ColourCode::BB => Var::Blast, ColourCode::BB => Var::Blast,
ColourCode::RG => return Err(err_msg("unhandled skill combo")), ColourCode::RG => Var::Slay, //
ColourCode::GB => return Err(err_msg("unhandled skill combo")), ColourCode::GB => return Err(err_msg("unhandled skill combo")),
ColourCode::BR => return Err(err_msg("unhandled skill combo")), ColourCode::BR => Var::Banish, //
}, },
Var::Block => match colour_code { Var::Block => match colour_code {
ColourCode::RR => Var::Parry, ColourCode::RR => Var::Parry,
@ -240,8 +249,8 @@ impl Vbox {
ColourCode::RR => Var::Empower, ColourCode::RR => Var::Empower,
ColourCode::GG => Var::Triage, ColourCode::GG => Var::Triage,
ColourCode::BB => Var::Amplify, ColourCode::BB => Var::Amplify,
ColourCode::RG => return Err(err_msg("unhandled skill combo")), ColourCode::RG => Var::Survival,
ColourCode::GB => Var::Purify, ColourCode::GB => return Err(err_msg("unhandled skill combo")),
ColourCode::BR => Var::Haste, ColourCode::BR => Var::Haste,
}, },
Var::Debuff => match colour_code { Var::Debuff => match colour_code {
@ -250,15 +259,15 @@ impl Vbox {
ColourCode::BB => Var::Curse, ColourCode::BB => Var::Curse,
ColourCode::RG => return Err(err_msg("unhandled skill combo")), ColourCode::RG => return Err(err_msg("unhandled skill combo")),
ColourCode::GB => Var::Siphon, ColourCode::GB => Var::Siphon,
ColourCode::BR => return Err(err_msg("unhandled skill combo")), ColourCode::BR => Var::Slow,
}, },
Var::Stun => match colour_code { Var::Stun => match colour_code {
ColourCode::RR => Var::Strangle, ColourCode::RR => Var::Strangle,
ColourCode::GG => Var::Throw, ColourCode::GG => Var::Throw,
ColourCode::BB => Var::Ruin, ColourCode::BB => Var::Ruin,
ColourCode::RG => return Err(err_msg("unhandled skill combo")), ColourCode::RG => return Err(err_msg("unhandled skill combo")),
ColourCode::GB => return Err(err_msg("unhandled skill combo")), ColourCode::GB => Var::Silence,
ColourCode::BR => Var::Banish, ColourCode::BR => Var::Hex,
}, },
_ => panic!("wrong base {:?}", base), _ => panic!("wrong base {:?}", base),
}; };