Merge branch 'master' of ssh://cryps.gg:40022/~/cryps

This commit is contained in:
ntr 2018-11-27 23:31:30 +11:00
commit 5d71a014d4
2 changed files with 18 additions and 23 deletions

View File

@ -136,31 +136,27 @@ function renderCryp(scene, group, cryp, skills, game, team, iter) {
return crypSpawn; return crypSpawn;
} }
function renderSkills(scene, group, cryp, account, game, team, iter) { function renderSkills(scene, group, cryp, game, team, iter) {
const nameTextPosition = skillTextPosition(iter, 0);
const skillList = []; const skillList = [];
const nameTextPosition = skillTextPosition(iter, 0);
const addSkill = (skill, i) => {
if (i === 0) group.add(scene.add.text(nameTextPosition[0], nameTextPosition[1], cryp.name, TEXT.HEADER));
const skillTextPos = skillTextPosition(iter, i + 2);
const skillObj = new CrypSkill(scene, skillTextPos[0], skillTextPos[1], team, skill, cryp);
group.add(scene.add.existing(skillObj));
skillList.push(skillObj);
};
if (scene.registry.get('resolve')) return true; if (scene.registry.get('resolve')) return true;
if (game.phase === 'Skill' && cryp.account === account.id) { if (game.phase === 'Skill' && cryp.account === scene.account.id) {
if (cryp.hp.base === 0) return true; if (cryp.hp.base === 0) return true;
const crypName = scene.add.text(nameTextPosition[0], nameTextPosition[1], cryp.name, TEXT.HEADER); cryp.skills.forEach(addSkill);
crypName.text = cryp.name; } else if (game.phase === 'Target' && cryp.account !== scene.account.id) {
cryp.skills.forEach((skill, i) => {
const skillText = skillTextPosition(iter, i + 2);
const skillObj = new CrypSkill(scene, skillText[0], skillText[1], team, skill, cryp);
scene.add.existing(skillObj);
skillList.push(skillObj);
group.addMultiple([crypName, skillObj]);
});
} else if (game.phase === 'Target' && cryp.account !== account.id) {
const blockSkill = game.stack.find(skill => skill.source_cryp_id === cryp.id); const blockSkill = game.stack.find(skill => skill.source_cryp_id === cryp.id);
// cryp not casting this turn // cryp not casting this turn
if (!blockSkill) return false; if (!blockSkill) return false;
const crypName = scene.add.text(nameTextPosition[0], nameTextPosition[1], cryp.name, TEXT.HEADER); addSkill(blockSkill, 0);
const skillText = skillTextPosition(iter, 2);
const skillObj = new CrypSkill(scene, skillText[0], skillText[1], team, blockSkill, cryp);
scene.add.existing(skillObj);
skillList.push(skillObj);
group.addMultiple([crypName, skillObj]);
} }
return skillList; return skillList;
} }
@ -174,7 +170,7 @@ class DrawCrypTeams extends Phaser.GameObjects.Group {
const [enemyTeam] = game.teams.filter(t => t.id !== account.id); const [enemyTeam] = game.teams.filter(t => t.id !== account.id);
const renderTeam = (cryp, iter, team) => { const renderTeam = (cryp, iter, team) => {
const skillsObj = renderSkills(scene, this, cryp, account, game, team, iter); const skillsObj = renderSkills(scene, this, cryp, game, team, iter);
const crypObj = renderCryp(scene, this, cryp, skillsObj, game, team, iter); const crypObj = renderCryp(scene, this, cryp, skillsObj, game, team, iter);
const addKeys = (game.phase === 'Skill' && !team) || (game.phase === 'Target' && team); const addKeys = (game.phase === 'Skill' && !team) || (game.phase === 'Target' && team);
if (addKeys) scene.crypKeyHandler(crypObj, iter); if (addKeys) scene.crypKeyHandler(crypObj, iter);

View File

@ -3,7 +3,6 @@ const fs = require('fs');
const { POSITIONS: { COMBAT }, TEXT } = require('./constants'); const { POSITIONS: { COMBAT }, TEXT } = require('./constants');
const { DrawCrypTeams, CrypImage, CrypSkill } = require('./combat.cryps'); const { DrawCrypTeams, CrypImage, CrypSkill } = require('./combat.cryps');
const CombatSkills = require('./combat.skills');
const renderResolutions = require('./combat.render'); const renderResolutions = require('./combat.render');
const CRYP_KEY_MAP = ['keydown_ONE', 'keydown_TWO', 'keydown_THREE']; const CRYP_KEY_MAP = ['keydown_ONE', 'keydown_TWO', 'keydown_THREE'];
@ -50,8 +49,8 @@ class Combat extends Phaser.Scene {
this.registry.set('gameAnimating', false); this.registry.set('gameAnimating', false);
this.account = this.registry.get('account'); this.account = this.registry.get('account');
this.log = this.add.text(logX, logY, '', TEXT.NORMAL); this.log = this.add.text(COMBAT.LOG.x(), COMBAT.LOG.y(), '', TEXT.NORMAL);
this.log.setWordWrapWidth(logWidth); this.log.setWordWrapWidth(COMBAT.LOG.width());
return true; return true;
} }