Skip to content

Commit

Permalink
docs: Add examples for Battlefield 1943 and Battlefield: Bad Company
Browse files Browse the repository at this point in the history
  • Loading branch information
cetteup committed Jul 4, 2023
1 parent ab1226a commit 9e2f473
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/bf1943.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from urllib.parse import quote

from pybfbc2stats import FeslClient, Platform, Namespace, SecureConnection
from pybfbc2stats.packet import FeslPacket


def main():
with FeslClient('ea_account_name', 'ea_account_password', Platform.ps3) as client:
# Override the connection to connect to the Battlefield 1943 backend
client.connection = SecureConnection(
'beach-ps3-server.fesl.ea.com',
18331,
FeslPacket,
client.connection.timeout
)
client.client_string = b'beach-ps3'

quoted_name = quote('sam707')
persona = client.lookup_username(quoted_name, Namespace.ps3)
stats = client.get_stats(int(persona['userId']), [b'games', b'wins', b'losses'])
print(stats)


if __name__ == '__main__':
main()
26 changes: 26 additions & 0 deletions examples/bfbc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from urllib.parse import quote

from pybfbc2stats import FeslClient, Platform, Namespace, SecureConnection
from pybfbc2stats.packet import FeslPacket


def main():
with FeslClient('ea_account_name', 'ea_account_password', Platform.xbox360) as client:
# We don't know the hostname of the Xbox 360 backend, but we can use the PS3 backend with an Xbox client string
client.connection = SecureConnection(
'bfbc-ps3.fesl.ea.com',
18800,
FeslPacket,
client.connection.timeout
)
client.client_string = b'bfbc-360'

quoted_name = quote('daddyo21252')
# Bad Company uses different ("legacy") namespaces (XBL_SUB and PS3_SUB)
persona = client.lookup_username(quoted_name, Namespace.XBL_SUB)
stats = client.get_stats(int(persona['userId']), [b'games', b'wins', b'losses'])
print(stats)


if __name__ == '__main__':
main()

0 comments on commit 9e2f473

Please sign in to comment.