Integrated VE_FORBRYDERNE's Adventure Mode + Cleanup

Adventure Mode allows you to play this like AID, perfect for Choose your own Adventure models
This commit is contained in:
henk717
2021-08-19 13:18:01 +02:00
parent efbe40f1f6
commit 00414d26e2
9 changed files with 171 additions and 1977 deletions

View File

@ -18,6 +18,8 @@ var button_importwi;
var button_impaidg;
var button_settings;
var button_format;
var button_mode;
var button_mode_label;
var button_send;
var button_actedit;
var button_actmem;
@ -63,6 +65,9 @@ var rs_close;
var seqselmenu;
var seqselcontents;
var memorymode = false;
var gamestarted = false;
// Key states
var shift_down = false;
var do_clear_ent = false;
@ -71,6 +76,10 @@ var do_clear_ent = false;
var allowtoggle = false;
var formatcount = 0;
// Adventure
var action_mode = 0; // 0: story, 1: action
var adventure = false;
//=================================================================//
// METHODS
//=================================================================//
@ -120,6 +129,9 @@ function addSetting(ob) {
if(allowtoggle) {
socket.send({'cmd': $(this).attr('id'), 'data': $(this).prop('checked')});
}
if(ob.id == "setadventure"){
setadventure($(this).prop('checked'));
}
});
}
}
@ -345,6 +357,8 @@ function editModeSelect(n) {
}
function enterMemoryMode() {
memorymode = true;
setmodevisibility(false);
showMessage("Edit the memory to be sent with each request to the AI.");
button_actmem.html("Cancel");
hide([button_actback, button_actretry, button_actedit, button_delete, button_actwi]);
@ -353,6 +367,8 @@ function enterMemoryMode() {
}
function exitMemoryMode() {
memorymode = false;
setmodevisibility(adventure);
hideMessage();
button_actmem.html("Memory");
show([button_actback, button_actretry, button_actedit, button_actwi]);
@ -391,12 +407,26 @@ function returnWiList(ar) {
function dosubmit() {
var txt = input_text.val();
socket.send({'cmd': 'submit', 'data': txt});
socket.send({'cmd': 'submit', 'actionmode': adventure ? action_mode : 0, 'data': txt});
input_text.val("");
hideMessage();
hidegenseqs();
}
function changemode() {
if(gamestarted) {
action_mode += 1;
action_mode %= 2; // Total number of action modes (Story and Action)
} else {
action_mode = 0; // Force "Story" mode if game is not started
}
switch (action_mode) {
case 0: button_mode_label.html("Story"); break;
case 1: button_mode_label.html("Action"); break;
}
}
function newTextHighlight(ref) {
ref.addClass("color_green");
ref.addClass("colorfade");
@ -533,6 +563,23 @@ function hidegenseqs() {
});
}
function setmodevisibility(state) {
if(state){ // Enabling
show([button_mode]);
$("#inputrow").addClass("show_mode");
} else{ // Disabling
hide([button_mode]);
$("#inputrow").removeClass("show_mode");
}
}
function setadventure(state) {
adventure = state;
if(!memorymode){
setmodevisibility(state);
}
}
//=================================================================//
// READY/RUNTIME
//=================================================================//
@ -553,6 +600,8 @@ $(document).ready(function(){
button_impaidg = $("#btn_impaidg");
button_settings = $('#btn_settings');
button_format = $('#btn_format');
button_mode = $('#btnmode')
button_mode_label = $('#btnmode_label')
button_send = $('#btnsend');
button_actedit = $('#btn_actedit');
button_actmem = $('#btn_actmem');
@ -613,6 +662,12 @@ $(document).ready(function(){
format_menu.html("");
wi_menu.html("");
} else if(msg.cmd == "updatescreen") {
_gamestarted = gamestarted
gamestarted = msg.gamestarted;
if(_gamestarted != gamestarted) {
action_mode = 0;
changemode();
}
// Send game content to Game Screen
game_text.html(msg.data);
// Scroll to bottom of text
@ -795,6 +850,11 @@ $(document).ready(function(){
} else if(msg.cmd == "updateuseprompt") {
// Update toggle state
$("#setuseprompt").prop('checked', msg.data).change();
} else if(msg.cmd == "updateadventure") {
// Update toggle state
$("#setadventure").prop('checked', msg.data).change();
// Update adventure state
setadventure(msg.data);
}
});
@ -808,6 +868,10 @@ $(document).ready(function(){
button_send.on("click", function(ev) {
dosubmit();
});
button_mode.on("click", function(ev) {
changemode();
});
button_actretry.on("click", function(ev) {
socket.send({'cmd': 'retry', 'data': ''});