Skip to content

Commit

Permalink
Resolves #98 (#99)
Browse files Browse the repository at this point in the history
* feat(issue-98): Add SC2Action class

* test(issue-98): Add units tests to SC2Action

* refactor(issue-98): Fix typo in SC2Action unit tests

* refactor(issue-98): Rename action_id to action

#98

* refactor(issue-98): Rename action to action_function

#99

Co-authored-by: Álvaro Paiva <[email protected]>

---------

Co-authored-by: Álvaro Paiva <[email protected]>
  • Loading branch information
CinquilCinquil and alvarofpp authored Aug 4, 2024
1 parent 616f29b commit 6d15f53
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/units/sc2/actions/test_sc2_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import unittest

from pysc2.lib import actions

from urnai.actions.sc2_action import SC2Action

_BUILD_REFINERY = actions.RAW_FUNCTIONS.Build_Refinery_pt
_NO_OP = actions.FUNCTIONS.no_op

class TestSC2Action(unittest.TestCase):

def test_run(self):

run_no_op = SC2Action.run(_NO_OP)
run_build_refinery = SC2Action.run(_BUILD_REFINERY, 'now', 0)

self.assertEqual(run_no_op.function, _NO_OP.id)
self.assertEqual(run_no_op.arguments, [])

self.assertEqual(run_build_refinery.function, _BUILD_REFINERY.id)
self.assertEqual(run_build_refinery.arguments, [[actions.Queued['now']], [0]])
9 changes: 9 additions & 0 deletions urnai/sc2/actions/sc2_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pysc2.lib.actions import FunctionCall


class SC2Action:

"""This class encapsulates the usage of actions from pysc2"""

def run(action_function, *args) -> FunctionCall:
return action_function(*args)

0 comments on commit 6d15f53

Please sign in to comment.