lettertea / React-Visual-Novel

A visual novel application made with React.

Home Page:https://rvn.netlify.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: Create Route array instead of choicesCount

footballdaddy opened this issue · comments

I am modifying a bit and I believe it is better to have an array for checking if the desired choice has been done.

Example code:
const updatedChoicesCount = [...this.state.route, choice]; if (updatedChoicesCount.includes('throwRock')) { this.setFrame(10); } else if (updatedChoicesCount.includes('noRock')) { this.setFrame(27); }

You will get a clear indication of what route the player has taken over time. This especially useful if a choice requires multiple choices to be true to be done. (e.g. picked keys and locked door to show a scene of safe house on player return)

Excellent suggestion! You can definitely access the choices store like that pretty easily. The reason why I felt that it was better to make it into an object rather than an array is to accommodate when someone makes a certain choice more than one time. For example, if you decided to allow the users to throw a rock at the block a second time afterwards and see a different outcome, you can write this:

if (updatedChoicesCount.throwRock === 2) {
      this.setFrame(someIndex);
    }

Also, sorry for the slightly late response time. I didn't expect this application to receive any traction, so I didn't pay much to the issues section. Feel free to make further suggestions!

Actually, let me try it out completely. I closed the issue too early. I'll try to report back soon.

I like your use of the spread operator in updating the array. I've actually changed some code because of it, which can be reflected here in the routes-jumps-and-stores branch. Developers no longer need to declare the choices in the initial state.

However, in the end, I didn't switch to using an array. I was thinking that in some games, the choices are made to win "affection points." The developer may want to allow the user to see a certain scene once the user achieves a value. I felt that incrementing the value of a key in an object would best allow that.

I rewrote a few other things too in the branch, I've changed the way how users can jump to an index after making the choice. Rather than finding the index then setting the frame, developers can simply create two properties, (jumpTo and receiveJump, or jumpToBecauseStore and receiveJumpBecauseStore) with the same values to jump. Here's a site to see it in application. I recommend looking at novelFrames.js, Choices.js, and App.js to follow along.