Skip to content

Commit

Permalink
Command class redone
Browse files Browse the repository at this point in the history
The Command class code done as a proper class that automatically adds it to the list.
Also release 1.3
  • Loading branch information
ThePix committed Nov 8, 2022
1 parent 4492701 commit f368f8f
Show file tree
Hide file tree
Showing 19 changed files with 467 additions and 451 deletions.
Binary file added QuestJS-1-3.zip
Binary file not shown.
80 changes: 40 additions & 40 deletions game-banks/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


/*
commands.push(new Cmd('Kick', {
new Cmd('Kick', {
npcCmd:true,
rules:[cmdRules.isPresent],
regex:/^(kick) (.+)$/,
Expand All @@ -15,9 +15,9 @@ commands.push(new Cmd('Kick', {
msg("{pv:char:kick:true} {ob:item:the}, but nothing happens.", options);
return false;
},
}));
})
commands.push(new Cmd('Move', {
new Cmd('Move', {
npcCmd:true,
rules:[cmdRules.isPresent],
regex:/^(move) (.+)$/,
Expand All @@ -29,72 +29,72 @@ commands.push(new Cmd('Move', {
msg("{pv:char:be:true} not something you can move.", options);
return false;
},
}));
})
*/


// kyle, in stasis

commands.push(new Cmd('Get in pod1', {
new Cmd('Get in pod1', {
regex:/^(.+), ?(?:get in|go in|in) (?:stasis pod|stasis|pod)$/,
npcCmd:true,
attName:"stasis",
objects:[
{scope:parser.isHere, attName:"npc"},
],
defmsg:"That's not about to get in a stasis!",
}));
commands.push(new Cmd('Get in pod2', {
})
new Cmd('Get in pod2', {
regex:/^(?:tell|ask|instruct) (.+) to (?:get in|go in|in) (?:stasis pod|stasis|pod)$/,
npcCmd:true,
attName:"stasis",
objects:[
{scope:parser.isHere, attName:"npc"},
],
defmsg:"That's not about to get in a stasis!",
}));
})

commands.push(new Cmd('Stop1', {
new Cmd('Stop1', {
regex:/^(.+), (?:stop|halt|forget it)$/,
npcCmd:true,
attName:"stopAgenda",
objects:[
{scope:parser.isHere, attName:"npc"},
],
defmsg:"That's not doing anything!",
}));
commands.push(new Cmd('Stop2', {
})
new Cmd('Stop2', {
regex:/^(?:tell|ask|instruct) (.+) to (?:stop|halt|forget it)$/,
npcCmd:true,
attName:"stopAgenda",
objects:[
{scope:parser.isHere, attName:"npc"},
],
defmsg:"That's not doing anything",
}));
})


commands.push(new Cmd('Launch', {
new Cmd('Launch', {
regex:/^(?:launch|deploy) (.+)$/,
npcCmd:true,
objects:[
{scope:parser.isInWorld, extendedScope:true},
],
defmsg:"You can't launch that!",
}));
})

commands.push(new Cmd('Revive', {
new Cmd('Revive', {
regex:/^(?:revive|wake|awaken) (.+)$/,
npcCmd:true,
objects:[
{scope:parser.isInWorld},
],
defmsg:"You can't revive that!",
}));
})



commands.push(new Cmd('Spray', {
new Cmd('Spray', {
regex:/^(?:spray) (.+)$/,
rules:[
function(cmd, char, item, multiple) {
Expand All @@ -113,27 +113,27 @@ commands.push(new Cmd('Spray', {
{scope:parser.isHere},
],
defmsg:"You can't spray that!",
}));
})

commands.push(new Cmd('Pressurise', {
new Cmd('Pressurise', {
regex:/^(?:pressuri[sz]e|pres) (.+)$/,
attName:'pressure',
objects:[
{scope:isRoomScope, extendedScope:true},
],
script:function(objects) { return handlePressurise(player, objects, true) },
defmsg:'Not something you can pressurise.',
}));
commands.push(new Cmd('Depressurise', {
})
new Cmd('Depressurise', {
regex:/^(?:depressuri[sz]e|evacuate|depres) (.+)$/,
attName:'pressure',
objects:[
{scope:isRoomScope, extendedScope:true},
],
script:function(objects) { return handlePressurise(player, objects, false) },
defmsg:'Not something you can evacuate.',
}));
commands.push(new Cmd('NpcPressurise1', {
})
new Cmd('NpcPressurise1', {
regex:/^(.+), ?(?:pressuri[sz]e|pres) (.+)$/,
attName:'pressure',
objects:[
Expand All @@ -150,8 +150,8 @@ commands.push(new Cmd('NpcPressurise1', {
objects.shift();
return handlePressurise(npc, objects, true);
},
}));
commands.push(new Cmd('NpcPressurise2', {
})
new Cmd('NpcPressurise2', {
regex:/^(?:tell|ask|instruct) (.+) to (?:pressuri[sz]e|pres) (.+)$/,
attName:'pressure',
objects:[
Expand All @@ -168,8 +168,8 @@ commands.push(new Cmd('NpcPressurise2', {
objects.shift();
return handlePressurise(npc, objects, true);
},
}));
commands.push(new Cmd('NpcDepressurise1', {
})
new Cmd('NpcDepressurise1', {
regex:/^(.+), ?(?:depressuri[sz]e|evacuate|depres|evac) (.+)$/,
attName:'pressure',
objects:[
Expand All @@ -186,8 +186,8 @@ commands.push(new Cmd('NpcDepressurise1', {
objects.shift()
return handlePressurise(npc, objects, false)
},
}))
commands.push(new Cmd('NpcDepressurise2', {
})
new Cmd('NpcDepressurise2', {
regex:/^(?:tell|ask|instruct) (.+) to (?:depressuri[sz]e|evacuate|depres) (.+)$/,
attName:'pressure',
objects:[
Expand All @@ -204,7 +204,7 @@ commands.push(new Cmd('NpcDepressurise2', {
objects.shift()
return handlePressurise(npc, objects, false)
},
}))
})


function handlePressurise(char, objects, pressurise) {
Expand Down Expand Up @@ -265,7 +265,7 @@ function handlePressurise(char, objects, pressurise) {



commands.push(new Cmd('Approach', {
new Cmd('Approach', {
regex:/^approach (.+)$/,
objects:[
{scope:'isShip'},
Expand All @@ -291,9 +291,9 @@ commands.push(new Cmd('Approach', {
w.alienShip.status = 2;
return world.SUCCESS
},
}));
})

commands.push(new Cmd('Scan', {
new Cmd('Scan', {
regex:/^scan (.+)$/,
objects:[
{scope:'isShip'},
Expand Down Expand Up @@ -323,7 +323,7 @@ commands.push(new Cmd('Scan', {
w.alienShip.status = 2
return world.SUCCESS
},
}))
})

function isShip(item) {
return item.isShip
Expand All @@ -332,7 +332,7 @@ function isShip(item) {



commands.push(new Cmd('ProbeStatus', {
new Cmd('ProbeStatus', {
regex:/^probes?$/,
script:function() {
const arr = getProbes();
Expand All @@ -353,20 +353,20 @@ commands.push(new Cmd('ProbeStatus', {
metamsg("Active:" + currentPlanet().eventIsActive());
return world.SUCCESS_NO_TURNSCRIPTS;
},
}));
})





commands.unshift(new Cmd('MapUpdate', {
new Cmd('MapUpdate', {
regex:/^map?$/,
script:function() {
updateMap()
metamsg("Done")
return world.SUCCESS_NO_TURNSCRIPTS
},
}));
})



Expand All @@ -385,7 +385,7 @@ findCmd('MetaHelp').script = function() {
return world.SUCCESS_NO_TURNSCRIPTS
}

commands.push(new Cmd('HelpSubject', {
new Cmd('HelpSubject', {
regex:/^(?:\?|help) (.*)$/,
objects:[
{special:'text'},
Expand Down Expand Up @@ -492,4 +492,4 @@ commands.push(new Cmd('HelpSubject', {
},
},
]
}));
})
24 changes: 12 additions & 12 deletions game-buttons/code.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use strict"

/*
commands.unshift(new Cmd('Charge', {
new Cmd('Charge', {
npcCmd:true,
regex:/^(?:charge|power) (.+)$/,
objects:[
{scope:parser.isHeld}
],
defmsg:"{pv:item:'be:true} not something you can charge.",
}))
})
*/


Expand Down Expand Up @@ -42,7 +42,7 @@ io.getItemHtml = function(item, loc, isSubItem, highlight) {

parser.isRoom =function(o) { return o.room }

commands.unshift(new Cmd('GoTo', {
new Cmd('GoTo', {
npcCmd:true,
regex:/^(?:go to|go) (.+)$/,
objects:[
Expand All @@ -59,7 +59,7 @@ commands.unshift(new Cmd('GoTo', {
}
return failedmsg("{pv:item:be:true} not a destination you can get to from here.", {item:room})
},
}))
})



Expand All @@ -70,19 +70,19 @@ parser.isContact = function(o) { return o.contact }
const smartPhoneFunctions = ["Contacts", "Take photo", "Photo gallery", "Search internet", "Hang up", "News feed"]

for (let el of smartPhoneFunctions) {
commands.unshift(new Cmd(el, {
new Cmd(el, {
regex:new RegExp('^' + el.toLowerCase() + ' (.+)$'),
attName:verbify(el),
objects:[
{scope:parser.isHeld},
],
defmsg:"{pv:item:'be:true} not something you can do that with.",
}))
})
}



commands.unshift(new Cmd('Phone', {
new Cmd('Phone', {
npcCmd:true,
regex:/^(?:telephone|phone|call|contact) (.+)$/,
objects:[
Expand All @@ -91,11 +91,11 @@ commands.unshift(new Cmd('Phone', {
script:function(objects) {
return w.phone.makeCall(objects[0][0]) ? world.SUCCESS : world.FAILED
},
}))
})



commands.unshift(new Cmd('HangUp', {
new Cmd('HangUp', {
npcCmd:true,
regex:/^(?:hang up|end call)$/,
objects:[
Expand All @@ -105,15 +105,15 @@ commands.unshift(new Cmd('HangUp', {
w.phone.hangUp()
return world.SUCCESS
},
}))
})







commands.unshift(new Cmd('DialogTest', {
new Cmd('DialogTest', {
npcCmd:true,
regex:/^(?:dialog) (.*)$/,
objects:[
Expand All @@ -128,5 +128,5 @@ commands.unshift(new Cmd('DialogTest', {
})
return world.SUCCESS_NO_TURNSCRIPTS
},
}))
})

4 changes: 2 additions & 2 deletions game-cloak/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ findCmd('MetaHelp').script = function() {



commands.push(new Cmd('HangUp', {
new Cmd('HangUp', {
regex:/^(?:hang up|hang) (.+?)(?: on the hook| on hook|)$/,
objects:[
{scope:parser.isHeld},
Expand All @@ -49,5 +49,5 @@ commands.push(new Cmd('HangUp', {
return world.SUCCESS
}
}
}))
})

Loading

0 comments on commit f368f8f

Please sign in to comment.