Example #1
0
    def DrawGame(self,flip=True):

	screen = self.screen
	g = self.g
	p = self.p
	playernames = self.g.playernames

	# DRAWING           
	screen.fill((0x00, 0xb0, 0x00))
	#Stage area
	pygame.draw.rect(screen,(0,0,0),(g.curstagexy[0]-5,g.curstagexy[1]-5,g.curstagexy[2]+10,g.curstagexy[3]+10))
	pygame.draw.rect(screen,(0,255,0),g.curstagexy)

	sr = screen.get_rect()
	centerx = sr.centerx
	centery = sr.centery

	#Turn arrows
	arrow_length = 30
	headw = 10
	headl = 15
	if g.turn==0:
	    fl = [[(centerx,centery+20),(centerx,centery+20+arrow_length)],
		  [(centerx-headw,centery+20+arrow_length-headl),(centerx,centery+20+arrow_length)],
		  [(centerx+headw,centery+20+arrow_length-headl),(centerx,centery+20+arrow_length)]]
	elif g.turn==1:
	    fl = [[(centerx-90,centery-50),(centerx-90-arrow_length,centery-50)],
		  [(centerx-90-arrow_length+headl,centery-50-headw),(centerx-90-arrow_length,centery-50)],
		  [(centerx-90-arrow_length+headl,centery-50+headw),(centerx-90-arrow_length,centery-50)]]
	elif g.turn==2:
	    fl = [[(centerx,centery-90),(centerx,centery-90-arrow_length)],
		  [(centerx-headw,centery-90-arrow_length+headl),(centerx,centery-90-arrow_length)],
		  [(centerx+headw,centery-90-arrow_length+headl),(centerx,centery-90-arrow_length)]]
	elif g.turn==3:
	    fl = [[(centerx+100,centery-50),(centerx+100+arrow_length,centery-50)],
		  [(centerx+100+arrow_length-headl,centery-headw-50),(centerx+100+arrow_length,centery-50)],
		  [(centerx+100+arrow_length-headl,centery+headw-50),(centerx+100+arrow_length,centery-50)]]
	for points in fl:
	    pygame.draw.aaline(screen,(200,0,0), points[0], points[1])

	if g.roundOver:
	    for c in g.cardGroup.cards:
		if (c.side==0) & c.location in range(3,401):
		    c.flip()

	pygame.draw.rect(screen,(0,0,0),(g.curlocxy[1][0]+2,g.curlocxy[1][1]+2,70,90),2)

	g.cardGroup.draw(screen)

	if g.selectionRect.width > 0 and g.selectionRect.height > 0:
	    pygame.draw.rect(screen,(0xff,0xff,0x00),g.selectionRect,3)

	if g.curState().turnState == PRE_DRAW:
	    state_text = "Draw or pick up"
	else:
	    state_text = "Meld or discard"
	    
	#Score area
	pygame.draw.rect(screen,(0,0,0),(g.curscorex-5,5,280,60))
	pygame.draw.rect(screen,(0,0,255),(g.curscorex,10,270,50))

	font = pygame.font.Font("freesansbold.ttf", 14)
	font2 = pygame.font.Font("FreeSans.ttf", 14)
	roundtext = font.render("%s%s" % ("ROUND ",g.round),1,(255,255,255))
	team1text = font.render("%s%s" % ("Team 1: ",g.team1score),1,(255,255,255))
	team2text = font.render("%s%s" % ("Team 2: ",g.team2score),1,(255,255,255))
	curteamtext = font2.render("%s%s%s" % (playernames[g.turn],": ",state_text),1,(255,255,255))	
	
	roundpos = roundtext.get_rect()
	roundpos.centerx = g.curscorex + 40
	roundpos.centery = 23
	team1pos = roundtext.get_rect()
	team1pos.centerx = g.curscorex + 110
	team1pos.centery = 23
	team2pos = roundtext.get_rect()
	team2pos.centerx = g.curscorex + 210
	team2pos.centery = 23
	curteampos = roundtext.get_rect()
	curteampos.centerx = g.curscorex + 40
	curteampos.centery = 43
	screen.blit(roundtext,roundpos)
	screen.blit(team1text,team1pos)
	screen.blit(team2text,team2pos)
	screen.blit(curteamtext,curteampos)

        #Chat window

	self.chatwin.chatdisplay.text = ""

	if not self.chatwin.shaded:
	    for i in range(-1,-8,-1):
		try:
		    text = self.g.chatlist[i]
		    count = 0
		    rendered = gui.wrapText(text + "\n" + self.chatwin.chatdisplay.text,self.chatwin.chatdisplay.style['font'],self.chatwin.chatdisplay.size[0])
		    for char in rendered: 
			if char=="\n": count += 1
		    if count<9:
			self.chatwin.chatdisplay.text = self.g.chatlist[i] + "\n" +self.chatwin.chatdisplay.text
		except: pass

	gui.setEvents()
	try:
	    self.desktop.update()
	except: pass
	self.desktop.draw()

	if flip: pygame.display.flip()