albibong 1.0.0__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 (46) hide show
  1. albibong-1.0.0/.gitignore +209 -0
  2. albibong-1.0.0/LICENSE +19 -0
  3. albibong-1.0.0/PKG-INFO +15 -0
  4. albibong-1.0.0/pyproject.toml +41 -0
  5. albibong-1.0.0/requirements.txt +3 -0
  6. albibong-1.0.0/src/albibong/__init__.py +82 -0
  7. albibong-1.0.0/src/albibong/classes/__init__.py +0 -0
  8. albibong-1.0.0/src/albibong/classes/character.py +83 -0
  9. albibong-1.0.0/src/albibong/classes/coords.py +9 -0
  10. albibong-1.0.0/src/albibong/classes/dungeon.py +59 -0
  11. albibong-1.0.0/src/albibong/classes/item.py +41 -0
  12. albibong-1.0.0/src/albibong/classes/location.py +48 -0
  13. albibong-1.0.0/src/albibong/classes/logger.py +122 -0
  14. albibong-1.0.0/src/albibong/classes/packet_handler.py +61 -0
  15. albibong-1.0.0/src/albibong/classes/world_data.py +327 -0
  16. albibong-1.0.0/src/albibong/gui_dist/No Equipment.png +0 -0
  17. albibong-1.0.0/src/albibong/gui_dist/assets/index-BFSx0nua.css +1 -0
  18. albibong-1.0.0/src/albibong/gui_dist/assets/index-DAndaN_4.js +161 -0
  19. albibong-1.0.0/src/albibong/gui_dist/fame.png +0 -0
  20. albibong-1.0.0/src/albibong/gui_dist/index.html +14 -0
  21. albibong-1.0.0/src/albibong/gui_dist/re_spec.png +0 -0
  22. albibong-1.0.0/src/albibong/gui_dist/silver.png +0 -0
  23. albibong-1.0.0/src/albibong/gui_dist/vite.svg +1 -0
  24. albibong-1.0.0/src/albibong/photon_packet_parser/__init__.py +4 -0
  25. albibong-1.0.0/src/albibong/photon_packet_parser/command_type.py +7 -0
  26. albibong-1.0.0/src/albibong/photon_packet_parser/crc_calculator.py +16 -0
  27. albibong-1.0.0/src/albibong/photon_packet_parser/event_data.py +4 -0
  28. albibong-1.0.0/src/albibong/photon_packet_parser/message_type.py +6 -0
  29. albibong-1.0.0/src/albibong/photon_packet_parser/number_serializer.py +22 -0
  30. albibong-1.0.0/src/albibong/photon_packet_parser/operation_request.py +4 -0
  31. albibong-1.0.0/src/albibong/photon_packet_parser/operation_response.py +6 -0
  32. albibong-1.0.0/src/albibong/photon_packet_parser/photon_packet_parser.py +168 -0
  33. albibong-1.0.0/src/albibong/photon_packet_parser/protocol16_deserializer.py +302 -0
  34. albibong-1.0.0/src/albibong/photon_packet_parser/protocol16_type.py +23 -0
  35. albibong-1.0.0/src/albibong/photon_packet_parser/segmented_packet.py +5 -0
  36. albibong-1.0.0/src/albibong/resources/EventCode.py +579 -0
  37. albibong-1.0.0/src/albibong/resources/OperationCode.py +499 -0
  38. albibong-1.0.0/src/albibong/resources/event_code.json +577 -0
  39. albibong-1.0.0/src/albibong/resources/items.json +54035 -0
  40. albibong-1.0.0/src/albibong/resources/maps.json +3565 -0
  41. albibong-1.0.0/src/albibong/resources/operation_code.json +497 -0
  42. albibong-1.0.0/src/albibong/threads/__init__.py +0 -0
  43. albibong-1.0.0/src/albibong/threads/http_server.py +60 -0
  44. albibong-1.0.0/src/albibong/threads/packet_handler_thread.py +32 -0
  45. albibong-1.0.0/src/albibong/threads/sniffer_thread.py +27 -0
  46. albibong-1.0.0/src/albibong/threads/websocket_server.py +168 -0
@@ -0,0 +1,209 @@
1
+ # Created by https://www.toptal.com/developers/gitignore/api/python,macos
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=python,macos
3
+
4
+ ### macOS ###
5
+ # General
6
+ .DS_Store
7
+ .AppleDouble
8
+ .LSOverride
9
+
10
+ # Icon must end with two \r
11
+ Icon
12
+
13
+
14
+ # Thumbnails
15
+ ._*
16
+
17
+ # Files that might appear in the root of a volume
18
+ .DocumentRevisions-V100
19
+ .fseventsd
20
+ .Spotlight-V100
21
+ .TemporaryItems
22
+ .Trashes
23
+ .VolumeIcon.icns
24
+ .com.apple.timemachine.donotpresent
25
+
26
+ # Directories potentially created on remote AFP share
27
+ .AppleDB
28
+ .AppleDesktop
29
+ Network Trash Folder
30
+ Temporary Items
31
+ .apdisk
32
+
33
+ ### macOS Patch ###
34
+ # iCloud generated files
35
+ *.icloud
36
+
37
+ ### Python ###
38
+ # Byte-compiled / optimized / DLL files
39
+ __pycache__/
40
+ *.py[cod]
41
+ *$py.class
42
+
43
+ # C extensions
44
+ *.so
45
+
46
+ # Distribution / packaging
47
+ .Python
48
+ build/
49
+ develop-eggs/
50
+ dist/
51
+ downloads/
52
+ eggs/
53
+ .eggs/
54
+ lib/
55
+ lib64/
56
+ parts/
57
+ sdist/
58
+ var/
59
+ wheels/
60
+ share/python-wheels/
61
+ *.egg-info/
62
+ .installed.cfg
63
+ *.egg
64
+ MANIFEST
65
+
66
+ # PyInstaller
67
+ # Usually these files are written by a python script from a template
68
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
69
+ *.manifest
70
+ *.spec
71
+
72
+ # Installer logs
73
+ pip-log.txt
74
+ pip-delete-this-directory.txt
75
+
76
+ # Unit test / coverage reports
77
+ htmlcov/
78
+ .tox/
79
+ .nox/
80
+ .coverage
81
+ .coverage.*
82
+ .cache
83
+ nosetests.xml
84
+ coverage.xml
85
+ *.cover
86
+ *.py,cover
87
+ .hypothesis/
88
+ .pytest_cache/
89
+ cover/
90
+
91
+ # Translations
92
+ *.mo
93
+ *.pot
94
+
95
+ # Django stuff:
96
+ *.log
97
+ local_settings.py
98
+ db.sqlite3
99
+ db.sqlite3-journal
100
+
101
+ # Flask stuff:
102
+ instance/
103
+ .webassets-cache
104
+
105
+ # Scrapy stuff:
106
+ .scrapy
107
+
108
+ # Sphinx documentation
109
+ docs/_build/
110
+
111
+ # PyBuilder
112
+ .pybuilder/
113
+ target/
114
+
115
+ # Jupyter Notebook
116
+ .ipynb_checkpoints
117
+
118
+ # IPython
119
+ profile_default/
120
+ ipython_config.py
121
+
122
+ # pyenv
123
+ # For a library or package, you might want to ignore these files since the code is
124
+ # intended to run in multiple environments; otherwise, check them in:
125
+ # .python-version
126
+
127
+ # pipenv
128
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
129
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
130
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
131
+ # install all needed dependencies.
132
+ #Pipfile.lock
133
+
134
+ # poetry
135
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
136
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
137
+ # commonly ignored for libraries.
138
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
139
+ #poetry.lock
140
+
141
+ # pdm
142
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
143
+ #pdm.lock
144
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
145
+ # in version control.
146
+ # https://pdm.fming.dev/#use-with-ide
147
+ .pdm.toml
148
+
149
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
150
+ __pypackages__/
151
+
152
+ # Celery stuff
153
+ celerybeat-schedule
154
+ celerybeat.pid
155
+
156
+ # SageMath parsed files
157
+ *.sage.py
158
+
159
+ # Environments
160
+ .env
161
+ .venv
162
+ env/
163
+ venv/
164
+ ENV/
165
+ env.bak/
166
+ venv.bak/
167
+
168
+ # Spyder project settings
169
+ .spyderproject
170
+ .spyproject
171
+
172
+ # Rope project settings
173
+ .ropeproject
174
+
175
+ # mkdocs documentation
176
+ /site
177
+
178
+ # mypy
179
+ .mypy_cache/
180
+ .dmypy.json
181
+ dmypy.json
182
+
183
+ # Pyre type checker
184
+ .pyre/
185
+
186
+ # pytype static type analyzer
187
+ .pytype/
188
+
189
+ # Cython debug symbols
190
+ cython_debug/
191
+
192
+ # PyCharm
193
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
194
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
195
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
196
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
197
+ #.idea/
198
+
199
+ ### Python Patch ###
200
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
201
+ poetry.toml
202
+
203
+ # ruff
204
+ .ruff_cache/
205
+
206
+ # LSP config files
207
+ pyrightconfig.json
208
+
209
+ # End of https://www.toptal.com/developers/gitignore/api/python,macos
albibong-1.0.0/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.3
2
+ Name: albibong
3
+ Version: 1.0.0
4
+ Summary: An Albion Online damage, heal and dungeon tracker for UNIX-based operating systems
5
+ Project-URL: Homepage, https://github.com/imjangkar/albibong
6
+ Project-URL: Issues, https://github.com/imjangkar/albibong/issues
7
+ Author-email: imjangkar <imjangkar@gmail.com>
8
+ License-File: LICENSE
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.8
13
+ Requires-Dist: pywebview==5.1
14
+ Requires-Dist: scapy==2.5.0
15
+ Requires-Dist: websockets==12.0
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [tool.hatch.build]
6
+ exclude = [
7
+ "/.*",
8
+ "/dump",
9
+ "/log",
10
+ "/pcap",
11
+ "/tests",
12
+ "/gui",
13
+ "/readme_screenshots",
14
+ "/README.md"
15
+ ]
16
+
17
+ [project.scripts]
18
+ albibong = "albibong:main"
19
+
20
+ [project]
21
+ name = "albibong"
22
+ version = "1.0.0"
23
+ authors = [
24
+ { name="imjangkar", email="imjangkar@gmail.com" },
25
+ ]
26
+ description = "An Albion Online damage, heal and dungeon tracker for UNIX-based operating systems"
27
+ requires-python = ">=3.8"
28
+ classifiers = [
29
+ "Programming Language :: Python :: 3",
30
+ "License :: OSI Approved :: MIT License",
31
+ "Operating System :: OS Independent",
32
+ ]
33
+ dependencies = [
34
+ "scapy==2.5.0",
35
+ "websockets==12.0",
36
+ "pywebview==5.1"
37
+ ]
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/imjangkar/albibong"
41
+ Issues = "https://github.com/imjangkar/albibong/issues"
@@ -0,0 +1,3 @@
1
+ scapy==2.5.0
2
+ websockets==12.0
3
+ pywebview==5.1
@@ -0,0 +1,82 @@
1
+ import queue
2
+ import sys
3
+ from time import sleep
4
+
5
+ import webview
6
+ from scapy.all import rdpcap
7
+
8
+ from albibong.classes.logger import Logger
9
+ from albibong.classes.packet_handler import PacketHandler
10
+ from albibong.threads.http_server import HttpServerThread
11
+ from albibong.threads.packet_handler_thread import PacketHandlerThread
12
+ from albibong.threads.sniffer_thread import SnifferThread
13
+ from albibong.threads.websocket_server import get_ws_server
14
+
15
+ logger = Logger(__name__, stdout=True, log_to_file=False)
16
+
17
+
18
+ def read_pcap(path):
19
+ packet_handler = PacketHandler()
20
+ scapy_cap = rdpcap(path)
21
+ for packet in scapy_cap:
22
+ packet_handler.handle(packet)
23
+
24
+
25
+ def sniff():
26
+ _sentinel = object()
27
+ packet_queue = queue.Queue()
28
+
29
+ p = SnifferThread(name="sniffer", out_queue=packet_queue, sentinel=_sentinel)
30
+
31
+ c = PacketHandlerThread(
32
+ name="packet_handler",
33
+ in_queue=packet_queue,
34
+ sentinel=_sentinel,
35
+ )
36
+
37
+ p.start()
38
+ c.start()
39
+
40
+ ws_server = get_ws_server()
41
+ ws_server.start()
42
+
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
+ )
56
+
57
+ def on_closing():
58
+ c.stop()
59
+ p.stop()
60
+ ws_server.stop()
61
+ http_server.stop()
62
+
63
+ window.events.closing += on_closing
64
+
65
+ webview.start()
66
+
67
+
68
+ def main():
69
+ if len(sys.argv) > 1:
70
+ ws_server = get_ws_server()
71
+ ws_server.start()
72
+
73
+ http_server = HttpServerThread(name="http_server")
74
+ http_server.start()
75
+
76
+ read_pcap(sys.argv[1])
77
+ else:
78
+ sniff()
79
+
80
+
81
+ if __name__ == "__main__":
82
+ main()
File without changes
@@ -0,0 +1,83 @@
1
+ import json
2
+
3
+ from albibong.classes.coords import Coords
4
+ from albibong.classes.item import Item
5
+ from albibong.threads.websocket_server import send_event
6
+
7
+ DIVISOR = 10000
8
+
9
+
10
+ class Character:
11
+
12
+ def __init__(
13
+ self,
14
+ id: int,
15
+ username: str,
16
+ guild: str,
17
+ alliance: str,
18
+ coords: Coords,
19
+ equipment: list[Item] = [Item.get_item_from_code("0")] * 10,
20
+ ):
21
+ self.id = id
22
+ self.username = username
23
+ self.guild = guild
24
+ self.alliance = alliance
25
+ self.coords = coords
26
+ self.fame_gained: int = 0
27
+ self.re_spec_gained: int = 0
28
+ self.silver_gained: int = 0
29
+ self.damage_dealt: int = 0
30
+ self.healing_dealt: int = 0
31
+ self.loot: list[str] = []
32
+ self.equipment = equipment
33
+
34
+ def handle_health_update(self, parameters):
35
+ if 2 in parameters:
36
+ if parameters[2] < 0:
37
+ if parameters[0] != self.id:
38
+ self.damage_dealt += abs(parameters[2])
39
+ else:
40
+ self.healing_dealt += abs(parameters[2])
41
+
42
+ def update_coords(self, parameters):
43
+ if 3 in parameters:
44
+ self.coords = Coords(parameters[3][0], parameters[3][1])
45
+
46
+ def update_fame(self, parameters):
47
+ fame = parameters[2] / DIVISOR
48
+ self.fame_gained += fame
49
+ event = {
50
+ "type": "update_fame",
51
+ "payload": {"username": self.username, "fame_gained": fame},
52
+ }
53
+ send_event(event)
54
+
55
+ def update_re_spec(self, parameters):
56
+ re_spec = parameters[2] / DIVISOR
57
+ self.re_spec_gained += re_spec
58
+ event = {
59
+ "type": "update_re_spec",
60
+ "payload": {"username": self.username, "re_spec_gained": re_spec},
61
+ }
62
+ send_event(event)
63
+
64
+ def update_loot(self, parameters):
65
+ if 3 in parameters and parameters[3] == True:
66
+ if 5 in parameters:
67
+ silver = parameters[5] / DIVISOR
68
+ self.silver_gained += silver
69
+ event = {
70
+ "type": "update_silver",
71
+ "payload": {"username": self.username, "silver_gained": silver},
72
+ }
73
+ send_event(event)
74
+ else:
75
+ self.loot.append(parameters[4])
76
+
77
+ def update_equipment(self, equipments):
78
+ new_eq = []
79
+ if equipments != []:
80
+ for eq in equipments:
81
+ obj = Item.get_item_from_code(str(eq))
82
+ new_eq.append(obj)
83
+ self.equipment = new_eq
@@ -0,0 +1,9 @@
1
+ class Coords:
2
+
3
+ def __init__(self, x, y):
4
+ self.x: float = x
5
+ self.y: float = y
6
+
7
+ @staticmethod
8
+ def serialize(coords):
9
+ return {"x": coords.x, "y": coords.y}
@@ -0,0 +1,59 @@
1
+ from datetime import datetime
2
+ import uuid
3
+
4
+ DIVISOR = 10000
5
+
6
+
7
+ class Dungeon:
8
+
9
+ def __init__(self, type, name) -> None:
10
+ self.id = uuid.uuid4()
11
+ self.type = type
12
+ self.name = name
13
+ self.tier = 0
14
+ self.fame_gained = 0
15
+ self.silver_gained = 0
16
+ self.re_spec_gained = 0
17
+ self.loot = []
18
+ self.start_time = datetime.now()
19
+ self.time_elapsed = 0
20
+
21
+ @staticmethod
22
+ def serialize(dungeon):
23
+ return {
24
+ "id": str(dungeon.id),
25
+ "type": dungeon.type,
26
+ "name": dungeon.name,
27
+ "tier": dungeon.tier,
28
+ "fame": dungeon.fame_gained,
29
+ "silver": dungeon.silver_gained,
30
+ "re_spec": dungeon.re_spec_gained,
31
+ "date_time": dungeon.start_time.strftime("%a %d %b %Y, %I:%M%p"),
32
+ "time_elapsed": str(dungeon.time_elapsed).split(".")[0],
33
+ }
34
+
35
+ @staticmethod
36
+ def serialize_many(dungeons):
37
+ serialized = []
38
+ for key, value in dungeons.items():
39
+ serialized.append(Dungeon.serialize(value))
40
+ return serialized
41
+
42
+ def get_elapsed_time(self):
43
+ end_time = datetime.now()
44
+ self.time_elapsed = end_time - self.start_time
45
+
46
+ def update_fame(self, parameters):
47
+ fame = parameters[2] / DIVISOR
48
+ self.fame_gained += fame
49
+
50
+ def update_re_spec(self, parameters):
51
+ re_spec = parameters[2] / DIVISOR
52
+ self.re_spec_gained += re_spec
53
+
54
+ def update_loot(self, parameters):
55
+ if 3 in parameters and parameters[3] == True:
56
+ silver = parameters[5] / DIVISOR
57
+ self.silver_gained += silver
58
+ else:
59
+ self.loot.append(parameters[4])
@@ -0,0 +1,41 @@
1
+ import json
2
+ import os
3
+
4
+ itemsJsonPath = os.path.join(os.path.dirname(__file__), "../resources/items.json")
5
+ with open(itemsJsonPath) as json_file:
6
+ item_data = json.load(json_file)
7
+
8
+
9
+ class Item:
10
+
11
+ def __init__(self, id: str, name: str, unique_name: str):
12
+ self.id = id
13
+ self.name = name
14
+ self.unique_name = unique_name
15
+ self.image = (
16
+ "https://render.albiononline.com/v1/item/" + self.unique_name
17
+ if self.unique_name != "None"
18
+ else "../public/No Equipment.png"
19
+ )
20
+
21
+ @staticmethod
22
+ def serialize(item):
23
+ return {
24
+ "id": item.id,
25
+ "name": item.name,
26
+ "unique_name": item.unique_name,
27
+ "image": item.image,
28
+ }
29
+
30
+ @staticmethod
31
+ def serialize_many(items):
32
+ serialized = []
33
+ for item in items:
34
+ serialized.append(Item.serialize(item))
35
+ return serialized
36
+
37
+ @classmethod
38
+ def get_item_from_code(cls, code: str):
39
+ item = item_data[code]
40
+
41
+ return cls(id=item["id"], name=item["name"], unique_name=item["unique_name"])
@@ -0,0 +1,48 @@
1
+ import json
2
+ import os
3
+
4
+ mapsJsonPath = os.path.join(os.path.dirname(__file__), "../resources/maps.json")
5
+ with open(mapsJsonPath) as json_file:
6
+ map_data = json.load(json_file)
7
+
8
+
9
+ class Location:
10
+
11
+ def __init__(self, id: str, name: str, type: str):
12
+ self.id = id
13
+ self.name = name
14
+ self.type = type
15
+
16
+ def is_black_zone(self):
17
+ if self.type == "OPENPVP_BLACK":
18
+ return True
19
+ elif self.type == "DUNGEON_BLACK":
20
+ return True
21
+ elif self.type == "PASSAGE_BLACK":
22
+ return True
23
+ elif self.type == "TUNNEL":
24
+ return True
25
+ else:
26
+ return False
27
+
28
+ def is_red_zone(self):
29
+ if self.type == "OPENPVP_RED":
30
+ return True
31
+ elif self.type == "DUNGEON_RED":
32
+ return True
33
+ elif self.type == "PASSAGE_RED":
34
+ return True
35
+ else:
36
+ return False
37
+
38
+ def is_safe_zone(self):
39
+ if self.is_black_zone() == False and self.is_red_zone() == False:
40
+ return True
41
+ else:
42
+ return False
43
+
44
+ @classmethod
45
+ def get_location_from_code(cls, code: str):
46
+ location = map_data[code]
47
+
48
+ return cls(id=location["id"], name=location["name"], type=location["type"])