Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Forked from anonymous/gist:1618812
Created January 16, 2012 03:01
Show Gist options
  • Select an option

  • Save hughfdjackson/1618815 to your computer and use it in GitHub Desktop.

Select an option

Save hughfdjackson/1618815 to your computer and use it in GitHub Desktop.
grom358 - MtG
function Card(cardName, cardType) {
this.cardName = cardName;
this.cardType = cardType;
this.manaCost = new Mana();
this.tapped = false;
this.summonSickness = false;
this.power = 0;
this.toughness = 0;
this.owner = null;
this.player = null;
this.abilities = [];
}
Card.prototype.tap = function() {
this.tapped = true;
};
Card.prototype.untap = function() {
this.tapped = false;
};
Card.prototype.convertedManaCost = function() {
return this.manaCost.total();
};
function Swamp() {
Card.apply(this, 'Swamp', 'Land');
}
// make the prototype of swamp an instance of card
Swamp.prototype = new Card()
// reset the constructor value of Swamp.prototype ( which originally pointed to Swamp, but got overwritten in the above assignment.
Swamp.prototype.constructor = Swamp
Swamp.prototype.tap = function() {
this.tapped = true;
this.player.manaPool.black++;
};
Swamp.prototype.untap = function() {
this.tapped = false;
this.player.manaPool.black--;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment