本文整理汇总了Python中lib.game.Game类的典型用法代码示例。如果您正苦于以下问题:Python Game类的具体用法?Python Game怎么用?Python Game使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Game类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_contestant_can_switch
def test_contestant_can_switch(self):
door_1, door_2, door_3 = Door(False), Door(True), Door(False)
game = Game(door_1, door_2, door_3)
game.contestant_guess = door_1
game.contestant_switch()
self.assertNotEqual(door_1, game.contestant_guess)
self.assertIsInstance(game.contestant_guess, Door)
示例2: __init__
class Bot:
def __init__(self, config):
self.config = config
self.irc = Irc(config)
self.game = Game()
def run(self):
last_start = time.time()
while True:
new_messages = self.irc.recv_messages(1024)
if new_messages:
for message in new_messages:
button = message['message'].lower()
username = message['username']
if not self.game.is_valid_button(button):
continue
if self.config['start_throttle']['enabled'] and button == 'start':
if time.time() - last_start < self.config['start_throttle']['time']:
continue
pbutton(username, button)
self.game.push_button(button)
if button == 'start':
last_start = time.time()
示例3: test_case_where_contestant_guesses_correctly
def test_case_where_contestant_guesses_correctly(self):
door_1, door_2, door_3 = Door(False), Door(True), Door(False)
game = Game(door_1, door_2, door_3)
game.contestant_guess = door_2
game.host_open_door()
self.assertEqual(False, door_2.is_open)
self.assertEqual(True, door_1.is_open ^ door_3.is_open)
示例4: test_play_states_when_the_player_wins
def test_play_states_when_the_player_wins(mocker):
mocker.patch('lib.console.display')
mocker.patch('lib.player_input.read_choice', return_value="p")
mocker.patch('lib.computer_input.read_choice', return_value="r")
Game.play()
lib.console.display.assert_any_call("Player wins!")
示例5: test_drop_piece_returns_final_position
def test_drop_piece_returns_final_position(self):
g = Game() # 6x7 by default
self.assertEquals(g._drop_piece('X', 0), (0,5))
self.assertEquals(g._drop_piece('X', 0), (0,4))
self.assertEquals(g._drop_piece('X', 0), (0,3))
self.assertEquals(g._drop_piece('O', 0), (0,2))
self.assertEquals(g._drop_piece('X', 0), (0,1))
self.assertEquals(g._drop_piece('X', 0), (0,0))
示例6: test_play_states_when_a_tie_occurres
def test_play_states_when_a_tie_occurres(mocker):
mocker.patch('lib.console.display')
mocker.patch('lib.player_input.read_choice', return_value="r")
mocker.patch('lib.computer_input.read_choice', return_value="r")
Game.play()
lib.console.display.assert_any_call("It's a tie!")
示例7: test_play_computers_choice_is_displayed_if_computer_picks_other_option
def test_play_computers_choice_is_displayed_if_computer_picks_other_option(mocker):
mocker.patch('lib.console.display')
mocker.patch('lib.console.display_no_newline')
mocker.patch('lib.player_input.read_choice')
mocker.patch('lib.computer_input.read_choice', return_value="r")
Game.play()
lib.console.display.assert_any_call("Computer played Rock!")
示例8: test_play_computers_choice_is_displayed
def test_play_computers_choice_is_displayed(mocker):
mocker.patch('lib.console.display')
mocker.patch('lib.console.display_no_newline')
mocker.patch('lib.player_input.read_choice')
mocker.patch('lib.computer_input.read_choice', return_value="p")
Game.play()
lib.console.display.assert_any_call("Computer played Paper!")
示例9: test_play_prompts_for_users_option
def test_play_prompts_for_users_option(mocker):
mocker.patch('lib.console.display')
mocker.patch('lib.console.display_no_newline')
mocker.patch('lib.player_input.read_choice')
mocker.patch('lib.computer_input.read_choice')
Game.play()
lib.console.display.assert_any_call("Rock (r), Paper (p) or Scissors (s):")
示例10: test_get_pieces
def test_get_pieces(self):
g = Game(rows=1)
g.drop_cross(0)
g.drop_round(1)
self.assertTrue((0,0) in g._get_pieces('X'))
self.assertFalse((1,0) in g._get_pieces('X'))
self.assertTrue((1,0) in g._get_pieces('O'))
self.assertFalse((0,0) in g._get_pieces('O'))
示例11: test_dealCardsDealsCorrectly
def test_dealCardsDealsCorrectly(self):
deck = Deck()
game = Game('SomeGameName', self.m)
game.addPlayer(self.j) # This isn't really necessary.
game.dealCards([self.m, self.j], deck)
self.assertEqual(self.m.hand.size(), 3)
self.assertEqual(self.m.up.size(), 3)
self.assertEqual(self.m.down.size(), 3)
self.assertEqual(self.j.hand.size(), 3)
self.assertEqual(self.j.up.size(), 3)
self.assertEqual(self.m.down.size(), 3)
self.assertEqual(deck.size(), (52 - 18))
示例12: __init__
def __init__(self):
self.config = config
self.irc = Irc(config)
self.game = Game()
self.extConfig=configparser.ConfigParser()
self.message_buffer = deque(' ',self.bufferLength) #deque happens to be marginally more convenient for this
self.curQueue=comQueue() #Based on Queue object, and therefore threadsafe
self.daQueue=demAnQueue() #Based on deque object, and therefore threadsafe
self.queueStatus="Nominal"
self.lastButton=""
self.voteCount={}
self.lastPushed=""
self.voteItems=self.voteCount.items() #Dynamically changing list in python 3 that keeps up with voteCount
self.democracy=False #Anarchy is default on.
self.game.democracy=self.democracy #Command processor needs this information due to slightly different processing in democracy vs. anarchy
self.lastConfigTime=time.time() #Timer on config file updates
self.configUpdateFreq=60 #config file updates every 60 seconds
###DEFAULT VALUES (should be overwritten by readConfigText() at the end###
self.botConfig={'votetime':20,
'checktime':0.1,
'votethresh':75}
###END DEFAULT VALUES###
self.readConfigText() #read in config file (after all possible object initializations)
self.daQueue.updateQueue() #It's poor form that I have to do this, but it's cleanest
示例13: __init__
def __init__(self):
self.config = config
self.irc = Irc(config)
self.game = Game()
self.stats = Stats()
if self.config['features']['gui_stats']:
self.GUI = GUI(self)
示例14: __init__
def __init__(self):
self.config = config
self.irc = Irc(config)
self.game = Game()
self.message_buffer = []
self.scrolling_chat = []
self.chat_buffer = []
self.game_tracker = [0,0,0,0,0,0,0,0,0]
self.windowSurface = pygame.display.set_mode((1300,800), 0, 32)
self.BLACK = (0,0,0)
self.WHITE = (255,255,255)
self.start = time.clock()
self.game_timer = 0
self.old_time = 0;
self.xwins = 0
self.owins = 0
self.cats_games = 0
self.games = 0
self.who_starts = 0
self.whos_move = 0
self.suspend = 0
self.winner = False
self.is_cats = False
self.music = pygame.mixer.Sound('music_loop.wav')
self.basicFont = pygame.font.SysFont(None, 36)
示例15: test_rotatesPlayersCorrectly
def test_rotatesPlayersCorrectly(self):
game = Game("SomeGameName", self.m)
game.addPlayer(self.j)
game.beginGame()
self.assertRegex(game.currentPlayer.name, self.j.name)
game.rotateCurrentPlayer()
self.assertRegex(game.currentPlayer.name, self.m.name)