Skip to content

Commit

Permalink
More JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Veilleux-Gaboury committed May 6, 2015
1 parent a13a13e commit d402fc2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
22 changes: 18 additions & 4 deletions extra-resources/keywords-effects.js
Expand Up @@ -6,7 +6,10 @@
"use strict";

keywords.effects.print = {
/** Build action description */
/**
* Build action description
* @param {Object} obj - The applicable card object along with related properties/values.
*/
description: function (obj) {
print("calling description: " + obj);
return "print " + obj.message.length + " characters";
Expand All @@ -24,7 +27,10 @@ keywords.effects.print = {
};

keywords.effects.damage = {
/** Build action description */
/**
* Build action description
* @param {Object} obj - The applicable card object along with related properties/values.
*/
description: function(obj) {
return "Deal " + valueDescription(obj.value) + " damage to " + obj.target;
},
Expand All @@ -45,7 +51,10 @@ keywords.effects.damage = {
};

keywords.effects.heal = {
/** Build action description */
/**
* Build action description
* @param {Object} obj - The applicable card object along with related properties/values.
*/
description: function(obj) {
return "Heal " + valueDescription(obj.value) + " damage to " + obj.target;
},
Expand All @@ -66,7 +75,12 @@ keywords.effects.heal = {
};

keywords.effects.summon = {
/** Build action description */
/**
* Build action description
* @param {Object} obj - The applicable card object along with related properties/values.
*/
* @param {Object} obj - The applicable card object along with related properties/values.
*/
description: function(obj) {
return "Summon " + valueDescription(obj.count) + " " + obj.card + " at " + obj.who + " " + obj.where;
},
Expand Down
47 changes: 47 additions & 0 deletions extra-resources/keywords-filters.js
@@ -1,7 +1,21 @@
/**
* Defines filters applicable to effect keywords.
* @module keywords-filter
*/

keywords.filters.owner = {
/**
* Build owner filter description.
* @param {Object} value - The applicable card object along with related properties/values.
*/
description: function (value) {
return "owned by " + value;
},
/**
* Declares applicable owner filter.
* @param {Object} entity - The applicable card entity.
* @param {string} filter - The owner declared by the filter.
*/
func: function (entity, filter) {
if (filter === "owner") {
return function (source, target) {
Expand Down Expand Up @@ -41,9 +55,18 @@ keywords.filters.owner = {
};

keywords.filters.zone = {
/**
* Build zone filter description.
* @param {Object} value - The applicable card object along with related properties/values.
*/
description: function (value) {
return "on " + value;
},
/**
* Declares applicable zone filter.
* @param {Object} entity - The applicable card entity.
* @param {string} filter - The zone declared by the filter.
*/
func: function (entity, filter) {
return function (source, target) {
if (!target.hasComponent(com.cardshifter.modapi.cards.CardComponent.class)) {
Expand All @@ -57,9 +80,18 @@ keywords.filters.zone = {
};

keywords.filters.creature = {
/**
* Build creature filter description.
* @param {Object} value - The applicable card object along with related properties/values.
*/
description: function (value) {
return "creature";
},
/**
* Declares applicable creature filter.
* @param {Object} entity - The applicable card entity.
* @param {string} filter - The creature declared by the filter.
*/
func: function (entity, filter) {
return function (source, target) {
return target.hasComponent(com.cardshifter.modapi.base.CreatureTypeComponent.class);
Expand All @@ -68,16 +100,31 @@ keywords.filters.creature = {
};

keywords.filters.creatureType = {
/**
* Build creatureType filter description
* @param {Object} value - The applicable card object along with related properties/values.
*/
description: function (value) {
return value + " creatures";
},
/**
* Declares applicable creatureType filter.
* @param {Object} entity - The applicable card entity.
* @param {string} filter - The creatureType declared by the filter.
*/
func: function (entity, filter) {
return function (source, target) {
return filter === target.getComponent(com.cardshifter.modapi.base.CreatureTypeComponent.class).creatureType;
}
}
};

/**
*
* @param entity {Object} - Applicable card entity.
* @param filter {Object} - Applicable card object.
* @returns {Function} - Returns if the source and target make a valid function.
*/
function resolveFilter(entity, filter) {
var description = "";
var functions = [];
Expand Down

0 comments on commit d402fc2

Please sign in to comment.