-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add examples for Battlefield 1943 and Battlefield: Bad Company
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |