Merge and refactor
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
module.exports = {
|
||||
TEXT: {
|
||||
NORMAL: { fontFamily: 'monospace', fontSize: 16, color: '#ffffff' },
|
||||
HEADER: { fontFamily: 'monospace', fontSize: 24, color: '#ffffff', fontStyle: 'bold' },
|
||||
},
|
||||
|
||||
SKILLS: {
|
||||
LEARNABLE: [
|
||||
'Attack',
|
||||
|
||||
// -----------------
|
||||
// Nature
|
||||
// -----------------
|
||||
'Block', // reduce dmg
|
||||
'Parry', // avoid all dmg
|
||||
'Snare',
|
||||
|
||||
// 'Paralyse',
|
||||
|
||||
'Strangle', // physical dot and disable
|
||||
|
||||
'Stun',
|
||||
'Evade', // actively evade
|
||||
'Evasion', // adds evasion to cryp
|
||||
|
||||
|
||||
// -----------------
|
||||
// Technology
|
||||
// -----------------
|
||||
// 'Replicate',
|
||||
// 'Swarm',
|
||||
// 'Orbit',
|
||||
// 'Repair',
|
||||
// 'Scan', // track?
|
||||
|
||||
// -----------------
|
||||
// Nonviolence
|
||||
// -----------------
|
||||
'Heal',
|
||||
'Triage', // hot
|
||||
// 'TriageTick',
|
||||
'Throw', // no dmg stun', adds vulnerable
|
||||
'Charm',
|
||||
'Calm',
|
||||
'Rez',
|
||||
|
||||
// -------------------
|
||||
// Destruction
|
||||
// -------------------
|
||||
'Blast',
|
||||
'Amplify',
|
||||
'Decay', // dot
|
||||
// 'DecayTick', // dot
|
||||
'Drain',
|
||||
// 'DrainTick',
|
||||
'Curse',
|
||||
'Plague', // aoe dot
|
||||
'Ruin', // aoe
|
||||
|
||||
// -----------------
|
||||
// Purity
|
||||
// -----------------
|
||||
'Empower',
|
||||
'Slay',
|
||||
'Shield',
|
||||
'Silence',
|
||||
'Inquiry',
|
||||
'Purify',
|
||||
'Purge',
|
||||
// '// Precision',
|
||||
|
||||
// -----------------
|
||||
// Chaos
|
||||
// -----------------
|
||||
'Banish',
|
||||
'Hex',
|
||||
'Fear',
|
||||
'Taunt',
|
||||
'Pause', // speed slow
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -11,29 +11,32 @@ class CrypList extends Phaser.Scene {
|
||||
create() {
|
||||
this.registry.events.on('changedata', this.updateData, this);
|
||||
this.input.on('gameobjectup', this.clickHandler, this);
|
||||
this.CrypPage = null;
|
||||
console.log('creating');
|
||||
return true;
|
||||
}
|
||||
|
||||
updateData(parent, key, data) {
|
||||
if (key === 'cryps') {
|
||||
this.clearCryps();
|
||||
if (this.CrypRow) this.CrypRow.destroy(true);
|
||||
this.CrypRow = new CrypRow(this, data);
|
||||
if (this.CrypPage) {
|
||||
const cryp = data.find(c => c.id === this.CrypPage.id);
|
||||
this.displaySkills(cryp);
|
||||
}
|
||||
}
|
||||
window.redraw = this.clearCryps.bind(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
clearCryps() {
|
||||
if (this.CrypRow) this.CrypRow.destroy(true);
|
||||
displaySkills(cryp) {
|
||||
if (cryp) {
|
||||
if (this.CrypPage) {
|
||||
this.CrypPage.destroy(true);
|
||||
}
|
||||
this.CrypPage = new CrypPage(this, cryp);
|
||||
}
|
||||
}
|
||||
|
||||
clickHandler(pointer, crypBox) {
|
||||
if (this.CrypPage) {
|
||||
this.CrypPage.destroy(true);
|
||||
}
|
||||
this.CrypPage = new CrypPage(this, crypBox.cryp);
|
||||
this.displaySkills(crypBox.cryp);
|
||||
return true;
|
||||
// this.registry.get('ws').sendGamePve(crypBox.cryp.id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const Phaser = require('phaser');
|
||||
|
||||
const { TEXT, SKILLS } = require('./constants');
|
||||
|
||||
const ROW_WIDTH = 400;
|
||||
const ROW_HEIGHT = 200;
|
||||
const ROW_FILL = 0x888888;
|
||||
@@ -14,14 +16,34 @@ const yPos = i => (i * ROW_HEIGHT + ROW_MARGIN) + TOP_MARGIN;
|
||||
class CrypPage extends Phaser.GameObjects.Group {
|
||||
constructor(scene, cryp) {
|
||||
super(scene);
|
||||
this.add(scene.add.text(500, 500, cryp.name, {
|
||||
fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold',
|
||||
}));
|
||||
cryp.skills.forEach((skill, i) => this.add(
|
||||
scene.add.text(500, 500 + (TEXT_MARGIN * (i + 1)), skill.skill, {
|
||||
fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold',
|
||||
})
|
||||
));
|
||||
this.id = cryp.id;
|
||||
this.scene = scene;
|
||||
this.ws = scene.registry.get('ws');
|
||||
this.add(scene.add.text(500, 500, cryp.name, TEXT.HEADER));
|
||||
|
||||
const knownSkill = (skill, i) => {
|
||||
const text = scene.add.text(500, 500 + (TEXT_MARGIN * (i + 1)), skill.skill, TEXT.NORMAL)
|
||||
.setInteractive();
|
||||
|
||||
text.on('pointerdown', () => {
|
||||
this.ws.sendCrypForget(cryp.id, skill.skill);
|
||||
});
|
||||
this.add(text);
|
||||
};
|
||||
|
||||
const learnable = (skill, i) => {
|
||||
const text = scene.add.text(600, 0 + (TEXT_MARGIN * (i + 1)), skill, TEXT.NORMAL)
|
||||
.setInteractive();
|
||||
|
||||
text.on('pointerdown', () => {
|
||||
this.ws.sendCrypLearn(cryp.id, skill);
|
||||
});
|
||||
this.add(text);
|
||||
text.cryp = cryp;
|
||||
};
|
||||
|
||||
cryp.skills.forEach(knownSkill);
|
||||
SKILLS.LEARNABLE.forEach(learnable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const Phaser = require('phaser');
|
||||
|
||||
const { TEXT } = require('./constants');
|
||||
|
||||
const ROW_WIDTH = 400;
|
||||
const ROW_HEIGHT = 200;
|
||||
const ROW_FILL = 0x888888;
|
||||
@@ -23,8 +25,8 @@ class CrypRow extends Phaser.GameObjects.Group {
|
||||
|
||||
row.cryp = cryp;
|
||||
this.add(row);
|
||||
this.add(list.add.text(X_ORIGIN, Y_ORIGIN + (TEXT_MARGIN * 0), cryp.name, { fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold' }));
|
||||
this.add(list.add.text(X_ORIGIN, Y_ORIGIN + (TEXT_MARGIN * 1), cryp.stamina.base, { fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold' }));
|
||||
this.add(list.add.text(X_ORIGIN, Y_ORIGIN + (TEXT_MARGIN * 0), cryp.name, TEXT.HEADER));
|
||||
this.add(list.add.text(X_ORIGIN, Y_ORIGIN + (TEXT_MARGIN * 1), cryp.stamina.base, TEXT.NORMAL));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
const Phaser = require('phaser');
|
||||
|
||||
const CrypList = require('./cryp.list');
|
||||
const CrypPage = require('./cryp.page');
|
||||
const Menu = require('./menu');
|
||||
// const Passives = require('./passives');
|
||||
|
||||
function renderCryps(store) {
|
||||
function renderCryps(store, socket) {
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
// parent: 'cryps',
|
||||
@@ -23,7 +22,6 @@ function renderCryps(store) {
|
||||
scene: [
|
||||
Menu,
|
||||
CrypList,
|
||||
// Passives,
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
const Phaser = require('phaser');
|
||||
|
||||
const { TEXT } = require('./constants');
|
||||
|
||||
class Menu extends Phaser.Scene {
|
||||
constructor(props) {
|
||||
super({ key: 'Menu', active: true });
|
||||
}
|
||||
|
||||
create() {
|
||||
this.add.text(0, 0, 'cryps.gg', { fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold' });
|
||||
this.add.text(0, 0, 'cryps.gg', TEXT.HEADER);
|
||||
this.scene.sleep('Passives');
|
||||
this.input.keyboard.on('keydown_F', () => {
|
||||
this.scene.wake('Passives');
|
||||
}, 0, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,14 @@ function createSocket(store) {
|
||||
send({ method: 'cryp_spawn', params: { name } });
|
||||
}
|
||||
|
||||
function sendCrypLearn(id, skill) {
|
||||
send({ method: 'cryp_learn', params: { id, skill } });
|
||||
}
|
||||
|
||||
function sendCrypForget(id, skill) {
|
||||
send({ method: 'cryp_forget', params: { id, skill } });
|
||||
}
|
||||
|
||||
function sendGameState(id) {
|
||||
send({ method: 'game_state', params: { id } });
|
||||
}
|
||||
@@ -203,6 +211,8 @@ function createSocket(store) {
|
||||
sendGameSkill,
|
||||
sendGameTarget,
|
||||
sendCrypSpawn,
|
||||
sendCrypLearn,
|
||||
sendCrypForget,
|
||||
sendItemUse,
|
||||
connect,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user