Well, today was... interesting.
I began by trying to fully parse my CSV into a 2d array. Several hours later, I reverted the code to last night's version, and drank a Coke.
>_>
HOWEVER. since then, I have managed to create a function witch will search my bestiary array and return a matching index. ATM that input is user-typed in all caps ("DRAGON" or "GOAT"), but it does return that entry's stats correctly. I'm using
strQue = a_sBestiary[xx].substr(0,(a_sBestiary[xx].find(",")));
to grab the first CSV field from the unformatted array, then using
if (QUEREY.compare(strQue) == 0 )
to check if it's the line i'm looking for, and looping that from 0 to [bestiarylength] until I find it (or come up with "DERP, it aint here", exit(2)
^hoping that's a decent way to do it, and wont make a user's comp explode or something.
Tonight I'm going to write up an RNG file, to hold anything where I need a random number, both for dice rolls and generators.
Now... does anybody have any advice on how to organize a master list so I can use the RNG to pick random creatures? I was thinking I could use an enumerated list, but that would preclude modding.
I could pull another array from this one, just to yank the names out (via substring again), and use the RNG/whatever on that index. This is the way I know I can do it, but if there's a simpler way...? I was mucking around with lists, but I'm not sure that's what I want?
I'm still very much confused by dynamic memory, though I'm planning on reading through those sections on learncpp.com again later.
I think... the next things before monday are
[a] a RNG
use the stat array to feed the critter constructor. I was having some issues with getline, so I switched over to just using "file >> strLine" (which is fine, as my CSV is correctly formatted). As for extracting information from the array - which would return me a line such as
GOAT,5,1,1,1,1,1,1,5,0,10,5,1
what's the best (read:simplest) way to parse that into separate strings and then into the creature's properties? I'm thinking... can I loop through functions? I'm going to have a bunch of
void Set[Property](input) {[parse 1st field of data]}
can I set up a For loop, or will I have to manually increment everything?
Also, if I use [string].find(','), can I make sure it discards the data so I dont end up putting the same field in every stat? and is it safe to cast those string fragments as integers with
int (str[parsed int value])
?
Once I have those, I can get to work on the player object, and then I can hop into combat code O_o (any pointers there would be nice too.)