示例#1
0
文件: network.py 项目: jamwt/pyker
def end_hand(table_name, game):
	game.make_payments()
	game.finish_hand()
	if game.game_ended:
		gaction(table_name, "%s wins the game" % game.active_players.values()[0].nick)
	else:
		call_later(1.0, start_hand, table_name, game)
示例#2
0
文件: network.py 项目: jamwt/pyker
def blinds_iter(table_name, game):
	try:
		game.advance_blinds()
	except StopIteration:
		pass
	else:
		gaction(table_name, 
		"the blinds will increase to $%s, $%s on the next hand"
		% (game.sb_amt, game.bb_amt))
		call_later(game.blinds_timer * 60,
		blinds_iter, table_name, game)
示例#3
0
文件: network.py 项目: jamwt/pyker
def bet_iter(table_name, game):
	if game.action == None:
		call_later(0.8, hand_iter, table_name, game)
	else:
		pos, play = game.action
		nh = net_handlers[play.nick]
		if game.bet_made and game.pot.deficit(pos):
			c_s = ' ($%s to call)' % (game.pot.deficit(pos))
		else:
			c_s = ''
		nh.command("Action is to you%s" % c_s)
		gsync(table_name)
示例#4
0
文件: network.py 项目: jamwt/pyker
	def cmd_start(self, evt, data):
		if not self.player.sitting:
			self.error("you are not sitting down at a table")
		elif self.game.started:
			self.error("game is already started")
		else:
			self.game.start()
			call_later(self.game.blinds_timer * 60,
			blinds_iter, self.table_name, self.game)
			self.gaction("%s has started the game" % self.player.nick)
			call_later(1.0, self.gaction, "cards are dealt to determine initial dealer")
			call_later(1.5, self.sync)
			call_later(1.7, self.gaction, "%s has the high card and will start as dealer" % 
			self.game.players[self.game.dealer].nick)
			call_later(5.5, start_hand, self.table_name, self.game)
示例#5
0
文件: network.py 项目: jamwt/pyker
def start_hand(table_name, game):
	game.start_hand()
	game.state['handnum'] = game.state.get('handnum', 0) + 1
	gaction(table_name, "starting hand #%d" % game.state['handnum'])
	gsync(table_name)
	call_later(1.3, deal_pockets, table_name, game)
	call_later(1.5, gsync, table_name)
	call_later(2, betting_round, table_name, game)
示例#6
0
文件: network.py 项目: jamwt/pyker
def hand_iter(table_name, game):
	if game.hand_over:
		table_moves[table_name] = {}
		game.evaluate()
		shown_hands = 0
		for pos, info in game.show:
			if info:
				phrase = get_hand_phrase(info[0])
				gaction(table_name, "%s shows %s" % 
				(game.players[pos].nick, phrase))
				table_moves[table_name][pos] = (phrase, None)
				shown_hands += 1
			else:
				gaction(table_name, "%s folds" % 
				(game.players[pos].nick,))
				table_moves[table_name][pos] = ('fold', True)
		winners = {}
		for x, pot in enumerate(game.payouts):
			ind = len(game.payouts) - x
			if ind == 1:
				p_name = 'main pot'
			else:
				p_name = 'side pot'
			if len(pot) > 1:
				o = []
				for pos, amt in pot:
					o.append('%s ($%s)' % (game.players[pos].nick, amt))
				gaction(table_name, '%s split %s' % (', '.join(o), p_name))
			else:
				pos, amt = pot[0]
				gaction(table_name, '%s wins %s ($%s)' % (game.players[pos].nick,
				p_name, amt))
		gsync(table_name)
		call_later(4.0 + (2 * shown_hands), end_hand, table_name, game)

	else:
		c_l = len(game.community)
		game.deal_community()
		new_cards = game.community[c_l:]
		gaction(table_name, "community cards dealt: %s" % ', '.join(new_cards))
		gsync(table_name)
		if game.show_all:
			if len(game.community) == 5:
				game.check_for_winners()
			call_later(2.0, hand_iter, table_name, game)
		else:
			call_later(2.0, betting_round, table_name, game)