1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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 (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];
- }
- }
|