albibong 1.0.7__tar.gz → 1.1.1__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 (83) hide show
  1. {albibong-1.0.7 → albibong-1.1.1}/.gitignore +2 -0
  2. {albibong-1.0.7 → albibong-1.1.1}/PKG-INFO +3 -1
  3. {albibong-1.0.7 → albibong-1.1.1}/pyproject.toml +5 -2
  4. albibong-1.1.1/src/albibong/__init__.py +173 -0
  5. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/__main__.py +6 -0
  6. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/character.py +7 -23
  7. albibong-1.1.1/src/albibong/classes/dungeon.py +80 -0
  8. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/__init__.py +17 -1
  9. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_event_character_equipment_changed.py +2 -10
  10. albibong-1.1.1/src/albibong/classes/event_handler/handle_event_might_and_favor_received_event.py +18 -0
  11. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_event_other_grabbed_loot.py +9 -0
  12. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_event_party.py +6 -13
  13. albibong-1.1.1/src/albibong/classes/event_handler/handle_event_update_fame.py +16 -0
  14. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_event_update_re_spec_points.py +9 -0
  15. albibong-1.1.1/src/albibong/classes/event_handler/handle_operation_change_cluster.py +38 -0
  16. albibong-1.1.1/src/albibong/classes/event_handler/handle_operation_farmable_harvest.py +17 -0
  17. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_operation_join.py +14 -36
  18. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/world_data_utils.py +62 -30
  19. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/item.py +19 -4
  20. albibong-1.1.1/src/albibong/classes/location.py +151 -0
  21. albibong-1.1.1/src/albibong/classes/utils.py +29 -0
  22. albibong-1.1.1/src/albibong/gui_dist/assets/index-B31tZ4Ku.css +1 -0
  23. albibong-1.1.1/src/albibong/gui_dist/assets/index-BkyL_QUY.js +168 -0
  24. albibong-1.1.1/src/albibong/gui_dist/favor.png +0 -0
  25. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/gui_dist/index.html +2 -2
  26. albibong-1.1.1/src/albibong/gui_dist/might.png +0 -0
  27. albibong-1.1.1/src/albibong/migrations/001_init.py +97 -0
  28. albibong-1.1.1/src/albibong/migrations/002_alter_dungeon_table.py +53 -0
  29. albibong-1.1.1/src/albibong/models/models.py +12 -0
  30. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/requirements.txt +2 -0
  31. albibong-1.1.1/src/albibong/resources/items_by_unique_name.json +55282 -0
  32. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/resources/maps.json +259 -259
  33. albibong-1.1.1/src/albibong/threads/__init__.py +0 -0
  34. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/threads/http_server.py +4 -0
  35. albibong-1.1.1/src/albibong/threads/sniffer_thread.py +65 -0
  36. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/threads/websocket_server.py +80 -43
  37. albibong-1.0.7/src/albibong/__init__.py +0 -89
  38. albibong-1.0.7/src/albibong/classes/dungeon.py +0 -59
  39. albibong-1.0.7/src/albibong/classes/event_handler/handle_event_update_fame.py +0 -7
  40. albibong-1.0.7/src/albibong/classes/event_handler/handle_operation_change_cluster.py +0 -43
  41. albibong-1.0.7/src/albibong/classes/location.py +0 -20
  42. albibong-1.0.7/src/albibong/classes/utils.py +0 -9
  43. albibong-1.0.7/src/albibong/gui_dist/assets/index-DZvgNqlG.css +0 -1
  44. albibong-1.0.7/src/albibong/gui_dist/assets/index-Dt6hyZiS.css +0 -1
  45. albibong-1.0.7/src/albibong/gui_dist/assets/index-E7pha23k.js +0 -161
  46. albibong-1.0.7/src/albibong/gui_dist/assets/index-WIuC9Mnh.js +0 -161
  47. albibong-1.0.7/src/albibong/threads/sniffer_thread.py +0 -28
  48. {albibong-1.0.7 → albibong-1.1.1}/LICENSE +0 -0
  49. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/assets/boom_small.mp3 +0 -0
  50. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/__init__.py +0 -0
  51. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/coords.py +0 -0
  52. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_event_health.py +0 -0
  53. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_event_in_combat_state_update.py +0 -0
  54. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_event_new_character.py +0 -0
  55. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/event_handler/handle_operation_move.py +0 -0
  56. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/logger.py +0 -0
  57. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/packet_handler.py +0 -0
  58. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/classes/world_data.py +0 -0
  59. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/gui_dist/Albibong.png +0 -0
  60. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/gui_dist/No Equipment.png +0 -0
  61. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/gui_dist/fame.png +0 -0
  62. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/gui_dist/re_spec.png +0 -0
  63. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/gui_dist/silver.png +0 -0
  64. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/gui_dist/vite.svg +0 -0
  65. {albibong-1.0.7/src/albibong/threads → albibong-1.1.1/src/albibong/models}/__init__.py +0 -0
  66. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/__init__.py +0 -0
  67. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/command_type.py +0 -0
  68. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/crc_calculator.py +0 -0
  69. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/event_data.py +0 -0
  70. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/message_type.py +0 -0
  71. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/number_serializer.py +0 -0
  72. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/operation_request.py +0 -0
  73. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/operation_response.py +0 -0
  74. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/photon_packet_parser.py +0 -0
  75. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/protocol16_deserializer.py +0 -0
  76. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/protocol16_type.py +0 -0
  77. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/photon_packet_parser/segmented_packet.py +0 -0
  78. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/resources/EventCode.py +0 -0
  79. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/resources/OperationCode.py +0 -0
  80. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/resources/event_code.json +0 -0
  81. /albibong-1.0.7/src/albibong/resources/items.json → /albibong-1.1.1/src/albibong/resources/items_by_id.json +0 -0
  82. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/resources/operation_code.json +0 -0
  83. {albibong-1.0.7 → albibong-1.1.1}/src/albibong/threads/packet_handler_thread.py +0 -0
@@ -7,6 +7,8 @@ dump/
7
7
  log/
8
8
  pcap/
9
9
  .vscode
10
+ src/*.db
11
+ *.db
10
12
 
11
13
  ### macOS ###
12
14
  # General
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: albibong
3
- Version: 1.0.7
3
+ Version: 1.1.1
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
@@ -10,6 +10,8 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.10
13
+ Requires-Dist: peewee-migrate==1.13.0
14
+ Requires-Dist: peewee==3.17.6
13
15
  Requires-Dist: pywebview==5.1
14
16
  Requires-Dist: scapy==2.5.0
15
17
  Requires-Dist: websockets==12.0
@@ -11,7 +11,8 @@ exclude = [
11
11
  "/tests",
12
12
  "/gui",
13
13
  "/readme_screenshots",
14
- "/README.md"
14
+ "/README.md",
15
+ "/*.db"
15
16
  ]
16
17
 
17
18
  [project.scripts]
@@ -19,7 +20,7 @@ albibong = "albibong:main"
19
20
 
20
21
  [project]
21
22
  name = "albibong"
22
- version = "1.0.7"
23
+ version = "1.1.1"
23
24
  authors = [
24
25
  { name="imjangkar", email="imjangkar@gmail.com" },
25
26
  ]
@@ -34,6 +35,8 @@ dependencies = [
34
35
  "scapy==2.5.0",
35
36
  "websockets==12.0",
36
37
  "pywebview==5.1",
38
+ "peewee==3.17.6",
39
+ "peewee-migrate==1.13.0",
37
40
  ]
38
41
 
39
42
  [project.urls]
@@ -0,0 +1,173 @@
1
+ import json
2
+ import os
3
+ import queue
4
+ import random
5
+ import socket
6
+ import sys
7
+ import uuid
8
+ from datetime import datetime, timedelta
9
+ from pathlib import Path
10
+ from time import sleep
11
+
12
+ import webview
13
+ from peewee_migrate import Router
14
+ from scapy.all import rdpcap
15
+
16
+ from albibong.classes.logger import Logger
17
+ from albibong.classes.packet_handler import PacketHandler
18
+ from albibong.classes.utils import Utils
19
+ from albibong.models.models import SQLITE_DB, db
20
+ from albibong.threads.http_server import HttpServerThread
21
+ from albibong.threads.packet_handler_thread import PacketHandlerThread
22
+ from albibong.threads.sniffer_thread import SnifferThread
23
+ from albibong.threads.websocket_server import get_ws_server
24
+
25
+ logger = Logger(__name__, stdout=True, log_to_file=False)
26
+ PORT = random.randrange(8500, 8999)
27
+
28
+ home_dir = os.path.expanduser("~")
29
+ DUNGEON_JSON = f"{home_dir}/Albibong/list_dungeon.json"
30
+
31
+ current_path = os.path.dirname(__file__)
32
+ MIGRATION_FOLDER = os.path.join(current_path, f"migrations")
33
+
34
+
35
+ def read_pcap(path):
36
+ packet_handler = PacketHandler()
37
+ scapy_cap = rdpcap(path)
38
+ for packet in scapy_cap:
39
+ packet_handler.handle(packet)
40
+
41
+
42
+ def get_dungeon_end_time(str, start_time):
43
+ timer = str.split(":")
44
+ seconds = int(timer[0]) * 3600 + int(timer[1]) * 60 + int(timer[2])
45
+ return timedelta(seconds=seconds) + start_time
46
+
47
+
48
+ def check_db_validity():
49
+ migrate = Router(db, migrate_dir=MIGRATION_FOLDER)
50
+
51
+ if Path(SQLITE_DB).is_file() == False:
52
+ if Path(DUNGEON_JSON).is_file() == True:
53
+
54
+ migrate.run("001_init")
55
+
56
+ # convert json db to sqlite db
57
+ json_data = json.load(open(DUNGEON_JSON))
58
+
59
+ for dungeon in json_data:
60
+ start_time = datetime.strptime(
61
+ dungeon["date_time"], "%a %d %b %Y, %I:%M%p"
62
+ )
63
+ type_splitted = set(dungeon["type"].split("_"))
64
+
65
+ if "CORRUPTED" in type_splitted:
66
+ converted_type = "CORRUPTED DUNGEON"
67
+ elif "HARDCORE" in type_splitted:
68
+ converted_type = "HARDCORE EXPEDITION"
69
+ elif "10V10" in type_splitted:
70
+ converted_type = "HELLGATE 10V10"
71
+ elif "5V5" in type_splitted:
72
+ converted_type = "HELLGATE 5V5"
73
+ elif "2V2" in type_splitted:
74
+ converted_type = "HELLGATE 2V2"
75
+ elif "DUNGEON" in type_splitted:
76
+ converted_type = "STATIC DUNGEON"
77
+ elif "RANDOMDUNGEON" in type_splitted:
78
+ converted_type = "SPAWN DUNGEON"
79
+
80
+ asd = [
81
+ ("id", str(uuid.uuid4())),
82
+ ("type", f"{converted_type}"),
83
+ ("name", f'{dungeon["name"]}'),
84
+ ("tier", f'{dungeon["tier"]}'),
85
+ ("fame", f'{dungeon["fame"]}'),
86
+ ("silver", f'{dungeon["silver"]}'),
87
+ ("re_spec", f'{dungeon["re_spec"]}'),
88
+ ("start_time", f"{start_time}"),
89
+ (
90
+ "end_time",
91
+ f'{get_dungeon_end_time(dungeon["time_elapsed"], start_time)}',
92
+ ),
93
+ ("meter", ""),
94
+ ]
95
+
96
+ columns = ", ".join([x[0] for x in asd])
97
+ values = ", ".join([f'"{x[1]}"' for x in asd])
98
+ sql_query = f"INSERT INTO dungeon ({columns}) VALUES ({values})"
99
+
100
+ db.execute_sql(sql_query)
101
+
102
+ migrate.run()
103
+
104
+
105
+ def sniff(useWebview, is_debug=False):
106
+
107
+ check_db_validity()
108
+
109
+ _sentinel = object()
110
+ packet_queue = queue.Queue()
111
+
112
+ p = SnifferThread(
113
+ name="sniffer", out_queue=packet_queue, sentinel=_sentinel, is_debug=is_debug
114
+ )
115
+ c = PacketHandlerThread(
116
+ name="packet_handler",
117
+ in_queue=packet_queue,
118
+ sentinel=_sentinel,
119
+ )
120
+
121
+ p.start()
122
+ c.start()
123
+
124
+ ws_server = get_ws_server()
125
+ ws_server.start()
126
+
127
+ if useWebview:
128
+ sock = socket.socket()
129
+ sock.bind(("", 0))
130
+ port = sock.getsockname()[1]
131
+ sock.close()
132
+
133
+ http_server = HttpServerThread(name="http_server", port=port)
134
+ http_server.start()
135
+
136
+ window = webview.create_window(
137
+ "Albibong",
138
+ url=f"http://localhost:{port}/",
139
+ width=1280,
140
+ height=720,
141
+ zoomable=True,
142
+ )
143
+
144
+ def on_closing():
145
+ c.stop()
146
+ p.stop()
147
+ ws_server.stop()
148
+ http_server.stop()
149
+ db.close()
150
+
151
+ window.events.closing += on_closing
152
+
153
+ webview.start()
154
+ else:
155
+ try:
156
+ while True:
157
+ sleep(100)
158
+ except KeyboardInterrupt as e:
159
+ p.stop()
160
+ ws_server.stop()
161
+
162
+
163
+ def main(useWebview=True):
164
+ if len(sys.argv) > 1:
165
+ if sys.argv[-1] == "--debug":
166
+ Utils.get_user_specifications("pip")
167
+ sniff(useWebview, is_debug=True)
168
+ else:
169
+ ws_server = get_ws_server()
170
+ ws_server.start()
171
+ read_pcap(sys.argv[1])
172
+ else:
173
+ sniff(useWebview)
@@ -1,6 +1,12 @@
1
+ import sys
2
+
1
3
  from albibong import main
2
4
  from albibong.classes.logger import use_logger
5
+ from albibong.classes.utils import Utils
3
6
 
4
7
  if __name__ == "__main__":
5
8
  use_logger(True)
9
+
10
+ if sys.argv[-1] == "--debug":
11
+ Utils.get_user_specifications("source code")
6
12
  main(useWebview=False)
@@ -1,10 +1,9 @@
1
- from datetime import datetime, timedelta
2
1
  import json
2
+ from datetime import datetime, timedelta
3
3
  from uuid import UUID
4
4
 
5
5
  from albibong.classes.coords import Coords
6
6
  from albibong.classes.item import Item
7
- from albibong.threads.websocket_server import send_event
8
7
 
9
8
  DIVISOR = 10000
10
9
 
@@ -35,6 +34,8 @@ class Character:
35
34
  self.re_spec_gained: int = 0
36
35
  self.silver_gained: int = 0
37
36
  self.loot: list[str] = []
37
+ self.might_gained: int = 0
38
+ self.favor_gained: int = 0
38
39
 
39
40
  # Combat
40
41
  self.damage_dealt: int = 0
@@ -69,37 +70,16 @@ class Character:
69
70
  def update_fame(self, parameters):
70
71
  fame = parameters[2] / DIVISOR
71
72
  self.fame_gained += fame
72
- event = {
73
- "type": "update_fame",
74
- "payload": {"username": self.username, "fame_gained": self.fame_gained},
75
- }
76
- send_event(event)
77
73
 
78
74
  def update_re_spec(self, parameters):
79
75
  re_spec = parameters[2] / DIVISOR
80
76
  self.re_spec_gained += re_spec
81
- event = {
82
- "type": "update_re_spec",
83
- "payload": {
84
- "username": self.username,
85
- "re_spec_gained": self.re_spec_gained,
86
- },
87
- }
88
- send_event(event)
89
77
 
90
78
  def update_loot(self, parameters):
91
79
  if 3 in parameters and parameters[3] == True:
92
80
  if 5 in parameters:
93
81
  silver = parameters[5] / DIVISOR
94
82
  self.silver_gained += silver
95
- event = {
96
- "type": "update_silver",
97
- "payload": {
98
- "username": self.username,
99
- "silver_gained": self.silver_gained,
100
- },
101
- }
102
- send_event(event)
103
83
  else:
104
84
  self.loot.append(parameters[4])
105
85
 
@@ -110,3 +90,7 @@ class Character:
110
90
  obj = Item.get_item_from_code(str(eq))
111
91
  new_eq.append(obj)
112
92
  self.equipment = new_eq
93
+
94
+ def update_might_and_favor(self, parameters):
95
+ self.favor_gained += parameters[4] / DIVISOR
96
+ self.might_gained += parameters[1] / DIVISOR
@@ -0,0 +1,80 @@
1
+ import uuid
2
+ from datetime import datetime
3
+
4
+ from peewee import *
5
+ from playhouse.sqlite_ext import JSONField
6
+
7
+ from albibong.models.models import BaseModel
8
+
9
+ DIVISOR = 10000
10
+
11
+
12
+ class Dungeon(BaseModel):
13
+
14
+ id = UUIDField(unique=True, default=uuid.uuid4)
15
+ type = CharField()
16
+ name = CharField()
17
+ tier = FloatField(default=0)
18
+ fame = FloatField(default=0)
19
+ silver = FloatField(default=0)
20
+ re_spec = FloatField(default=0)
21
+ might = FloatField(default=0)
22
+ favor = FloatField(default=0)
23
+ start_time = DateTimeField(default=datetime.now)
24
+ end_time = DateTimeField(null=True, default=None)
25
+ meter = JSONField(default=dict)
26
+
27
+ @staticmethod
28
+ def serialize(dungeon):
29
+ time_elapsed = dungeon.end_time - dungeon.start_time
30
+ total_hours = time_elapsed.total_seconds() / 3600
31
+
32
+ return {
33
+ "id": str(dungeon.id),
34
+ "type": dungeon.type,
35
+ "name": dungeon.name,
36
+ "tier": dungeon.tier,
37
+ "fame": dungeon.fame,
38
+ "fame_per_hour": dungeon.fame / total_hours,
39
+ "silver": dungeon.silver,
40
+ "silver_per_hour": dungeon.silver / total_hours,
41
+ "re_spec": dungeon.re_spec,
42
+ "re_spec_per_hour": dungeon.re_spec / total_hours,
43
+ "might": dungeon.might,
44
+ "might_per_hour": dungeon.might / total_hours,
45
+ "favor": dungeon.favor,
46
+ "favor_per_hour": dungeon.favor / total_hours,
47
+ "date_time": dungeon.start_time.strftime("%a %d %b %Y, %I:%M%p"),
48
+ "time_elapsed": (
49
+ str(time_elapsed).split(".")[0] if dungeon.end_time else ""
50
+ ),
51
+ "meter": dungeon.meter,
52
+ }
53
+
54
+ def set_end_time(self):
55
+ self.end_time = datetime.now()
56
+
57
+ def update_fame(self, parameters):
58
+ fame = parameters[2] / DIVISOR
59
+ self.fame += fame
60
+
61
+ def update_re_spec(self, parameters):
62
+ re_spec = parameters[2] / DIVISOR
63
+ self.re_spec += re_spec
64
+
65
+ def update_might_and_favor(self, parameters):
66
+ self.favor += parameters[4] / DIVISOR
67
+ self.might += parameters[1] / DIVISOR
68
+
69
+ def update_loot(self, parameters):
70
+ if 3 in parameters and parameters[3] == True:
71
+ silver = parameters[5] / DIVISOR
72
+ self.silver += silver
73
+
74
+ def update_meter(self, party):
75
+ self.meter = party
76
+
77
+ @staticmethod
78
+ def get_all_dungeon():
79
+ query = Dungeon.select().order_by(Dungeon.start_time.desc())
80
+ return [Dungeon.serialize(dungeon) for dungeon in query]
@@ -8,6 +8,9 @@ from albibong.classes.event_handler.handle_event_health import (
8
8
  from albibong.classes.event_handler.handle_event_in_combat_state_update import (
9
9
  handle_event_in_combat_state_update,
10
10
  )
11
+ from albibong.classes.event_handler.handle_event_might_and_favor_received_event import (
12
+ handle_event_might_and_favor_received_event,
13
+ )
11
14
  from albibong.classes.event_handler.handle_event_new_character import (
12
15
  handle_event_new_character,
13
16
  )
@@ -29,13 +32,16 @@ from albibong.classes.event_handler.handle_event_update_re_spec_points import (
29
32
  from albibong.classes.event_handler.handle_operation_change_cluster import (
30
33
  handle_operation_change_cluster,
31
34
  )
35
+ from albibong.classes.event_handler.handle_operation_farmable_harvest import (
36
+ handle_operation_farmable_finish_grown_item,
37
+ handle_operation_farmable_harvest,
38
+ )
32
39
  from albibong.classes.event_handler.handle_operation_join import handle_operation_join
33
40
  from albibong.classes.event_handler.handle_operation_move import handle_operation_move
34
41
  from albibong.classes.world_data import WorldData
35
42
  from albibong.resources.EventCode import EventCode
36
43
  from albibong.resources.OperationCode import OperationCode
37
44
 
38
-
39
45
  EVENT_TYPE_PARAMETER = 252
40
46
  REQUEST_TYPE_PARAMETER = 253
41
47
  RESPONSE_TYPE_PARAMETER = 253
@@ -59,6 +65,10 @@ class EventHandler:
59
65
  self.event_handler[EventCode.UPDATE_RE_SPEC_POINTS.value] = (
60
66
  handle_event_update_re_spec_points
61
67
  )
68
+ self.event_handler[EventCode.MIGHT_AND_FAVOR_RECEIVED_EVENT.value] = (
69
+ handle_event_might_and_favor_received_event
70
+ )
71
+
62
72
  self.event_handler[EventCode.OTHER_GRABBED_LOOT.value] = (
63
73
  handle_event_other_grabbed_loot
64
74
  )
@@ -84,6 +94,12 @@ class EventHandler:
84
94
  self.response_handler[OperationCode.CHANGE_CLUSTER.value] = (
85
95
  handle_operation_change_cluster
86
96
  )
97
+ self.response_handler[OperationCode.FARMABLE_FINISH_GROWN_ITEM.value] = (
98
+ handle_operation_farmable_finish_grown_item
99
+ )
100
+ self.response_handler[OperationCode.FARMABLE_HARVEST.value] = (
101
+ handle_operation_farmable_harvest
102
+ )
87
103
 
88
104
  def on_request(self, world_data: WorldData, parameters):
89
105
  if REQUEST_TYPE_PARAMETER not in parameters:
@@ -1,5 +1,5 @@
1
+ from albibong.classes.event_handler.world_data_utils import WorldDataUtils
1
2
  from albibong.classes.world_data import WorldData
2
- from albibong.threads.websocket_server import send_event
3
3
 
4
4
 
5
5
  def handle_event_character_equipment_changed(world_data: WorldData, parameters):
@@ -11,14 +11,6 @@ def handle_event_character_equipment_changed(world_data: WorldData, parameters):
11
11
  ]
12
12
  if char.username in world_data.party_members:
13
13
  char.update_equipment(parameters[2])
14
- ws_update_character_equipment(world_data)
14
+ WorldDataUtils.ws_update_damage_meter(world_data)
15
15
  else:
16
16
  world_data.change_equipment_log[parameters[0]] = parameters[2]
17
-
18
-
19
- def ws_update_character_equipment(world_data: WorldData):
20
- event = {
21
- "type": "update_dps",
22
- "payload": {"party_members": world_data.serialize_party_members()},
23
- }
24
- send_event(event)
@@ -0,0 +1,18 @@
1
+ from albibong.classes.world_data import WorldData
2
+ from albibong.threads.websocket_server import send_event
3
+
4
+
5
+ def handle_event_might_and_favor_received_event(world_data: WorldData, parameters):
6
+ world_data.me.update_might_and_favor(parameters)
7
+ event = {
8
+ "type": "update_might_and_favor",
9
+ "payload": {
10
+ "username": world_data.me.username,
11
+ "favor_gained": world_data.me.favor_gained,
12
+ "might_gained": world_data.me.might_gained,
13
+ },
14
+ }
15
+ send_event(event)
16
+
17
+ if world_data.current_dungeon:
18
+ world_data.current_dungeon.update_might_and_favor(parameters)
@@ -1,5 +1,6 @@
1
1
  from albibong.classes.character import Character
2
2
  from albibong.classes.world_data import WorldData
3
+ from albibong.threads.websocket_server import send_event
3
4
 
4
5
 
5
6
  def handle_event_other_grabbed_loot(world_data: WorldData, parameters):
@@ -8,6 +9,14 @@ def handle_event_other_grabbed_loot(world_data: WorldData, parameters):
8
9
  if 2 in parameters and parameters[2] in world_data.characters:
9
10
  char: Character = world_data.characters[parameters[2]]
10
11
  char.update_loot(parameters)
12
+ event = {
13
+ "type": "update_silver",
14
+ "payload": {
15
+ "username": char.username,
16
+ "silver_gained": char.silver_gained,
17
+ },
18
+ }
19
+ send_event(event)
11
20
 
12
21
  # update dungeon data
13
22
  if world_data.current_dungeon and parameters[2] == world_data.me.username:
@@ -1,21 +1,22 @@
1
1
  from uuid import UUID
2
+
3
+ from albibong.classes.event_handler.world_data_utils import WorldDataUtils
2
4
  from albibong.classes.world_data import WorldData
3
- from albibong.threads.websocket_server import send_event
4
5
 
5
6
 
6
7
  def handle_event_party_joined(world_data: WorldData, parameters):
7
8
  world_data.party_members = set(parameters[5])
8
- ws_update_party_member(world_data)
9
+ WorldDataUtils.ws_update_damage_meter(world_data)
9
10
 
10
11
 
11
12
  def handle_event_party_disbanded(world_data: WorldData, parameters):
12
13
  world_data.party_members = {world_data.me.username}
13
- ws_update_party_member(world_data)
14
+ WorldDataUtils.ws_update_damage_meter(world_data)
14
15
 
15
16
 
16
17
  def handle_event_party_player_joined(world_data: WorldData, parameters):
17
18
  world_data.party_members.add(parameters[2])
18
- ws_update_party_member(world_data)
19
+ WorldDataUtils.ws_update_damage_meter(world_data)
19
20
 
20
21
 
21
22
  def handle_event_party_player_left(world_data: WorldData, parameters):
@@ -27,12 +28,4 @@ def handle_event_party_player_left(world_data: WorldData, parameters):
27
28
  # self out party
28
29
  if name == world_data.me.username:
29
30
  world_data.party_members = {world_data.me.username}
30
- ws_update_party_member(world_data)
31
-
32
-
33
- def ws_update_party_member(world_data: WorldData):
34
- event = {
35
- "type": "update_dps",
36
- "payload": {"party_members": world_data.serialize_party_members()},
37
- }
38
- send_event(event)
31
+ WorldDataUtils.ws_update_damage_meter(world_data)
@@ -0,0 +1,16 @@
1
+ from albibong.classes.world_data import WorldData
2
+ from albibong.threads.websocket_server import send_event
3
+
4
+
5
+ def handle_event_update_fame(world_data: WorldData, parameters):
6
+ world_data.me.update_fame(parameters)
7
+ event = {
8
+ "type": "update_fame",
9
+ "payload": {
10
+ "username": world_data.me.username,
11
+ "fame_gained": world_data.me.fame_gained,
12
+ },
13
+ }
14
+ send_event(event)
15
+ if world_data.current_dungeon:
16
+ world_data.current_dungeon.update_fame(parameters)
@@ -1,10 +1,19 @@
1
1
  from albibong.classes.world_data import WorldData
2
+ from albibong.threads.websocket_server import send_event
2
3
 
3
4
 
4
5
  def handle_event_update_re_spec_points(world_data: WorldData, parameters):
5
6
 
6
7
  # update char data
7
8
  world_data.me.update_re_spec(parameters)
9
+ event = {
10
+ "type": "update_re_spec",
11
+ "payload": {
12
+ "username": world_data.me.username,
13
+ "re_spec_gained": world_data.me.re_spec_gained,
14
+ },
15
+ }
16
+ send_event(event)
8
17
 
9
18
  # update dungeon data
10
19
  if world_data.current_dungeon:
@@ -0,0 +1,38 @@
1
+ from albibong.classes.event_handler.world_data_utils import WorldDataUtils
2
+ from albibong.classes.location import Island, Location
3
+ from albibong.classes.world_data import WorldData
4
+ from albibong.threads.websocket_server import send_event
5
+
6
+
7
+ def handle_operation_change_cluster(world_data: WorldData, parameters):
8
+ world_data.change_equipment_log = {}
9
+
10
+ if type(world_data.current_map).__name__ == "Island":
11
+ WorldDataUtils.set_island_status(
12
+ current_island=world_data.current_map, parameters=parameters
13
+ )
14
+
15
+ if 1 in parameters:
16
+ check_map = Location.get_location_from_code(parameters[1])
17
+ map_type_splitted = set(check_map.type.split(" "))
18
+ WorldDataUtils.set_dungeon_status(world_data, check_map, map_type_splitted)
19
+
20
+ if "ISLAND" in map_type_splitted:
21
+ island = Island.get_island_from_code(parameters[1])
22
+ island.name = f"{parameters[2]}'s {island.name}"
23
+ world_data.current_map = island
24
+ elif "HIDEOUT" in map_type_splitted:
25
+ hideout = Location.get_location_from_code(parameters[1])
26
+ hideout.name = f"{parameters[2]}'s {hideout.name}"
27
+ world_data.current_map = hideout
28
+
29
+ elif 0 in parameters:
30
+ check_map = Location.get_location_from_code(parameters[0])
31
+ map_type_splitted = set(check_map.type.split(" "))
32
+ is_dungeon = WorldDataUtils.set_dungeon_status(
33
+ world_data, check_map, map_type_splitted
34
+ )
35
+ if is_dungeon == False:
36
+ world_data.current_map = Location.get_location_from_code(parameters[0])
37
+
38
+ WorldDataUtils.ws_update_location(world_data)
@@ -0,0 +1,17 @@
1
+ from albibong.classes.world_data import WorldData
2
+
3
+
4
+ def handle_operation_farmable_harvest(world_data: WorldData, parameters):
5
+ if type(world_data.current_map).__name__ == "Island":
6
+ for i in range(len(parameters[0])):
7
+ world_data.current_map.add_crop(
8
+ unique_name=parameters[0][i], quantity=parameters[1][i]
9
+ )
10
+
11
+
12
+ def handle_operation_farmable_finish_grown_item(world_data: WorldData, parameters):
13
+ if type(world_data.current_map).__name__ == "Island":
14
+ for i in range(len(parameters[0])):
15
+ world_data.current_map.add_animal(
16
+ unique_name=parameters[0][i], quantity=parameters[1][i]
17
+ )