ContentAtomCombat.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ///<reference path="../ContentAtom.ts"/>
  2. ///<reference path="../ContentNounSimple.ts"/>
  3. /**
  4. * This atom should be used in place of the default atom when handling Combat.
  5. */
  6. class ContentAtomCombat extends ContentAtom {
  7. /**
  8. * Only one of the following markers appears at once.
  9. */
  10. public static HIT = new ContentNounSimple("HIT");
  11. public static MISS = new ContentNounSimple("MISS");
  12. public static CRITICAL = new ContentNounSimple("CRITICAL");
  13. /**
  14. * Only one of the following markers appears at once.
  15. */
  16. public static KNOCKED = new ContentNounSimple("KNOCKED");
  17. public static KNOCKED_OFF = new ContentNounSimple("KNOCKED_OFF");
  18. public static KILLED = new ContentNounSimple("KILLED");
  19. public attacker : any;
  20. public target : any;
  21. public weapons : ContentAtom = new ContentAtom();
  22. public markers : ContentAtom = new ContentAtom();
  23. constructor (attacker : any, target : any, weapons : Array<any> = [], markers : Array<ContentNounSimple> = []) {
  24. super();
  25. this.attacker = attacker;
  26. this.target = target;
  27. this.weapons.addNoun(...weapons);
  28. this.markers.addNoun(...markers);
  29. }
  30. public compareAgainst (other : ContentAtom) {
  31. if (other instanceof ContentAtomCombat) {
  32. return (
  33. ContentAtom.compareNoun(this.attacker, other.attacker) &&
  34. ContentAtom.compareNoun(this.target, other.target) &&
  35. this.weapons.compareAgainst(other.weapons) &&
  36. this.markers.compareAgainst(other.markers)
  37. );
  38. }
  39. return false;
  40. }
  41. public getAtomPriority () {
  42. return (
  43. ContentAtom.weightNoun(this.attacker) +
  44. ContentAtom.weightNoun(this.target) +
  45. this.weapons.getAtomPriority() +
  46. this.markers.getAtomPriority()
  47. );
  48. }
  49. }
  50. //new ContentAtomCombat(WorldState.player, OrcDebugger, [HumanoidHands], [ContentAtomCombat.HIT]);
  51. //Looks good.