I’m making an RPG in C++ and the items (loot/gear) will have immutable base versions, but then the player can get instantiations of them which can change with use and modification. These mutable instantiations will be saved in the DB. But I’m wondering if the base versions should be defined in JSON, or a separate DB (with the same schema), or maybe the same DB (seems dangerous), or if I should just hardcode them in C++ in the ItemFactory.

How have you approached this problem in your games? How do game engines do it? I’m using SDL2 so I’m doing most of these systems from scratch.

  • Scoopta
    link
    fedilink
    arrow-up
    3
    ·
    5 hours ago

    Honestly I’d just hand write a CSV parser, they aren’t that complicated ESPECIALLY if you don’t care about having commas in your data because then you don’t need to quote wrap the entries but that’s just me.

    • e0qdk@reddthat.com
      link
      fedilink
      arrow-up
      2
      ·
      5 hours ago

      Same. I already have one I wrote myself that’s good enough for my needs – which means it doesn’t handle quoting or alternate line endings or other quirks. (I can just change the separator to \t if I really need commas in values, and since I control the data format, I can just say “it will always have Unix line endings” to keep it simple.)

      There’s probably thousands of open source CSV parsers out there though if you don’t want to roll your own, but I don’t have a specific recommendation.

      • Scoopta
        link
        fedilink
        arrow-up
        2
        ·
        3 hours ago

        Yeah, I had the same thought LOL. If you need commas in your data just use a TSV and call it good. I have yet to need the commas though