Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #98 #99

Merged
merged 5 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 TestActionBase(unittest.TestCase):
CinquilCinquil marked this conversation as resolved.
Show resolved Hide resolved

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_id, *args) -> FunctionCall:
CinquilCinquil marked this conversation as resolved.
Show resolved Hide resolved
return action_id(*args)