albibong 1.0.1__tar.gz → 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {albibong-1.0.1 → albibong-1.0.3}/.gitignore +7 -0
  2. {albibong-1.0.1 → albibong-1.0.3}/PKG-INFO +1 -1
  3. {albibong-1.0.1 → albibong-1.0.3}/pyproject.toml +1 -1
  4. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/__init__.py +32 -27
  5. albibong-1.0.3/src/albibong/__main__.py +6 -0
  6. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/character.py +3 -0
  7. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/logger.py +13 -2
  8. albibong-1.0.3/src/albibong/classes/utils.py +9 -0
  9. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/world_data.py +80 -40
  10. albibong-1.0.3/src/albibong/resources/EventCode.py +587 -0
  11. albibong-1.0.3/src/albibong/resources/event_code.json +585 -0
  12. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/resources/items.json +15569 -15530
  13. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/threads/http_server.py +3 -3
  14. albibong-1.0.1/src/albibong/__main__.py +0 -4
  15. albibong-1.0.1/src/albibong/resources/EventCode.py +0 -579
  16. albibong-1.0.1/src/albibong/resources/event_code.json +0 -577
  17. {albibong-1.0.1 → albibong-1.0.3}/LICENSE +0 -0
  18. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/__init__.py +0 -0
  19. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/coords.py +0 -0
  20. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/dungeon.py +0 -0
  21. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/item.py +0 -0
  22. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/location.py +0 -0
  23. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/classes/packet_handler.py +0 -0
  24. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/No Equipment.png +0 -0
  25. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/assets/index-BFSx0nua.css +0 -0
  26. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/assets/index-DAndaN_4.js +0 -0
  27. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/fame.png +0 -0
  28. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/index.html +0 -0
  29. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/re_spec.png +0 -0
  30. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/silver.png +0 -0
  31. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/gui_dist/vite.svg +0 -0
  32. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/__init__.py +0 -0
  33. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/command_type.py +0 -0
  34. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/crc_calculator.py +0 -0
  35. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/event_data.py +0 -0
  36. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/message_type.py +0 -0
  37. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/number_serializer.py +0 -0
  38. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/operation_request.py +0 -0
  39. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/operation_response.py +0 -0
  40. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/photon_packet_parser.py +0 -0
  41. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/protocol16_deserializer.py +0 -0
  42. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/protocol16_type.py +0 -0
  43. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/photon_packet_parser/segmented_packet.py +0 -0
  44. {albibong-1.0.1 → albibong-1.0.3/src/albibong}/requirements.txt +0 -0
  45. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/resources/OperationCode.py +0 -0
  46. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/resources/maps.json +0 -0
  47. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/resources/operation_code.json +0 -0
  48. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/threads/__init__.py +0 -0
  49. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/threads/packet_handler_thread.py +0 -0
  50. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/threads/sniffer_thread.py +0 -0
  51. {albibong-1.0.1 → albibong-1.0.3}/src/albibong/threads/websocket_server.py +0 -0
@@ -1,6 +1,13 @@
1
1
  # Created by https://www.toptal.com/developers/gitignore/api/python,macos
2
2
  # Edit at https://www.toptal.com/developers/gitignore?templates=python,macos
3
3
 
4
+
5
+ ## Additional
6
+ dump/
7
+ log/
8
+ pcap/
9
+ .vscode
10
+
4
11
  ### macOS ###
5
12
  # General
6
13
  .DS_Store
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: albibong
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: A cross-platform Albion Online damage, fame, and dungeon tracker
5
5
  Project-URL: Homepage, https://github.com/imjangkar/albibong
6
6
  Project-URL: Issues, https://github.com/imjangkar/albibong/issues
@@ -19,7 +19,7 @@ albibong = "albibong:main"
19
19
 
20
20
  [project]
21
21
  name = "albibong"
22
- version = "1.0.1"
22
+ version = "1.0.3"
23
23
  authors = [
24
24
  { name="imjangkar", email="imjangkar@gmail.com" },
25
25
  ]
@@ -1,4 +1,5 @@
1
1
  import queue
2
+ import random
2
3
  import sys
3
4
  from time import sleep
4
5
 
@@ -13,7 +14,7 @@ from albibong.threads.sniffer_thread import SnifferThread
13
14
  from albibong.threads.websocket_server import get_ws_server
14
15
 
15
16
  logger = Logger(__name__, stdout=True, log_to_file=False)
16
-
17
+ PORT = random.randrange(8500,8999)
17
18
 
18
19
  def read_pcap(path):
19
20
  packet_handler = PacketHandler()
@@ -22,7 +23,7 @@ def read_pcap(path):
22
23
  packet_handler.handle(packet)
23
24
 
24
25
 
25
- def sniff():
26
+ def sniff(useWebview):
26
27
  _sentinel = object()
27
28
  packet_queue = queue.Queue()
28
29
 
@@ -40,39 +41,43 @@ def sniff():
40
41
  ws_server = get_ws_server()
41
42
  ws_server.start()
42
43
 
43
- http_server = HttpServerThread(name="http_server")
44
- http_server.start()
45
-
46
- # sleep(0.25)
47
- # with open("../gui/dist/index.html", "r") as html:
48
- window = webview.create_window(
49
- "Albibong",
50
- # "../../gui/dist/index.html",
51
- url="http://localhost:8000/",
52
- width=1280,
53
- height=720,
54
- zoomable=True,
55
- )
44
+ if useWebview:
45
+ print("addr",PORT)
46
+
47
+ http_server = HttpServerThread(name="http_server", port=PORT)
48
+ http_server.start()
56
49
 
57
- def on_closing():
58
- c.stop()
59
- p.stop()
60
- ws_server.stop()
61
- http_server.stop()
50
+ window = webview.create_window(
51
+ "Albibong",
52
+ url=f"http://localhost:{PORT}/",
53
+ width=1280,
54
+ height=720,
55
+ zoomable=True,
56
+ )
62
57
 
63
- window.events.closing += on_closing
58
+ def on_closing():
59
+ c.stop()
60
+ p.stop()
61
+ ws_server.stop()
62
+ http_server.stop()
64
63
 
65
- webview.start()
64
+ window.events.closing += on_closing
65
+
66
+ webview.start()
67
+ else:
68
+ try:
69
+ while True:
70
+ sleep(100)
71
+ except KeyboardInterrupt as e:
72
+ p.stop()
73
+ ws_server.stop()
66
74
 
67
75
 
68
- def main():
76
+ def main(useWebview=True):
69
77
  if len(sys.argv) > 1:
70
78
  ws_server = get_ws_server()
71
79
  ws_server.start()
72
80
 
73
- http_server = HttpServerThread(name="http_server")
74
- http_server.start()
75
-
76
81
  read_pcap(sys.argv[1])
77
82
  else:
78
- sniff()
83
+ sniff(useWebview)
@@ -0,0 +1,6 @@
1
+ from albibong import main
2
+ from albibong.classes.logger import use_logger
3
+
4
+ if __name__ == "__main__":
5
+ use_logger(True)
6
+ main(useWebview=False)
@@ -1,4 +1,5 @@
1
1
  import json
2
+ from uuid import UUID
2
3
 
3
4
  from albibong.classes.coords import Coords
4
5
  from albibong.classes.item import Item
@@ -12,6 +13,7 @@ class Character:
12
13
  def __init__(
13
14
  self,
14
15
  id: int,
16
+ uuid: UUID,
15
17
  username: str,
16
18
  guild: str,
17
19
  alliance: str,
@@ -19,6 +21,7 @@ class Character:
19
21
  equipment: list[Item] = [Item.get_item_from_code("0")] * 10,
20
22
  ):
21
23
  self.id = id
24
+ self.uuid = uuid
22
25
  self.username = username
23
26
  self.guild = guild
24
27
  self.alliance = alliance
@@ -7,6 +7,13 @@ from scapy.all import wrpcap
7
7
 
8
8
  from albibong.photon_packet_parser import EventData, OperationRequest, OperationResponse
9
9
 
10
+ isUsingLogger = False
11
+
12
+
13
+ def use_logger(value):
14
+ global isUsingLogger
15
+ isUsingLogger = value
16
+
10
17
 
11
18
  class Logger(logging.Logger):
12
19
  def __init__(
@@ -25,7 +32,7 @@ class Logger(logging.Logger):
25
32
 
26
33
  self.file_timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H%M%S")
27
34
  log_filepath = os.path.join(
28
- os.path.expanduser("~"), f"Albibong/log/log_{self.file_timestamp}.txt"
35
+ os.path.dirname(__file__), f"../../../log/log_{self.file_timestamp}.txt"
29
36
  )
30
37
  os.makedirs(os.path.dirname(log_filepath), exist_ok=True)
31
38
 
@@ -63,6 +70,9 @@ class Logger(logging.Logger):
63
70
  return datetime.now(timezone.utc).strftime("%H:%M:%S")
64
71
 
65
72
  def log_payload(self, payload):
73
+ if not isUsingLogger:
74
+ return
75
+
66
76
  if type(payload) == EventData:
67
77
  self.log_event(payload)
68
78
  elif type(payload) == OperationRequest:
@@ -72,8 +82,9 @@ class Logger(logging.Logger):
72
82
 
73
83
  def log_dps_meter_state(self, state: bool):
74
84
  text = f"{self.get_timestamp()} DPS METER IS {'RUNNING. The damages below this point will be recorded.' if state else 'PAUSED. The damages below this point will NOT be recorded.'}"
75
- self.info(text)
76
85
  print(text)
86
+ if isUsingLogger:
87
+ self.info(text)
77
88
 
78
89
  def log_event(self, payload: EventData):
79
90
  if self.ignore_event:
@@ -0,0 +1,9 @@
1
+ from uuid import UUID
2
+
3
+
4
+ class Utils:
5
+
6
+ @staticmethod
7
+ def convert_int_arr_to_uuid(arr):
8
+ b = bytes(arr)
9
+ return UUID(bytes=b)
@@ -1,12 +1,14 @@
1
1
  import json
2
2
  import os
3
3
  from collections import deque
4
+ from uuid import UUID
4
5
 
5
6
  from albibong.classes.character import Character
6
7
  from albibong.classes.coords import Coords
7
8
  from albibong.classes.dungeon import Dungeon
8
9
  from albibong.classes.item import Item
9
10
  from albibong.classes.location import Location
11
+ from albibong.classes.utils import Utils
10
12
  from albibong.resources.EventCode import EventCode
11
13
  from albibong.resources.OperationCode import OperationCode
12
14
  from albibong.threads.websocket_server import send_event
@@ -20,6 +22,7 @@ class WorldData:
20
22
  def __init__(self) -> None:
21
23
  self.me: Character = Character(
22
24
  id=None,
25
+ uuid=None,
23
26
  username="not initialized",
24
27
  guild="not initialized",
25
28
  alliance="not initialized",
@@ -29,6 +32,7 @@ class WorldData:
29
32
  self.current_dungeon: Dungeon = None
30
33
  self.characters: dict[str, Character] = {}
31
34
  self.char_id_to_username: dict[int, str] = {self.me.id: self.me.username}
35
+ self.char_uuid_to_username: dict[UUID, str] = {self.me.uuid: self.me.username}
32
36
  self.change_equipment_log: dict[int, list] = {}
33
37
  self.party_members: set[str] = set()
34
38
  self.is_dps_meter_running: bool = True
@@ -73,6 +77,7 @@ class WorldData:
73
77
  elif parameters[252] == EventCode.NEW_CHARACTER.value:
74
78
  self.create_character(
75
79
  id=parameters[0],
80
+ uuid=parameters[7],
76
81
  username=parameters[1],
77
82
  guild=parameters[8] if 8 in parameters else "",
78
83
  alliance=parameters[49] if 49 in parameters else "",
@@ -159,19 +164,18 @@ class WorldData:
159
164
  send_event(event)
160
165
 
161
166
  def update_party_member(self, parameters):
162
- if self.me != None:
163
- self.party_members.add(self.me.username)
164
167
  if parameters[252] == EventCode.PARTY_JOINED.value:
165
- for member in parameters[5]:
166
- self.party_members.add(member)
168
+ self.party_members = set(parameters[5])
167
169
  elif parameters[252] == EventCode.PARTY_DISBANDED.value:
168
- self.party_members = set()
170
+ self.party_members = {self.me.username}
169
171
  elif parameters[252] == EventCode.PARTY_PLAYER_JOINED.value:
170
172
  self.party_members.add(parameters[2])
171
173
  elif parameters[252] == EventCode.PARTY_PLAYER_LEFT.value:
172
- if parameters[0] in self.char_id_to_username:
173
- name = self.char_id_to_username[parameters[0]]
174
- self.party_members.remove(name)
174
+ uuid = UUID(bytes=bytes(parameters[1]))
175
+ if uuid in self.char_uuid_to_username:
176
+ name = self.char_uuid_to_username[uuid]
177
+ if name == self.me.username:
178
+ self.party_members = {self.me.username}
175
179
  event = {
176
180
  "type": "update_dps",
177
181
  "payload": {"party_members": self.serialize_party_members()},
@@ -193,29 +197,35 @@ class WorldData:
193
197
  def change_character_equipment(self, parameters):
194
198
  if 2 in parameters:
195
199
  if parameters[0] in self.char_id_to_username:
196
- char = self.characters[self.char_id_to_username[parameters[0]]]
197
- if char.username in self.party_members:
198
- char.update_equipment(parameters[2])
199
- event = {
200
- "type": "update_dps",
201
- "payload": {"party_members": self.serialize_party_members()},
202
- }
203
- send_event(event)
200
+ if self.char_id_to_username[parameters[0]] != "not initialized":
201
+ char = self.characters[self.char_id_to_username[parameters[0]]]
202
+ if char.username in self.party_members:
203
+ char.update_equipment(parameters[2])
204
+ event = {
205
+ "type": "update_dps",
206
+ "payload": {
207
+ "party_members": self.serialize_party_members()
208
+ },
209
+ }
210
+ send_event(event)
204
211
  else:
205
212
  self.change_equipment_log[parameters[0]] = parameters[2]
206
213
 
207
214
  def handle_join_response(self, parameters):
208
215
  # set my character
209
-
210
216
  self.convert_id_to_name(old_id=self.me.id, new_id=parameters[0], char=self.me)
211
-
217
+ self.me.uuid = Utils.convert_int_arr_to_uuid(parameters[1])
212
218
  self.me.username = parameters[2]
213
219
  self.me.guild = parameters[57] if 57 in parameters else ""
214
220
  self.me.alliance = parameters[77] if 77 in parameters else ""
215
- self.characters[self.me.username] = self.me
216
221
  if self.me.id in self.change_equipment_log:
217
222
  self.me.update_equipment(self.change_equipment_log[self.me.id])
218
223
 
224
+ # put self in characters list
225
+ self.characters[self.me.username] = self.me
226
+ self.char_uuid_to_username[self.me.uuid] = self.me.username
227
+
228
+ # put self in party
219
229
  self.party_members.add(self.me.username)
220
230
 
221
231
  # set map my character is currently in
@@ -246,8 +256,13 @@ class WorldData:
246
256
  ),
247
257
  },
248
258
  }
259
+ event_party = {
260
+ "type": "update_dps",
261
+ "payload": {"party_members": self.serialize_party_members()},
262
+ }
249
263
  send_event(event_map)
250
264
  send_event(event_char)
265
+ send_event(event_party)
251
266
 
252
267
  def convert_id_to_name(self, old_id, new_id, char: Character):
253
268
  if old_id in self.char_id_to_username:
@@ -258,6 +273,7 @@ class WorldData:
258
273
  def create_character(
259
274
  self,
260
275
  id: int,
276
+ uuid: list[int],
261
277
  username: str,
262
278
  guild: str,
263
279
  alliance: str,
@@ -269,6 +285,7 @@ class WorldData:
269
285
  if username not in self.characters:
270
286
  char: Character = Character(
271
287
  id=id,
288
+ uuid=Utils.convert_int_arr_to_uuid(uuid),
272
289
  username=username,
273
290
  guild=guild,
274
291
  alliance=alliance,
@@ -277,6 +294,7 @@ class WorldData:
277
294
  char.update_equipment(equipments)
278
295
  self.characters[char.username] = char
279
296
  self.char_id_to_username[char.id] = char.username
297
+ self.char_uuid_to_username[char.uuid] = char.username
280
298
 
281
299
  # change map
282
300
  else:
@@ -290,32 +308,54 @@ class WorldData:
290
308
 
291
309
  total_damage = 0
292
310
  total_heal = 0
311
+
312
+ # get total damage and heal for percentage
293
313
  for key, value in self.characters.items():
294
314
  if key in self.party_members:
295
315
  total_damage += value.damage_dealt
296
316
  total_heal += value.healing_dealt
297
317
 
298
- for key, value in self.characters.items():
299
- if key in self.party_members:
300
- if value.equipment != []:
301
- weapon = Item.serialize(value.equipment[0])["image"]
302
- data = {
303
- "username": value.username,
304
- "damage_dealt": value.damage_dealt,
305
- "damage_percent": (
306
- round(value.damage_dealt / total_damage * 100, 2)
307
- if total_damage > 0
308
- else 0
309
- ),
310
- "healing_dealt": value.healing_dealt,
311
- "heal_percent": (
312
- round(value.healing_dealt / total_heal * 100, 2)
313
- if total_heal > 0
314
- else 0
315
- ),
316
- "weapon": weapon,
317
- }
318
- serialized.append(data)
318
+ for member in self.party_members:
319
+ # member character initialized
320
+ if member in self.characters:
321
+ char = self.characters[member]
322
+ username = char.username
323
+ damage_dealt = char.damage_dealt
324
+ damage_percent = (
325
+ round(char.damage_dealt / total_damage * 100, 2)
326
+ if total_damage > 0
327
+ else 0
328
+ )
329
+ healing_dealt = char.healing_dealt
330
+ heal_percent = (
331
+ round(char.healing_dealt / total_heal * 100, 2)
332
+ if total_heal > 0
333
+ else 0
334
+ )
335
+ weapon = (
336
+ Item.serialize(char.equipment[0])["image"]
337
+ if char.equipment != []
338
+ else "../public/No Equipment.png"
339
+ )
340
+
341
+ # member character not initialized
342
+ else:
343
+ username = member
344
+ damage_dealt = 0
345
+ damage_percent = 0
346
+ healing_dealt = 0
347
+ heal_percent = 0
348
+ weapon = "../public/No Equipment.png"
349
+
350
+ data = {
351
+ "username": username,
352
+ "damage_dealt": damage_dealt,
353
+ "damage_percent": damage_percent,
354
+ "healing_dealt": healing_dealt,
355
+ "heal_percent": heal_percent,
356
+ "weapon": weapon,
357
+ }
358
+ serialized.append(data)
319
359
  serialized.sort(key=lambda x: x["damage_dealt"], reverse=True)
320
360
  return serialized
321
361