-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
51 lines (45 loc) · 1.76 KB
/
player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import flet as ft
from tiles import Tiles
from drag_controlls import DragControlls
class Player:
def __init__(self, page, dc):
self.page = page
self.player_names = ["Player 1","|", "Player 2"]
self.dc = dc
def set_up_player_names(self):
# Create player name row
player_name_row = ft.Row(
controls=[ft.Text(player_name, color="black") for player_name in self.player_names],
alignment=ft.MainAxisAlignment.CENTER,
)
player_name_container=ft.Container(
content=player_name_row,
margin=ft.Margin(5, 5, 5, 5),
)
return player_name_container
def set_up_player(self):
# Player letter tiles
player_tiles = list(Tiles().pick_seven_letters())
# Create draggable tiles for the player
tile_row = ft.Row(
controls=[
ft.Stack([
Tiles().player_drag_target(self.dc),
Tiles().player_tile(tile, 1, self.dc)
])
for tile in player_tiles
],
spacing=2,
alignment=ft.MainAxisAlignment.CENTER,
)
player_row_stack = ft.Stack([
ft.Row(controls=[
ft.Container(bgcolor=ft.colors.BLUE_ACCENT_400, expand=False, height=10, width=45*7+20),
],alignment=ft.MainAxisAlignment.CENTER,),
ft.Container(content=tile_row,
margin=ft.Margin(0, 0, 0, 5))
],alignment=ft.alignment.bottom_center,)
return {
"tile_row": player_row_stack,
"draggable_tiles": [{'tile': tile, 'item': item} for tile, item in zip(player_tiles, tile_row.controls)]
}