diff --git a/.gitignore b/.gitignore index cf70988..617b07a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ **/node_modules +public/bundle.js \ No newline at end of file diff --git a/public/index.html b/public/index.html index cbd19e9..61405bd 100644 --- a/public/index.html +++ b/public/index.html @@ -10,6 +10,10 @@ -

-
+
+

Textual Game

+
+
+
\ No newline at end of file diff --git a/src/index.js b/src/index.js index a3a5e7a..323c3c4 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,10 @@ const jsonContent = [{ id: 'choice-2', text: 'Choice 2', nextNode: 'node-exit' + }, { + id: 'choice-3', + text: 'Choice 3', + nextNode: 'node-exit' }] }, { id: 'node-2', @@ -44,11 +48,24 @@ function selectChoice(choiceId) { ); const selectedChoice = allChoices.find(choice => choice.id === choiceId); const nextNode = jsonContent.find(node => node.id === selectedChoice.nextNode); + + addChoiceToHistory(selectedChoice); updateActiveNode(nextNode); } +function addChoiceToHistory(selectedChoice) { + const choiceDiv = document.createElement('div'); + choiceDiv.innerHTML = selectedChoice.text; + choiceDiv.classList.add('choice-div'); + document.getElementById('history').appendChild(choiceDiv); +} + function updateActiveNode(node) { - document.getElementById('active-node').innerHTML = node.text; + const nodeDiv = document.createElement('div'); + nodeDiv.innerHTML = node.text; + nodeDiv.classList.add('node-div'); + document.getElementById('history').appendChild(nodeDiv); + document.getElementById('choices').innerHTML = ''; printChoices(node); }