def player_move(self, _player: player.Player): dice1, dice2 = self.roll_dice() # roll the dice print(dice1, dice2) current_region = self.__region_list[_player.move(dice1, dice2)] # player current region assert isinstance(current_region, region.Region) # check if current_region is Region class _type = current_region.get_buy_type(_player.get_id()) # with vaues in constant.py, set purchase type # checking desert. if current_region.is_desert() and not _player.check_desert(): _player.set_stop() messagebox.showerror("Desert", "You are in desert!") # pay toll when region is owned by other player. if _player.get_id() != current_region.get_owner_id() and current_region.get_owner_id() is not None: _toll = current_region.get_toll() _player.pay_money(_toll, current_region.get_owner()) print("%s gave $%d money to %s" % (_player.get_player_name(), _toll, current_region.get_owner().get_player_name())) # get the price of region. current_region_price = current_region.get_sales_price(_player.get_id()) # when player has enough money, then ask whether buy the region or not if _player.get_current_money() >= current_region_price and current_region.can_buy(): want_to_buy = messagebox.askyesno("Buy", constant.ASK_BUY_MESSAGE[_type] % current_region_price) if want_to_buy: current_region.buy(_player) # checking dice is double or not. if dice1 != dice2: self.__current_player_no = (self.__current_player_no + 1) % constant.PLAYER_NO else: messagebox.showinfo("Double", "Your dices ar Double!") return dice1, dice2
def test_player_move(self, _player: player.Player, dice1: int, dice2: int): current_region = self.__region_list[_player.move(dice1, dice2)] # 현재 _player 가 있는 지역 assert isinstance(current_region, region.Region) # 적절한 값인지 체크 _type = current_region.get_buy_type(_player.get_id()) # 구매 타입을 정한다. constant.py 에 있는 내용 참조. if current_region.is_desert() and not _player.check_desert(): _player.set_stop() # 통행료 지급하는 부분 if _player.get_id() != current_region.get_owner_id() and current_region.get_owner_id() is not None: _toll = current_region.get_toll() _player.pay_money(_toll, current_region.get_owner()) print("%s gave $%d money to %s" % (_player.get_player_name(), _toll, current_region.get_owner().get_player_name())) # 지역 구매 여부 묻기 current_region_price = current_region.get_sales_price(_player.get_id()) if _player.get_current_money() >= current_region_price: ask = input(constant.ASK_BUY_MESSAGE[_type] % current_region_price) if ask is 'Y': current_region.buy(_player) elif ask is 'N': pass
def player_move(self, _player: player.Player): dice1, dice2 = self.roll_dice() # 주사위를 던진다. print(dice1, dice2) current_region = self.__region_list[_player.move(dice1, dice2)] # 현재 _player 가 있는 지역 assert isinstance(current_region, region.Region) # 적절한 값인지 체크 _type = current_region.get_buy_type(_player.get_id()) # 구매 타입을 정한다. constant.py 에 있는 내용 참조. if current_region.is_desert() and not _player.check_desert(): _player.set_stop() # 통행료 지급하는 부분 if _player.get_id() != current_region.get_owner_id() and current_region.get_owner_id() is not None: _toll = current_region.get_toll() _player.pay_money(_toll, current_region.get_owner()) print("%s gave $%d money to %s" % (_player.get_player_name(), _toll, current_region.get_owner().get_player_name())) # 지역 구매 여부 묻기 current_region_price = current_region.get_sales_price(_player.get_id()) if _player.get_current_money() >= current_region_price: want_to_buy = messagebox.askyesno("Buy", constant.ASK_BUY_MESSAGE[_type] % current_region_price) if want_to_buy: current_region.buy(_player) return dice1, dice2