Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro-core
Commits
1179f090
Commit
1179f090
authored
May 23, 2018
by
nekrozar
Committed by
nanahira
May 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Card.IsAttack(#164)
parent
93056400
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
+50
-0
interpreter.cpp
interpreter.cpp
+2
-0
libcard.cpp
libcard.cpp
+46
-0
scriptlib.h
scriptlib.h
+2
-0
No files found.
interpreter.cpp
View file @
1179f090
...
@@ -111,6 +111,8 @@ static const struct luaL_Reg cardlib[] = {
...
@@ -111,6 +111,8 @@ static const struct luaL_Reg cardlib[] = {
{
"IsLevel"
,
scriptlib
::
card_is_level
},
{
"IsLevel"
,
scriptlib
::
card_is_level
},
{
"IsRank"
,
scriptlib
::
card_is_rank
},
{
"IsRank"
,
scriptlib
::
card_is_rank
},
{
"IsLink"
,
scriptlib
::
card_is_link
},
{
"IsLink"
,
scriptlib
::
card_is_link
},
{
"IsAttack"
,
scriptlib
::
card_is_attack
},
{
"IsDefense"
,
scriptlib
::
card_is_defense
},
{
"IsRace"
,
scriptlib
::
card_is_race
},
{
"IsRace"
,
scriptlib
::
card_is_race
},
{
"IsLinkRace"
,
scriptlib
::
card_is_link_race
},
{
"IsLinkRace"
,
scriptlib
::
card_is_link_race
},
{
"IsAttribute"
,
scriptlib
::
card_is_attribute
},
{
"IsAttribute"
,
scriptlib
::
card_is_attribute
},
...
...
libcard.cpp
View file @
1179f090
...
@@ -946,6 +946,52 @@ int32 scriptlib::card_is_link(lua_State *L) {
...
@@ -946,6 +946,52 @@ int32 scriptlib::card_is_link(lua_State *L) {
lua_pushboolean
(
L
,
result
);
lua_pushboolean
(
L
,
result
);
return
1
;
return
1
;
}
}
int32
scriptlib
::
card_is_attack
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
!
(
pcard
->
data
.
type
&
TYPE_MONSTER
)
&&
!
(
pcard
->
get_type
()
&
TYPE_MONSTER
)
&&
!
(
pcard
->
current
.
location
&
LOCATION_MZONE
))
lua_pushboolean
(
L
,
0
);
else
{
uint32
atk
=
pcard
->
get_attack
();
uint32
count
=
lua_gettop
(
L
)
-
1
;
uint32
result
=
FALSE
;
for
(
uint32
i
=
0
;
i
<
count
;
++
i
)
{
if
(
lua_isnil
(
L
,
i
+
2
))
continue
;
uint32
tatk
=
lua_tointeger
(
L
,
i
+
2
);
if
(
atk
==
tatk
)
{
result
=
TRUE
;
break
;
}
}
lua_pushboolean
(
L
,
result
);
}
return
1
;
}
int32
scriptlib
::
card_is_defense
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
((
pcard
->
data
.
type
&
TYPE_LINK
)
||
(
!
(
pcard
->
data
.
type
&
TYPE_MONSTER
)
&&
!
(
pcard
->
get_type
()
&
TYPE_MONSTER
)
&&
!
(
pcard
->
current
.
location
&
LOCATION_MZONE
)))
lua_pushboolean
(
L
,
0
);
else
{
uint32
def
=
pcard
->
get_defense
();
uint32
count
=
lua_gettop
(
L
)
-
1
;
uint32
result
=
FALSE
;
for
(
uint32
i
=
0
;
i
<
count
;
++
i
)
{
if
(
lua_isnil
(
L
,
i
+
2
))
continue
;
uint32
tdef
=
lua_tointeger
(
L
,
i
+
2
);
if
(
def
==
tdef
)
{
result
=
TRUE
;
break
;
}
}
lua_pushboolean
(
L
,
result
);
}
return
1
;
}
int32
scriptlib
::
card_is_race
(
lua_State
*
L
)
{
int32
scriptlib
::
card_is_race
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
...
...
scriptlib.h
View file @
1179f090
...
@@ -113,6 +113,8 @@ public:
...
@@ -113,6 +113,8 @@ public:
static
int32
card_is_level
(
lua_State
*
L
);
static
int32
card_is_level
(
lua_State
*
L
);
static
int32
card_is_rank
(
lua_State
*
L
);
static
int32
card_is_rank
(
lua_State
*
L
);
static
int32
card_is_link
(
lua_State
*
L
);
static
int32
card_is_link
(
lua_State
*
L
);
static
int32
card_is_attack
(
lua_State
*
L
);
static
int32
card_is_defense
(
lua_State
*
L
);
static
int32
card_is_race
(
lua_State
*
L
);
static
int32
card_is_race
(
lua_State
*
L
);
static
int32
card_is_link_race
(
lua_State
*
L
);
static
int32
card_is_link_race
(
lua_State
*
L
);
static
int32
card_is_attribute
(
lua_State
*
L
);
static
int32
card_is_attribute
(
lua_State
*
L
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment