MegaGlub / spell-builder

Project for a homebrew table top magic system
0 stars 0 forks source link

Unable to read located wand data files #17

Closed Josh194 closed 1 month ago

Josh194 commented 1 month ago

(completely fresh installation) SB correctly explores wand data folder, and locates a saved wand, but fails to actually read the file.

Relavent section of log is:

Tring to build wands...                       logging.js:14
    Exploring: data/wands                     logging.js:14

Failed to load resource:        data/wands/test-wand.json:1 
net::ERR_FILE_NOT_FOUND

Uncaught TypeError: Failed to fetch              json.js:23 
    at fetchRawJSON (json.js:23:12)
    at readJSONDirectory (json.js:17:27)
    at buildWands (main.js:114:30)
    at main.js:54:7

(side note: top of log contains minor typo)

Located file does in fact exist (data/wands/test-wand.json), and appears to contain valid data:

{
    "type": "Wand",
    "name": "Test Wand",
    "flavor": "Random Subtitle",
    "image": "images/wands/wierd-metal-frame.png",
    "slots": [
        "Bolt",
        "Arc",
        "Flame"
    ]
}

Aside from fixing the read failure itself, this exception should be caught somewhere; currently, the application simply hangs with no indication of failure.

MegaGlub commented 1 month ago

Looks like building the program with electron-forge caused some sort of fuckery with the relative file path, as it's trying to read from the file ./resources/apar.asar/data/wands instead of just ./data/wands. Highly strange that it functions with the spell components but not the saved wands.

Josh194 commented 1 month ago

Also not sure why the components file is read without error, but worth noting it does not seem to be reading the correct file (as with the wands), as available components are not preserved across runs, despite the (apparent) existence of a valid file:

{ 
    "arr" : [
        "Nothing",
        "Ball",
        "Bolt",
        "Arc",
        "Stick",
        "Orbit",
        // etc...
    ]
}

at data/save/availableComponents.json