12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- class SayHimHerIt extends Say {
- private node = document.createTextNode("a ");
- private target : Thing;
- private uppercase = true;
- public constructor (target : Thing, autoUppercase? : boolean) {
- super();
- this.target = target;
- if (autoUppercase != undefined) {
- this.uppercase = autoUppercase;
- }
- }
- public async getPureElements (say : Say) : Promise<Array<Element | Text>> {
- let next = this.target;
- if (next == undefined) {
- this.node.nodeValue = "";
- } else {
- if (next instanceof Humanoid) {
- let gender = next.getGenderValue();
- if (WorldState.isPlayer(next)) {
- this.node.nodeValue = "me";
- } else if (gender.genderValueCorrected > 65) {
- this.node.nodeValue = "her ";
- } else if (gender.genderValueCorrected < 35) {
- this.node.nodeValue = "him ";
- } else {
- // This person is androgynous...
- if (gender.hasPenisBulge || gender.hasPenis) {
- this.node.nodeValue = "him ";
- } else if (gender.hasVagina || gender.hasTits) {
- this.node.nodeValue = "her ";
- } else {
- this.node.nodeValue = "them ";
- }
- }
- } else {
- // TODO: If we ever have gendered non-humanoids, they must be added here.
- this.node.nodeValue = "it ";
- }
- if (this.uppercase && say.currentParagraph.length == 0) {
- this.node.nodeValue = this.node.nodeValue.charAt(0).toUpperCase()
- + this.node.nodeValue.substr(1, this.node.nodeValue.length - 1);
- }
- }
- return [this.node];
- }
- }
|