#! /usr/bin/env python # -*- coding: UTF-8 -*- """ Athenarum Trade: gioco in python creato da Frafra (francesco.it@gmail.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. """ # Descrizione del file __module_name__ = "Athenarum Trade" __module_version__ = __revision__ = versione = "0.4a" __module_description__ = "Giochino" import random, time, sys # Impostazioni title="Athenarum Trade - Mercato" materia={0:"oro", 1:"cibo", 2:"legno", 3:"armi", 4:"vino"} myoro, mycibo, mylegno, myarmi, myvino=85.0, 125.0, 150.0, 90.0, 110.0 oro=[random.randrange(450.0, 700.0)] cibo=[random.randrange(200.0, 450.0)] legno=[random.randrange(75.0, 190.0)] armi=[random.randrange(70.0, 120.0)] vino=[random.randrange(90.0, 140.0)] riserva={0:"myoro", 1:"mycibo", 2:"mylegno", 3:"myarmi", 4:"myvino"} soldi=150.0 anni=0 def screen(): global soldi, myoro, mycibo, mylegno, myarmi, anni for x in range(len(materia)): type=globals()[materia[x]] type.append(type[0]+type[0]/100*random.randrange(random.randrange(-17,-5), random.randrange(5, 15))) for x in range(len(title)+4): print "\b*", print "\n* "+title+" *" for x in range(len(title)+4): print "\b*", print txt="Soldi disponibili: "+str(int(soldi)) print "* "+txt, for y in range(len(title)-len(txt)-1): print "\b ", print " *" for x in range(len(title)+4): print "\b*", print for x in range(len(materia)): type=globals()[materia[x]] txt="* "+materia[x].capitalize()+": "+str(type[1])+"\t\t\b" p=100-type[0]*100/type[1] if p==0: p=" =" elif 0p>-10: p="-0"+str(0-p)+"%" elif p>=10: p="+"+str(p)+"%" elif p<=-10: p="-"+str(0-p)+"%" print txt+p+" *" for x in range(len(title)+4): print "\b*", print for x in range(len(riserva)): type=globals()[riserva[x]] txt=riserva[x].capitalize()+": "+str(type) print "* "+txt, for y in range(len(title)-len(txt)-1): print "\b ", print " *" for x in range(len(title)+4): print "\b*", print y=q=0 while y!=1: try: print "| Cosa vendere? [quit/niente/", for x in range(1, len(materia)+1): if x < len(materia): print "\b"+str(x)+"/", else: print "\b"+str(x), type=raw_input("\b] ") if type.lower()=="quit": q=1 break elif type.lower()=="niente": break type=int(type)-1 qnt=float(raw_input("| Quanto? ")) if qnt>globals()[riserva[type]]: print "| Impossibile, quantitativo troppo alto." y=0 else: soldi=soldi+globals()[materia[type]][1]*qnt/100 globals()[riserva[type]]=globals()[riserva[type]]-qnt y=1 except: print "| Valore non corretto." y=0 y=0 while y!=1: try: if q: return 0 break print "| Cosa comprare? [quit/niente/", for x in range(1, len(materia)+1): if x < len(materia): print "\b"+str(x)+"/", else: print "\b"+str(x), type=raw_input("\b] ") if type.lower()=="quit": return 0 break elif type.lower()=="niente": break type=int(type)-1 qnt=float(raw_input("| Quanto? ")) if soldi