Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyCommandCenter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Starcraft AI Course
PyCommandCenter
Commits
911d46ce
Commit
911d46ce
authored
5 years ago
by
David Bergström
Browse files
Options
Downloads
Patches
Plain Diff
Make it possible to compare UnitTypeID with UNIT_TYPEID
parent
863026a8
No related branches found
No related tags found
No related merge requests found
Pipeline
#6605
passed
5 years ago
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python-api-src/lib_sc2_typeenums.cpp
+2
-1
2 additions, 1 deletion
python-api-src/lib_sc2_typeenums.cpp
python-api-src/library.cpp
+2
-1
2 additions, 1 deletion
python-api-src/library.cpp
tests/unittypeid.py
+25
-0
25 additions, 0 deletions
tests/unittypeid.py
with
29 additions
and
2 deletions
python-api-src/lib_sc2_typeenums.cpp
+
2
−
1
View file @
911d46ce
...
@@ -217,7 +217,8 @@ void define_typeenums(py::module & m)
...
@@ -217,7 +217,8 @@ void define_typeenums(py::module & m)
.
value
(
"NEUTRAL_UNBUILDABLEPLATESDESTRUCTIBLE"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_UNBUILDABLEPLATESDESTRUCTIBLE
)
.
value
(
"NEUTRAL_UNBUILDABLEPLATESDESTRUCTIBLE"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_UNBUILDABLEPLATESDESTRUCTIBLE
)
.
value
(
"NEUTRAL_UTILITYBOT"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_UTILITYBOT
)
.
value
(
"NEUTRAL_UTILITYBOT"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_UTILITYBOT
)
.
value
(
"NEUTRAL_VESPENEGEYSER"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_VESPENEGEYSER
)
.
value
(
"NEUTRAL_VESPENEGEYSER"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_VESPENEGEYSER
)
.
value
(
"NEUTRAL_XELNAGATOWER"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_XELNAGATOWER
);
.
value
(
"NEUTRAL_XELNAGATOWER"
,
sc2
::
UNIT_TYPEID
::
NEUTRAL_XELNAGATOWER
)
.
def
(
"__eq__"
,
[](
const
sc2
::
UNIT_TYPEID
&
value
,
sc2
::
UnitTypeID
&
value2
)
{
return
value
==
value2
;
});
py
::
enum_
<
sc2
::
ABILITY_ID
>
(
m
,
"ABILITY_ID"
)
py
::
enum_
<
sc2
::
ABILITY_ID
>
(
m
,
"ABILITY_ID"
)
.
value
(
"INVALID"
,
sc2
::
ABILITY_ID
::
INVALID
)
.
value
(
"INVALID"
,
sc2
::
ABILITY_ID
::
INVALID
)
...
...
This diff is collapsed.
Click to expand it.
python-api-src/library.cpp
+
2
−
1
View file @
911d46ce
...
@@ -50,7 +50,8 @@ PYBIND11_MODULE(library, m)
...
@@ -50,7 +50,8 @@ PYBIND11_MODULE(library, m)
py
::
class_
<
sc2
::
UnitTypeID
>
(
m
,
"UnitTypeID"
)
py
::
class_
<
sc2
::
UnitTypeID
>
(
m
,
"UnitTypeID"
)
.
def
(
py
::
init
<
sc2
::
UNIT_TYPEID
>
());
.
def
(
py
::
init
<
sc2
::
UNIT_TYPEID
>
())
.
def
(
"__eq__"
,
[](
const
sc2
::
UnitTypeID
&
value
,
sc2
::
UNIT_TYPEID
&
value2
)
{
return
value
==
value2
;
});
py
::
implicitly_convertible
<
sc2
::
UNIT_TYPEID
,
sc2
::
UnitTypeID
>
();
py
::
implicitly_convertible
<
sc2
::
UNIT_TYPEID
,
sc2
::
UnitTypeID
>
();
...
...
This diff is collapsed.
Click to expand it.
tests/unittypeid.py
0 → 100644
+
25
−
0
View file @
911d46ce
import
unittest
import
sys
sys
.
path
.
append
(
'
build/python-api-src
'
)
from
library
import
UnitTypeID
,
UNIT_TYPEID
class
TestUnitType
(
unittest
.
TestCase
):
def
test_equality
(
self
):
self
.
assertTrue
(
UNIT_TYPEID
.
TERRAN_ARMORY
==
UNIT_TYPEID
.
TERRAN_ARMORY
)
def
test_inequality
(
self
):
self
.
assertFalse
(
UNIT_TYPEID
.
TERRAN_ARMORY
!=
UNIT_TYPEID
.
TERRAN_ARMORY
)
def
test_convert_equality
(
self
):
unit_typeid
=
UNIT_TYPEID
.
TERRAN_ARMORY
self
.
assertTrue
(
unit_typeid
==
UnitTypeID
(
unit_typeid
))
self
.
assertTrue
(
UnitTypeID
(
unit_typeid
)
==
unit_typeid
)
self
.
assertFalse
(
UnitTypeID
(
unit_typeid
)
!=
unit_typeid
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment