Skip to content

Commit

Permalink
🔀 Refactor class MemberOffset650 and MemberOffset to use a size varia…
Browse files Browse the repository at this point in the history
…ble instead of hardcoded size values
  • Loading branch information
nyaoouo committed Oct 7, 2023
1 parent fd71991 commit 4d9649b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ff_draw/mem/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class MemberOffset:
level = 0x206
shield = 0x207

size_ = 0X230


class MemberOffset650:
status = 0x0
Expand All @@ -39,6 +41,8 @@ class MemberOffset650:
level = 0x366
shield = 0x367

size_ = 0X390


class Member:
offsets = MemberOffset
Expand Down Expand Up @@ -94,7 +98,7 @@ class Party:
def __init__(self, handle, address):
self.handle = handle
self.address = address
self.members = [Member(self.handle, self.address + self.offsets.members + i * 0x230) for i in range(28)]
self.members = [Member(self.handle, self.address + self.offsets.members + i * Member.offsets.size_) for i in range(28)]

def __iter__(self):
for i in range(self.party_size):
Expand All @@ -115,13 +119,12 @@ def __init__(self, main: 'XivMem'):
self.main = main
real_party_address = main.scanner.find_point('48 ? ? * * * * 48 89 74 24 ? b2')[0]
replay_party_address = real_party_address + main.scanner.find_val('74 ? f6 05 ? ? ? ? ? 48 ? ? * * * * 75')[0]
self.real_party = Party(self.main.handle, real_party_address)
self.replay_party = Party(self.main.handle, replay_party_address)

if main.game_version >= (6, 5, 0):
Member.offsets = MemberOffset650
else:
Member.offsets = MemberOffset
self.real_party = Party(self.main.handle, real_party_address)
self.replay_party = Party(self.main.handle, replay_party_address)

@property
def party_list(self):
Expand Down

0 comments on commit 4d9649b

Please sign in to comment.