Skip to content

Commit

Permalink
plugin: set correct license type
Browse files Browse the repository at this point in the history
  • Loading branch information
Mixaill committed Sep 28, 2019
1 parent 26b3811 commit 6b5d27a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Galaxy Wargaming plugin",
"platform": "wargaming",
"guid": "91728e8a-33c3-4b6d-8382-4dd31043dec1",
"version": "0.7.4",
"version": "0.7.5",
"description": "Galaxy Wargaming plugin",
"author": "Mikhail Paulyshka",
"email": "[email protected]",
Expand Down
3 changes: 2 additions & 1 deletion plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ async def get_owned_games(self):
owned_applications = list()

for instance in self._wgc.get_owned_applications().values():
owned_applications.append(Game(instance.get_application_id(), instance.get_application_fullname(), None, LicenseInfo(LicenseType.FreeToPlay, None)))
license_info = LicenseInfo(LicenseType.SinglePurchase if instance.is_application_purchased() else LicenseType.FreeToPlay, None)
owned_applications.append(Game(instance.get_application_id(), instance.get_application_fullname(), None, license_info))

return owned_applications

Expand Down
17 changes: 12 additions & 5 deletions wgc/wgc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,14 +646,21 @@ def fetch_product_list(self) -> List[WGCOwnedApplication]:
return product_list

for product in showroom_data['data']['showcase']:
app = WGCOwnedApplication(product)
if not app.get_application_instances():
#check that instances are exists
if not product['instances']:
logging.warn('wgc_api/fetch_product_list: product has no instances %s' % product)
continue

app_gameid = list(app.get_application_instances().values())[0].get_application_gameid()

#prase game id
app_gameid = None
try:
app_gameid = product['instances'][0]['application_id'].split('.')[0]
except:
logging.exception('wgc_api/fetch_product_list: failed to get app_id')

if app_gameid in self.GAMES_F2P or app_gameid in purchased_gameids:
product_list.append(app)
is_purchased = app_gameid in purchased_gameids and app_gameid not in self.GAMES_F2P
product_list.append(WGCOwnedApplication(product, is_purchased))

return product_list

Expand Down
20 changes: 14 additions & 6 deletions wgc/wgc_application_owned.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from .wgc_location import WGCLocation

class WGCOwnedApplicationInstance(object):
def __init__(self, app_data, instance_data):
def __init__(self, app_data, instance_data, is_purchased):
self._name = app_data['game_name']
self._data = instance_data
self.__is_purchased = is_purchased

def get_application_id(self):
return self._data['application_id']
Expand All @@ -34,6 +35,9 @@ def get_application_install_url(self):
def get_update_service_url(self):
return self._data['update_service_url']

def is_application_purchased(self) -> bool:
return self.__is_purchased

def install_application(self) -> bool:
if not WGCLocation.is_wgc_installed():
logging.warning('WGCOwnedApplicationInstance/install_application: failed to install %s because WGC is not installed' % self.get_application_id())
Expand All @@ -45,16 +49,20 @@ def install_application(self) -> bool:

class WGCOwnedApplication():

def __init__(self, data):
self._data = data
def __init__(self, data, is_purchased):
self.__data = data
self.__is_purchased = is_purchased

self._instances = dict()
for instance_json in self._data['instances']:
instance_obj = WGCOwnedApplicationInstance(self._data, instance_json)
for instance_json in self.__data['instances']:
instance_obj = WGCOwnedApplicationInstance(self.__data, instance_json, is_purchased)
self._instances[instance_obj.get_application_id()] = instance_obj

def is_application_purchased(self) -> bool:
return self.__is_purchased

def get_application_name(self) -> str:
return fixup_gamename(self._data['game_name'])
return fixup_gamename(self.__data['game_name'])

def get_application_instances(self) -> Dict[str, WGCOwnedApplicationInstance]:
return self._instances

0 comments on commit 6b5d27a

Please sign in to comment.