hseager / you-are-merlin

You are Merlin - A Rust text adventure game
https://hseager.github.io/you-are-merlin-www/
GNU General Public License v3.0
25 stars 1 forks source link

`get_actions` shouldn't join with commas #6

Closed tolik518 closed 4 months ago

tolik518 commented 5 months ago

The get_actions-method currently imposes an issue, since actions which have a , in the name won't get recognized as one action because , is getting used to join/split the strings.

https://github.com/hseager/you-are-merlin/blob/1582fa51bc162f477f71595b5b3610908320cb5f/src/lib.rs#L62-L76

A specific issue are items containing a , image

The code to read actions is over here:
https://github.com/hseager/you-are-merlin-www/blob/master/src/components/Controls.tsx#L28

          actions={actions ? actions.split(",") : []}
          sendAction={sendAction}

So an easy fix would be to use another character which isn't used in texts, like the pipe-symbol |.

hseager commented 4 months ago

Thanks for raising this too!

I've put in a fix by returning an vec from lib.rs and leaving it up to the client to handle displaying the actions. This gets generated as an array in wasm so we only need to .join(", ") for the keyboard version.