Implement working character associations with SSO character

This commit is contained in:
Ryan Holmes
2018-03-14 17:53:48 -04:00
parent f52f39984f
commit 9d379d966c
5 changed files with 77 additions and 17 deletions

View File

@@ -205,11 +205,14 @@ class HandledImplantBoosterList(HandledList):
HandledList.append(self, thing)
class HandledSsoCharacterList(HandledList):
class HandledSsoCharacterList(list):
def append(self, character):
for x in self:
print(x)
HandledList.append(self, character)
old = next((x for x in self if x.client == character.client), None)
if old is not None:
pyfalog.warning("Removing SSO Character with same hash: {}".format(repr(old)))
list.remove(self, old)
list.append(self, character)
class HandledProjectedModList(HandledList):

View File

@@ -163,6 +163,18 @@ class Character(object):
def name(self, name):
self.savedName = name
def setSsoCharacter(self, character, clientHash):
if character is not None:
self.__ssoCharacters.append(character)
else:
for x in self.__ssoCharacters:
if x.client == clientHash:
self.__ssoCharacters.remove(x)
def getSsoCharacter(self, clientHash):
return next((x for x in self.__ssoCharacters if x.client == clientHash), None)
@property
def alphaCloneID(self):
return self.__alphaCloneID

View File

@@ -49,3 +49,9 @@ class SsoCharacter(object):
self.accessTokenExpires - datetime.datetime.utcnow()
).total_seconds()
}
def __repr__(self):
return "SsoCharacter(ID={}, name={}, client={}) at {}".format(
self.ID, self.characterName, self.client, hex(id(self))
)