Skip to content

Instantly share code, notes, and snippets.

@sean-codes
Created February 8, 2017 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sean-codes/9a129de9d183dc0b622512e51efcb522 to your computer and use it in GitHub Desktop.
Save sean-codes/9a129de9d183dc0b622512e51efcb522 to your computer and use it in GitHub Desktop.
Video Game Spell System
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