#! /usr/bin/python
import random
import time
import pygame
from pygame.locals import *
pygame.init()
SCREEN_WIDTH = 500
SCREEN_HEIGHT = 350
def subasta(oferta, sujeto1, sujeto2, saldosujeto1, saldosujeto2, done, ultima):
while done==False:
if sujeto1 > sujeto2:
oferta = sujeto1
elif sujeto1 == sujeto2:
sujeto1 = int(sujeto1+random.randint(1, 10))
sujeto2 = int(sujeto2+random.randint(1, 10))
else:
oferta = sujeto2
if ultima == True:
done = True
textoferta = str(oferta)
textsujeto1 = str(sujeto1)
textsujeto2 = str(sujeto2)
pygame.display.update()
screen.blit(letra2.render("Subasta", True, (34, 139, 34)), (130, 50))
screen.blit(letra.render("Oferta Mayor: %s " % textoferta, True, (0, 0, 0)), (50, 100))
screen.blit(letra.render("Sujeto1 ofrece: %s " % textsujeto1, True, (0, 0, 0)), (50, 140))
screen.blit(letra.render("Sujeto2 ofrece: %s " % textsujeto2, True, (0, 0, 0)), (50, 180))
pygame.display.update()
screen.blit(fondo, (0, 0))
time.sleep(1)
if sujeto1 > sujeto2:
sujeto2 = sujeto1+random.randint(1,100)
elif sujeto1 < sujeto2:
sujeto1 = sujeto2+random.randint(1,100)
if sujeto1 > saldosujeto1:
sujeto1 = saldosujeto1
print "Sujeto1 ya ofrecio todo su saldo"
ultima = True
screen.blit(letra.render("Gano sujeto2 con: %s " % textsujeto2, True, (255, 0, 0)), (50, 220))
elif sujeto2 > saldosujeto2:
sujeto2 = saldosujeto2
print "Sujeto2 ya ofrecio todo su saldo"
screen.blit(letra.render("Gano sujeto1 con: %s " % textsujeto1, True, (255, 0, 0)), (50, 220))
ultima = True
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
if __name__ == "__main__":
try:
oferta = int(val)
except:
oferta = int(raw_input('Ingresa el precio inicial: '))
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Subasta")
fondo = pygame.image.load("lol.png")
screen.blit(fondo, (0, 0))
letra = pygame.font.Font(None, 40)
letra2 = pygame.font.Font(None, 60)
screen.blit(fondo, (0, 0))
pygame.display.flip()
time.sleep(2)
saldosujeto1 = int(random.randint(1000, 10000))# Saldo del sujeto 1
saldosujeto2 = int(random.randint(1000, 10000))# Saldo del sujeto 2
print saldosujeto1
print saldosujeto2
if oferta < 0:
print "El numero es negativo"
exit()
else:
sujeto1 = int(oferta+random.randint(1, 10))# Primer grito
sujeto2 = int(oferta+random.randint(1, 10))# Primer grito
if sujeto1 == sujeto2:
sujeto1 = int(sujeto1+random.randint(1, 10))
sujeto2 = int(sujeto2+random.randint(1, 10))
textoferta = str(oferta)
textsujeto1 = str(sujeto1)
textsujeto2 = str(sujeto2)
done = False
ultima = False
pygame.display.update()
subasta(oferta, sujeto1, sujeto2, saldosujeto1, saldosujeto2, done, ultima)