(function () {
A.Preverbs.toggle = {
name: "toggle",
prettyname: "toggle",
past_tense: "toggled",
synonyms: ["toggle"],
gerund: "toggling",
phrase1: {
accepts_noun: true,
requires_noun: true,
noun_must_be: {
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
},
with_params: {},
doTry: function () {
var input = this.game.getInput();
var subject = input.getSubject();
var verb_phrase = input.verb_phrase;
var direct_object = input.getAsset(1);
var direct_preposition = input.getPreposition(1);
var indirect_object = input.getAsset(2);
var indirect_preposition = input.getPreposition(2);
var indirect_inferred;
var results;
var msg = "";
if (!direct_object.isDOV("toggle")) {
this.game.debug(
`D1450 | ${this.name}.js | ${direct_object.id}.dov.toggle.enabled is false `
);
msg += `${direct_object.Articlename} can't be ${this.past_tense}. `;
this.handleFailure(msg);
return null;
}
if (
direct_object.allowVerbOnce(this.name, "dov") &&
direct_object.didVerb(this.name, "dov")
) {
this.game.debug(
`D2044 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.once and ${direct_object.id}.did.${this.name}.directly `
);
msg += `$(We) can't ${this.name} ${direct_object.articlename} again. `;
this.handleFailure(msg);
return false;
}
if (input.hasStructure("verb noun")) {
if (direct_object.allowVerbWithNothing(this.name, "dov")) {
return true;
}
if (!direct_object.hasIndirectObjects(this.name)) {
this.game.debug(
`D2045 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.with_nothing is false `
);
msg += `$(We) $(don't) know of a way to ${this.name} ${direct_object.articlename}. `;
this.handleFailure(msg);
return false;
}
results = this.tryToInferIndirectObject({
direct_object: direct_object,
context: subject,
handle_input: true,
});
if (results.prompt) {
this.game.debug(`D2046 | ${this.name}.js | soft prompt for noun2 `);
msg += `What would $(we) like to ${this.name} ${direct_object.articlename} with? `;
this.handleFailure(msg);
return false;
} else if (results.success) {
indirect_object = results.indirect_object;
indirect_preposition = "with";
indirect_inferred = true;
input.setAsset(2, indirect_object);
input.setPreposition(2, indirect_preposition);
input.setStructure("verb noun preposition noun");
this.game.printInferred(
`${indirect_preposition} ${indirect_object.articlename}`
);
}
}
if (input.hasStructure("verb noun preposition noun")) {
if ("with" === indirect_preposition) {
if (!this.game.parser.selectInHands(indirect_object.id).length) {
this.game.debug(
`D2047 | ${this.name}.js | ${indirect_object.id}.$is("inhands") is false `
);
msg += `$(We're) not holding ${indirect_object.articlename}. `;
this.handleFailure(msg);
return null;
}
}
if (direct_object.allowVerbWithAnything(this.name, "dov")) {
return true;
}
if (
!direct_object.allowVerbWithAsset(this.name, indirect_object, "dov")
) {
this.game.debug(
`D2048 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.with_assets/with_classes does not include ${indirect_object.id} `
);
msg += `$(We) can't ${this.name} ${direct_object.articlename} ${indirect_preposition} ${indirect_object.articlename}. `;
this.handleFailure(msg);
return null;
}
if (!indirect_object.isIOV(this.name)) {
this.game.debug(
`D2049 | ${this.name}.js | ${indirect_object.id}.iov.${this.name}.enabled is false `
);
msg += `$(We) can't ${this.name} anything ${indirect_preposition} ${indirect_object.articlename}. `;
this.handleFailure(msg);
return false;
}
if (
indirect_object.allowVerbOnce(this.name, "iov") &&
indirect_object.iDidVerb(this.name, "iov")
) {
this.game.debug(
`D2050 | ${this.name}.js | ${indirect_object.id}.iov.${
this.name
}.once and ${indirect_object.id}.did.${this.name}.indirectly is ${
indirect_object.did[this.name].indirectly
} `
);
msg += `${indirect_object.Articlename} has already been used to ${this.name} something. `;
this.handleFailure(msg);
return null;
}
}
return true;
},
doSuccess: function () {
var input = this.game.getInput();
var subject = input.getSubject();
var verb_phrase = input.verb_phrase;
var direct_object = input.getAsset(1);
var direct_preposition = input.getPreposition(1);
var indirect_object = input.getAsset(2);
var indirect_preposition = input.getPreposition(2);
var results;
var msg = "";
msg +=
`$(We) ${this.agree()}` +
`${direct_preposition ? " " + direct_preposition : ""}` +
`${direct_object ? " " + direct_object.articlename : ""}` +
`${indirect_preposition ? " " + indirect_preposition : ""}` +
`${indirect_object ? " " + indirect_object.articlename : ""}` +
`. `;
return this.handleSuccess(msg, direct_object);
},
};
})();