CombatDescription.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /// <reference path="../ContentDescription.ts" />
  2. /// <reference path="CombatPokeUnit.ts" />
  3. /// <reference path="CombatUnit.ts" />
  4. /**
  5. * Quick Cheat Sheet of markers!
  6. * When making a description take these markers into account while describing the action! If a marker describes something
  7. * please include it if you add it to the description. Example: if you describe the attack as a "heavy hit!", make sure
  8. * to add the HIGH_DAMAGE marker, we don't want a "heavy hit!" to be displayed for an attack that caused 1 damage.
  9. *
  10. * Mandatory Markers - Include only one and clone description for each
  11. * CombatHit.FULL_DODGE
  12. * CombatHit.PARTIAL_DODGE
  13. * CombatHit.FULL_HIT
  14. *
  15. * Mandatory Markers - Include only one and clone description for each. These don't show up in FULL_DODGE
  16. * CombatResult.KNOCKED
  17. * CombatResult.KNOCKED_OFF
  18. * CombatResult.KILLED
  19. *
  20. * Non-Mandatory Markers - Include at most one per description, none makes a description fit more attacks. These don't show up in FULL_DODGE.
  21. * CombatDamage.LOW_DAMAGE
  22. * CombatDamage.MEDIUM_DAMAGE
  23. * CombatDamage.HIGH_DAMAGE
  24. */
  25. class CombatDescription extends ContentDescription {
  26. public static DESCRIPTIONS = [];
  27. public constructor (name : string) {
  28. super(name, new ContentGroup());
  29. CombatDescription.DESCRIPTIONS.push(this);
  30. }
  31. public setDescriptionFunction (descriptionFor : (actor : any, target : any, weapons : Array<any>, markers : Array<any>) => Say) {
  32. let finalFunction = (description : CombatDescription, group : ContentGroup) => {
  33. // Combat only has one unit
  34. let unit = <CombatUnit> group.getUnit(0);
  35. return descriptionFor (unit.getActor().nouns[0], unit.getTarget().nouns[0], unit.getWeapons(), unit.getMarkers());
  36. }
  37. this.description = finalFunction;
  38. return this;
  39. }
  40. public addUnit () {
  41. let unit = new CombatUnit();
  42. (<ContentGroup> this.group).addUnit(unit);
  43. return unit;
  44. }
  45. public static getDescription (target : ContentGroup) {
  46. return ContentDescription.pickDescriptions(CombatDescription.DESCRIPTIONS, target);
  47. }
  48. }