forked from turicfr/CPPS-PCL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
penguin.py
63 lines (60 loc) · 1.88 KB
/
penguin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Penguin(object):
def __init__(self, penguin_id, name, member, color, head, face, neck, body, hand, feet, pin, background, x=None, y=None, frame=None, unknown=None, rank=None):
self.id = penguin_id
self.name = name
self.member = member
self.color = color
self.head = head
self.face = face
self.neck = neck
self.body = body
self.hand = hand
self.feet = feet
self.pin = pin
self.background = background
self.x = x
self.y = y
self.frame = frame
# self.??? = unknown
self.rank = rank
@classmethod
def from_player(cls, player):
if not player:
raise ValueError("Invalid player")
player = player.split("|")
penguin_id = int(player[0])
name = player[1]
member = int(player[2])
color = int(player[3], 0)
head = int(player[4])
face = int(player[5])
neck = int(player[6])
body = int(player[7])
hand = int(player[8])
feet = int(player[9])
pin = int(player[10])
background = int(player[11])
if len(player) > 16:
x = int(player[12])
y = int(player[13])
try:
frame = int(player[14])
except ValueError:
frame = None
unknown = int(player[15])
rank = int(player[16])
return cls(penguin_id, name, member, color, head, face, neck, body, hand, feet, pin, background, x, y, frame, unknown, rank)
if len(player) > 12:
# ??? = int(player[12])
return cls(penguin_id, name, member, color, head, face, neck, body, hand, feet, pin, background)
return cls(penguin_id, name, member, color, head, face, neck, body, hand, feet, pin, background)
class Buddy(Penguin):
def __init__(self, penguin_id, name, online):
super(Buddy, self).__init__(penguin_id, name, None, None, None, None, None, None, None, None, None, None)
self.online = online
@classmethod
def from_buddy(cls, buddy):
if not buddy:
raise ValueError("Invalid buddy")
penguin_id, name, online = buddy.split("|")
return cls(int(penguin_id), name, online == "1")