-
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 * Remove debug print statements * Remove blank lines * Add requirement for Lightneuron implant * Adjust blank lines * Fix syntax
- Loading branch information
1 parent
c4b14e2
commit ee8f3c9
Showing
2 changed files
with
38 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,21 @@ | ||
from plugins.stockpile.app.requirements.base_requirement import BaseRequirement | ||
from app.utility.base_service import BaseService | ||
|
||
|
||
class Requirement(BaseRequirement): | ||
|
||
async def enforce(self, link, operation): | ||
""" | ||
Given a link and the current operation, ensure the ability will only run if the | ||
agent with the given ID/PAW is listed in the Agents tab on the Caldera Server GUI. | ||
:param link | ||
:param operation | ||
:return: True if it complies, False if it doesn't | ||
""" | ||
agent_paws = [agent.paw for agent in BaseService.get_service('data_svc').ram['agents']] | ||
for uf in link.used: | ||
# Remove the "@" character if it appears in the given fact | ||
# In order to accomodate the Lightneuron implant ID | ||
if uf.value.replace("@", "") in agent_paws: | ||
return True | ||
return False |
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,17 @@ | ||
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 | ||
""" | ||
agent_paws = [agent.paw for agent in await operation.active_agents()] | ||
for uf in link.used: | ||
if uf.value in agent_paws: | ||
return True | ||
return False |