-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new requirements file to run abilities only if agent paw exists
- Loading branch information
1 parent
296a41d
commit e28ec65
Showing
1 changed file
with
23 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,23 @@ | ||
from plugins.stockpile.app.requirements.base_requirement import BaseRequirement | ||
|
||
|
||
class Requirement(BaseRequirement): | ||
|
||
async def enforce(self, link, operation): | ||
""" | ||
Given a link and the current operation, ensure will only run if the agent with the given ID/PAW is alive. | ||
:param link | ||
:param operation | ||
:return: True if it complies, False if it doesn't | ||
""" | ||
print("\n\n*********************\nin check_registered.py") | ||
agent_paws = [agent.paw for agent in await operation.active_agents()] | ||
for uf in link.used: | ||
print("id: ", uf.value ," agent_paws:", agent_paws) | ||
if uf.value in agent_paws: | ||
print("returning true - run this ability") | ||
return True | ||
print("returning false - don't run this ability") | ||
return False | ||
|