How to use ladder method in hypothesis

Best Python code snippet using hypothesis

clubladderview.py

Source:clubladderview.py Github

copy

Full Screen

1# Embedded file name: scripts/client/gui/Scaleform/daapi/view/lobby/cyberSport/ClubLadderView.py2import BigWorld3from adisp import process4from debug_utils import LOG_DEBUG5from helpers.i18n import makeString as _ms6from gui.clubs.club_helpers import isSeasonInProgress7from gui.clubs.contexts import GetClubsContendersCtx8from gui.clubs.events_dispatcher import showClubProfile9from gui.clubs.formatters import getDivisionString, getLeagueString10from gui.clubs.items import ClubContenderItem11from gui.clubs.settings import getLadderChevron64x64, getLadderChevron256x25612from gui.Scaleform.daapi.view.lobby.cyberSport.ClubProfileWindow import ClubPage13from gui.Scaleform.daapi.view.meta.StaticFormationLadderViewMeta import StaticFormationLadderViewMeta14from gui.Scaleform.locale.TOOLTIPS import TOOLTIPS15from gui.Scaleform.locale.WAITING import WAITING16from gui.Scaleform.locale.CYBERSPORT import CYBERSPORT17from gui.shared.formatters import text_styles18from gui.shared.view_helpers.emblems import ClubEmblemsHelper19class ClubLadderView(StaticFormationLadderViewMeta, ClubPage, ClubEmblemsHelper):20 def __init__(self):21 super(ClubLadderView, self).__init__()22 self._clubDbID = None23 self._owner = None24 self._clubEmblems = {}25 self._hasLadderInfo = False26 self._requestedIconIDs = []27 return28 def onClubUpdated(self, club):29 if club is not None:30 self._initializeGui(club)31 return32 def showFormationProfile(self, clubDbID):33 showClubProfile(long(clubDbID))34 def onClubsSeasonStateChanged(self, isSeasonInProgress):35 club = self.clubsCtrl.getClub(self._clubDbID)36 if club is not None:37 self.as_updateHeaderDataS(self.__packHeaderData(club))38 self.__setLadderData(club)39 return40 def onClubLadderInfoChanged(self, ladderInfo):41 club = self.clubsCtrl.getClub(self._clubDbID)42 if club is not None:43 self.as_updateHeaderDataS(self.__packHeaderData(club))44 self.__setLadderData(club)45 return46 def onClubEmblem32x32Received(self, clubDbID, emblem):47 self._clubEmblems[clubDbID] = emblem48 if str(clubDbID) in self._requestedIconIDs:49 self.as_onUpdateClubIconS(str(clubDbID), self.getMemoryTexturePath(emblem))50 def updateClubIcons(self, ids):51 self._requestedIconIDs = ids52 self.__updateIcons()53 def __updateIcons(self):54 iconsMap = {}55 if self._clubEmblems:56 for clubDbID, emblem in self._clubEmblems.iteritems():57 if str(clubDbID) in self._requestedIconIDs:58 iconsMap[clubDbID] = self.getMemoryTexturePath(emblem)59 self.as_onUpdateClubIconsS({'iconsMap': iconsMap})60 def _initializeGui(self, club):61 self.as_setLadderStateS(self.__packLadderState(club))62 self.as_updateHeaderDataS(self.__packHeaderData(club))63 self.__setLadderData(club)64 def _populate(self):65 super(ClubLadderView, self)._populate()66 def _dispose(self):67 super(ClubLadderView, self)._dispose()68 self.clearClub()69 self._clubDbID = None70 self._owner = None71 self._clubEmblems = None72 self._hasLadderInfo = None73 self._requestedIconIDs = None74 return75 @process76 def __setLadderData(self, club):77 if club.wasInRatedBattleThisSeason():78 self.showWaiting(WAITING.CLUBS_CLUB_GET)79 results = yield self.clubsCtrl.sendRequest(GetClubsContendersCtx(club.getClubDbID()), allowDelay=True)80 if results.isSuccess():81 self._hasLadderInfo = True82 clubs = map(ClubContenderItem.build, results.data)83 self.as_updateLadderDataS(self.__packLadderData(clubs))84 else:85 self._hasLadderInfo = False86 self.hideWaiting()87 else:88 yield lambda callback = None: callback89 self.as_setLadderStateS(self.__packLadderState(club))90 return91 def __packLadderState(self, club):92 if not isSeasonInProgress():93 showStateMessage = True94 title = CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERSTATUS_NOSEASON95 message = CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERMSG_NOSEASON96 elif not club.wasInRatedBattleThisSeason() or not self._hasLadderInfo:97 showStateMessage = True98 title = CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERSTATUS_NOBATTLES99 message = CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERMSG_NOBATTLES100 else:101 showStateMessage = False102 title = CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERSTATUS_INLADDER103 message = CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERMSG_INLADDER104 return {'showStateMessage': showStateMessage,105 'stateMessage': {'title': text_styles.middleTitle(title),106 'message': text_styles.main(message),107 'iconPath': getLadderChevron256x256()}}108 def __packHeaderData(self, club):109 ladderInfo = club.getLadderInfo()110 return {'divisionName': self.__getDivisionText(ladderInfo),111 'divisionPositionText': self.__getPositionText(ladderInfo),112 'formationIconPath': getLadderChevron64x64(ladderInfo.division) if ladderInfo.isInLadder() else '',113 'tableHeaders': self.__packTableHeaders(),114 'clubDBID': str(self._clubDbID)}115 def __getDivisionText(self, ladderInfo):116 if ladderInfo.isInLadder():117 divisionStr = getDivisionString(ladderInfo.division)118 leagueStr = getLeagueString(ladderInfo.getLeague())119 return text_styles.highTitle(_ms(CYBERSPORT.STATICFORMATION_LADDERVIEW_DIVISIONNAME_TEXT, division=divisionStr, league=leagueStr))120 return ''121 def __getPositionText(self, ladderInfo):122 if ladderInfo.isInLadder():123 fmtPosition = text_styles.middleTitle(str(ladderInfo.position))124 fmtPoint = text_styles.middleTitle(str(ladderInfo.getRatingPoints()))125 return text_styles.standard(_ms(CYBERSPORT.STATICFORMATION_LADDERVIEW_DIVISIONPOSITION_TEXT, place=fmtPosition, points=fmtPoint))126 return ''127 def __packTableHeaders(self):128 return [self.__packTableHeaderItem(CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERTABLE_HEADERPLACE_TEXT, tooltip=TOOLTIPS.STATICFORMATIONLADDERVIEW_TABLE_HEADERPLACE, fieldName='placeSortValue', sortOrder=1),129 self.__packTableHeaderItem(CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERTABLE_HEADERPOINTS_TEXT, tooltip=TOOLTIPS.STATICFORMATIONLADDERVIEW_TABLE_HEADERPOINTS, fieldName='pointsSortValue', sortOrder=2),130 self.__packTableHeaderItem(CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERTABLE_HEADERFORMATIONNAME_TEXT, tooltip=TOOLTIPS.STATICFORMATIONLADDERVIEW_TABLE_HEADERFORMATIONNAME, fieldName='formationNameSortValue'),131 self.__packTableHeaderItem(CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERTABLE_HEADERBATTLESCOUNT_TEXT, tooltip=TOOLTIPS.STATICFORMATIONLADDERVIEW_TABLE_HEADERBATTLESCOUNT, fieldName='battlesCountSortValue'),132 self.__packTableHeaderItem(CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERTABLE_HEADERWINSPERCENT_TEXT, tooltip=TOOLTIPS.STATICFORMATIONLADDERVIEW_TABLE_HEADERWINPERCENT, fieldName='winPercentSortValue'),133 self.__packTableHeaderItem(CYBERSPORT.STATICFORMATION_LADDERVIEW_LADDERTABLE_HEADERSHOWFORMATIONPROFILE_TEXT, tooltip=TOOLTIPS.STATICFORMATIONLADDERVIEW_TABLE_HEADERSHOWFORMATIONPROFILE)]134 def __packTableHeaderItem(self, label, tooltip = '', fieldName = '', sortOrder = 0):135 return {'label': text_styles.standard(label),136 'toolTip': tooltip,137 'sortOrder': sortOrder,138 'iconId': fieldName}139 def __packLadderData(self, clubs):140 formations = []141 club = self.clubsCtrl.getClub(self._clubDbID)142 ladderInfo = club.getLadderInfo()143 if club and ladderInfo.isInLadder():144 for clubInfo in sorted(clubs, key=lambda club: club.ladderRank):145 self.requestClubEmblem32x32(clubInfo.clubDBID, clubInfo.clubEmblemUrl)146 battlesCount = BigWorld.wg_getNiceNumberFormat(clubInfo.battlesCount)147 winsPercent = 0148 if clubInfo.battlesCount > 0:149 winsPercent = clubInfo.winsCount / float(clubInfo.battlesCount) * 100150 winsPercentStr = BigWorld.wg_getNiceNumberFormat(winsPercent) + '%'151 clubName = clubInfo.clubName152 ladderPoints = clubInfo.getRatingPoints(ladderInfo.getDivision())153 emblem = self._clubEmblems.get(clubInfo.clubDBID, None)154 texturePath = self.getMemoryTexturePath(emblem) if emblem else ''155 formations.append({'formationId': str(clubInfo.clubDBID),156 'showProfileBtnText': _ms(CYBERSPORT.STATICFORMATION_LADDERVIEW_SHOWFORMATIONPROFILEBTN_TEXT),157 'showProfileBtnTooltip': TOOLTIPS.STATICFORMATIONLADDERVIEW_SHOWFORMATIONPROFILEBTN,158 'emblemIconPath': texturePath,159 'place': text_styles.standard(str(clubInfo.ladderRank)),160 'placeSortValue': clubInfo.ladderRank,161 'points': text_styles.middleTitle(str(ladderPoints)),162 'pointsSortValue': ladderPoints,163 'formationName': text_styles.highTitle(clubName),164 'formationNameSortValue': clubName,165 'battlesCount': text_styles.stats(battlesCount),166 'battlesCountSortValue': clubInfo.battlesCount,167 'winPercent': text_styles.stats(winsPercentStr),168 'winPercentSortValue': winsPercent,169 'isCurrentTeam': self._clubDbID == clubInfo.clubDBID})...

Full Screen

Full Screen

nav_parser.py

Source:nav_parser.py Github

copy

Full Screen

1import struct2from file_handler import FileHandler3from obj_struct import Area, EncounterPath, EncounterSpot, HidingSpot, Ladder, LadderConnection, Place, VisibleArea, Connection, NavMesh, Vector4from vars_size import VarsSize567class Parser:8 def __init__(self):9 self.raw_files = self._get_raw_files()1011 self.offset = int()12 self.current_file = bytes()1314 def initialize_parser(self, map_name):15 file = self.raw_files.get(map_name)16 if not file:17 raise KeyError("{} doesn't exist".format(map_name))1819 self.current_file = file20 self.offset = 02122 def parse(self, map_name):23 self.initialize_parser(map_name)2425 magic = self.read("I", VarsSize.uint32)26 if magic != 4277009102:27 raise Exception("Wrong magic number, it is not a nav file")2829 navmesh = NavMesh()3031 navmesh.major_version = self.read("I", VarsSize.uint32)32 if navmesh.major_version < 6 or navmesh.major_version > 16:33 raise Exception('Version is too old')3435 if navmesh.major_version >= 10:36 navmesh.minor_version = self.read("I", VarsSize.uint32)3738 navmesh.bsp_size = self.read("I", VarsSize.uint32)3940 if navmesh.major_version >= 14:41 navmesh.is_mesh_analyzed = self.read("B", VarsSize.uint8)4243 place_count = self.read("H", VarsSize.uint16)4445 for i in range(place_count):46 cur_place = Place()47 cur_place.id = i + 14849 name_len = self.read("H", VarsSize.uint16)50 cur_place.name = self.read("{}s".format(name_len-1), name_len)5152 navmesh.places[i + 1] = cur_place5354 if navmesh.major_version > 11:55 has_unnamed_areas = self.read("B", VarsSize.uint8)5657 area_count = self.read("I", VarsSize.uint32)58 for i in range(area_count):59 area = Area()6061 area.id = self.read("I", VarsSize.uint32)62 if navmesh.major_version <= 8:63 area.flags = self.read("B", VarsSize.uint8)64 elif navmesh.major_version < 13:65 area.flags = self.read("H", VarsSize.uint16)66 else:67 area.flags = self.read("I", VarsSize.uint32)6869 area.north_west = self.read("3f", VarsSize.Vector)70 area.south_east = self.read("3f", VarsSize.Vector)71 area.north_east_z = self.read("f", VarsSize.float)72 area.south_west_z = self.read("f", VarsSize.float)7374 for direction in range(4):7576 connection_count = self.read("I", VarsSize.uint32)77 for j in range(connection_count):78 cur_connection = Connection()79 cur_connection.source_area = area80 cur_connection.nav_direction = direction8182 cur_connection.target_area_id = self.read("I", VarsSize.uint32)83 area.connections.append(cur_connection)8485 hiding_spot_count = self.read("B", VarsSize.uint8)86 for j in range(hiding_spot_count):87 cur_hiding_spot = HidingSpot()88 cur_hiding_spot.id = self.read("I", VarsSize.uint32)89 cur_hiding_spot.position = self.read("3f", VarsSize.Vector)90 cur_hiding_spot.flags = self.read("B", VarsSize.uint8)9192 area.hiding_spots.append(cur_hiding_spot)9394 if navmesh.major_version < 15:95 approch_area_count = self.read("B", VarsSize.uint8)96 self.increase_offset((4*3 + 2) * int(approch_area_count))9798 encounter_paths_count = self.read("I", VarsSize.uint32)99 for j in range(encounter_paths_count):100 cur_path = EncounterPath()101102 cur_path.from_area_id = self.read("I", VarsSize.uint32)103 cur_path.from_direction = self.read("B", VarsSize.uint8)104 cur_path.to_area_id = self.read("I", VarsSize.uint32)105 cur_path.to_direction = self.read("B", VarsSize.uint8)106107 spot_count = self.read("B", VarsSize.uint8)108 for s in range(spot_count):109 cur_spot = EncounterSpot()110111 cur_spot.order_id = self.read("I", VarsSize.uint32)112 distance = self.read("B", VarsSize.uint8)113114 cur_spot.distance = distance / 255115116 cur_path.spots.append(cur_spot)117118 place_id = self.read("H", VarsSize.uint16)119 place = navmesh.places.get(place_id)120 if place:121 area.place = place122 place.areas.append(area)123124 for direction in range(2):125 ladder_connection_count = self.read("I", VarsSize.uint32)126127 for j in range(ladder_connection_count):128 cur_ladder_connection = LadderConnection()129 cur_ladder_connection.source_area = area130 cur_ladder_connection.nav_ladder_direction = direction131 cur_ladder_connection.target_id = self.read("I", VarsSize.uint32)132133 area.ladder_connections.append(cur_ladder_connection)134135 area.earliest_occupy_time_first_team = self.read("f", VarsSize.float)136 area.earliest_occupy_time_second_team = self.read("f", VarsSize.float)137138 if navmesh.major_version >= 11:139 area.north_west_light_intensity = self.read("f", VarsSize.float)140 area.north_east_light_intensity = self.read("f", VarsSize.float)141 area.south_east_light_intensity = self.read("f", VarsSize.float)142 area.south_west_light_intensity = self.read("f", VarsSize.float)143144 if navmesh.major_version >= 16:145 visible_area_count = self.read("I", VarsSize.uint32)146 for j in range(visible_area_count):147 cur_visible_area = VisibleArea()148149 cur_visible_area.visible_area_id = self.read("I", VarsSize.uint32)150 cur_visible_area.attributes = self.read("b", VarsSize.uint8)151152 area.visible_areas.append(cur_visible_area)153154 area.inherit_visibility_from = self.read("I", VarsSize.uint32)155156 garbage_count = self.read("b", VarsSize.uint8)157158 self.increase_offset(garbage_count * 14)159160 navmesh.areas[area.id] = area161162 ladder_count = self.read('I', VarsSize.uint32)163 for i in range(ladder_count):164 cur_ladder = Ladder()165 cur_ladder.id = self.read('I', VarsSize.uint32)166 cur_ladder.width = self.read("f", VarsSize.float)167 cur_ladder.top = self.read("3f", VarsSize.Vector)168 cur_ladder.bottom = self.read("3f", VarsSize.Vector)169 cur_ladder.length = self.read("f", VarsSize.float)170 cur_ladder.direction = self.read('I', VarsSize.uint32)171172 cur_ladder.top_forward_area_id = self.read('I', VarsSize.uint32)173 cur_ladder.top_forward_area = navmesh.areas.get(cur_ladder.top_forward_area_id)174 cur_ladder.top_left_area_id = self.read('I', VarsSize.uint32)175 cur_ladder.top_left_area = navmesh.areas.get(cur_ladder.top_left_area_id)176 cur_ladder.top_right_area_id = self.read('I', VarsSize.uint32)177 cur_ladder.top_right_area = navmesh.areas.get(cur_ladder.top_right_area_id)178 cur_ladder.top_behind_area_id = self.read('I', VarsSize.uint32)179 cur_ladder.top_behind_area = navmesh.areas.get(cur_ladder.top_behind_area_id)180 cur_ladder.bottom_area_id = self.read('I', VarsSize.uint32)181 cur_ladder.bottom_area = navmesh.areas.get(cur_ladder.bottom_area_id)182183 navmesh.ladders[cur_ladder.id] = cur_ladder184185 return navmesh186187 def read(self, format_string, byte_size):188 output = struct.unpack_from(format_string, self.current_file, self.offset)189 self.increase_offset(byte_size)190 if byte_size == VarsSize.Vector and format_string in ['fff', '3f']:191 return Vector(output)192 return output[0]193194 def increase_offset(self, value):195 self.offset += value196197 @staticmethod198 def _get_raw_files():199 handler = FileHandler() ...

Full Screen

Full Screen

2469.py

Source:2469.py Github

copy

Full Screen

1#-*- encoding: utf-8 -*-2import sys3r=sys.stdin.readline4k = int(r()) # k: 참가한 사람의 수5n = int(r()) # n: 전체 가로 줄의 수6final = r().rstrip() # final: 사다리를 타고 난 후 결정된 최종 순서7pre = {} # 감추어진 줄 이전8aft = {} # 감추어진 줄 이후9ladder = []10for i in range(k): # 참가한 사람의 수만큼 사다리에 입력11 ladder.append(chr(65 + i))12hidden_line = 013for i in range(n): # 감추어진 줄 찾기14 line = r().rstrip()15 16 if '?' in line:17 hidden_line = i18 break19 20 pre[i] = line21for i in range(n - hidden_line - 1):22 aft[i] = r().rstrip()23pre_ladder = {} # 숨겨진 줄 앞까지 실행한 상태24for i in range(k):25 ind = i26 for j in range(hidden_line):27 chk = 0 # 1: 왼쪽, 2: 오른쪽28 if ind > 0: # 사다리의 왼쪽에 막대가 있는지 체크29 if pre[j][ind-1] == '-':30 chk = 131 32 if ind < k-1: # 사다리의 오른쪽에 막대가 있는지 체크33 if pre[j][ind] == '-':34 chk = 235 36 if chk == 1: ind -= 137 elif chk == 2: ind += 138 pre_ladder[ladder[i]] = ind39aft_ladder = {}40for i in range(k):41 ind = i42 for j in range(n - hidden_line - 1): # 뒤에서부터 체크43 chk = 0 # 1: 왼쪽, 2: 오른쪽44 if ind > 0: # 사다리의 왼쪽에 막대가 있는지 체크45 if aft[n-hidden_line-j-2][ind-1] == '-':46 chk = 147 48 if ind < k-1: # 사다리의 오른쪽에 막대가 있는지 체크49 if aft[n-hidden_line-j-2][ind] == '-':50 chk = 251 52 if chk == 1: ind -= 153 elif chk == 2: ind += 154 55 aft_ladder[final[i]] = ind56hidden_ladder = ['*'] * (k-1) # 숨겨진 사다리57for c in pre_ladder:58 if abs(pre_ladder[c] - aft_ladder[c]) > 1: # 숨겨진 사다리를 만들 수 없는 경우59 print('x' * (k-1))60 exit()61 62 if pre_ladder[c] == aft_ladder[c] + 1:63 hidden_ladder[aft_ladder[c]] = '-'64 65 if pre_ladder[c] == aft_ladder[c] - 1:66 hidden_ladder[pre_ladder[c]] = '-'67# 검산68for c in pre_ladder:69 if pre_ladder[c] > 0:70 if hidden_ladder[pre_ladder[c]-1] == '-':71 if pre_ladder[c] - 1 != aft_ladder[c]:72 print('x' * (k-1))73 exit()74 75 if pre_ladder[c] < k-1:76 if hidden_ladder[pre_ladder[c]] == '-':77 if pre_ladder[c] + 1 != aft_ladder[c]:78 print('x' * (k-1))79 exit()80result = ''.join(hidden_ladder)81if '--' in result: # 숨겨진 사다리를 만들 수 없는 경우82 print('x' * (k-1))83 exit()84 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful