generateur_scenario.py

Created by gengisclan

Created on August 18, 2023

2.76 KB

En panne d’idée pour vos jeux de rôles ? Ce programme vous aideras surement !!!


'''
Cree par Gengisclan le 17/08/2023
'''

# Modules
from kandinsky import *
from random import randint
from time import sleep
from ion import *


def Logo():
  fill_rect(0,0,320,240,(0,)*3)
  fill_rect(100,80,120,60,(255,)*3)
  fill_rect(101,81,118,58,(0,)*3)
  draw_string("Cree par",120,90,(255,)*3,(0,)*3)
  draw_string("Gengisclan",110,110,(255,)*3,(0,)*3)
  sleep(2)

def Dessin_boutons(bouton,coul=(0,)*3):
  fill_rect(bouton[3],bouton[4],bouton[1],bouton[2],(255,)*3)
  fill_rect(bouton[3]+1,bouton[4]+1,bouton[1]-2,bouton[2]-2,coul)
  draw_string(bouton[0],bouton[3]+10,bouton[4]+10,(255,)*3,coul)

# Genere le scenario  
def Scenario(persos,actions,objets):
  global separ
  part1=persos[randint(0,len(persos)-1)]
  choix=randint(0,len(actions)-1)
  part2=" "+actions[choix]
  # Verifie si le separateur a ete
  # selectionne
  while part2==" ----":
    choix=randint(0,len(actions)-1)
    part2=" "+actions[choix]
  if choix>separ:part3="u"+persos[randint(0,len(persos)-1)][1:]
  else: part3=objets[randint(0,len(objets)-1)]
  return [part1+part2,part3]  

# Affiche la page
def Page():
  scena=Scenario(persos,actions,objets)
  Boutons[3][0]=scena[0]
  Boutons[4][0]=scena[1]
  Dessin_boutons(Boutons[1])
  Dessin_boutons(Boutons[2])
  Dessin_boutons(Boutons[3])
  Dessin_boutons(Boutons[4])

# Detecte la position du separateur dans la
# liste d'actions
def Separateur(actions):
  for i in range(len(actions)-1):
      if actions[i]=="----":
        return i

Boutons=[
# [Texte,Longueur,Largeur,x,y]
["OK pour generer",170,40,75,150], 
["OK pour recommencer",210,40,55,110],
["EXE pour quitter",180,40,70,160],
["",300,40,10,10],
["",300,40,10,60]
]

# Ingredients du scenario
persos=[ # 1
"Une princesse",
"Un voleur",
"Un mage",
"Un ministre",
"Une sorciere",
"Un demon",
"Un farfadet",
"Un cardinal",
"Un docteur",
"Un loup",
"Une breris",
"Un chevalier",
"Un empereur",
"Un roi",
"Un moine",
"Un paysan",
"Un assassin",
"Un idiot",
"Un marchand",
"Un elfe",
"Un nain",
]

actions=[ # 2
"a vole",
"a mange",
"a perdu",
"a achete",
"a construit",
"a detruit",
"a invoque",
"a desintegre",
"a cache",
"a vu",
"----",# Ne pas toucher a cette ligne
"a kidnappe",
"a parle a",
"a rencontre",
"a desintegre",
"a mange",
"a tue",
"a cache",
"a soudoye",
"a invoque",
"a vu",
]

objets=[ # 3
"un grimoire",
"une fiole",
"un temple",
"une carotte",
"une foret",
"une montre",
"un canape",
"une clef",
"un etale",
"un sort",
"un calendrier",
"un gril",
"une machette",
"une bouteille",
"un tapis",
"une lanterne",
"une torche",
"un carosse",
"une epee",
"un arc",
]


part1="";part2="";part3=""
separ=Separateur(actions)
Logo()
fill_rect(0,0,320,240,(0,)*3)
Page()
while not keydown(KEY_EXE):
  if keydown(KEY_OK):
    fill_rect(0,0,320,240,(0,)*3)
    Page()
    while keydown(KEY_OK):
      pass

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.