I'm trying to make a Javascript version of a basic "life path generator" often found in pen and paper RPGs. I've made generators based on the template found here: http://ift.tt/2l9ewt1
Unfortunately I can't figure out how to make a reference to a previously selected random outcome.
The pen and paper equivalent might look something like this: Roll d6 to determine class (Bard, Cleric, Druid, Fighter, Rogue, Wizard). Roll a d20 to determine a background for character (with each background being unique to its class).
I'm guessing I'll make arrays or objects for each set, but I don't know how to make the second set trigger off the first random selection automatically. I'd like to have it set where I can press one button and have everything generated randomly.
Here is as close as I can figure out:
var gen_data = {};
gen_data['main'] = {
'You are a {class}.'
if {class} = Bard '{bardBackstory}'
else if {class} = Cleric '{clericBackstory}'
else if {class} = Druid '{druidBackstory}'
else if {class} = Fighter '{fighterBackstory}'
else if {class} = Rogue '{rogueBackstory}'
else if {class} = Wizard 'wizardBackstory}'
};
gen_data['class'] = {
'1': 'Bard',
'2': 'Cleric',
'3': 'Druid',
'4': 'Fighter',
'5': 'Rogue',
'6': 'Wizard
};
gen_data['bardBackstory'] = {
'1': 'story1',
'2': 'story2',
'3': 'etc'
};
gen_data['clericBackstory'] = {
'1': 'story1',
'2': 'story2',
'3': 'etc'
};
gen_data['druidBackstory'] = {
'1': 'story1',
'2': 'story2',
'3': 'etc'
};
gen_data['fighterBackstory'] = {
'1': 'story1',
'2': 'story2',
'3': 'etc'
};
gen_data['rogueBackstory'] = {
'1': 'story1',
'2': 'story2',
'3': 'etc'
};
gen_data['wizardBackstory'] = {
'1': 'story1',
'2': 'story2',
'3': 'etc'
};
Aucun commentaire:
Enregistrer un commentaire