def create_tiles(self): # Simples for suit in range(gpmjcore.Suits.NUM_OF_SIMPLES): for number in range(1, 10): for x in range(4): tile = gpmjcore.Tile(suit, number) if number == 5 and x < self.config.num_of_red5[suit]: tile.b_red = True self.tiles.append(tile) # Winds for number in range(gpmjcore.Winds.NUM_OF_WINDS): for x in range(4): self.tiles.append(gpmjcore.Tile(gpmjcore.Suits.WINDS, number)) # Dragons for number in range(gpmjcore.Dragons.NUM_OF_DRAGONS): for x in range(4): self.tiles.append(gpmjcore.Tile(gpmjcore.Suits.DRAGONS, number))
def test_stolen_kong_handler(self): tile = gpmjcore.Tile(gpmjcore.Suits.DOTS, 1) result = self.player.stolen_kong_handler(tile) self.assertEqual(result, False)
def test_pong_handler(self): melds = [] tile = gpmjcore.Tile(gpmjcore.Suits.DOTS, 1) (result1, result2) = self.player.pong_handler(tile, melds) self.assertIsNone(result1) self.assertIsNone(result2)
def test_win_discard_handler(self): tile = gpmjcore.Tile(gpmjcore.Suits.DOTS, 1) result = self.player.win_discard_handler(tile) self.assertEqual(result, True)
def test_different_9orphans_handler(self): tile = gpmjcore.Tile(gpmjcore.Suits.DOTS, 1) result = self.player.different_9orphans_handler(tile) self.assertEqual(result, False)
def test_declare_ready_handler(self): tiles = [] tile = gpmjcore.Tile(gpmjcore.Suits.DOTS, 1) result = self.player.declare_ready_handler(tile, tiles) self.assertIsNone(result)
def test_added_kong_handler(self): melds = [] tile = gpmjcore.Tile(gpmjcore.Suits.DOTS, 1) result = self.player.added_kong_handler(tile, melds) self.assertIsNone(result)
def test_pickup_tile_after_declared_ready_handler(self): tile = gpmjcore.Tile(gpmjcore.Suits.DOTS, 1) result = self.player.pickup_tile_after_declared_ready_handler(tile) self.assertEqual(result, tile)
def __init__(self, master): canvas = tk.Canvas(master, bg='green', width=600, height=600, bd=2) canvas.place(x=0, y=0) self.img = tk.PhotoImage(file='tiles/j1.png') canvas.create_image(20, 20, image=self.img, tag="img1") canvas.delete("img1") # test self.create_tile_images() hand = gpmjcore.Hand() hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.DOTS, 1)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.DOTS, 9)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.BAMBOO, 1)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.BAMBOO, 9)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.CHARACTERS, 1)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.CHARACTERS, 9)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.WINDS, 0)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.WINDS, 1)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.WINDS, 2)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.WINDS, 3)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.DRAGONS, 0)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.DRAGONS, 1)) hand.append_tile(gpmjcore.Tile(gpmjcore.Suits.DRAGONS, 2)) self.draw_hand(canvas, hand, 20, 100)