Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.player[player_int].character = enums.Character.UNKNOWN_CHARACTER
return False
if label == "cursor_x":
self.player[player_int].cursor_x = unpack('> 8
self.player[player_int].action_counter = temp
return False
if label == "action_frame":
temp = unpack('
try:
data = self.sock.recvfrom(9096)[0].decode('utf-8').splitlines()
except socket.timeout:
return None
# Strip the null terminator, pad with zeros, then convert to bytes
return data[0], binascii.unhexlify(data[1].strip('\x00').zfill(8))
"""Represents the state of a single player"""
class PlayerState:
character = enums.Character.UNKNOWN_CHARACTER
x = 0
y = 0
percent = 0
stock = 0
facing = True
action = enums.Action.UNKNOWN_ANIMATION
action_counter = 0
action_frame = 0
invulnerable = False
invulnerability_left = 0
hitlag_frames_left = 0
hitstun_frames_left = 0
charging_smash = 0
jumps_left = 0
on_ground = True
speed_air_x_self = 0
speed_y_self = 0
speed_x_attack = 0
speed_y_attack = 0
speed_ground_x_self = 0
cursor_x = 0
cursor_y = 0
def isbmove(self, character, action):
# If we're missing it, don't call it a B move
if action == Action.UNKNOWN_ANIMATION:
return False
# Don't consider peach float to be a B move
# But the rest of her float aerials ARE
if character == Character.PEACH and action in [Action.LASER_GUN_PULL, \
Action.NEUTRAL_B_CHARGING, Action.NEUTRAL_B_ATTACKING]:
return False
# Peach smashes also shouldn't be B moves
if character == Character.PEACH and action in [Action.SWORD_DANCE_2_MID, Action.SWORD_DANCE_1, \
Action.SWORD_DANCE_2_HIGH]:
return False
if Action.LASER_GUN_PULL.value <= action.value:
return True
return False
hitbox_4_status = False
hitbox_1_x = 0
hitbox_1_y = 0
hitbox_2_x = 0
hitbox_2_y = 0
hitbox_3_x = 0
hitbox_3_y = 0
hitbox_4_x = 0
hitbox_4_y = 0
# For internal use only, ignore these
next_x = 0
next_y = 0
prev_x = 0
prev_x = 0
# Start from a standing state
prev_action = Action.UNKNOWN_ANIMATION
"""Produces a list representation of the player's state"""
def tolist(self):
thelist = []
thelist.append(self.x)
thelist.append(self.y)
thelist.append(self.percent)
thelist.append(self.stock)
thelist.append(int(self.facing))
thelist.append(self.action.value)
#We're... gonna leave this one out for now since it's a bit irrelevant
#thelist.append(self.action_counter)
thelist.append(self.action_frame)
thelist.append(int(self.invulnerable))
thelist.append(self.hitlag_frames_left)
thelist.append(self.hitstun_frames_left)