Created
February 8, 2017 00:50
-
-
Save sean-codes/9a129de9d183dc0b622512e51efcb522 to your computer and use it in GitHub Desktop.
Video Game Spell System
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spells = { | |
shield: { | |
buff: { | |
type: 'reflect', | |
duration: 60 | |
}, | |
castTime: 30, | |
mana: -20 | |
}, | |
fireball:{ | |
projectile: { | |
type: 'fireball' | |
}, | |
castTime: 30, | |
mana: -10 | |
} | |
} | |
var buffs = { | |
reflect: { | |
duration: 120, | |
reduceDamage: 1, | |
reflect: true | |
} | |
} | |
var projectiles = { | |
fireball: { | |
duration: 120, | |
damage: 4 | |
} | |
} | |
var player = { | |
health: 100, | |
mana: 100, | |
buffs: [], | |
casting: 0,//Time left to finish casting spell | |
castingSpell: undefined; | |
} | |
player.cast = function(spell){ | |
if(casting) return; | |
castingSpell = spell | |
casting = spells[spell].castTime || 0; | |
} | |
player.step = function(){ | |
//reduce cast timer | |
//Cast on 0 | |
//Reduce buffs timers | |
//Remove done buffs | |
//Run buffs | |
} | |
player.cast('fireball'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment