SayHisHersIts.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. class SayHisHersIts extends Say {
  2. private node = document.createTextNode("a ");
  3. private target : Thing;
  4. private uppercase = true;
  5. public constructor (target : Thing, autoUppercase? : boolean) {
  6. super();
  7. this.target = target;
  8. if (autoUppercase != undefined) {
  9. this.uppercase = autoUppercase;
  10. }
  11. }
  12. public async getPureElements (say : Say) : Promise<Array<Element | Text>> {
  13. let next = this.target;
  14. if (next == undefined) {
  15. this.node.nodeValue = "";
  16. } else {
  17. if (next instanceof Humanoid) {
  18. let gender = next.getGenderValue();
  19. if (WorldState.isPlayer(next)) {
  20. this.node.nodeValue = "your ";
  21. } else if (gender.genderValueCorrected > 65) {
  22. this.node.nodeValue = "hers ";
  23. } else if (gender.genderValueCorrected < 35) {
  24. this.node.nodeValue = "his ";
  25. } else {
  26. // This person is androgynous...
  27. if (gender.hasPenisBulge || gender.hasPenis) {
  28. this.node.nodeValue = "his ";
  29. } else if (gender.hasVagina || gender.hasTits) {
  30. this.node.nodeValue = "hers ";
  31. } else {
  32. this.node.nodeValue = "their ";
  33. }
  34. }
  35. } else {
  36. // TODO: If we ever have gendered non-humanoids, they must be added here.
  37. this.node.nodeValue = "its ";
  38. }
  39. if (this.uppercase && say.currentParagraph.length == 0) {
  40. this.node.nodeValue = this.node.nodeValue.charAt(0).toUpperCase()
  41. + this.node.nodeValue.substr(1, this.node.nodeValue.length - 1);
  42. }
  43. }
  44. return [this.node];
  45. }
  46. }