mercredi 23 octobre 2019

Making an in depth "quiz" for Dungeons and Dragons

I know this might be a long shot but any help would be really appreciated.

I've been struggling to make a quiz with a randomized question bank where the questions will be able to increase a number of different counters (each question will be different in what they return). Below i show what i have so far and two example questions with only a few of the "counter increases" that they will ultimately have. Is there a way to put the questions i have into a bank so each time the quiz is run it has a different 20 questions from a bank of 50 or so?

barbarian_count = 0
bard_count = 0
cleric_count = 0
druid_count = 0
fighter_count = 0
monk_count = 0
paladin_count = 0
ranger_count = 0
rogue_count = 0
sorcerer_count = 0
warlock_count = 0
wizard_count = 0

STR_count = 0
DEX_count = 0
CON_count = 0
INT_count = 0
WIS_count = 0
CHA_count = 0

law_count = 0
chaos_count = 0
neutrallc_count = 0

good_count = 0
neutralge_count = 0
evil_count = 0

Acolyte_count = 0
Charlatan_count = 0
CriminalSpy_count = 0
Entertainer_count = 0
Folkhero_count = 0
Gladiator_count = 0
Guildartmerchant_count = 0
hermit_count = 0
knight_count = 0
noble_count = 0
outlander_count = 0
pirate_count = 0
sage_count = 0
sailor_count = 0
soldier_count = 0
urchin_count = 0


q1_answer = input ("Passion or Reason? \na) Passion \nb) Reason\n")

if q1_answer.lower() == "a":
    barbarian_count += 1
  bard_count += 1
  chaos_count += 1
elif q1_answer.lower() == "b":
    wizard_count += 1
  law_count += 1
else:
    print("sorry, try again.")


q2 = q2_answer = input ("Fame or Honor? \na) Fame \nb) Honor\n")

if q2_answer.lower() == "a":
    bard_count += 1
elif q2_answer.lower() == "b":
    paladin_count += 1
else:
    print("sorry, try again.")




if barbarian_count > wizard_count and barbarian_count > bard_count and barbarian_count > paladin_count:
    print("You have the heart of a barbarian")
elif wizard_count > barbarian_count and wizard_count > bard_count and wizard_count > paladin_count:
    print("You have the heart of a wizard")
elif bard_count > wizard_count and bard_count > paladin_count and bard_count > barbarian_count:
  print("You have the heart of a bard")
elif paladin_count > wizard_count and paladin_count > barbarian_count and paladin_count > bard_count:
  print("You have the heart of a paladin")

input('Press ENTER to exit')

I tried making a list with something like

question_bank = [
  {
    'q1 = [q1_answer = input ("Passion or Reason? \na) Passion \nb) Reason\n")

if q1_answer.lower() == "a":
    barbarian_count += 1
elif q1_answer.lower() == "b":
    wizard_count += 1
else:
    print("sorry, try again."]'
  },
  {
    'q2 = q2_answer = input ("Fame or Honor? \na) Fame \nb) Honor\n")

if q2_answer.lower() == "a":
    bard_count += 1
elif q2_answer.lower() == "b":
    paladin_count += 1
else:
    print("sorry, try again.")'
  }
]


But have realized lists do not work like that, i think.

Any advice? I was hoping i could put each full script for each question into a list so i could use the "import random" and random.choice or random.sample to then pull the full question's script.




Aucun commentaire:

Enregistrer un commentaire