(function () {
A.Preverbs.screw = {
name: "screw",
prettyname: "screw",
past_tense: "screwed",
synonyms: ["screw"],
state: "screwed",
gerund: "screwing",
accepts_structures: [
"verb noun",
"verb preposition noun",
"verb noun preposition noun",
"verb noun preposition noun preposition noun",
],
phrase1: {
accepts_noun: true,
noun_must_be: {
in_inventory_if_takeable: true,
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
accepts_preposition: true,
accepts_these_prepositions: ["in", "on", "into", "onto", "off", "out"],
},
phrase2: {
accepts_noun: true,
noun_must_be: {
in_inventory_if_takeable: true,
known: true,
tangible: true,
present: true,
visible: true,
reachable: true,
},
accepts_preposition: true,
requires_preposition: true,
accepts_these_prepositions: ["to", "in", "into", "onto", "with"],
},
phrase3: {
accepts_noun: true,
noun_must_be: {
in_inventory_if_takeable: true,
known: true,
tangible: true,
present: true,
reachable: true,
},
accepts_preposition: true,
requires_preposition: true,
accepts_these_prepositions: ["with"],
},
with_params: {
max_turns: 1,
},
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_object2 = input.getAsset(3);
var indirect_preposition2 = input.getPreposition(3);
var target_object, target_preposition;
var tool_preposition = "with";
var tool_object;
var tool_inferred;
var results;
var msg = "";
if (verb_phrase === "screw to") {
}
if (verb_phrase === "screw in to" || verb_phrase === "screw into") {
}
if (verb_phrase === "screw on to" || verb_phrase === "screw onto") {
}
if (
direct_preposition &&
(direct_preposition === "off" || direct_preposition === "out")
) {
if (direct_object.isDOV("unscrew")) {
return this.game.dictionary.doVerb("unscrew");
}
this.game.debug(
`D2155 | ${this.name}.js | not handling ${this.name} ${direct_preposition}`
);
msg += `$(We) $(don't) know how to ${this.name} ${direct_preposition} ${direct_object.articlename}. `;
this.handleFailure(msg);
return false;
}
if (indirect_preposition === "with") {
tool_object = indirect_object;
}
if (indirect_preposition2 === "with") {
tool_object = indirect_object2;
}
if (indirect_preposition && "with" !== indirect_preposition) {
target_object = indirect_object;
target_preposition = indirect_preposition;
}
if (!direct_object.isDOV(this.name)) {
this.game.debug(
`D2136 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.enabled is false `
);
msg += `${direct_object.Articlename} can't be ${this.past_tense}. `;
this.handleFailure(msg);
return false;
}
if (
direct_object.allowVerbOnce(this.name, "dov") &&
direct_object.didVerb(this.name, "dov")
) {
this.game.debug(
`D2139 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.once and ${direct_object.id}.did.${this.name}.directly `
);
msg += `${direct_object.Articlename} has already been ${this.past_tense}. `;
this.handleFailure(msg);
return false;
}
if (this.hasState() && direct_object.isVerbState(this.name)) {
this.game.debug(
`D1396 | ${this.name}.js | ${
direct_object.id
}.is.${this.getState()} is ${direct_object.isVerbState(this.name)}`
);
msg += `${direct_object.Articlename_is} already ${this.getState()}. `;
this.handleFailure(msg);
return null;
}
if (input.hasStructure("verb noun")) {
if (direct_object.allowVerbWithNothing(this.name, "dov")) {
return true;
}
if (!direct_object.hasIndirectObjects(this.name)) {
this.game.debug(
`D2149 | ${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(`D2150 | ${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) {
tool_inferred = true;
tool_object = results.indirect_object;
tool_preposition = "with";
this.game.printInferred(
`${tool_preposition} ${tool_object.articlename}`
);
}
}
if (tool_object) {
input.verb_params.tool_object = tool_object;
input.verb_params.tool_preposition = tool_preposition;
if (
!this.game.parser.selectInHands(tool_object.id).length &&
!tool_inferred
) {
this.game.debug(
`D2151 | ${this.name}.js | ${tool_object.id}.$is("inhands") is false `
);
msg += `$(We're) not holding ${tool_object.articlename}. `;
this.handleFailure(msg);
return null;
}
if (direct_object.allowVerbWithAnything(this.name, "dov")) {
return true;
}
if (direct_object.allowVerbWithNothing(this.name, "dov")) {
this.game.debug(
`D2152 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.with_nothing `
);
msg += `$(We) $(don't) need ${tool_object.articlename} to ${this.name} ${
direct_preposition ? direct_preposition : ""
} ${direct_object.articlename}. `;
this.handleFailure(msg);
return null;
}
if (!direct_object.allowVerbWithAsset(this.name, tool_object, "dov")) {
this.game.debug(
`D2153 | ${this.name}.js | ${direct_object.id}.dov.${this.name}.with_assets/with_classes does not include ${tool_object.id} `
);
msg += `$(We) can't ${this.name} ${direct_object.articlename} ${tool_preposition} ${tool_object.articlename}. `;
this.handleFailure(msg);
return null;
}
if (!tool_object.isIOV(this.name)) {
this.game.debug(
`D2154 | ${this.name}.js | ${tool_object.id}.iov.${this.name}.enabled is false `
);
msg += `$(We) can't ${this.name} ${
direct_preposition ? direct_preposition : ""
} anything ${tool_preposition} ${tool_object.articlename}. `;
this.handleFailure(msg);
return false;
}
if (
tool_object.allowVerbOnce(this.name, "iov") &&
tool_object.iDidVerb(this.name, "iov")
) {
this.game.debug(
`D1395 | ${this.name}.js | ${tool_object.id}.iov.${
this.name
}.once and ${tool_object.id}.did.${this.name}.indirectly is ${
tool_object.did[this.name].indirectly
} `
);
msg += `${tool_object.Articlename} has already been used to ${
this.name
} ${direct_preposition ? direct_preposition : ""} something. `;
this.handleFailure(msg);
return null;
}
}
if (target_object) {
input.verb_params.target_object = target_object;
input.verb_params.target_preposition = target_preposition;
if (
direct_object.getPlaceAssetId === target_object.id &&
direct_object.isPlacedAtAspect("attached")
) {
if (
direct_object.is.screwed >=
direct_object.dov[this.name].with_params.max_turns
) {
this.game.debug(
`D1394 | ${this.name}.js | ${direct_object.id} is already screwed ${target_preposition} ${target_object.id}`
);
msg += `${direct_object.Articlename_is} already screwed ${target_preposition} } to ${indirect_object.articlename}. `;
this.handleFailure(msg);
return null;
}
}
else {
results = this.tryToPutThisInThatAspect(
direct_object,
target_preposition,
target_object
);
if (results.fail) {
msg = results.msg;
this.handleFailure(msg);
if (results.end_turn) return false;
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 tool_object = input.verb_params.tool_object;
var tool_preposition = input.verb_params.tool_preposition;
var target_object = input.verb_params.target_object;
var target_preposition = input.verb_params.target_preposition;
var doParent = direct_object.getPlaceAsset();
var msg = "";
var results;
if (target_object && target_object.id !== doParent.id) {
results = direct_object.moveFrom(doParent);
if ("undefined" !== typeof results) return results;
results = direct_object.moveTo("attached", target_object);
if ("undefined" !== typeof results) return results;
}
direct_object.is.screwed = Math.min(
direct_object.is.screwed + 1,
direct_object.dov[this.name].with_params.max_turns
);
msg +=
`$(We) ${this.agree()}` +
`${direct_preposition ? " " + direct_preposition : ""}` +
`${direct_object ? " " + direct_object.articlename : ""}` +
`${target_preposition ? " " + target_preposition : ""}` +
`${target_object ? " " + target_object.articlename : ""}` +
`${tool_preposition ? " " + tool_preposition : ""}` +
`${tool_object ? " " + tool_object.articlename : ""}` +
`. `;
return this.handleSuccess(msg, direct_object);
},
};
})();