Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Add Loadout functionality to Player objects (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Chrisp authored and Ethan Chrisp committed Feb 1, 2020
1 parent b7a22c6 commit 538ed4c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
45 changes: 44 additions & 1 deletion callofduty/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List, Optional

from .enums import Mode, Platform, Title
from .loadout import Loadout, LoadoutItem
from .object import Object

log: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -144,9 +145,51 @@ async def leaderboard(self, title: Title, **kwargs):
title, self.platform, self.username, **kwargs
)

async def loadouts(self, title: Title, **kwargs) -> List[Loadout]:
"""
Get the Call of Duty player's loadouts for the specified title and mode.
Parameters
----------
title : callofduty.Title
Call of Duty title to get the player's loadouts from.
mode: callofduty.Mode, optional
Call of Duty mode to get the player's loadouts from (default is Multiplayer.)
Returns
-------
list
Array of loadout objects.
"""

return await self._client.GetPlayerLoadouts(
self.platform, self.username, title, **kwargs
)

async def loadoutUnlocks(self, title: Title, **kwargs) -> List[LoadoutItem]:
"""
Get the Call of Duty player's loadout unlocks for the specified title and mode.
Parameters
----------
title : callofduty.Title
Call of Duty title to get the player's loadout unlocks from.
mode: callofduty.Mode, optional
Call of Duty mode to get the player's loadout unlocks from (default is Multiplayer.)
Returns
-------
list
Array of loadout item objects.
"""

return await self._client.GetPlayerLoadoutUnlocks(
self.platform, self.username, title, **kwargs
)

async def authenticityStamp(self, phrase: str, **kwargs) -> dict:
"""
Get a Call of Duty Authenticity Stamp for the player and specified phrase.
Get the Call of Duty player's Authenticity Stamp for the specified phrase.
Parameters
----------
Expand Down
11 changes: 11 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,21 @@ async def main():
# if wildcard.id is not None:
# print(f" - Wildcard: {wildcard.id}")

# player = await client.GetPlayer(Platform.PlayStation, "ImMotive__")
# loadouts = await player.loadouts(Title.BlackOps4)
# for loadout in loadouts:
# if loadout.name != "":
# print(f"Class: {loadout.name} (Unlocked: {loadout.unlocked})")

# unlocks = await client.GetPlayerLoadoutUnlocks(Platform.PlayStation, "ImMotive__", Title.BlackOps4)
# for unlock in unlocks:
# print(unlock.id)

# player = await client.GetPlayer(Platform.PlayStation, "ImMotive__")
# unlocks = await player.loadoutUnlocks(Title.BlackOps4)
# for unlock in unlocks:
# print(unlock.id)

# stamp = await client.GetAuthenticityStamp(
# Platform.BattleNet, "Slicky#21337", "Swiftly Snarling Gamy Generators"
# )
Expand Down

0 comments on commit 538ed4c

Please sign in to comment.