Fixing save/load

This commit is contained in:
Alexander Yakovlev 2021-08-14 19:18:12 +07:00
parent 372040caf2
commit b403c3efdd
Signed by: oreolek
GPG key ID: 8D24103F5EE2A6C0
4 changed files with 35 additions and 26 deletions

View file

@ -1,19 +0,0 @@
- I looked at Monsieur Fogg
* ... and I could contain myself no longer.<st>Continues the story.</st>
'What is the purpose of our journey, Monsieur?'
'A wager,' he replied.
* * 'A wager!'[] I returned.
He nodded.
* * * 'But surely that is foolishness!'
* * * 'A most serious matter then!'
- - - He nodded again.
* * * 'But can we win?'
'That is what we will endeavour to find out,' he answered.
* * * 'A modest wager, I trust?'
'Twenty thousand pounds,' he replied, quite flatly.
* * * I asked nothing further of him then[.], and after a final, polite cough, he offered nothing more to me. <>
* * 'Ah[.'],' I replied, uncertain what I thought.
- - After that, <>
* ... but I said nothing<st>Ends the story</st>[] and <>
- we passed the day in silence.
- -> END

14
game/game.ink Normal file
View file

@ -0,0 +1,14 @@
Интересное дело: когда друзья просят меня о помощи, я готов им помочь. Когда я оказываюсь заперт в хижине пятнадцатилетнего маньяка, никто не хочет поднимать трубку.
->beginning
=== beginning ===
+ [<ell>Осмотреться<st>Ссылки с символом паузы доступны всегда и не будут продвигать сюжет.</st>]
Это милая комната, ничего так.
->beginning
* Кричать[]?
Это заброшенная деревня, здесь нет людей. Ну, кроме маньяка.
Но его лучше не призывать. -> beginning
* А вообще, лучше начать историю чуть раньше…
(Пятью минутами ранее) МАНЬЯК
->END

View file

@ -1,6 +1,6 @@
import jQuery from 'jquery'
const inkjs = require('inkjs').Story;
const entryPoint = 'game/fogg.ink.json';
const entryPoint = 'game/game.ink.json';
let continueToNextChoice, displayText, loadGame, saveChoice, s;
@ -58,6 +58,7 @@ continueToNextChoice = function(s) {
choice = ref[j];
let text = choice.text.replace('<st>', '<span class="subtitle">');
text = text.replace('</st>', '</span>')
text = text.replace('<ell>', '<span class="ellipsis">⏸️&nbsp;</span>');
jQuery("#options").append(`<li><a href='#' id='choice-${choice.index}' data-index=${choice.index}>${text}</a></li>`);
}
jQuery("#options").fadeIn(500);
@ -71,13 +72,26 @@ continueToNextChoice = function(s) {
};
loadGame = function(s) {
let index, j, len, ref, results;
let index, j, ref, results;
ref = window.progress;
results = [];
for (j = 0, len = ref.length; j < len; j++) {
index = ref[j];
const len = ref.length;
while(s.canContinue) {
displayText(s, false);
results.push(s.ChooseChoiceIndex(index));
}
for (j = 0; j < len; j++) {
index = ref[j];
if (!index) {
continue
}
if (!s.currentChoices[index]) {
continue
}
displayText(s, false);
s.ChooseChoiceIndex(index)
while(s.canContinue) {
displayText(s, false);
}
}
return results;
};
@ -114,7 +128,7 @@ jQuery(document).on('click', "#options li a", function() {
});
jQuery(document).on('click', "#options li", function() {
s.ChooseChoiceIndex(jQuery(this).find('a').data("index"));
saveChoice(jQuery(this).data("index"));
saveChoice(jQuery(this).find('a').data("index"));
continueToNextChoice(s);
return false;
});

View file

@ -15,7 +15,7 @@ module.exports = {
onBeforeRun: [
{
cmd: "inklecate",
args: ["game/fogg.ink"],
args: ["game/game.ink"],
options: {
cwd: process.cwd()
}