From 4e775d662a9edf9c133a15b7c3b41e583534a099 Mon Sep 17 00:00:00 2001 From: Steven Myers Date: Sat, 3 Nov 2018 18:54:28 -0400 Subject: [PATCH] Adding a few more simple spells. small UI fixes --- src/assets/js/game/entities/actors/Player.js | 9 +- src/assets/js/game/magic/Spell.js | 94 ++++++++++++++++++-- src/components/Inventory.vue | 7 +- src/components/Spellbook.vue | 51 ++++++----- 4 files changed, 126 insertions(+), 35 deletions(-) diff --git a/src/assets/js/game/entities/actors/Player.js b/src/assets/js/game/entities/actors/Player.js index 260183b9..cc13816b 100644 --- a/src/assets/js/game/entities/actors/Player.js +++ b/src/assets/js/game/entities/actors/Player.js @@ -17,7 +17,7 @@ import HealthPotion from '#/entities/items/potions/HealthPotion.js' import StrengthPotion from '#/entities/items/potions/StrengthPotion.js' import ManaPotion from '#/entities/items/potions/ManaPotion.js' // Spells -import { targetTypes, MagicDart, Regeneration, Pain, VampiricDraining, AnimateDead, MinorHeal } from '#/magic/Spell.js' +import { targetTypes, spellTypes, MagicDart, FireBall, Rage, MinorHeal, Shock } from '#/magic/Spell.js' // effects import { BleedEnchantment } from '#/modifiers/Enchantment.js' // Misc @@ -50,12 +50,12 @@ export default class Player extends Actor { description: [' attacked ', ' stabbed ', ' jabbed ', ' smashed '], /* stat caps */ maxhp: 50, - maxmana: 18, + maxmana: 15, /* current stats */ xp: 50, level: 1, hp: 50, - mana: 18, + mana: 15, str: 1, def: 1, /* Per-turn effects */ @@ -148,6 +148,9 @@ export default class Player extends Actor { this.addToInventory(new ManaPotion(this.x, this.y, 608)) this.cb.spells.push(new MagicDart()) this.cb.spells.push(new MinorHeal()) + this.cb.spells.push(new Shock()) + this.cb.spells.push(new FireBall()) + this.cb.spells.push(new Rage()) this.selectSpell(this.cb.spells[0]) this.mouseEnabled = false this.commandQueue = [] diff --git a/src/assets/js/game/magic/Spell.js b/src/assets/js/game/magic/Spell.js index 927915d1..3a61b768 100644 --- a/src/assets/js/game/magic/Spell.js +++ b/src/assets/js/game/magic/Spell.js @@ -3,6 +3,7 @@ import ROT from 'rot-js' import { getRandomInt, getDiceRoll } from '#/utils/HelperFunctions.js' import { RegenerationEffect } from '#/modifiers/Effect.js' +import { StrengthBuff } from '#/modifiers/Buff.js' import { Game } from '#/Game.js' import { Corpse, corpseTypes } from '#/entities/items/misc/Corpse.js' import Skeleton from '#/entities/actors/enemies/Skeleton.js' @@ -11,6 +12,7 @@ import Zombie from '#/entities/actors/enemies/Zombie.js' export const spellTypes = { CONJURATION: 'CONJURATION', RESTORATION: 'RESTORATION', + ENCHANTMENT: 'ENCHANTMENT', CHARMS: 'CHARMS', ICE: 'ICE', AIR: 'AIR', @@ -44,7 +46,7 @@ export class Spell { Object.assign(this, options) } - cast() {} // to be overwritten + cast() { } // to be overwritten } /* Restoration Spells */ @@ -52,9 +54,9 @@ export class MinorHeal extends Spell { constructor(options) { super({ name: 'Minor Heal', - hoverInfo: 'Mend your wounds with healing energy. Regenerates 20 health.', + hoverInfo: 'Mend your wounds with healing energy. Regenerates 15 health.', action: entity => { - entity.heal(20) + entity.heal(15) }, splashArt: 'minor_heal', type: spellTypes.RESTORATION, @@ -65,7 +67,7 @@ export class MinorHeal extends Spell { } cast(target, caster) { - let healthRecovered = Math.max(0, caster.cb.maxhp - caster.cb.hp - 20) + let healthRecovered = Math.max(0, caster.cb.maxhp - caster.cb.hp - 15) if (caster === Game.player) Game.log(`You mend your wounds with a healing spell and recover ${healthRecovered} health points.`, '#e3c91c') else Game.log(`${caster.name.capitalize()} used minor heal to regenerate 20 health points.`, 'plum') @@ -87,7 +89,7 @@ export class MagicDart extends Spell { splashArt: 'magic_dart', type: spellTypes.CONJURATION, targetType: targetTypes.TARGET, - manaCost: 3 + manaCost: 2 }) Object.assign(this, options) } @@ -101,6 +103,84 @@ export class MagicDart extends Spell { } } +export class Shock extends Spell { + constructor(options) { + super({ + name: 'Shock', + hoverInfo: 'Releases a small zap of electrical energy. Deals 3-6 damage to a target.', + action: (entity, hit) => { + entity.damage(hit) + }, + splashArt: 'shock', + type: spellTypes.AIR, + targetType: targetTypes.TARGET, + manaCost: 6 + }) + Object.assign(this, options) + } + + cast(target, caster) { + let dmg = getRandomInt(3, 6) // remember to update hover info if this changes! + if (target === Game.player) Game.log(`You took ${dmg} damage from a Shock spell!`, 'attack') + else Game.log(`Shock electrifies the ${target.name} for ${dmg} electrical damage.`, 'player_move') + + this.action(target, dmg) + } +} + +export class FireBall extends Spell { + constructor(options) { + super({ + name: 'Fire Ball', + hoverInfo: 'Summon a ball of fire and hurl it towards a target. Deals 12-20 damage to a target.', + action: (entity, hit) => { + entity.damage(hit) + }, + splashArt: 'fireball', + type: spellTypes.FIRE, + targetType: targetTypes.TARGET, + manaCost: 12 + }) + Object.assign(this, options) + } + + cast(target, caster) { + let dmg = getRandomInt(12, 20) // remember to update hover info if this changes! + if (target === Game.player) Game.log(`You took ${dmg} fire damage from a Fire Ball spell!`, 'attack') + else Game.log(`Fire Ball sears the ${target.name} for ${dmg} fire damage.`, 'player_move') + + this.action(target, dmg) + } +} + +export class Rage extends Spell { + constructor(options) { + super({ + name: 'Rage', + hoverInfo: 'Overcome with rage and fury, your strength is boosted by 3 for 5 turns.', + action: (entity) => { + let buff = new StrengthBuff(3) + buff.duration += 2 + entity.addNewBuff(buff) + }, + splashArt: 'berserker_rage', + type: spellTypes.ENCHANTMENT, + targetType: targetTypes.SELF, + manaCost: 6 + }) + Object.assign(this, options) + } + + cast(target, caster) { + if (caster === Game.player) + Game.log(`You feel a burning rage and intensity within you. Strength is coursing through your veins...`, 'alert') + else Game.log(`${caster.name.capitalize()} becomes enraged.`, 'alert') + + this.action(caster) + } +} + + /* Necromancy Spells */ export class Pain extends Spell { @@ -203,12 +283,12 @@ export const reanimate = corpse => { /* returns an array of corpses :) */ export const getNearbyCorpses = actor => { - let fov = new ROT.FOV.PreciseShadowcasting(function(x, y) { + let fov = new ROT.FOV.PreciseShadowcasting(function (x, y) { return Game.inbounds(x, y) && Game.map.data[y][x].visible() }) let visibleTiles = [] - fov.compute(actor.x, actor.y, actor.cb.range, function(x, y, r, visibility) { + fov.compute(actor.x, actor.y, actor.cb.range, function (x, y, r, visibility) { if (Game.inbounds(x, y)) visibleTiles.push(Game.map.data[y][x]) }) diff --git a/src/components/Inventory.vue b/src/components/Inventory.vue index 70e2fa35..22f61097 100644 --- a/src/components/Inventory.vue +++ b/src/components/Inventory.vue @@ -46,6 +46,11 @@ div.v-expansion-panel__header { border-radius: 2px; } +code { + background-color: #424242; + color: white; +} + /* .selectedItem { background-color: green; margin: 2px; @@ -71,7 +76,7 @@ div.v-expansion-panel__header { Inventory - press d to drop. press e to interact + press d to drop. press e to interact diff --git a/src/components/Spellbook.vue b/src/components/Spellbook.vue index 524a26ba..aa559adb 100644 --- a/src/components/Spellbook.vue +++ b/src/components/Spellbook.vue @@ -9,6 +9,7 @@ code { background-color: #424242; + color: white; } .selected_spell { @@ -67,33 +68,35 @@ code { Spellbook - press e or to set active spell + press e or to set active spell - - - - - - - - - {{spell.name}} - - - - {{spell.hoverInfo}} + + + + + + + + + + {{spell.name}} + + + + {{spell.hoverInfo}} + + + + {{spell.manaCost}} mana points + + + Select Spell + Active Spell + - - - {{spell.manaCost}} mana points - - - Select Spell - Active Spell - - - + +