Wondering about implementing a story/combat/story pattern
Wondering about implementing a story/combat/story pattern
I'm thinking of something more complex but working on a simpler model first, so I know this sounds simplistic.
Basically I'm going to have a series of text strings in the database, each a paragraph of story.
It shows you the first paragraph (at position 0)
You fight a monster
That increments your paragraph count once you/if you beat it
Which shows you the next paragraph (now at position 1)
and so on. Latter I'll add some more things, but I'd like to get a basic model working first.
I've actually implemented the paragraph increment already (using my old module I posted here (which I added a 'home base' in between page between monster battles, to show the paragraph)
I'm just wondering what is the best way to store all these text strings? I'm used to code compilers that let you use gridded arrays like [1,5] or whatever. Because I don't just want paragraphs, I'll want chapters latter and it'd be far more wieldy if I could use a gridded array.
What do you all think?
Basically I'm going to have a series of text strings in the database, each a paragraph of story.
It shows you the first paragraph (at position 0)
You fight a monster
That increments your paragraph count once you/if you beat it
Which shows you the next paragraph (now at position 1)
and so on. Latter I'll add some more things, but I'd like to get a basic model working first.
I've actually implemented the paragraph increment already (using my old module I posted here (which I added a 'home base' in between page between monster battles, to show the paragraph)
I'm just wondering what is the best way to store all these text strings? I'm used to code compilers that let you use gridded arrays like [1,5] or whatever. Because I don't just want paragraphs, I'll want chapters latter and it'd be far more wieldy if I could use a gridded array.
What do you all think?
Last edited by Callan S. on Sat May 29, 2010 11:49 pm, edited 1 time in total.
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Wondering about implementing a story/combat/story pattern
i may not be certain what you are asking for but if you wanting to know the best way to store the text strings it would be simply a text field in the DB and a couple type fields attached to it.
Something similar to
where " swings his mighty sword into the " would be the random text, would have battle = 1 or true as one field and sword = 1 as another, so yu could have multiple text strings that could be the same where sword = 1 AND battle =1, like
remember you can use the explode() to cut a sentence into multiple parts to make what i have done above
for instance
Something similar to
Code: Select all
$name . " swings his mighty sword into the ". $creature;Code: Select all
$name . " slices his sword at ". $creature;Code: Select all
$name . " drops his sword and ". $creature . " laughs";for instance
Code: Select all
$fightinfo3 = "drops his sword and / laughs";
$firstline = explode("/", $fightinfo3);
echo $name . $firstline[0] . $creature . $firstline[1];Re: Wondering about implementing a story/combat/story pattern
I didn't describe it too well - it'd go like this
"You leave the safety of the villages outer wall, and head into the wilderness, whose threats make themselves immediately apparent"
Fight with monster (just like in the basic tute), once the fight has been won...
"You see a ruined cottage ahead - but there's something strange about it..."
Fight with monster
"There's a strange light glowing inside...and the walls seems ever so slightly transparent..."
Fight with monster
And so on...
Now I was thinking you'd store these in the actual database - like you store a players name and current hitpoints in the database. Obviously not in the players database - I'd make a new database entry for 'story' or suchlike.
Or would it better to put them into a PHP script and then use an include statement where it's needed? I don't want anyone to read the story in advance by reading the source of a page?
"You leave the safety of the villages outer wall, and head into the wilderness, whose threats make themselves immediately apparent"
Fight with monster (just like in the basic tute), once the fight has been won...
"You see a ruined cottage ahead - but there's something strange about it..."
Fight with monster
"There's a strange light glowing inside...and the walls seems ever so slightly transparent..."
Fight with monster
And so on...
Now I was thinking you'd store these in the actual database - like you store a players name and current hitpoints in the database. Obviously not in the players database - I'd make a new database entry for 'story' or suchlike.
Or would it better to put them into a PHP script and then use an include statement where it's needed? I don't want anyone to read the story in advance by reading the source of a page?
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Wondering about implementing a story/combat/story pattern
yes you could store these in the database without any issue.
Re: Wondering about implementing a story/combat/story pattern
But I'm wondering if there's a neat way - for example, I'm going to have alot of those text strings, and then I'm going to have several seperate stories, over time.
Right now the database seems to want a seperate name for each line, like I might have
story1 = "blah blah"
story2 = "blih blih"
But then I have to use a bunch of if statements to call up the right one.
I want/hope there's some naming convention more like
story[1]
story[2]
There doesn't seem to be any way to add a structure to the database that has those qualities? So I'm stuck with using a bunch of clunky if statements so if I want story 2, I use an 'if $storytouse = 2...' etc rather than just calling on story[2]?
If I understand the explode function you gave, that helps somewhat because atleast for an individual story I could store all of it in one massive string, then use the function to break it up to show the one I want with '$firstline[0]', since that does give you the [] to work with. Thanks for that
Right now the database seems to want a seperate name for each line, like I might have
story1 = "blah blah"
story2 = "blih blih"
But then I have to use a bunch of if statements to call up the right one.
I want/hope there's some naming convention more like
story[1]
story[2]
There doesn't seem to be any way to add a structure to the database that has those qualities? So I'm stuck with using a bunch of clunky if statements so if I want story 2, I use an 'if $storytouse = 2...' etc rather than just calling on story[2]?
If I understand the explode function you gave, that helps somewhat because atleast for an individual story I could store all of it in one massive string, then use the function to break it up to show the one I want with '$firstline[0]', since that does give you the [] to work with. Thanks for that
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Re: Wondering about implementing a story/combat/story pattern
Oh hang on - can you call upon monsters by their ID number rather than their name?
If so then I've probably got what I want, I just give each story string an incrementing ID and call on the id. I'll mess around more. Thanks halls!
If so then I've probably got what I want, I just give each story string an incrementing ID and call on the id. I'll mess around more. Thanks halls!
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
- PaxBritannia
- Posts: 680
- Joined: Sun Apr 18, 2010 1:54 pm
Re: Wondering about implementing a story/combat/story pattern
If you are using PHP, they shouldn't be able to tell the story by reading the source code, provided you don't give them the actual script.
And yes you ca call it by id, but then you will need to
Select * from story where id = yada each time
OR
you could call a function and pass the story id through the function.
Pax.
And yes you ca call it by id, but then you will need to
Select * from story where id = yada each time
OR
you could call a function and pass the story id through the function.
Pax.
Re: Wondering about implementing a story/combat/story pattern
Oh that's right, you only see the source of what the PHP generates, not the PHP...I'm just not used to thinking in browser game terms! So I could use either - I think I'll use the data base for now, but I'll keep the PHP option in mind!
Actually, with that explode function is there a way of determining how many divide characters there are (in halls example he uses a '/')? I want to keep a tight database and instead of adding an entry for the number of paragraphs, I'd like the php script to simply count them. Or would that put more load on the server and it'd be better to refer to a number left in the database?
Actually, with that explode function is there a way of determining how many divide characters there are (in halls example he uses a '/')? I want to keep a tight database and instead of adding an entry for the number of paragraphs, I'd like the php script to simply count them. Or would that put more load on the server and it'd be better to refer to a number left in the database?
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
- PaxBritannia
- Posts: 680
- Joined: Sun Apr 18, 2010 1:54 pm
Re: Wondering about implementing a story/combat/story pattern
I would just have a database with two columns: id and text. Every time you need text, just refer to it by the id.
If you want to not query the database, and save processing power, you could put it in the script through a variable (but only define it if you need to echo it or it will still waste processing power).
Pax.
If you want to not query the database, and save processing power, you could put it in the script through a variable (but only define it if you need to echo it or it will still waste processing power).
Pax.
Re: Wondering about implementing a story/combat/story pattern
Yeah, but I want to divide them by chapters, not all of which will have the same number of paragraphs. Having a long list of text strings in the DB would make them all blur into each other.
For anyone else wondering about that count thing I asked about, I found a function that can count the arrays after you've used the explode function. Here's an example:
For anyone else wondering about that count thing I asked about, I found a function that can count the arrays after you've used the explode function. Here's an example:
Code: Select all
$result = count($paragraph);Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog