Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding=utf-8
- from tkinter import *
- from threading import Timer
- from datetime import datetime
- import time
- import random
- class PlayerUnit :
- hAmount = 0 # 말 갯수
- selObject = None # 움직이기로 선택한 말 (None=선택안함, "I"=보관함, 그외 고유 좌표)
- def __init__(self) :
- self.hAmount = 3
- self.selObject = None
- class Horse :
- C = [[0]*2 for i in range(20)]
- R = [[0] * 2 for i in range(7)]
- L = [[0] * 2 for i in range(7)]
- Location = ""
- master = None
- hButton = None
- Amount = 1
- def __init__(self, loc, Turn, window) :
- self.defLoc()
- if (loc >= 5) :
- self.Location = "R0"
- else :
- self.Location = f"C{loc}"
- self.master = window
- self.hButton = Button(
- self.master,
- relief='solid',
- width=4,
- height=2,
- command=self.selectMe,
- text=f"{self.Amount}"
- )
- if(Turn == 0) :
- self.hButton.configure(bg='dodgerblue')
- elif (Turn == 1):
- self.hButton.configure(bg='red', fg='snow')
- elif (Turn == 2):
- self.hButton.configure(bg='gold')
- elif (Turn == 3):
- self.hButton.configure(bg='green2')
- self.hButton.place(x = self.C[loc][0], y = self.C[loc][1])
- def selectMe(self) :
- all.selObject = self.Location
- print(f" └ 말 선택됨 : {self.Location}")
- all.MovingHorse()
- all.SelectAble(False)
- def Replace(self) :
- idx = int(self.Location[1:])
- if (self.Location[:1] == "C") :
- self.hButton.place(x=self.C[idx][0], y=self.C[idx][1])
- elif (self.Location[:1] == "L") :
- self.hButton.place(x=self.L[idx][0], y=self.L[idx][1])
- elif (self.Location[:1] == "R") :
- self.hButton.place(x=self.R[idx][0], y=self.R[idx][1])
- def defLoc(self):
- '''좌표지정'''
- x = 0
- y = 1
- count = 0
- self.C[count][x] = self.L[6][x] = 421
- self.C[count][y] = self.L[6][y] = 421
- count = 5
- self.C[count][x] = self.R[0][x] = 421
- self.C[count][y] = self.R[0][y] = 23
- count = 10
- self.C[count][x] = self.L[0][x] = 23
- self.C[count][y] = self.L[0][y] = 23
- count = 15
- self.C[count][x] = self.R[6][x] = 23
- self.C[count][y] = self.R[6][y] = 421
- t_x = 421
- t_y = 340
- for count in range(1, 5) :
- self.C[count][x] = t_x
- self.C[count][y] = t_y
- t_y -= 75
- t_x = 340
- t_y = 23
- for count in range(6, 11) :
- self.C[count][x] = t_x
- self.C[count][y] = t_y
- t_x -= 75
- t_x = 23
- t_y = 115
- for count in range(11, 16) :
- self.C[count][x] = t_x
- self.C[count][y] = t_y
- t_y += 75
- t_x = 111
- t_y = 421
- for count in range(16, 20):
- self.C[count][x] = t_x
- self.C[count][y] = t_y
- t_x += 75
- self.R[1][x] = 340
- self.R[1][y] = 100
- self.R[2][x] = 285
- self.R[2][y] = 155
- self.R[3][x] = self.L[3][x] = 223
- self.R[3][y] = self.L[3][y] = 220
- self.R[4][x] = 160
- self.R[4][y] = 285
- self.R[5][x] = 102
- self.R[5][y] = 340
- self.L[1][x] = 102
- self.L[1][y] = 100
- self.L[2][x] = 160
- self.L[2][y] = 155
- self.L[4][x] = 285
- self.L[4][y] = 285
- self.L[5][x] = 345
- self.L[5][y] = 340
- class Yut :
- Board_C = [[None]*3 for i in range(20)]
- Board_R = [[None]*3 for i in range(7)]
- Board_L = [[None]*3 for i in range(7)]
- Score = [0] * 4
- MaxPlayer = 0 # 플레이중인 플레이어 수
- TurnCount = 0 # 몇번째 플레이어
- selObject = None
- PlayAble = True # 굴리기 가능여부
- Horse_img = [None] * 4 # 말 이미지 집합
- Yut_img = [None] * 4 # 윷 이미지 집합
- Dis_horse_but = [None] * 4 # 말 버튼 집합
- Dis_horse_count = [None] * 4 # 말 갯수 레이블 집합
- Yut_Front = None # 윷 앞 이미지
- Yut_Back = None # 윷 뒤 이미지
- Yut_BackB = None # 윷 백도 위 이미지
- Player = None
- Horse_Area = None
- Board_Area = None
- NowRolled = False
- Roll = 0 # 윷 값
- def __init__(self, master) : # GUI 생성 및 게임 초기화
- global Board_img
- global Horse_img
- global Yut_img
- global Yut_Front
- global Yut_Back
- global Yut_BackB
- ###### 게임에 필요한 이미지 로드 ######
- for i in range(0,4) :
- self.Horse_img[i] = PhotoImage(file=f"resource/Horse{i+1}.png")
- self.Yut_Front = PhotoImage(file="resource/Yut_Front.png")
- self.Yut_Back = PhotoImage(file="resource/Yut_Back.png")
- self.Yut_BackB = PhotoImage(file="resource/Yut_BackB.png")
- Board_img = PhotoImage(file="resource/Board.png")
- ###### 게임 판 GUI ######
- # 게임 판 레이블 프레임
- self.Board_Area = LabelFrame(master, text="윷놀이 판", padx=10, pady=10)
- self.Board_Area.place(x=10, y=10)
- # 게임 판 레이블
- boardImg = Label(self.Board_Area, image=Board_img)
- boardImg.pack()
- ###### 윷 롤링 구역 GUI ######
- # 윷 롤링 구역 레이블 프레임
- Play_Area = LabelFrame(master, text="윷", padx=6, pady=10)
- Play_Area.place(x=10, y=539)
- # 윷 롤링 구역 (검정색 사각형)
- rollArea = Label(Play_Area, width=55, height=13, background='black')
- rollArea.pack(side='left', padx=5)
- # 윷 배치
- x_loc = 80
- x_gap = 80
- for i in range(0, 4) :
- self.Yut_img[i] = Label(master, image=self.Yut_Front, width=30, height=164,)
- self.Yut_img[i].place(x=x_loc, y=585)
- x_loc += x_gap
- ###### 윷 롤링 버튼 GUI ######
- button = Button(
- Play_Area,
- text='윷 던지기',
- relief='solid',
- width=10,
- height=13,
- command=self.Rolling
- )
- button.pack(side='right', padx=5)
- ###### 로그 박스 GUI ######
- Log_Area = LabelFrame(master, text="로그", padx=10, pady=9)
- Log_Area.place(x=530, y=10)
- frame = Frame(Log_Area, width=320, height=730, bd=1)
- frame.pack()
- self.listbox_log = Listbox(frame, height=30, width=45, activestyle='none')
- self.listbox_log.bindtags((self.listbox_log, master, "all"))
- self.scrollbar_log = Scrollbar(frame)
- self.scrollbar_log.pack(side='right', fill='y')
- self.listbox_log.pack(side='left',fill='y')
- self.listbox_log.configure(yscrollcommand = self.scrollbar_log.set)
- self.scrollbar_log.configure(command = self.listbox_log.yview)
- self.item_num = 0
- ###### 말 GUI ######
- self.Horse_Area = LabelFrame(master, text="말 보관", padx=10, pady=10)
- self.Horse_Area.place(x=530, y=539)
- hFrame = Frame(self.Horse_Area, width=339, height=205, bd=1)
- hFrame.pack()
- # 말 이미지
- x_loc = 45
- x_gap = 70
- Dis_horse_img = [None] * 4
- for i in range(0, 4) :
- Dis_horse_img[i] = Label(self.Horse_Area, image=self.Horse_img[i])
- Dis_horse_img[i].place(x=x_loc, y=50)
- x_loc += x_gap
- # 말 갯수
- x_loc = 47
- x_gap = 70
- for i in range(0, 4) :
- self.Dis_horse_count[i] = Label(self.Horse_Area, text="없음")
- self.Dis_horse_count[i].place(x=x_loc, y=30)
- x_loc += x_gap
- # 말 버튼
- for i in range(0, 4) :
- self.Dis_horse_but[i] = Button(
- self.Horse_Area,
- text='선택',
- width=5,
- height=1,
- relief='solid',
- command=self.Select_Home,
- bg='snow'
- )
- x_loc += x_gap
- def iniGame(self, Max) : # # # # # # # # # # # # # # # # # # # # # 게임 초기화
- self.MaxPlayer = Max
- self.Player = [None] * Max
- self.OnBoard_Horse = [None] * (3 * Max)
- for i in range(0, self.MaxPlayer) :
- self.Player[i] = PlayerUnit()
- self.ReHorseAmount()
- def addLog(self, text) : # # # # # # # # # # # # # # # # # # # # # 로그 추가 메소드
- now = datetime.now()
- self.listbox_log.insert(END,"[%02d:%02d:%02d] " %(now.hour, now.minute, now.second) + str(text))
- self.listbox_log.select_clear(self.listbox_log.size() - 2)
- self.listbox_log.select_set(END)
- self.listbox_log.yview(END)
- self.item_num += 1
- def ReHorseAmount(self) : # # # # # # # # # # # # # # # # # # # # # 말 갯수 GUI 갱신
- for i in range(0, self.MaxPlayer) :
- self.Dis_horse_count[i].configure(text=f"{self.Player[i].hAmount}개")
- def Rolling(self) : # 윷 롤링 메소드
- if (self.PlayAble) and (self.NowRolled == False) :
- result = 0
- # 윷 롤링
- print(f" {self.TurnCount +1}번 플레이어 턴")
- print(f" └ 윷 던짐")
- RandYut = [0] * 4
- for i in range(0, 4) :
- RandYut[i] = random.randrange(0, 2)
- if(RandYut[i] == 1) :
- if(i == 0) :
- self.Yut_img[i].configure(image = self.Yut_BackB)
- else :
- self.Yut_img[i].configure(image = self.Yut_Back)
- else :
- self.Yut_img[i].configure(image = self.Yut_Front)
- result += RandYut[i]
- # 도, 1번째가 뒤집어졌을때 result를 -1로 (백도)
- if(result == 1) and (RandYut[0] == 1) :
- result = -1
- # 출력
- if(result < 0) :
- self.addLog(f"백도가 나왔습니다!")
- elif(result == 0) :
- self.addLog(f"모가 나왔습니다!")
- result = 5
- elif(result == 1) :
- self.addLog(f"도가 나왔습니다!")
- elif(result == 2) :
- self.addLog(f"개가 나왔습니다!")
- elif(result == 3) :
- self.addLog(f"걸이 나왔습니다!")
- elif(result == 4) :
- self.addLog(f"윷이 나왔습니다!")
- print(f" └ 윷 결과 : {result}")
- self.addLog("움직일 말을 선택해주세요.")
- self.Roll = result
- self.SelectAble(True)
- self.NowRolled = True
- else :
- self.addLog("아직 윷을 굴릴 수 없습니다.")
- def Select_Home(self) : # # # # # # # # # # # # # # # # # # # # # 말 선택 (보관함)
- self.selObject = "I"
- print(f" └ 말 선택됨 : {self.selObject}")
- if (self.Roll < 0) :
- self.addLog("백도가 나와 말을 세울수 없습니다.")
- self.MovingHorse()
- self.SelectAble(False)
- def MovingHorse(self) :
- amount = self.Roll
- returnValue = False
- field = ""
- Move_Loc = ""
- if (self.selObject == "I") and (amount > 0):
- self.Player[self.TurnCount].hAmount -= 1
- self.ReHorseAmount()
- # 0 = 객체
- # 1 = 플레이어
- # 2 = 갯수
- if (amount != 5) :
- print(f" └ 말 이동함 : {self.selObject} → C{amount}")
- if (self.Board_C[amount][0] == None) :
- # 전진 칸에 아무것도 없다면
- self.Board_C[amount][0] = Horse(amount, self.TurnCount, self.Board_Area)
- self.Board_C[amount][1] = self.TurnCount
- self.Board_C[amount][2] = 1
- else :
- # 전진 칸에 무언가가 있다면
- if (self.Board_C[amount][1] == self.TurnCount) :
- # 그 무언가가 자신의 말이라면
- self.Board_C[amount][2] += 1
- self.addLog(f"{self.Board_C[amount][1] + 1}번 플레이어의 말이 업혔습니다.")
- print(f" └ 말 업힘 : C{amount}")
- returnValue = False
- else :
- # 그 무언가가 타인의 말이라면
- self.addLog(f"{self.Board_C[amount][1] +1}번 플레이어의 말이 잡혔습니다.")
- print(f" └ {self.Board_C[amount][1] + 1}번 말 잡음 : C{amount}")
- self.Board_C[amount][0].hButton.place_forget()
- self.Player[self.Board_C[amount][1]].hAmount += self.Board_C[amount][2]
- self.Board_C[amount] = [None] * 3
- self.Board_C[amount][0] = Horse(amount, self.TurnCount, self.Board_Area)
- self.Board_C[amount][1] = self.TurnCount
- self.Board_C[amount][2] = 1
- returnValue = True
- else :
- print(f" └ 말 이동함 : {self.selObject} → R0")
- if (self.Board_R[0][0] == None) :
- # 전진 칸에 아무것도 없다면
- self.Board_R[0][0] = Horse(amount, self.TurnCount, self.Board_Area)
- self.Board_R[0][1] = self.TurnCount
- self.Board_R[0][2] = 1
- else :
- # 전진 칸에 무언가가 있다면
- if (self.Board_R[0][1] == self.TurnCount) :
- # 그 무언가가 자신의 말이라면
- self.Board_R[0][2] += 1
- self.addLog(f"{self.Board_R[0][1] + 1}번 플레이어의 말이 업혔습니다.")
- print(f" └ 말 업힘 : R0")
- returnValue = False
- else :
- # 그 무언가가 타인의 말이라면
- self.addLog(f"{self.Board_R[0][1] +1}번 플레이어의 말이 잡혔습니다.")
- print(f" └ {self.Board_R[0][1] + 1}번 말 잡음 : R0")
- self.Board_R[0][0].hButton.place_forget()
- self.Player[self.Board_R[0][1]].hAmount += self.Board_R[0][2]
- self.Board_R[0] = [None] * 3
- self.Board_R[0][0] = Horse(amount, self.TurnCount, self.Board_Area)
- self.Board_R[0][1] = self.TurnCount
- self.Board_R[0][2] = 1
- returnValue = True
- elif (self.selObject != "I") :
- if (amount > 0) :
- field = self.selObject[:1]
- Cur_idx = int(self.selObject[1:])
- Move_Loc = ""
- if (field == "R") and (Cur_idx == 3):
- field = "L"
- Next_idx = Cur_idx + amount
- if (field == "C") :
- if (Next_idx > 20) :
- field = "END"
- else :
- if (Next_idx == 5) :
- Move_Loc = "R0"
- elif (Next_idx == 10) :
- Move_Loc = "L0"
- elif (Next_idx == 20) :
- Move_Loc = "L6"
- else :
- Move_Loc = f"C{Next_idx}"
- elif (field == "L") :
- if (Next_idx > 6) :
- field = "END"
- else :
- Move_Loc = f"L{Next_idx}"
- elif (field == "R") :
- if (Next_idx > 6) :
- Move_Loc = f"C{amount + 14}"
- else :
- Move_Loc = f"R{Next_idx}"
- else :
- # 백도
- field = self.selObject[:1]
- Next_idx = int(self.selObject[1:]) - 1
- Move_Loc = ""
- if (field == "C"):
- if (Next_idx < 0):
- field = "END"
- else:
- if (Next_idx == 0):
- Move_Loc = "L0"
- elif (Next_idx == 5):
- Move_Loc = "R0"
- elif (Next_idx == 10):
- Move_Loc = "L0"
- else:
- Move_Loc = f"C{Next_idx}"
- elif (field == "L"):
- if (Next_idx > 6):
- field = "END"
- elif (Next_idx < 0):
- Move_Loc = "C9"
- else:
- Move_Loc = f"L{Next_idx}"
- elif (field == "R"):
- if (Next_idx > 6):
- amount = Next_idx - amount
- Move_Loc = f"C{amount + 15}"
- elif (Next_idx < 0):
- Move_Loc = "C4"
- else:
- if (Next_idx == 3):
- Move_Loc = "L3"
- else:
- Move_Loc = f"R{Next_idx}"
- print(f" └ 말 이동함 : {self.selObject} → {Move_Loc}")
- # 통과 조건
- if (field == "END"):
- num = int(self.selObject[1:])
- score = 0
- if (self.selObject[:1] == "C") :
- self.Board_C[num][0].hButton.place_forget()
- self.Score[self.TurnCount] += self.Board_C[num][2]
- score = self.Board_C[num][2]
- elif (self.selObject[:1] == "L") :
- self.Board_L[num][0].hButton.place_forget()
- self.Score[self.TurnCount] += self.Board_L[num][2]
- score = self.Board_L[num][2]
- self.DeleteLoc(self.selObject)
- self.addLog(f"{self.TurnCount + 1} 플레이어의 {score}개 득점!")
- print(f" └ {score}점 득점")
- for i in range(0, len(self.Score)) :
- if (self.Score[i] >= 3) :
- self.addLog(f"{self.TurnCount + 1} 플레이어가 승리했습니다!")
- print(f" └ 승리")
- print("게임 끝")
- return
- else:
- # 말 이동
- num = int(Move_Loc[1:])
- if (Move_Loc[:1] == "C"):
- if (self.Board_C[num][0] != None):
- if (self.Board_C[num][1] == self.TurnCount):
- self.ForgetLoc(self.selObject)
- self.Board_C[num][2] += self.callNum(self.selObject)
- self.addLog(f"{self.Board_C[num][1] + 1}번 플레이어의 말이 업혔습니다.")
- print(f" └ 말 업힘 : C{num}")
- returnValue = False
- else:
- self.Board_C[num][0].hButton.place_forget()
- self.addLog(f"{self.Board_C[num][1] + 1}번 플레이어의 말이 잡혔습니다.")
- print(f" └ {self.Board_C[num][1]+1}번 말 잡음 : C{num}")
- self.Player[self.Board_C[num][1]].hAmount += self.Board_C[num][2]
- self.Board_C[num] = self.ChangeLoc(self.selObject)
- self.DeleteLoc(self.selObject)
- returnValue = True
- self.DeleteLoc(self.selObject)
- else:
- self.Board_C[num] = self.ChangeLoc(self.selObject)
- self.DeleteLoc(self.selObject)
- self.Board_C[num][0].Location = Move_Loc
- self.Board_C[num][0].Replace()
- elif (Move_Loc[:1] == "L"):
- if (self.Board_L[num][0] != None):
- if (self.Board_L[num][1] == self.TurnCount):
- self.ForgetLoc(self.selObject)
- self.Board_L[num][2] += self.callNum(self.selObject)
- self.addLog(f"{self.Board_L[num][1] + 1}번 플레이어의 말이 업혔습니다.")
- print(f" └ 말 업힘 : L{num}")
- returnValue = False
- else:
- self.Board_L[num][0].hButton.place_forget()
- self.addLog(f"{self.Board_L[num][1] + 1}번 플레이어의 말이 잡혔습니다.")
- print(f" └ {self.Board_L[num][1] + 1}번 말 잡음 : L{num}")
- self.Player[self.Board_L[num][1]].hAmount += self.Board_L[num][2]
- self.Board_L[num] = self.ChangeLoc(self.selObject)
- self.DeleteLoc(self.selObject)
- returnValue = True
- self.DeleteLoc(self.selObject)
- else:
- self.Board_L[num] = self.ChangeLoc(self.selObject)
- self.DeleteLoc(self.selObject)
- self.Board_L[num][0].Location = Move_Loc
- self.Board_L[num][0].Replace()
- elif (Move_Loc[:1] == "R"):
- if (self.Board_R[num][0] != None):
- if (self.Board_R[num][1] == self.TurnCount):
- self.ForgetLoc(self.selObject)
- self.Board_R[num][2] += self.callNum(self.selObject)
- self.addLog(f"{self.Board_R[num][1] + 1}번 플레이어의 말이 업혔습니다.")
- print(f" └ 말 업힘 : R{num}")
- returnValue = False
- else:
- self.Board_R[num][0].hButton.place_forget()
- self.addLog(f"{self.Board_R[num][1] + 1}번 플레이어의 말이 잡혔습니다.")
- print(f" └ {self.Board_R[num][1] + 1}번 말 잡음 : R{num}")
- self.Player[self.Board_R[num][1]].hAmount += self.Board_R[num][2]
- self.Board_R[num] = self.ChangeLoc(self.selObject)
- self.DeleteLoc(self.selObject)
- returnValue = True
- self.DeleteLoc(self.selObject)
- else:
- self.Board_R[num] = self.ChangeLoc(self.selObject)
- self.DeleteLoc(self.selObject)
- self.Board_R[num][0].Location = Move_Loc
- self.Board_R[num][0].Replace()
- self.NowRolled = False
- if (returnValue) or (self.Roll >= 4):
- self.TryTurn()
- else :
- self.NextTurn()
- def SelectAble(self, value) :
- if (value == True) :
- x_loc = 39
- x_gap = 70
- for i in range(0, 4):
- self.Dis_horse_but[i].place_forget()
- if (i == self.TurnCount):
- if (self.Player[i].hAmount < 1):
- continue
- self.Dis_horse_but[i].place(x=x_loc, y=110)
- x_loc += x_gap
- for i in range(0, len(self.Board_C)):
- if (self.Board_C[i][0] != None):
- if (self.Board_C[i][1] == self.TurnCount):
- self.Board_C[i][0].hButton.configure(state='normal', text=f"{self.Board_C[i][2]}")
- else:
- self.Board_C[i][0].hButton.configure(text=f"{self.Board_C[i][2]}")
- self.Board_C[i][0].hButton.configure(state='disable')
- for i in range(0, len(self.Board_L)):
- if (self.Board_L[i][0] != None):
- if (self.Board_L[i][1] == self.TurnCount):
- self.Board_L[i][0].hButton.configure(state='normal', text=f"{self.Board_L[i][2]}")
- else:
- self.Board_L[i][0].hButton.configure(text=f"{self.Board_L[i][2]}")
- self.Board_L[i][0].hButton.configure(state='disable')
- for i in range(0, len(self.Board_R)):
- if (self.Board_R[i][0] != None):
- if (self.Board_R[i][1] == self.TurnCount):
- self.Board_R[i][0].hButton.configure(state='normal', text=f"{self.Board_R[i][2]}")
- else:
- self.Board_R[i][0].hButton.configure(text=f"{self.Board_R[i][2]}")
- self.Board_R[i][0].hButton.configure(state='disable')
- else :
- for i in range(0, 4):
- self.Dis_horse_but[i].place_forget()
- for i in range(0, len(self.Board_C)) :
- if (self.Board_C[i][0] != None) :
- self.Board_C[i][0].hButton.configure(text=f"{self.Board_C[i][2]}")
- self.Board_C[i][0].hButton.configure(state='disable')
- for i in range(0, len(self.Board_L)) :
- if (self.Board_L[i][0] != None) :
- self.Board_L[i][0].hButton.configure(text=f"{self.Board_L[i][2]}")
- self.Board_L[i][0].hButton.configure(state='disable')
- for i in range(0, len(self.Board_R)) :
- if (self.Board_R[i][0] != None) :
- self.Board_R[i][0].hButton.configure(text=f"{self.Board_R[i][2]}")
- self.Board_R[i][0].hButton.configure(state='disable')
- self.ReHorseAmount()
- def callNum(self, select) :
- num = int(select[1:])
- if (select[:1] == "C") :
- return self.Board_C[num][2]
- elif (select[:1] == "L") :
- return self.Board_L[num][2]
- elif (select[:1] == "R") :
- return self.Board_R[num][2]
- def ForgetLoc(self, select) :
- num = int(select[1:])
- if (select[:1] == "C") :
- self.Board_C[num][0].hButton.place_forget()
- elif (select[:1] == "L") :
- self.Board_L[num][0].hButton.place_forget()
- elif (select[:1] == "R") :
- self.Board_R[num][0].hButton.place_forget()
- def ChangeLoc(self, select) :
- num = int(select[1:])
- if (select[:1] == "C") :
- return self.Board_C[num]
- elif (select[:1] == "L") :
- return self.Board_L[num]
- elif (select[:1] == "R") :
- return self.Board_R[num]
- def DeleteLoc(self, select) :
- num = int(select[1:])
- if (select[:1] == "C") :
- self.Board_C[num] = [None] * 3
- elif (select[:1] == "L") :
- self.Board_L[num] = [None] * 3
- elif (select[:1] == "R") :
- self.Board_R[num] = [None] * 3
- def TryTurn(self) :
- self.selObject = None
- self.SelectAble(False)
- self.addLog(f"한번더 기회가 주어집니다.")
- print(f" └ 턴 다시 진행")
- def NextTurn(self) :
- self.TurnCount += 1
- if (self.TurnCount >= self.MaxPlayer) :
- self.TurnCount = 0
- self.selObject = None
- self.SelectAble(False)
- self.addLog(f"{all.TurnCount + 1}번 플레이어의 차례입니다. 윷을 던져주세요")
- print(f" └ 턴 넘어감")
- # Main
- root = Tk()
- root.iconbitmap(default = 'resource/icon.ico')
- root.title("윷놀이")
- root.geometry("900x795")
- root.resizable(False, False)
- global all
- while True :
- try :
- Max = int(input("몇 인용으로 게임하시겠습니까? : "))
- if (Max >= 2) and (Max <= 4) :
- break
- print("\n2인 이상 4인 이하의 게임입니다.")
- except ValueError :
- print("\n올바르지 않은 문자가 포함됬습니다.")
- print("────────────────────────")
- all = Yut(root)
- all.addLog(f"게임이 {Max}인용으로 시작됩니다.")
- all.addLog(f"{all.TurnCount + 1}번 플레이어의 차례입니다. 윷을 던져주세요")
- all.iniGame(Max)
- root.lift()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement