Skip to content

Commit

Permalink
Merge pull request Larkenx#46 from Larkenx/freature/more-spells
Browse files Browse the repository at this point in the history
Merging to fix small glitches with spellbook cards. Adding some more spells
  • Loading branch information
Larkenx authored Nov 3, 2018
2 parents 81487dc + 4e775d6 commit 99edaae
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 35 deletions.
9 changes: 6 additions & 3 deletions src/assets/js/game/entities/actors/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 = []
Expand Down
94 changes: 87 additions & 7 deletions src/assets/js/game/magic/Spell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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',
Expand Down Expand Up @@ -44,17 +46,17 @@ export class Spell {
Object.assign(this, options)
}

cast() {} // to be overwritten
cast() { } // to be overwritten
}

/* Restoration Spells */
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,
Expand All @@ -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')
Expand All @@ -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)
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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])
})

Expand Down
7 changes: 6 additions & 1 deletion src/components/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ div.v-expansion-panel__header {
border-radius: 2px;
}
code {
background-color: #424242;
color: white;
}
/* .selectedItem {
background-color: green;
margin: 2px;
Expand All @@ -71,7 +76,7 @@ div.v-expansion-panel__header {
<span class="headline pl-2" style="color: #535353">Inventory</span>
<v-spacer />
<span class="pr-233" style="color: #535353">
press <code style="background-color: #424242">d</code> to drop. press <code style="background-color: #424242">e</code> to interact
press <code>d</code> to drop. press <code>e</code> to interact
</span>
</v-layout>
<v-layout v-for="(index, row) in Math.ceil(inventory.length / 3)" :key="row" justify-start style="margin-left: 25px;">
Expand Down
51 changes: 27 additions & 24 deletions src/components/Spellbook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
code {
background-color: #424242;
color: white;
}
.selected_spell {
Expand Down Expand Up @@ -67,33 +68,35 @@ code {
<span class="headline pl-2" style="color: #535353">Spellbook</span>
<v-spacer />
<span class="pr-233" style="color: #535353">
press <code>e</code> or <code>⏎</code>to set active spell
press <code>e</code> or <code>⏎</code> to set active spell
</span>
</v-layout>
<v-layout wrap justify-space-around>
<v-card class="ma-2 pa-3" width="300px" height="200px" v-for="(spell, index) in spells" :key="index" :class="{selected_spell: spell === selectedSpellSlot.spell, unselected_spell: spell !== selectedSpellSlot.spell}" @click.native="selectSpellAtIndex(index)">
<v-layout fill-height column>
<v-layout wrap align-content-center align-center justify-center>
<v-flex>
<img :class="{active_spell_image: isActiveSpell(spell)}" width="32px" height="32px" v-bind:src="getSpellSplashArt(spell.type.toLowerCase(), spell.splashArt)">
</v-flex>
<v-flex style="flex-grow: 1">
<span>{{spell.name}}</span>
</v-flex>
</v-layout>
<v-layout justify-center align-center column fill-height>
<span class="pa-2">{{spell.hoverInfo}}</span>
<v-layout wrap>
<v-flex xs4 v-for="(spell, index) in spells" :key="index">
<v-card class="ma-2 pa-3" width="300px" height="200px" :class="{selected_spell: spell === selectedSpellSlot.spell, unselected_spell: spell !== selectedSpellSlot.spell}" @click.native="selectSpellAtIndex(index)">
<v-layout fill-height column>
<v-layout wrap align-content-center align-center justify-center>
<v-flex>
<img :class="{active_spell_image: isActiveSpell(spell)}" width="32px" height="32px" v-bind:src="getSpellSplashArt(spell.type.toLowerCase(), spell.splashArt)">
</v-flex>
<v-flex style="flex-grow: 1">
<span>{{spell.name}}</span>
</v-flex>
</v-layout>
<v-layout justify-center align-center column fill-height>
<span class="pa-2">{{spell.hoverInfo}}</span>
</v-layout>
<v-card-actions>
<v-chip small style="color: white" color="#1e1f1f">
{{spell.manaCost}} mana points
</v-chip>
<v-spacer />
<v-btn v-if="!isActiveSpell(spell)" small flat color="yellow darken-4" @click.native="setActiveSpell(spell)">Select Spell</v-btn>
<v-btn v-else disabled small flat color="yellow darken-4" >Active Spell</v-btn>
</v-card-actions>
</v-layout>
<v-card-actions>
<v-chip small style="color: white" color="#1e1f1f">
{{spell.manaCost}} mana points
</v-chip>
<v-spacer />
<v-btn v-if="!isActiveSpell(spell)" small flat color="yellow darken-4" @click.native="setActiveSpell(spell)">Select Spell</v-btn>
<v-btn v-else disabled small flat color="yellow darken-4" >Active Spell</v-btn>
</v-card-actions>
</v-layout>
</v-card>
</v-card>
</v-flex>
</v-layout>
</v-card>
</v-flex>
Expand Down

0 comments on commit 99edaae

Please sign in to comment.