76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
const Phaser = require('phaser');
|
|
|
|
const Combat = require('./combat');
|
|
const CrypRows = require('./cryp.row');
|
|
const GameList = require('./game.list');
|
|
const StatSheet = require('./statsheet');
|
|
|
|
class CrypList extends Phaser.Scene {
|
|
constructor() {
|
|
super({ key: 'CrypList', active: true });
|
|
}
|
|
|
|
create() {
|
|
this.registry.events.off('changedata', this.updateData, this);
|
|
this.registry.events.off('setdata', this.updateData, this);
|
|
this.registry.events.on('changedata', this.updateData, this);
|
|
this.registry.events.on('setdata', this.updateData, this);
|
|
if (this.registry.get('cryps')) {
|
|
this.renderList();
|
|
this.renderGameList();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
updateData(parent, key, data) {
|
|
const UPDATE_KEYS = ['gameList', 'cryps'];
|
|
if (UPDATE_KEYS.includes(key)) {
|
|
this.renderList();
|
|
this.renderGameList();
|
|
}
|
|
|
|
if (key === 'game' && this.scene.isActive()) {
|
|
this.scene.sleep();
|
|
this.scene.add('Combat', Combat);
|
|
this.scene.run('Combat', data);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
renderList() {
|
|
const cryps = this.registry.get('cryps');
|
|
|
|
// your cryps
|
|
if (this.CrypRows) {
|
|
this.CrypRows.cleanup();
|
|
this.CrypRows.destroy(true);
|
|
}
|
|
this.CrypRows = new CrypRows(this, cryps);
|
|
}
|
|
|
|
renderGameList() {
|
|
const ws = this.registry.get('ws');
|
|
const cryps = this.registry.get('cryps');
|
|
const gameList = this.registry.get('gameList');
|
|
|
|
if (this.gameList) {
|
|
this.gameList.cleanup();
|
|
this.gameList.destroy(true);
|
|
}
|
|
|
|
this.gameList = new GameList({ list: this, ws, cryps, gameList, events: this.game.events });
|
|
}
|
|
|
|
displaySkills(cryp) {
|
|
if (cryp) {
|
|
this.scene.add('StatSheet', StatSheet);
|
|
this.scene.run('StatSheet', { cryp });
|
|
this.scene.stop();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
module.exports = CrypList;
|