-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds support for grabbing current operations (#5)
- Loading branch information
1 parent
700ae01
commit 05af269
Showing
11 changed files
with
261 additions
and
65 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,31 @@ | ||
import os | ||
import asyncio | ||
from dotenv import load_dotenv | ||
|
||
from pymerc.client import Client | ||
|
||
# Load the API_USER and API_TOKEN from the environment | ||
load_dotenv() | ||
|
||
|
||
async def calculate_ideal_labor_for_player_buildings(): | ||
client = Client(os.environ["API_USER"], os.environ["API_TOKEN"]) | ||
player = await client.player() | ||
|
||
total_labor = 0.0 | ||
|
||
for building in player.buildings: | ||
# Ensure we're using the Building class from pymerc.game | ||
building = await client.building(building.id) | ||
if building.production: | ||
labor_required = await building.calculate_current_labor_need() | ||
print( | ||
f"Building ID: {building.id}, Type: {building.type}, Recipe: {building.production.recipe.value}, Labor Required: {labor_required}") | ||
total_labor += labor_required | ||
|
||
print(f"Total labor required for all buildings: {total_labor}") | ||
|
||
await client.close() | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(calculate_ideal_labor_for_player_buildings()) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.