albibong 1.0.7__py3-none-any.whl → 1.1.1__py3-none-any.whl
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.
- albibong/__init__.py +92 -8
- albibong/__main__.py +6 -0
- albibong/classes/character.py +7 -23
- albibong/classes/dungeon.py +53 -32
- albibong/classes/event_handler/__init__.py +17 -1
- albibong/classes/event_handler/handle_event_character_equipment_changed.py +2 -10
- albibong/classes/event_handler/handle_event_might_and_favor_received_event.py +18 -0
- albibong/classes/event_handler/handle_event_other_grabbed_loot.py +9 -0
- albibong/classes/event_handler/handle_event_party.py +6 -13
- albibong/classes/event_handler/handle_event_update_fame.py +9 -0
- albibong/classes/event_handler/handle_event_update_re_spec_points.py +9 -0
- albibong/classes/event_handler/handle_operation_change_cluster.py +17 -22
- albibong/classes/event_handler/handle_operation_farmable_harvest.py +17 -0
- albibong/classes/event_handler/handle_operation_join.py +14 -36
- albibong/classes/event_handler/world_data_utils.py +62 -30
- albibong/classes/item.py +19 -4
- albibong/classes/location.py +136 -5
- albibong/classes/utils.py +20 -0
- albibong/gui_dist/assets/index-B31tZ4Ku.css +1 -0
- albibong/gui_dist/assets/index-BkyL_QUY.js +168 -0
- albibong/gui_dist/favor.png +0 -0
- albibong/gui_dist/index.html +2 -2
- albibong/gui_dist/might.png +0 -0
- albibong/migrations/001_init.py +97 -0
- albibong/migrations/002_alter_dungeon_table.py +53 -0
- albibong/models/__init__.py +0 -0
- albibong/models/models.py +12 -0
- albibong/requirements.txt +2 -0
- albibong/resources/items_by_unique_name.json +55282 -0
- albibong/resources/maps.json +259 -259
- albibong/threads/http_server.py +4 -0
- albibong/threads/sniffer_thread.py +39 -2
- albibong/threads/websocket_server.py +80 -43
- {albibong-1.0.7.dist-info → albibong-1.1.1.dist-info}/METADATA +3 -1
- {albibong-1.0.7.dist-info → albibong-1.1.1.dist-info}/RECORD +39 -32
- albibong/gui_dist/assets/index-DZvgNqlG.css +0 -1
- albibong/gui_dist/assets/index-Dt6hyZiS.css +0 -1
- albibong/gui_dist/assets/index-E7pha23k.js +0 -161
- albibong/gui_dist/assets/index-WIuC9Mnh.js +0 -161
- /albibong/resources/{items.json → items_by_id.json} +0 -0
- {albibong-1.0.7.dist-info → albibong-1.1.1.dist-info}/WHEEL +0 -0
- {albibong-1.0.7.dist-info → albibong-1.1.1.dist-info}/entry_points.txt +0 -0
- {albibong-1.0.7.dist-info → albibong-1.1.1.dist-info}/licenses/LICENSE +0 -0
albibong/__init__.py
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
1
3
|
import queue
|
|
2
4
|
import random
|
|
3
5
|
import socket
|
|
4
6
|
import sys
|
|
7
|
+
import uuid
|
|
8
|
+
from datetime import datetime, timedelta
|
|
9
|
+
from pathlib import Path
|
|
5
10
|
from time import sleep
|
|
6
11
|
|
|
7
12
|
import webview
|
|
13
|
+
from peewee_migrate import Router
|
|
8
14
|
from scapy.all import rdpcap
|
|
9
15
|
|
|
10
16
|
from albibong.classes.logger import Logger
|
|
11
17
|
from albibong.classes.packet_handler import PacketHandler
|
|
18
|
+
from albibong.classes.utils import Utils
|
|
19
|
+
from albibong.models.models import SQLITE_DB, db
|
|
12
20
|
from albibong.threads.http_server import HttpServerThread
|
|
13
21
|
from albibong.threads.packet_handler_thread import PacketHandlerThread
|
|
14
22
|
from albibong.threads.sniffer_thread import SnifferThread
|
|
@@ -17,6 +25,12 @@ from albibong.threads.websocket_server import get_ws_server
|
|
|
17
25
|
logger = Logger(__name__, stdout=True, log_to_file=False)
|
|
18
26
|
PORT = random.randrange(8500, 8999)
|
|
19
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
|
+
|
|
20
34
|
|
|
21
35
|
def read_pcap(path):
|
|
22
36
|
packet_handler = PacketHandler()
|
|
@@ -25,12 +39,79 @@ def read_pcap(path):
|
|
|
25
39
|
packet_handler.handle(packet)
|
|
26
40
|
|
|
27
41
|
|
|
28
|
-
def
|
|
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
|
+
|
|
29
109
|
_sentinel = object()
|
|
30
110
|
packet_queue = queue.Queue()
|
|
31
111
|
|
|
32
|
-
p = SnifferThread(
|
|
33
|
-
|
|
112
|
+
p = SnifferThread(
|
|
113
|
+
name="sniffer", out_queue=packet_queue, sentinel=_sentinel, is_debug=is_debug
|
|
114
|
+
)
|
|
34
115
|
c = PacketHandlerThread(
|
|
35
116
|
name="packet_handler",
|
|
36
117
|
in_queue=packet_queue,
|
|
@@ -44,7 +125,6 @@ def sniff(useWebview):
|
|
|
44
125
|
ws_server.start()
|
|
45
126
|
|
|
46
127
|
if useWebview:
|
|
47
|
-
|
|
48
128
|
sock = socket.socket()
|
|
49
129
|
sock.bind(("", 0))
|
|
50
130
|
port = sock.getsockname()[1]
|
|
@@ -66,6 +146,7 @@ def sniff(useWebview):
|
|
|
66
146
|
p.stop()
|
|
67
147
|
ws_server.stop()
|
|
68
148
|
http_server.stop()
|
|
149
|
+
db.close()
|
|
69
150
|
|
|
70
151
|
window.events.closing += on_closing
|
|
71
152
|
|
|
@@ -81,9 +162,12 @@ def sniff(useWebview):
|
|
|
81
162
|
|
|
82
163
|
def main(useWebview=True):
|
|
83
164
|
if len(sys.argv) > 1:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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])
|
|
88
172
|
else:
|
|
89
173
|
sniff(useWebview)
|
albibong/__main__.py
CHANGED
|
@@ -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)
|
albibong/classes/character.py
CHANGED
|
@@ -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
|
albibong/classes/dungeon.py
CHANGED
|
@@ -1,59 +1,80 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
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
|
|
3
8
|
|
|
4
9
|
DIVISOR = 10000
|
|
5
10
|
|
|
6
11
|
|
|
7
|
-
class Dungeon:
|
|
12
|
+
class Dungeon(BaseModel):
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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)
|
|
20
26
|
|
|
21
27
|
@staticmethod
|
|
22
28
|
def serialize(dungeon):
|
|
29
|
+
time_elapsed = dungeon.end_time - dungeon.start_time
|
|
30
|
+
total_hours = time_elapsed.total_seconds() / 3600
|
|
31
|
+
|
|
23
32
|
return {
|
|
24
33
|
"id": str(dungeon.id),
|
|
25
34
|
"type": dungeon.type,
|
|
26
35
|
"name": dungeon.name,
|
|
27
36
|
"tier": dungeon.tier,
|
|
28
|
-
"fame": dungeon.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
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,
|
|
31
47
|
"date_time": dungeon.start_time.strftime("%a %d %b %Y, %I:%M%p"),
|
|
32
|
-
"time_elapsed":
|
|
48
|
+
"time_elapsed": (
|
|
49
|
+
str(time_elapsed).split(".")[0] if dungeon.end_time else ""
|
|
50
|
+
),
|
|
51
|
+
"meter": dungeon.meter,
|
|
33
52
|
}
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
54
|
+
def set_end_time(self):
|
|
55
|
+
self.end_time = datetime.now()
|
|
45
56
|
|
|
46
57
|
def update_fame(self, parameters):
|
|
47
58
|
fame = parameters[2] / DIVISOR
|
|
48
|
-
self.
|
|
59
|
+
self.fame += fame
|
|
49
60
|
|
|
50
61
|
def update_re_spec(self, parameters):
|
|
51
62
|
re_spec = parameters[2] / DIVISOR
|
|
52
|
-
self.
|
|
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
|
|
53
68
|
|
|
54
69
|
def update_loot(self, parameters):
|
|
55
70
|
if 3 in parameters and parameters[3] == True:
|
|
56
71
|
silver = parameters[5] / DIVISOR
|
|
57
|
-
self.
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
@@ -1,7 +1,16 @@
|
|
|
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_fame(world_data: WorldData, parameters):
|
|
5
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)
|
|
6
15
|
if world_data.current_dungeon:
|
|
7
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:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from albibong.classes.event_handler.world_data_utils import WorldDataUtils
|
|
2
|
-
from albibong.classes.location import Location
|
|
2
|
+
from albibong.classes.location import Island, Location
|
|
3
3
|
from albibong.classes.world_data import WorldData
|
|
4
4
|
from albibong.threads.websocket_server import send_event
|
|
5
5
|
|
|
@@ -7,37 +7,32 @@ from albibong.threads.websocket_server import send_event
|
|
|
7
7
|
def handle_operation_change_cluster(world_data: WorldData, parameters):
|
|
8
8
|
world_data.change_equipment_log = {}
|
|
9
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
|
+
|
|
10
15
|
if 1 in parameters:
|
|
11
16
|
check_map = Location.get_location_from_code(parameters[1])
|
|
12
|
-
map_type_splitted = set(check_map.type.split("
|
|
17
|
+
map_type_splitted = set(check_map.type.split(" "))
|
|
13
18
|
WorldDataUtils.set_dungeon_status(world_data, check_map, map_type_splitted)
|
|
14
19
|
|
|
15
|
-
if "ISLAND" in map_type_splitted
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
18
28
|
|
|
19
29
|
elif 0 in parameters:
|
|
20
30
|
check_map = Location.get_location_from_code(parameters[0])
|
|
21
|
-
map_type_splitted = set(check_map.type.split("
|
|
31
|
+
map_type_splitted = set(check_map.type.split(" "))
|
|
22
32
|
is_dungeon = WorldDataUtils.set_dungeon_status(
|
|
23
33
|
world_data, check_map, map_type_splitted
|
|
24
34
|
)
|
|
25
35
|
if is_dungeon == False:
|
|
26
36
|
world_data.current_map = Location.get_location_from_code(parameters[0])
|
|
27
37
|
|
|
28
|
-
ws_update_location(world_data)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def ws_update_location(world_data: WorldData):
|
|
32
|
-
event = {
|
|
33
|
-
"type": "update_location",
|
|
34
|
-
"payload": {
|
|
35
|
-
"map": world_data.current_map.name if world_data.current_map else "None",
|
|
36
|
-
"dungeon": (
|
|
37
|
-
world_data.current_dungeon.name
|
|
38
|
-
if world_data.current_dungeon
|
|
39
|
-
else "None"
|
|
40
|
-
),
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
send_event(event)
|
|
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
|
+
)
|