From 601e617bfcd3f94038e68698426471c0ff16a505 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 22 Nov 2018 13:48:35 +1100 Subject: [PATCH 1/3] cryp page updates --- client/src/scenes/constants.js | 18 +++++++++++++ client/src/scenes/cryp.page.js | 46 +++++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/client/src/scenes/constants.js b/client/src/scenes/constants.js index 1aa2717a..48261fb4 100644 --- a/client/src/scenes/constants.js +++ b/client/src/scenes/constants.js @@ -19,6 +19,14 @@ const gameListHeight = () => Math.floor(window.innerHeight / 10); const gameListX = () => crypListWidth(); const gameListY = i => menuHeight() + (gameListHeight() * i); +const statsWidth = () => Math.floor(window.innerWidth - crypListWidth() - gameListWidth()); +const statsHeight = () => window.innerHeight - menuHeight(); +const statsY = () => menuHeight(); +const statsX = () => crypListWidth() + gameListWidth(); +const statsKnownX = () => Math.floor(statsX() + statsWidth() / 4); +const statsLearnableX = () => Math.floor(statsX() + statsWidth() / 2); +const statsTextMargin = () => 24; + const logWidth = () => Math.floor(combatWidth() * 0.2); const logHeight = () => combatHeight(); const logY = () => menuHeight(); @@ -45,6 +53,16 @@ module.exports = { rowWidth: crypListWidth, }, + STATS: { + x: statsX, + y: statsY, + width: statsWidth, + height: statsHeight, + knownX: statsKnownX, + learnableX: statsLearnableX, + textMargin: statsTextMargin, + }, + COMBAT: { x: combatX, y: combatY, diff --git a/client/src/scenes/cryp.page.js b/client/src/scenes/cryp.page.js index 6b5e17e8..b71bb0f2 100644 --- a/client/src/scenes/cryp.page.js +++ b/client/src/scenes/cryp.page.js @@ -1,17 +1,6 @@ const Phaser = require('phaser'); -const { TEXT, SKILLS } = require('./constants'); - -const ROW_WIDTH = 400; -const ROW_HEIGHT = 200; -const ROW_FILL = 0x888888; - -const TOP_MARGIN = 50; -const ROW_MARGIN = 50; -const TEXT_MARGIN = 24; - -const xPos = i => 0; -const yPos = i => (i * ROW_HEIGHT + ROW_MARGIN) + TOP_MARGIN; +const { TEXT, SKILLS, POSITIONS: { STATS } } = require('./constants'); class CrypPage extends Phaser.GameObjects.Group { constructor(scene, cryp) { @@ -19,10 +8,27 @@ class CrypPage extends Phaser.GameObjects.Group { 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 TEXT_MARGIN = STATS.textMargin(); + + const stat = (stat, i) => { + const STAT_X = STATS.x(); + const STAT_Y = (i * TEXT_MARGIN) + STATS.y() + TEXT_MARGIN; + + const text = scene.add.text(STAT_X, STAT_Y, `${stat.stat}: ${stat.base}`, TEXT.NORMAL); + + text.on('pointerdown', () => { + this.ws.sendCrypForget(cryp.id, skill.skill); + }); + this.add(text); + + } const knownSkill = (skill, i) => { - const text = scene.add.text(500, 500 + (TEXT_MARGIN * (i + 1)), skill.skill, TEXT.NORMAL) + const SKILL_X = STATS.knownX(); + const SKILL_Y = (i * TEXT_MARGIN) + STATS.y() + TEXT_MARGIN; + + const text = scene.add.text(SKILL_X, SKILL_Y, skill.skill, TEXT.NORMAL) .setInteractive(); text.on('pointerdown', () => { @@ -32,7 +38,10 @@ class CrypPage extends Phaser.GameObjects.Group { }; const learnable = (skill, i) => { - const text = scene.add.text(600, 0 + (TEXT_MARGIN * (i + 1)), skill, TEXT.NORMAL) + const SKILL_X = STATS.learnableX(); + const SKILL_Y = (i * TEXT_MARGIN) + STATS.y() + TEXT_MARGIN; + + const text = scene.add.text(SKILL_X, SKILL_Y, skill, TEXT.NORMAL) .setInteractive(); text.on('pointerdown', () => { @@ -42,7 +51,14 @@ class CrypPage extends Phaser.GameObjects.Group { text.cryp = cryp; }; + const CRYP_STATS = [cryp.stamina, cryp.phys_dmg, cryp.spell_dmg]; + this.add(scene.add.text(STATS.x(), STATS.y(), cryp.name, TEXT.HEADER)); + CRYP_STATS.forEach(stat); + + this.add(scene.add.text(STATS.knownX(), STATS.y(), 'Skills', TEXT.HEADER)); cryp.skills.forEach(knownSkill); + + this.add(scene.add.text(STATS.learnableX(), STATS.y(), 'Learnable', TEXT.HEADER)); SKILLS.LEARNABLE.forEach(learnable); } } From 784905cf248da1d366ecd4ad5952ab438e281774 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 22 Nov 2018 14:00:01 +1100 Subject: [PATCH 2/3] use correct stats --- client/src/scenes/cryp.page.js | 3 +-- server/src/cryp.rs | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/scenes/cryp.page.js b/client/src/scenes/cryp.page.js index b71bb0f2..38b016d3 100644 --- a/client/src/scenes/cryp.page.js +++ b/client/src/scenes/cryp.page.js @@ -21,8 +21,7 @@ class CrypPage extends Phaser.GameObjects.Group { this.ws.sendCrypForget(cryp.id, skill.skill); }); this.add(text); - - } + }; const knownSkill = (skill, i) => { const SKILL_X = STATS.knownX(); diff --git a/server/src/cryp.rs b/server/src/cryp.rs index f14860e0..7a0316ab 100755 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -44,7 +44,7 @@ pub enum Stat { PhysDmg, SpellDmg, Hp, - Stam, + Stamina, } #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] @@ -97,9 +97,9 @@ impl Cryp { return Cryp { id, account: id, - phys_dmg: CrypStat { base: 0, stat: Stat::Str }, - spell_dmg: CrypStat { base: 0, stat: Stat::Int }, - stamina: CrypStat { base: 0, stat: Stat::Stam }, + phys_dmg: CrypStat { base: 0, stat: Stat::PhysDmg }, + spell_dmg: CrypStat { base: 0, stat: Stat::SpellDmg }, + stamina: CrypStat { base: 0, stat: Stat::Stamina }, hp: CrypStat { base: 0, stat: Stat::Hp }, lvl: 0, xp: 0, From 2261d9d6e083f5c6c4485b7714c981f98a75db92 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 22 Nov 2018 14:13:32 +1100 Subject: [PATCH 3/3] remove unused pointerdown --- client/src/scenes/cryp.page.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/client/src/scenes/cryp.page.js b/client/src/scenes/cryp.page.js index 38b016d3..ee7755e2 100644 --- a/client/src/scenes/cryp.page.js +++ b/client/src/scenes/cryp.page.js @@ -11,15 +11,11 @@ class CrypPage extends Phaser.GameObjects.Group { const TEXT_MARGIN = STATS.textMargin(); - const stat = (stat, i) => { + const crypStat = (stat, i) => { const STAT_X = STATS.x(); const STAT_Y = (i * TEXT_MARGIN) + STATS.y() + TEXT_MARGIN; const text = scene.add.text(STAT_X, STAT_Y, `${stat.stat}: ${stat.base}`, TEXT.NORMAL); - - text.on('pointerdown', () => { - this.ws.sendCrypForget(cryp.id, skill.skill); - }); this.add(text); }; @@ -52,7 +48,7 @@ class CrypPage extends Phaser.GameObjects.Group { const CRYP_STATS = [cryp.stamina, cryp.phys_dmg, cryp.spell_dmg]; this.add(scene.add.text(STATS.x(), STATS.y(), cryp.name, TEXT.HEADER)); - CRYP_STATS.forEach(stat); + CRYP_STATS.forEach(crypStat); this.add(scene.add.text(STATS.knownX(), STATS.y(), 'Skills', TEXT.HEADER)); cryp.skills.forEach(knownSkill);