How to use read_boolean method in autotest

Best Python code snippet using autotest_python

fez_level.py

Source:fez_level.py Github

copy

Full Screen

...34 level_name = self.stream.read_string()35 connections = self.stream.read_object(ListReader, [MapNodeConnectionReader])36 node_type = self.stream.read_object(LevelNodeTypeReader)37 conditions = self.stream.read_object(WinConditionsReader)38 has_lesser_gate = self.stream.read_boolean()39 has_warp_gate = self.stream.read_boolean()40 return MapNode(level_name, connections, node_type, conditions, has_lesser_gate, has_warp_gate)41class MapNodeConnectionReader(BaseTypeReader, TypeReaderPlugin):42 target_type = 'FezEngine.Structure.MapNode+Connection'43 reader_name = 'FezEngine.Readers.MapNodeConnectionReader'44 def read(self):45 face = self.stream.read_object(FaceOrientationReader)46 node = self.stream.read_object(MapNodeReader)47 branch_oversize = self.stream.read_single()48 return MapNodeConnection(face, node, branch_oversize)49class WinConditionsReader(BaseTypeReader, TypeReaderPlugin):50 target_type = 'FezEngine.Structure.WinConditions'51 reader_name = 'FezEngine.Readers.WinConditionsReader'52 def read(self):53 chest_count = self.stream.read_int32()54 locked_door_count = self.stream.read_int32()55 unlocked_door_count = self.stream.read_int32()56 script_ids = self.stream.read_object(ListReader, [Int32Reader])57 cube_shard_count = self.stream.read_int32()58 other_collectible_count = self.stream.read_int32()59 split_up_count = self.stream.read_int32()60 secret_count = self.stream.read_int32()61 return WinConditions(chest_count, locked_door_count, unlocked_door_count, script_ids, cube_shard_count,62 other_collectible_count, split_up_count, secret_count)63class SkyReader(BaseTypeReader, TypeReaderPlugin):64 target_type = 'FezEngine.Structure.Sky'65 reader_name = 'FezEngine.Readers.SkyReader'66 def read(self):67 name = self.stream.read_string()68 background = self.stream.read_string()69 wind_speed = self.stream.read_single()70 density = self.stream.read_single()71 fog_density = self.stream.read_single()72 layers = self.stream.read_object(ListReader, [SkyLayerReader])73 clouds = self.stream.read_object(ListReader, [StringReader])74 shadows = self.stream.read_object(StringReader)75 stars = self.stream.read_object(StringReader)76 cloud_tint = self.stream.read_object(StringReader)77 vertical_tiling = self.stream.read_boolean()78 horizontal_scrolling = self.stream.read_boolean()79 layer_base_height = self.stream.read_single()80 inter_layer_vertical_distance = self.stream.read_single()81 inter_layer_horizontal_distance = self.stream.read_single()82 horizontal_distance = self.stream.read_single()83 vertical_distance = self.stream.read_single()84 layer_base_spacing = self.stream.read_single()85 wind_parallax = self.stream.read_single()86 wind_distance = self.stream.read_single()87 clouds_parallax = self.stream.read_single()88 shadow_opacity = self.stream.read_single()89 foliage_shadows = self.stream.read_boolean()90 no_per_face_layer_x_offset = self.stream.read_boolean()91 layer_base_x_offset = self.stream.read_single()92 return Sky(name, background, wind_speed, density, fog_density, layers, clouds, shadows, stars, cloud_tint,93 vertical_tiling, horizontal_scrolling, layer_base_height, inter_layer_vertical_distance,94 inter_layer_horizontal_distance, horizontal_distance, vertical_distance, layer_base_spacing,95 wind_parallax, wind_distance, clouds_parallax, shadow_opacity, foliage_shadows,96 no_per_face_layer_x_offset, layer_base_x_offset)97class SkyLayerReader(BaseTypeReader, TypeReaderPlugin):98 target_type = 'FezEngine.Structure.SkyLayer'99 reader_name = 'FezEngine.Readers.SkyLayerReader'100 def read(self):101 name = self.stream.read_string()102 in_front = self.stream.read_boolean()103 opacity = self.stream.read_single()104 fog_tint = self.stream.read_single()105 return SkyLayer(name, in_front, opacity, fog_tint)106class TrileSetReader(BaseTypeReader, TypeReaderPlugin):107 target_type = 'FezEngine.Structure.TrileSet'108 reader_name = 'FezEngine.Readers.TrileSetReader'109 def read(self):110 name = self.stream.read_string()111 triles = self.stream.read_object(DictionaryReader, [Int32Reader, TrileReader])112 texture_atlas = self.stream.read_object(Texture2DReader)113 return TrileSet(name, triles, texture_atlas)114class TrileReader(BaseTypeReader, TypeReaderPlugin):115 target_type = 'FezEngine.Structure.Trile'116 reader_name = 'FezEngine.Readers.TrileReader'117 def read(self):118 name = self.stream.read_string()119 cubemap_path = self.stream.read_string()120 size = self.stream.read_vector3()121 offset = self.stream.read_vector3()122 immaterial = self.stream.read_boolean()123 see_through = self.stream.read_boolean()124 thin = self.stream.read_boolean()125 force_hugging = self.stream.read_boolean()126 faces = self.stream.read_object(DictionaryReader, [FaceOrientationReader, CollisionTypeReader])127 geometry = self.stream.read_object(ShaderInstancedIndexedPrimitivesReader,128 [VertexPositionNormalTextureInstanceReader, Vector4Reader])129 actor_settings_type = self.stream.read_object(ActorTypeReader)130 actor_settings_face = self.stream.read_object(FaceOrientationReader)131 surface_type = self.stream.read_object(SurfaceTypeReader)132 atlas_offset = self.stream.read_vector2()133 return Trile(name, cubemap_path, size, offset, immaterial, see_through, thin, force_hugging, faces, geometry,134 actor_settings_type, actor_settings_face, surface_type, atlas_offset)135class LevelReader(BaseTypeReader, TypeReaderPlugin):136 target_type = 'FezEngine.Structure.Level'137 reader_name = 'FezEngine.Readers.LevelReader'138 def read(self):139 name = self.stream.read_object(StringReader)140 size = self.stream.read_vector3()141 starting_position = self.stream.read_object(TrileFaceReader)142 sequence_samples_path = self.stream.read_object(StringReader)143 flat = self.stream.read_boolean()144 skip_postprocess = self.stream.read_boolean()145 base_diffuse = self.stream.read_single()146 base_ambient = self.stream.read_single()147 gomez_halo_name = self.stream.read_object(StringReader)148 halo_filtering = self.stream.read_boolean()149 blinking_alpha = self.stream.read_boolean()150 loops = self.stream.read_boolean()151 water_type = self.stream.read_object(LiquidTypeReader)152 water_height = self.stream.read_single()153 sky_name = self.stream.read_string()154 trile_set_name = self.stream.read_object(StringReader)155 volumes = self.stream.read_object(DictionaryReader, [Int32Reader, VolumeReader])156 scripts = self.stream.read_object(DictionaryReader, [Int32Reader, ScriptReader])157 song_name = self.stream.read_object(StringReader)158 fap_fadeout_start = self.stream.read_int32()159 fap_fadeout_length = self.stream.read_int32()160 triles = self.stream.read_object(DictionaryReader, [TrileEmplacementReader, TrileInstanceReader])161 art_objects = self.stream.read_object(DictionaryReader, [Int32Reader, ArtObjectInstanceReader])162 background_planes = self.stream.read_object(DictionaryReader, [Int32Reader, BackgroundPlaneReader])163 groups = self.stream.read_object(DictionaryReader, [Int32Reader, TrileGroupReader])164 nonplayer_characters = self.stream.read_object(DictionaryReader, [Int32Reader, NpcInstanceReader])165 paths = self.stream.read_object(DictionaryReader, [Int32Reader, MovementPathReader])166 descending = self.stream.read_boolean()167 rainy = self.stream.read_boolean()168 low_pass = self.stream.read_boolean()169 muted_loops = self.stream.read_object(ListReader, [StringReader])170 ambience_tracks = self.stream.read_object(ListReader, [AmbienceTrackReader])171 node_type = self.stream.read_object(LevelNodeTypeReader)172 quantum = self.stream.read_boolean()173 return Level(name, size, starting_position, sequence_samples_path, flat, skip_postprocess, base_diffuse,174 base_ambient, gomez_halo_name, halo_filtering, blinking_alpha, loops, water_type, water_height,175 sky_name, trile_set_name, volumes, scripts, song_name, fap_fadeout_start, fap_fadeout_length,176 triles, art_objects, background_planes, groups, nonplayer_characters, paths, descending, rainy,177 low_pass, muted_loops, ambience_tracks, node_type, quantum)178class VolumeReader(BaseTypeReader, TypeReaderPlugin):179 target_type = 'FezEngine.Structure.Volume'180 reader_name = 'FezEngine.Readers.VolumeReader'181 def read(self):182 orientations = self.stream.read_object(ArrayReader, [FaceOrientationReader])183 v_from = self.stream.read_vector3()184 v_to = self.stream.read_vector3()185 actor_settings = self.stream.read_object(VolumeActorSettingsReader)186 return Volume(orientations, v_from, v_to, actor_settings)187class TrileEmplacementReader(ValueTypeReader, TypeReaderPlugin):188 target_type = 'FezEngine.Structure.TrileEmplacement'189 reader_name = 'FezEngine.Readers.TrileEmplacementReader'190 def read(self):191 return TrileEmplacement._make(self.stream.unpack('3i'))192class TrileInstanceReader(BaseTypeReader, TypeReaderPlugin):193 target_type = 'FezEngine.Structure.TrileInstance'194 reader_name = 'FezEngine.Readers.TrileInstanceReader'195 def read(self):196 values = self.stream.unpack('3f i B ?')197 position = Vector3._make(values[0:3])198 trile_id = values[3]199 orientation = values[4]200 actor_settings = None201 has_actor_settings = values[5]202 if has_actor_settings:203 actor_settings = self.stream.read_object(InstanceActorSettingsReader)204 overlapped_triles = self.stream.read_object(ListReader, [TrileInstanceReader])205 return TrileInstance(position, trile_id, orientation, actor_settings, overlapped_triles)206class ArtObjectInstanceReader(BaseTypeReader, TypeReaderPlugin):207 target_type = 'FezEngine.Structure.ArtObjectInstance'208 reader_name = 'FezEngine.Readers.ArtObjectInstanceReader'209 def read(self):210 name = self.stream.read_string()211 values = self.stream.unpack('3f 4f 3f')212 position = Vector3._make(values[0:3])213 rotation = Quaternion._make(values[3:7])214 scale = Vector3._make(values[7:10])215 actor_settings = self.stream.read_object(ArtObjectActorSettingsReader)216 return ArtObjectInstance(name, position, rotation, scale, actor_settings)217class BackgroundPlaneReader(BaseTypeReader, TypeReaderPlugin):218 target_type = 'FezEngine.Structure.BackgroundPlane'219 reader_name = 'FezEngine.Readers.BackgroundPlaneReader'220 def read(self):221 position = self.stream.read_vector3()222 rotation = self.stream.read_quaternion()223 scale = self.stream.read_vector3()224 size = self.stream.read_vector3()225 texture_name = self.stream.read_string()226 light_map = self.stream.read_boolean()227 allow_overbrightness = self.stream.read_boolean()228 filter_ = self.stream.read_color()229 animated = self.stream.read_boolean()230 doublesided = self.stream.read_boolean()231 opacity = self.stream.read_single()232 attached_group = self.stream.read_object(Int32Reader)233 billboard = self.stream.read_boolean()234 sync_with_samples = self.stream.read_boolean()235 crosshatch = self.stream.read_boolean()236 unknown = self.stream.read_boolean()237 always_on_top = self.stream.read_boolean()238 fullbright = self.stream.read_boolean()239 pixelated_lightmap = self.stream.read_boolean()240 x_texture_repeat = self.stream.read_boolean()241 y_texture_repeat = self.stream.read_boolean()242 clamp_texture = self.stream.read_boolean()243 actor_type = self.stream.read_object(ActorTypeReader)244 attached_plane = self.stream.read_object(Int32Reader)245 parallax_factor = self.stream.read_single()246 return BackgroundPlane(position, rotation, scale, size, texture_name, light_map, allow_overbrightness, filter_,247 animated, doublesided, opacity, attached_group, billboard, sync_with_samples, crosshatch,248 unknown, always_on_top, fullbright, pixelated_lightmap, x_texture_repeat,249 y_texture_repeat, clamp_texture, actor_type, attached_plane, parallax_factor)250class TrileGroupReader(BaseTypeReader, TypeReaderPlugin):251 target_type = 'FezEngine.Structure.TrileGroup'252 reader_name = 'FezEngine.Readers.TrileGroupReader'253 def read(self):254 triles = self.stream.read_object(ListReader, [TrileInstanceReader])255 path = self.stream.read_object(MovementPathReader)256 heavy = self.stream.read_boolean()257 actor_type = self.stream.read_object(ActorTypeReader)258 geyser_offset = self.stream.read_single()259 geyser_pause_for = self.stream.read_single()260 geyser_lift_for = self.stream.read_single()261 geyser_apex_height = self.stream.read_single()262 spin_center = self.stream.read_vector3()263 spin_clockwise = self.stream.read_boolean()264 spin_frequency = self.stream.read_single()265 spin_needs_triggering = self.stream.read_boolean()266 spin_180_degrees = self.stream.read_boolean()267 fall_on_rotate = self.stream.read_boolean()268 spin_offset = self.stream.read_single()269 associated_sound = self.stream.read_object(StringReader)270 return TrileGroup(triles, path, heavy, actor_type, geyser_offset, geyser_pause_for, geyser_lift_for,271 geyser_apex_height, spin_center, spin_clockwise, spin_frequency, spin_needs_triggering,272 spin_180_degrees, fall_on_rotate, spin_offset, associated_sound)273class TrileFaceReader(BaseTypeReader, TypeReaderPlugin):274 target_type = 'FezEngine.Structure.TrileFace'275 reader_name = 'FezEngine.Readers.TrileFaceReader'276 def read(self):277 trile_id = self.stream.read_object(TrileEmplacementReader)278 face = self.stream.read_object(FaceOrientationReader)279 return TrileFace(trile_id, face)280class NpcInstanceReader(BaseTypeReader, TypeReaderPlugin):281 target_type = 'FezEngine.Structure.NpcInstance'282 reader_name = 'FezEngine.Readers.NpcInstanceReader'283 def read(self):284 name = self.stream.read_string()285 position = self.stream.read_vector3()286 destination_offset = self.stream.read_vector3()287 walk_speed = self.stream.read_single()288 randomize_speech = self.stream.read_boolean()289 say_first_speech_line_once = self.stream.read_boolean()290 avoids_gomez = self.stream.read_boolean()291 actor_type = self.stream.read_object(ActorTypeReader)292 speech = self.stream.read_object(ListReader, [SpeechLineReader])293 actions = self.stream.read_object(DictionaryReader, [NpcActionReader, NpcActionContentReader])294 return NpcInstance(name, position, destination_offset, walk_speed, randomize_speech, say_first_speech_line_once,295 avoids_gomez, actor_type, speech, actions)296class MovementPathReader(BaseTypeReader, TypeReaderPlugin):297 target_type = 'FezEngine.Structure.MovementPath'298 reader_name = 'FezEngine.Readers.MovementPathReader'299 def read(self):300 segments = self.stream.read_object(ListReader, [PathSegmentReader])301 needs_trigger = self.stream.read_boolean()302 end_behavior = self.stream.read_object(PathEndBehaviorReader)303 sound_name = self.stream.read_object(StringReader)304 is_spline = self.stream.read_boolean()305 offset_seconds = self.stream.read_single()306 save_trigger = self.stream.read_boolean()307 return MovementPath(segments, needs_trigger, end_behavior, sound_name, is_spline, offset_seconds, save_trigger)308class AmbienceTrackReader(BaseTypeReader, TypeReaderPlugin):309 target_type = 'FezEngine.Structure.AmbienceTrack'310 reader_name = 'FezEngine.Readers.AmbienceTrackReader'311 def read(self):312 name = self.stream.read_object(StringReader)313 dawn = self.stream.read_boolean()314 day = self.stream.read_boolean()315 dusk = self.stream.read_boolean()316 night = self.stream.read_boolean()317 return AmbienceTrack(name, dawn, day, dusk, night)318class VolumeActorSettingsReader(BaseTypeReader, TypeReaderPlugin):319 target_type = 'FezEngine.Structure.VolumeActorSettings'320 reader_name = 'FezEngine.Readers.VolumeActorSettingsReader'321 def read(self):322 faraway_plane_offset = self.stream.read_vector2()323 is_point_of_interest = self.stream.read_boolean()324 dot_dialogue = self.stream.read_object(ListReader, [DotDialogueLineReader])325 water_locked = self.stream.read_boolean()326 code_pattern = self.stream.read_object(ArrayReader, [CodeInputReader])327 is_blackhole = self.stream.read_boolean()328 needs_trigger = self.stream.read_boolean()329 is_secret_passage = self.stream.read_boolean()330 return VolumeActorSettings(faraway_plane_offset, is_point_of_interest, dot_dialogue, water_locked, code_pattern,331 is_blackhole, needs_trigger, is_secret_passage)332class DotDialogueLineReader(BaseTypeReader, TypeReaderPlugin):333 target_type = 'FezEngine.Structure.DotDialogueLine'334 reader_name = 'FezEngine.Readers.DotDialogueLineReader'335 def read(self):336 resource_text = self.stream.read_object(StringReader)337 grouped = self.stream.read_boolean()338 return DotDialogueLine(resource_text, grouped)339class ScriptReader(BaseTypeReader, TypeReaderPlugin):340 target_type = 'FezEngine.Structure.Scripting.Script'341 reader_name = 'FezEngine.Readers.ScriptReader'342 def read(self):343 name = self.stream.read_string()344 timeout = self.stream.read_object(TimeSpanReader)345 triggers = self.stream.read_object(ListReader, [ScriptTriggerReader])346 conditions = self.stream.read_object(ListReader, [ScriptConditionReader])347 actions = self.stream.read_object(ListReader, [ScriptActionReader])348 one_time = self.stream.read_boolean()349 triggerless = self.stream.read_boolean()350 ignore_end_triggers = self.stream.read_boolean()351 level_wide_one_time = self.stream.read_boolean()352 disabled = self.stream.read_boolean()353 is_win_condition = self.stream.read_boolean()354 return Script(name, timeout, triggers, conditions, actions, one_time, triggerless, ignore_end_triggers,355 level_wide_one_time, disabled, is_win_condition)356class ScriptTriggerReader(BaseTypeReader, TypeReaderPlugin):357 target_type = 'FezEngine.Structure.Scripting.ScriptTrigger'358 reader_name = 'FezEngine.Readers.ScriptTriggerReader'359 def read(self):360 entity = self.stream.read_object(EntityReader)361 event = self.stream.read_string()362 return ScriptTrigger(entity, event)363class ScriptActionReader(BaseTypeReader, TypeReaderPlugin):364 target_type = 'FezEngine.Structure.Scripting.ScriptAction'365 reader_name = 'FezEngine.Readers.ScriptActionReader'366 def read(self):367 entity = self.stream.read_object(EntityReader)368 operation = self.stream.read_string()369 arguments = self.stream.read_object(ArrayReader, [StringReader])370 killswitch = self.stream.read_boolean()371 blocking = self.stream.read_boolean()372 return ScriptAction(entity, operation, arguments, killswitch, blocking)373class ScriptConditionReader(BaseTypeReader, TypeReaderPlugin):374 target_type = 'FezEngine.Structure.Scripting.ScriptCondition'375 reader_name = 'FezEngine.Readers.ScriptConditionReader'376 def read(self):377 entity = self.stream.read_object(EntityReader)378 operator = self.stream.read_object(ComparisonOperatorReader)379 property_ = self.stream.read_string()380 value = self.stream.read_string()381 return ScriptCondition(entity, operator, property_, value)382class EntityReader(BaseTypeReader, TypeReaderPlugin):383 target_type = 'FezEngine.Structure.Scripting.Entity'384 reader_name = 'FezEngine.Readers.EntityReader'385 def read(self):386 entity_type = self.stream.read_string()387 identifier = self.stream.read_object(Int32Reader)388 return Entity(entity_type, identifier)389class InstanceActorSettingsReader(BaseTypeReader, TypeReaderPlugin):390 target_type = 'FezEngine.Structure.InstanceActorSettings'391 reader_name = 'FezEngine.Readers.InstanceActorSettingsReader'392 def read(self):393 contained_trile = self.stream.read_object(Int32Reader)394 sign_text = self.stream.read_object(StringReader)395 sequence = self.stream.read_object(ArrayReader, [BooleanReader])396 sequence_sample_name = self.stream.read_object(StringReader)397 sequence_alternate_sample_name = self.stream.read_object(StringReader)398 host_volume = self.stream.read_object(Int32Reader)399 return InstanceActorSettings(contained_trile, sign_text, sequence, sequence_sample_name,400 sequence_alternate_sample_name, host_volume)401class ArtObjectActorSettingsReader(BaseTypeReader, TypeReaderPlugin):402 target_type = 'FezEngine.Structure.ArtObjectActorSettings'403 reader_name = 'FezEngine.Readers.ArtObjectActorSettingsReader'404 def read(self):405 inactive = self.stream.read_boolean()406 contained_trile = self.stream.read_object(ActorTypeReader)407 attached_group = self.stream.read_object(Int32Reader)408 spin_view = self.stream.read_object(ViewpointReader)409 spin_every = self.stream.read_single()410 spin_offset = self.stream.read_single()411 off_center = self.stream.read_boolean()412 rotation_center = self.stream.read_vector3()413 vibration_pattern = self.stream.read_object(ArrayReader, [VibrationMotorReader])414 code_pattern = self.stream.read_object(ArrayReader, [CodeInputReader])415 segment = self.stream.read_object(PathSegmentReader)416 next_node = self.stream.read_object(Int32Reader)417 destination_level = self.stream.read_object(StringReader)418 treasure_map_name = self.stream.read_object(StringReader)419 invisible_sides = self.stream.read_object(ArrayReader, [FaceOrientationReader])420 timeswitch_wind_back_speed = self.stream.read_single()421 return ArtObjectActorSettings(inactive, contained_trile, attached_group, spin_view, spin_every, spin_offset,422 off_center, rotation_center, vibration_pattern, code_pattern, segment, next_node,423 destination_level, treasure_map_name, invisible_sides, timeswitch_wind_back_speed)424class PathSegmentReader(BaseTypeReader, TypeReaderPlugin):425 target_type = 'FezEngine.Structure.PathSegment'426 reader_name = 'FezEngine.Readers.PathSegmentReader'427 def read(self):428 destination = self.stream.read_vector3()429 duration = self.stream.read_object(TimeSpanReader)430 wait_time_on_start = self.stream.read_object(TimeSpanReader)431 wait_time_on_finish = self.stream.read_object(TimeSpanReader)432 acceleration = self.stream.read_single()433 deceleration = self.stream.read_single()434 jitter_factor = self.stream.read_single()435 orientation = self.stream.read_quaternion()436 custom_data = None437 has_custom_data = self.stream.read_boolean()438 if has_custom_data:439 custom_data = self.stream.read_object(CameraNodeDataReader)440 return PathSegment(destination, duration, wait_time_on_start, wait_time_on_finish, acceleration, deceleration,441 jitter_factor, orientation, custom_data)442class SpeechLineReader(BaseTypeReader, TypeReaderPlugin):443 target_type = 'FezEngine.Structure.SpeechLine'444 reader_name = 'FezEngine.Readers.SpeechLineReader'445 def read(self):446 text = self.stream.read_object(StringReader)447 override_content = self.stream.read_object(NpcActionContentReader)448 return SpeechLine(text, override_content)449class NpcActionContentReader(BaseTypeReader, TypeReaderPlugin):450 target_type = 'FezEngine.Structure.NpcActionContent'451 reader_name = 'FezEngine.Readers.NpcActionContentReader'452 def read(self):453 animation_name = self.stream.read_object(StringReader)454 sound_name = self.stream.read_object(StringReader)455 return NpcActionContent(animation_name, sound_name)456class CameraNodeDataReader(BaseTypeReader, TypeReaderPlugin):457 target_type = 'FezEngine.Structure.CameraNodeData'458 reader_name = 'FezEngine.Readers.CameraNodeDataReader'459 def read(self):460 perspective = self.stream.read_boolean()461 pixels_per_trixel = self.stream.read_int32()462 sound_name = self.stream.read_object(StringReader)...

Full Screen

Full Screen

RemoteProcessClient.py

Source:RemoteProcessClient.py Github

copy

Full Screen

...34 self.write_int(2)35 def read_game_context(self):36 message_type = self.read_enum(RemoteProcessClient.MessageType)37 self.ensure_message_type(message_type, RemoteProcessClient.MessageType.GAME_CONTEXT)38 if not self.read_boolean():39 return None40 return Game(41 self.read_int(),42 self.read_int(), self.read_int(),43 self.read_int(), self.read_double(),44 self.read_int(), self.read_int(), self.read_int(), self.read_int(),45 self.read_int(), self.read_double(),46 self.read_int(), self.read_int(),47 self.read_int(), self.read_int(), self.read_int(),48 self.read_double(), self.read_double(), self.read_double(),49 self.read_double(), self.read_double(),50 self.read_double(), self.read_double(),51 self.read_int(), self.read_double(), self.read_int(), self.read_int(),52 self.read_int(), self.read_int(), self.read_int(),53 self.read_int(), self.read_int()54 )55 def read_player_context(self):56 message_type = self.read_enum(RemoteProcessClient.MessageType)57 if message_type == RemoteProcessClient.MessageType.GAME_OVER:58 return None59 self.ensure_message_type(message_type, RemoteProcessClient.MessageType.PLAYER_CONTEXT)60 return PlayerContext(self.read_trooper(), self.read_world()) if self.read_boolean() else None61 def write_move(self, move):62 self.write_enum(RemoteProcessClient.MessageType.MOVE)63 if move is None:64 self.write_boolean(False)65 else:66 self.write_boolean(True)67 self.write_enum(move.action)68 self.write_enum(move.direction)69 self.write_int(move.x)70 self.write_int(move.y)71 def close(self):72 self.socket.close()73 def read_world(self):74 if not self.read_boolean():75 return None76 return World(77 self.read_int(), self.read_int(), self.read_int(), self.read_players(),78 self.read_troopers(), self.read_bonuses(), self.read_cells(), self.read_cell_visibilities()79 )80 def read_players(self):81 player_count = self.read_int()82 if player_count < 0:83 return None84 players = []85 for player_index in xrange(player_count):86 if self.read_boolean():87 player = Player(88 self.read_long(), self.read_string(), self.read_int(), self.read_boolean(),89 self.read_int(), self.read_int()90 )91 players.append(player)92 else:93 players.append(None)94 return players95 def read_troopers(self):96 trooper_count = self.read_int()97 if trooper_count < 0:98 return None99 troopers = []100 for trooper_index in xrange(trooper_count):101 troopers.append(self.read_trooper())102 return troopers103 def read_trooper(self):104 if not self.read_boolean():105 return None106 return Trooper(107 self.read_long(), self.read_int(), self.read_int(), self.read_long(),108 self.read_int(), self.read_boolean(), self.read_enum(TrooperType), self.read_enum(TrooperStance),109 self.read_int(), self.read_int(), self.read_int(), self.read_int(),110 self.read_double(), self.read_double(), self.read_int(),111 self.read_int(), self.read_int(), self.read_int(), self.read_int(),112 self.read_boolean(), self.read_boolean(), self.read_boolean()113 )114 def read_bonuses(self):115 bonus_count = self.read_int()116 if bonus_count < 0:117 return None118 bonuses = []119 for bonus_index in xrange(bonus_count):120 if self.read_boolean():121 bonus = Bonus(122 self.read_long(), self.read_int(), self.read_int(), self.read_enum(BonusType)123 )124 bonuses.append(bonus)125 else:126 bonuses.append(None)127 return bonuses128 def read_cells(self):129 if self.cells is not None:130 return self.cells131 width = self.read_int()132 if width < 0:133 return None134 self.cells = []135 for x in xrange(width):136 height = self.read_int()137 if height < 0:138 self.cells.append(None)139 continue140 self.cells.append([])141 for y in xrange(height):142 self.cells[x].append(self.read_enum(CellType))143 return self.cells144 def read_cell_visibilities(self):145 if self.cell_visibilities is not None:146 return self.cell_visibilities147 world_width = self.read_int()148 if world_width < 0:149 return None150 world_height = self.read_int()151 if world_height < 0:152 return None153 stance_count = self.read_int()154 if stance_count < 0:155 return None156 self.cell_visibilities = self.read_bytes(world_width * world_height * world_width * world_height * stance_count)157 return self.cell_visibilities158 def ensure_message_type(self, actual_type, expected_type):159 if actual_type != expected_type:160 raise ValueError("Received wrong message [actual=%s, expected=%s]." % (actual_type, expected_type))161 def read_enum(self, enum_class):162 byte_array = self.read_bytes(RemoteProcessClient.SIGNED_BYTE_SIZE_BYTES)163 value = struct.unpack(RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + "b", byte_array)[0]164 for enum_key, enum_value in enum_class.__dict__.iteritems():165 if not str(enum_key).startswith("__") and value == enum_value:166 return enum_value167 return None168 def write_enum(self, value):169 self.write_bytes(struct.pack(RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + "b", -1 if value is None else value))170 def read_string(self):171 length = self.read_int()172 if length == -1:173 return None174 byte_array = self.read_bytes(length)175 return byte_array.decode("utf-8")176 def write_string(self, value):177 if value is None:178 self.write_int(-1)179 return180 byte_array = value.encode("utf-8")181 self.write_int(len(byte_array))182 self.write_bytes(byte_array)183 def read_boolean(self):184 byte_array = self.read_bytes(RemoteProcessClient.SIGNED_BYTE_SIZE_BYTES)185 return struct.unpack(RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + "b", byte_array)[0] != 0186 def read_boolean_array(self, count):187 byte_array = self.read_bytes(count * RemoteProcessClient.SIGNED_BYTE_SIZE_BYTES)188 unpacked_bytes = struct.unpack(RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + str(count) + "b", byte_array)189 return [unpacked_bytes[i] != 0 for i in xrange(count)]190 def write_boolean(self, value):191 self.write_bytes(struct.pack(RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + "b", 1 if value else 0))192 def read_int(self):193 byte_array = self.read_bytes(RemoteProcessClient.INTEGER_SIZE_BYTES)194 return struct.unpack(RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + "i", byte_array)[0]195 def write_int(self, value):196 self.write_bytes(struct.pack(RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + "i", value))197 def read_long(self):...

Full Screen

Full Screen

data_reader.py

Source:data_reader.py Github

copy

Full Screen

1from struct import unpack2from uuid import UUID3from .nbt import parse_nbt4def read_boolean(reader):5 return bool(unpack('>B', reader.read(1))[0])6def read_sbyte(reader):7 return unpack('>b', reader.read(1))[0]8def read_byte(reader):9 return unpack('>B', reader.read(1))[0]10def read_short(reader):11 return unpack('>h', reader.read(2))[0]12def read_ushort(reader):13 return unpack('>H', reader.read(2))[0]14def read_int(reader):15 return unpack('>i', reader.read(4))[0]16def read_long(reader):17 return unpack('>q', reader.read(8))[0]18def read_float(reader):19 return unpack('>f', reader.read(4))[0]20def read_double(reader):21 return unpack('>d', reader.read(8))[0]22def read_string(reader):23 length = read_varint(reader)24 string = reader.read(length).decode('utf8')25 return string26def read_chat(reader):27 return read_string(reader)28def read_identifier(reader):29 return read_string(reader)30def read_varint(reader):31 num_read = 032 result = 033 while True:34 read = read_byte(reader)35 value = read & 0b0111111136 result |= value << (7 * num_read)37 num_read += 138 if num_read > 5:39 raise Exception('VarInt is too large')40 if read & 0b10000000 == 0:41 break42 return result43def read_varlong(reader):44 num_read = 045 result = 046 while True:47 read = read_byte(reader)48 value = read & 0b0111111149 result |= value << (7 * num_read)50 num_read += 151 if num_read > 10:52 raise Exception('VarLong is too large')53 if read & 0b10000000 == 0:54 break55 return result56def _read_particle(reader):57 particle_id = read_varint(reader)58 if particle_id == 3:59 return particle_id, read_varint(reader)60 elif particle_id == 14:61 return particle_id, read_float(reader), read_float(reader), read_float(reader), read_float(reader)62 elif particle_id == 23:63 return particle_id, read_varint(reader)64 elif particle_id == 32:65 return particle_id, read_slot(reader)66 else:67 return particle_id,68def _read_entity_metadata_element(reader):69 value_type = read_varint(reader)70 if value_type == 0:71 return read_byte(reader)72 elif value_type == 1:73 return read_varint(reader)74 elif value_type == 2:75 return read_float(reader)76 elif value_type == 3:77 return read_string(reader)78 elif value_type == 4:79 return read_chat(reader)80 elif value_type == 5:81 if read_boolean(reader):82 return read_chat(reader)83 else:84 return None85 elif value_type == 6:86 return read_slot(reader)87 elif value_type == 7:88 return read_boolean(reader)89 elif value_type == 8:90 return (read_float(reader), read_float(reader), read_float(reader))91 elif value_type == 9:92 return read_position(reader)93 elif value_type == 10:94 if read_boolean(reader):95 return read_position(reader)96 else:97 return None98 elif value_type == 11:99 return read_varint(reader)100 elif value_type == 12:101 if read_boolean(reader):102 return read_uuid(reader)103 else:104 return None105 elif value_type == 13:106 return read_varint(reader)107 elif value_type == 14:108 return read_nbt(reader)109 elif value_type == 15:110 return _read_particle(reader)111def read_entity_metadata(reader):112 index = read_byte(reader)113 if index != 0xff:114 value_type = read_varint(reader)115 if value_type == 0:116 return read_byte(reader)117 elif value_type == 1:118 return read_varint(reader)119 elif value_type == 2:120 return read_float(reader)121 elif value_type == 3:122 return read_string(reader)123 elif value_type == 4:124 return read_chat(reader)125 elif value_type == 5:126 if read_boolean(reader):127 return read_chat(reader)128 else:129 return None130 elif value_type == 6:131 return read_slot(reader)132 elif value_type == 7:133 return read_boolean(reader)134 elif value_type == 8:135 return read_float(reader), read_float(reader), read_float(reader)136 elif value_type == 9:137 return read_position(reader)138 elif value_type == 10:139 if read_boolean(reader):140 return read_position(reader)141 else:142 return None143 elif value_type == 11:144 return read_varint(reader)145 elif value_type == 12:146 if read_boolean(reader):147 return read_uuid(reader)148 else:149 return None150 elif value_type == 13:151 if read_boolean(reader):152 return read_varint(reader)153 else:154 return None155 elif value_type == 14:156 return read_nbt(reader)157 elif value_type == 15:158 return _read_particle(reader)159 elif value_type == 16:160 return read_varint(reader)161 elif value_type == 17:162 if read_boolean(reader):163 return read_varint(reader)164 else:165 return None166 elif value_type == 18:167 return read_varint(reader)168 else:169 raise Exception('Invalid entity metadata type')170def read_slot(reader):171 return read_nbt(reader)172def read_nbt(reader):173 return parse_nbt(reader)174def read_position(reader):175 value = read_long(reader)176 x = (value & (0x3FFFFFF << 38)) >> 38...

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 autotest 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