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
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
MyCard
ygopro-core
Commits
e235487a
Commit
e235487a
authored
Aug 20, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Fluorohydride/ygopro-core
parents
4291281e
181ccafe
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
506 additions
and
360 deletions
+506
-360
card.cpp
card.cpp
+130
-89
card.h
card.h
+25
-6
effect.cpp
effect.cpp
+46
-11
effect.h
effect.h
+8
-2
field.cpp
field.cpp
+28
-28
field.h
field.h
+11
-8
interpreter.cpp
interpreter.cpp
+34
-3
interpreter.h
interpreter.h
+6
-4
libcard.cpp
libcard.cpp
+19
-4
libdebug.cpp
libdebug.cpp
+1
-1
libduel.cpp
libduel.cpp
+13
-6
libeffect.cpp
libeffect.cpp
+5
-4
operations.cpp
operations.cpp
+111
-110
processor.cpp
processor.cpp
+68
-84
scriptlib.h
scriptlib.h
+1
-0
No files found.
card.cpp
View file @
e235487a
This diff is collapsed.
Click to expand it.
card.h
View file @
e235487a
...
...
@@ -104,6 +104,24 @@ public:
public:
void
addcard
(
card
*
pcard
);
};
struct
sendto_param_t
{
void
set
(
uint8
p
,
uint8
pos
,
uint8
loc
,
uint8
seq
=
0
)
{
playerid
=
p
;
position
=
pos
;
location
=
loc
;
sequence
=
seq
;
}
void
clear
()
{
playerid
=
0
;
position
=
0
;
location
=
0
;
sequence
=
0
;
}
uint8
playerid
;
uint8
position
;
uint8
location
;
uint8
sequence
;
};
int32
scrtype
;
int32
ref_handle
;
duel
*
pduel
;
...
...
@@ -116,7 +134,7 @@ public:
uint8
summon_player
;
uint32
summon_info
;
uint32
status
;
uint32
operation
_param
;
sendto_param_t
sendto
_param
;
uint32
release_param
;
uint32
sum_param
;
uint32
position_param
;
...
...
@@ -272,19 +290,19 @@ public:
int32
check_fusion_substitute
(
card
*
fcard
);
int32
check_unique_code
(
card
*
pcard
);
void
get_unique_target
(
card_set
*
cset
,
int32
controler
);
void
get_unique_target
(
card_set
*
cset
,
int32
controler
,
card
*
icard
=
0
);
int32
check_cost_condition
(
int32
ecode
,
int32
playerid
);
int32
check_cost_condition
(
int32
ecode
,
int32
playerid
,
int32
sumtype
);
int32
is_summonable_card
();
int32
is_fusion_summonable_card
(
uint32
summon_type
);
int32
is_spsummonable
(
effect
*
peffect
);
int32
is_summonable
(
effect
*
peffect
,
uint8
min_tribute
,
uint32
zone
=
0x1f
);
int32
is_summonable
(
effect
*
peffect
,
uint8
min_tribute
,
uint32
zone
=
0x1f
,
uint32
releasable
=
0xff00ff
);
int32
is_can_be_summoned
(
uint8
playerid
,
uint8
ingore_count
,
effect
*
peffect
,
uint8
min_tribute
,
uint32
zone
=
0x1f
);
int32
get_summon_tribute_count
();
int32
get_set_tribute_count
();
int32
is_can_be_flip_summoned
(
uint8
playerid
);
int32
is_special_summonable
(
uint8
playerid
,
uint32
summon_type
);
int32
is_can_be_special_summoned
(
effect
*
reason_effect
,
uint32
sumtype
,
uint8
sumpos
,
uint8
sumplayer
,
uint8
toplayer
,
uint8
nocheck
,
uint8
nolimit
,
uint32
zone
);
int32
is_can_be_special_summoned
(
effect
*
reason_effect
,
uint32
sumtype
,
uint8
sumpos
,
uint8
sumplayer
,
uint8
toplayer
,
uint8
nocheck
,
uint8
nolimit
,
uint32
zone
,
uint8
nozoneusedcheck
=
0
);
int32
is_setable_mzone
(
uint8
playerid
,
uint8
ignore_count
,
effect
*
peffect
,
uint8
min_tribute
,
uint32
zone
=
0x1f
);
int32
is_setable_szone
(
uint8
playerid
,
uint8
ignore_fd
=
0
);
int32
is_affect_by_effect
(
effect
*
peffect
);
...
...
@@ -308,6 +326,7 @@ public:
int32
is_capable_attack
();
int32
is_capable_attack_announce
(
uint8
playerid
);
int32
is_capable_change_position
(
uint8
playerid
);
int32
is_capable_change_position_by_effect
(
uint8
playerid
);
int32
is_capable_turn_set
(
uint8
playerid
);
int32
is_capable_change_control
();
int32
is_control_can_be_changed
(
int32
ignore_mzone
,
uint32
zone
);
...
...
@@ -404,7 +423,7 @@ public:
#define RACE_DEVINE 0x200000 //
#define RACE_CREATORGOD 0x400000 //
#define RACE_WYRM 0x800000 //
#define RACE_CYBERS
0x1000000 //
#define RACE_CYBERS
E
0x1000000 //
//Reason
#define REASON_DESTROY 0x1 //
#define REASON_RELEASE 0x2 //
...
...
@@ -466,7 +485,7 @@ public:
#define STATUS_SUMMON_DISABLED 0x20000 //
#define STATUS_ACTIVATE_DISABLED 0x40000 //
#define STATUS_EFFECT_REPLACED 0x80000
#define STATUS_
UNION
0x100000
#define STATUS_
FUTURE_FUSION
0x100000
#define STATUS_ATTACK_CANCELED 0x200000
#define STATUS_INITIALIZING 0x400000
#define STATUS_ACTIVATED 0x800000
...
...
effect.cpp
View file @
e235487a
...
...
@@ -24,6 +24,7 @@ effect::effect(duel* pd) {
effect_owner
=
PLAYER_NONE
;
card_type
=
0
;
active_type
=
0
;
active_location
=
0
;
active_handler
=
0
;
id
=
0
;
code
=
0
;
...
...
@@ -34,6 +35,8 @@ effect::effect(duel* pd) {
range
=
0
;
s_range
=
0
;
o_range
=
0
;
count_limit
=
0
;
count_limit_max
=
0
;
reset_count
=
0
;
reset_flag
=
0
;
count_code
=
0
;
...
...
@@ -42,7 +45,6 @@ effect::effect(duel* pd) {
label_object
=
0
;
hint_timing
[
0
]
=
0
;
hint_timing
[
1
]
=
0
;
field_ref
=
0
;
status
=
0
;
condition
=
0
;
cost
=
0
;
...
...
@@ -146,16 +148,16 @@ int32 effect::is_available() {
status
&=
~
EFFECT_STATUS_AVAILABLE
;
return
res
;
}
// reset_count:
//
0x00ff: count of effect reset
//
0xf000: max count of activation, 0x0f00: left
count of activation
// reset_count:
count of effect reset
//
count_limit: left count of activation
//
count_limit_max: max
count of activation
int32
effect
::
check_count_limit
(
uint8
playerid
)
{
if
(
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
))
{
if
(
(
reset_count
&
0xf00
)
==
0
)
if
(
count_limit
==
0
)
return
FALSE
;
if
(
count_code
)
{
uint32
code
=
count_code
&
0xfffffff
;
uint32
count
=
(
reset_count
>>
12
)
&
0xf
;
uint32
count
=
count_limit_max
;
if
(
code
==
1
)
{
if
(
pduel
->
game_field
->
get_effect_code
((
count_code
&
0xf0000000
)
|
get_handler
()
->
fieldid
,
PLAYER_NONE
)
>=
count
)
return
FALSE
;
...
...
@@ -558,7 +560,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
if
((((
reset_flag
&
RESET_SELF_TURN
)
&&
pid
==
tp
)
||
((
reset_flag
&
RESET_OPPO_TURN
)
&&
pid
!=
tp
))
&&
(
reset_level
&
0x3ff
&
reset_flag
))
reset_count
--
;
if
(
(
reset_count
&
0xff
)
==
0
)
if
(
reset_count
==
0
)
return
TRUE
;
return
FALSE
;
break
;
...
...
@@ -578,9 +580,9 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
void
effect
::
dec_count
(
uint32
playerid
)
{
if
(
!
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
))
return
;
if
(
(
reset_count
&
0xf00
)
==
0
)
if
(
count_limit
==
0
)
return
;
reset_count
-=
0x100
;
count_limit
-=
1
;
if
(
count_code
)
{
uint32
code
=
count_code
&
0xfffffff
;
if
(
code
==
1
)
...
...
@@ -591,8 +593,7 @@ void effect::dec_count(uint32 playerid) {
}
void
effect
::
recharge
()
{
if
(
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
))
{
reset_count
&=
0xf0ff
;
reset_count
|=
(
reset_count
>>
4
)
&
0xf00
;
count_limit
=
count_limit_max
;
}
}
int32
effect
::
get_value
(
uint32
extraargs
)
{
...
...
@@ -627,6 +628,35 @@ int32 effect::get_value(effect* peffect, uint32 extraargs) {
return
(
int32
)
value
;
}
}
void
effect
::
get_value
(
uint32
extraargs
,
std
::
vector
<
int32
>*
result
)
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
1
+
extraargs
,
result
);
}
else
{
pduel
->
lua
->
params
.
clear
();
result
->
push_back
((
int32
)
value
);
}
}
void
effect
::
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
)
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
pduel
->
lua
->
add_param
(
pcard
,
PARAM_TYPE_CARD
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
}
else
{
pduel
->
lua
->
params
.
clear
();
result
->
push_back
((
int32
)
value
);
}
}
void
effect
::
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
)
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
pduel
->
lua
->
add_param
(
peffect
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
}
else
{
pduel
->
lua
->
params
.
clear
();
result
->
push_back
((
int32
)
value
);
}
}
int32
effect
::
check_value_condition
(
uint32
extraargs
)
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
...
...
@@ -689,3 +719,8 @@ int32 effect::in_range(const chain& ch) {
return
handler
->
overlay_target
?
TRUE
:
FALSE
;
return
range
&
ch
.
triggering_location
;
}
void
effect
::
set_activate_location
()
{
card
*
phandler
=
get_handler
();
active_location
=
phandler
->
current
.
location
;
//active_sequence = phandler->current.sequence;
}
effect.h
View file @
e235487a
...
...
@@ -42,17 +42,19 @@ public:
uint16
range
;
uint16
s_range
;
uint16
o_range
;
uint8
count_limit
;
uint8
count_limit_max
;
uint16
reset_count
;
uint32
reset_flag
;
uint32
count_code
;
uint32
category
;
uint32
label
;
uint32
hint_timing
[
2
];
uint32
card_type
;
uint32
active_type
;
uint32
active_location
;
card
*
active_handler
;
uint16
field_ref
;
uint16
status
;
uint32
label
;
void
*
label_object
;
int32
condition
;
int32
cost
;
...
...
@@ -83,6 +85,9 @@ public:
int32
get_value
(
uint32
extraargs
=
0
);
int32
get_value
(
card
*
pcard
,
uint32
extraargs
=
0
);
int32
get_value
(
effect
*
peffect
,
uint32
extraargs
=
0
);
void
get_value
(
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
int32
check_value_condition
(
uint32
extraargs
=
0
);
int32
get_speed
();
card
*
get_owner
()
const
;
...
...
@@ -91,6 +96,7 @@ public:
uint8
get_handler_player
();
int32
in_range
(
card
*
pcard
);
int32
in_range
(
const
chain
&
ch
);
void
set_activate_location
();
bool
is_flag
(
effect_flag
flag
)
const
{
return
!!
(
this
->
flag
[
0
]
&
flag
);
}
...
...
field.cpp
View file @
e235487a
This diff is collapsed.
Click to expand it.
field.h
View file @
e235487a
...
...
@@ -51,6 +51,7 @@ struct chain {
uint8
triggering_controler
;
uint16
triggering_location
;
uint8
triggering_sequence
;
uint8
triggering_position
;
effect
*
triggering_effect
;
group
*
target_cards
;
int32
replace_op
;
...
...
@@ -345,11 +346,11 @@ public:
void
move_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
,
uint8
pzone
=
FALSE
);
void
set_control
(
card
*
pcard
,
uint8
playerid
,
uint16
reset_phase
,
uint8
reset_count
);
card
*
get_field_card
(
uint32
playerid
,
uint32
location
,
uint32
sequence
);
int32
is_location_useable
(
uint32
playerid
,
uint32
location
,
uint32
sequence
);
int32
get_useable_count
(
card
*
pcard
,
uint8
playerid
,
uint8
location
,
uint8
uplayer
,
uint32
reason
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
);
int32
is_location_useable
(
uint32
playerid
,
uint32
location
,
uint32
sequence
,
uint8
neglect_used
=
0
);
int32
get_useable_count
(
card
*
pcard
,
uint8
playerid
,
uint8
location
,
uint8
uplayer
,
uint32
reason
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
,
uint8
neglect_used
=
0
);
int32
get_spsummonable_count
(
card
*
pcard
,
uint8
playerid
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
);
int32
get_useable_count
(
uint8
playerid
,
uint8
location
,
uint8
uplayer
,
uint32
reason
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
);
int32
get_tofield_count
(
uint8
playerid
,
uint8
location
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
);
int32
get_useable_count
(
uint8
playerid
,
uint8
location
,
uint8
uplayer
,
uint32
reason
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
,
uint8
neglect_used
=
0
);
int32
get_tofield_count
(
uint8
playerid
,
uint8
location
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
,
uint8
neglect_used
=
0
);
int32
get_useable_count_fromex
(
card
*
pcard
,
uint8
playerid
,
uint8
uplayer
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
);
int32
get_spsummonable_count_fromex
(
card
*
pcard
,
uint8
playerid
,
uint32
zone
=
0xff
,
uint32
*
list
=
0
);
int32
get_mzone_limit
(
uint8
playerid
,
uint8
uplayer
,
uint32
reason
);
...
...
@@ -383,7 +384,7 @@ public:
int32
get_release_list
(
uint8
playerid
,
card_set
*
release_list
,
card_set
*
ex_list
,
int32
use_con
,
int32
use_hand
,
int32
fun
,
int32
exarg
,
card
*
exc
,
group
*
exg
);
int32
check_release_list
(
uint8
playerid
,
int32
count
,
int32
use_con
,
int32
use_hand
,
int32
fun
,
int32
exarg
,
card
*
exc
,
group
*
exg
);
int32
get_summon_release_list
(
card
*
target
,
card_set
*
release_list
,
card_set
*
ex_list
,
card_set
*
ex_list_sum
,
group
*
mg
=
NULL
,
uint32
ex
=
0
);
int32
get_summon_release_list
(
card
*
target
,
card_set
*
release_list
,
card_set
*
ex_list
,
card_set
*
ex_list_sum
,
group
*
mg
=
NULL
,
uint32
ex
=
0
,
uint32
releasable
=
0xff00ff
);
int32
get_summon_count_limit
(
uint8
playerid
);
int32
get_draw_count
(
uint8
playerid
);
void
get_ritual_material
(
uint8
playerid
,
effect
*
peffect
,
card_set
*
material
);
...
...
@@ -398,7 +399,7 @@ public:
void
adjust_self_destroy_set
();
void
add_unique_card
(
card
*
pcard
);
void
remove_unique_card
(
card
*
pcard
);
effect
*
check_unique_onfield
(
card
*
pcard
,
uint8
controler
,
uint8
location
);
effect
*
check_unique_onfield
(
card
*
pcard
,
uint8
controler
,
uint8
location
,
card
*
icard
=
0
);
int32
check_spsummon_once
(
card
*
pcard
,
uint8
playerid
);
void
check_card_counter
(
card
*
pcard
,
int32
counter_type
,
int32
playerid
);
void
check_chain_counter
(
effect
*
peffect
,
int32
playerid
,
int32
chainid
,
bool
cancel
=
false
);
...
...
@@ -418,7 +419,7 @@ public:
int32
check_synchro_material
(
card
*
pcard
,
int32
findex1
,
int32
findex2
,
int32
min
,
int32
max
,
card
*
smat
,
group
*
mg
);
int32
check_tuner_material
(
card
*
pcard
,
card
*
tuner
,
int32
findex1
,
int32
findex2
,
int32
min
,
int32
max
,
card
*
smat
,
group
*
mg
);
int32
check_other_synchro_material
(
const
card_vector
&
nsyn
,
int32
lv
,
int32
min
,
int32
max
,
int32
mcount
);
int32
check_tribute
(
card
*
pcard
,
int32
min
,
int32
max
,
group
*
mg
,
uint8
toplayer
,
uint32
zone
=
0x1f
);
int32
check_tribute
(
card
*
pcard
,
int32
min
,
int32
max
,
group
*
mg
,
uint8
toplayer
,
uint32
zone
=
0x1f
,
uint32
releasable
=
0xff00ff
);
static
int32
check_with_sum_limit
(
const
card_vector
&
mats
,
int32
acc
,
int32
index
,
int32
count
,
int32
min
,
int32
max
);
static
int32
check_with_sum_limit_m
(
const
card_vector
&
mats
,
int32
acc
,
int32
index
,
int32
min
,
int32
max
,
int32
must_count
);
static
int32
check_with_sum_greater_limit
(
const
card_vector
&
mats
,
int32
acc
,
int32
index
,
int32
opmin
);
...
...
@@ -519,6 +520,7 @@ public:
void
move_to_field
(
card
*
target
,
uint32
move_player
,
uint32
playerid
,
uint32
destination
,
uint32
positions
,
uint32
enable
=
FALSE
,
uint32
ret
=
0
,
uint32
is_equip
=
FALSE
,
uint32
zone
=
0xff
);
void
change_position
(
card_set
*
targets
,
effect
*
reason_effect
,
uint32
reason_player
,
uint32
au
,
uint32
ad
,
uint32
du
,
uint32
dd
,
uint32
flag
,
uint32
enable
=
FALSE
);
void
change_position
(
card
*
target
,
effect
*
reason_effect
,
uint32
reason_player
,
uint32
npos
,
uint32
flag
,
uint32
enable
=
FALSE
);
void
operation_replace
(
int32
type
,
int32
step
,
group
*
targets
);
int32
remove_counter
(
uint16
step
,
uint32
reason
,
card
*
pcard
,
uint8
rplayer
,
uint8
s
,
uint8
o
,
uint16
countertype
,
uint16
count
);
int32
remove_overlay_card
(
uint16
step
,
uint32
reason
,
card
*
pcard
,
uint8
rplayer
,
uint8
s
,
uint8
o
,
uint16
min
,
uint16
max
);
...
...
@@ -547,7 +549,7 @@ public:
int32
discard_deck
(
uint16
step
,
uint8
playerid
,
uint8
count
,
uint32
reason
);
int32
move_to_field
(
uint16
step
,
card
*
target
,
uint32
enable
,
uint32
ret
,
uint32
is_equip
,
uint32
zone
);
int32
change_position
(
uint16
step
,
group
*
targets
,
effect
*
reason_effect
,
uint8
reason_player
,
uint32
enable
);
int32
operation_replace
(
uint16
step
,
effect
*
replace_effect
,
group
*
targets
,
card
*
arg
,
ptr
replace_type
);
int32
operation_replace
(
uint16
step
,
effect
*
replace_effect
,
group
*
targets
,
card
*
target
,
int32
is_destroy
);
int32
activate_effect
(
uint16
step
,
effect
*
peffect
);
int32
select_synchro_material
(
int16
step
,
uint8
playerid
,
card
*
pcard
,
int32
min
,
int32
max
,
card
*
smat
,
group
*
mg
);
int32
select_xyz_material
(
int16
step
,
uint8
playerid
,
uint32
lv
,
card
*
pcard
,
int32
min
,
int32
max
);
...
...
@@ -598,6 +600,7 @@ public:
#define CHAININFO_CHAIN_ID 0x800
#define CHAININFO_TYPE 0x1000
#define CHAININFO_EXTTYPE 0x2000
#define CHAININFO_TRIGGERING_POSITION 0x4000
//Timing
#define TIMING_DRAW_PHASE 0x1
#define TIMING_STANDBY_PHASE 0x2
...
...
interpreter.cpp
View file @
e235487a
...
...
@@ -221,6 +221,7 @@ static const struct luaL_Reg cardlib[] = {
{
"GetCounter"
,
scriptlib
::
card_get_counter
},
{
"EnableCounterPermit"
,
scriptlib
::
card_enable_counter_permit
},
{
"SetCounterLimit"
,
scriptlib
::
card_set_counter_limit
},
{
"IsCanChangePosition"
,
scriptlib
::
card_is_can_change_position
},
{
"IsCanTurnSet"
,
scriptlib
::
card_is_can_turn_set
},
{
"IsCanAddCounter"
,
scriptlib
::
card_is_can_add_counter
},
{
"IsCanRemoveCounter"
,
scriptlib
::
card_is_can_remove_counter
},
...
...
@@ -797,7 +798,7 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
}
params
.
clear
();
}
int32
interpreter
::
call_function
(
int32
f
,
uint32
param_count
,
u
int32
ret_count
)
{
int32
interpreter
::
call_function
(
int32
f
,
uint32
param_count
,
int32
ret_count
)
{
if
(
!
f
)
{
sprintf
(
pduel
->
strbuffer
,
"
\"
CallFunction
\"
: attempt to call a null function."
);
handle_message
(
pduel
,
1
);
...
...
@@ -841,7 +842,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, uint32 ret_count)
}
return
OPERATION_SUCCESS
;
}
int32
interpreter
::
call_card_function
(
card
*
pcard
,
char
*
f
,
uint32
param_count
,
u
int32
ret_count
)
{
int32
interpreter
::
call_card_function
(
card
*
pcard
,
char
*
f
,
uint32
param_count
,
int32
ret_count
)
{
if
(
param_count
!=
params
.
size
())
{
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCardFunction
\"
(c%d.%s): incorrect parameter count"
,
pcard
->
data
.
code
,
f
);
handle_message
(
pduel
,
1
);
...
...
@@ -881,7 +882,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
}
return
OPERATION_SUCCESS
;
}
int32
interpreter
::
call_code_function
(
uint32
code
,
char
*
f
,
uint32
param_count
,
u
int32
ret_count
)
{
int32
interpreter
::
call_code_function
(
uint32
code
,
char
*
f
,
uint32
param_count
,
int32
ret_count
)
{
if
(
param_count
!=
params
.
size
())
{
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCodeFunction
\"
: incorrect parameter count"
);
handle_message
(
pduel
,
1
);
...
...
@@ -1042,6 +1043,36 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
}
return
OPERATION_FAIL
;
}
int32
interpreter
::
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
int32
>*
result
)
{
int32
is_success
=
OPERATION_FAIL
;
if
(
!
f
)
{
params
.
clear
();
return
is_success
;
}
int32
stack_top
=
lua_gettop
(
current_state
);
no_action
++
;
call_depth
++
;
if
(
call_function
(
f
,
param_count
,
LUA_MULTRET
))
{
int32
stack_newtop
=
lua_gettop
(
current_state
);
for
(
int32
index
=
stack_top
+
1
;
index
<=
stack_newtop
;
++
index
)
{
int32
return_value
=
0
;
if
(
lua_isboolean
(
current_state
,
index
))
return_value
=
lua_toboolean
(
current_state
,
index
);
else
return_value
=
lua_tointeger
(
current_state
,
index
);
result
->
push_back
(
return_value
);
}
lua_settop
(
current_state
,
stack_top
);
is_success
=
OPERATION_SUCCESS
;
}
no_action
--
;
call_depth
--
;
if
(
call_depth
==
0
)
{
pduel
->
release_script_group
();
pduel
->
restore_assumes
();
}
return
is_success
;
}
int32
interpreter
::
call_coroutine
(
int32
f
,
uint32
param_count
,
uint32
*
yield_value
,
uint16
step
)
{
*
yield_value
=
0
;
if
(
!
f
)
{
...
...
interpreter.h
View file @
e235487a
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include "common.h"
#include <unordered_map>
#include <list>
#include <vector>
#include <cstring>
class
card
;
...
...
@@ -52,19 +53,20 @@ public:
void
unregister_effect
(
effect
*
peffect
);
void
register_group
(
group
*
pgroup
);
void
unregister_group
(
group
*
pgroup
);
int32
load_script
(
char
*
buffer
);
int32
load_card_script
(
uint32
code
);
void
add_param
(
void
*
param
,
int32
type
,
bool
front
=
false
);
void
add_param
(
ptr
param
,
int32
type
,
bool
front
=
false
);
void
push_param
(
lua_State
*
L
,
bool
is_coroutine
=
false
);
int32
call_function
(
int32
f
,
uint32
param_count
,
u
int32
ret_count
);
int32
call_card_function
(
card
*
pcard
,
char
*
f
,
uint32
param_count
,
u
int32
ret_count
);
int32
call_code_function
(
uint32
code
,
char
*
f
,
uint32
param_count
,
u
int32
ret_count
);
int32
call_function
(
int32
f
,
uint32
param_count
,
int32
ret_count
);
int32
call_card_function
(
card
*
pcard
,
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
call_code_function
(
uint32
code
,
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
check_condition
(
int32
f
,
uint32
param_count
);
int32
check_matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
get_operation_value
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
get_function_value
(
int32
f
,
uint32
param_count
);
int32
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
int32
>*
result
);
int32
call_coroutine
(
int32
f
,
uint32
param_count
,
uint32
*
yield_value
,
uint16
step
);
static
void
card2value
(
lua_State
*
L
,
card
*
pcard
);
...
...
libcard.cpp
View file @
e235487a
...
...
@@ -662,7 +662,7 @@ int32 scriptlib::card_get_destination(lua_State *L) {
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
lua_pushinteger
(
L
,
(
pcard
->
operation_param
>>
8
)
&
0xff
);
lua_pushinteger
(
L
,
pcard
->
sendto_param
.
location
);
return
1
;
}
int32
scriptlib
::
card_get_leave_field_dest
(
lua_State
*
L
)
{
...
...
@@ -1283,7 +1283,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
peffect
->
code
=
code
;
peffect
->
reset_flag
=
reset
;
peffect
->
flag
[
0
]
=
flag
|
EFFECT_FLAG_CANNOT_DISABLE
;
peffect
->
reset_count
|=
count
&
0xff
;
peffect
->
reset_count
=
count
;
peffect
->
label
=
lab
;
peffect
->
description
=
desc
;
pcard
->
add_effect
(
peffect
);
...
...
@@ -1661,13 +1661,16 @@ int32 scriptlib::card_is_can_be_special_summoned(lua_State *L) {
uint32
sumpos
=
POS_FACEUP
;
uint32
toplayer
=
sumplayer
;
uint32
zone
=
0xff
;
uint32
nozoneusedcheck
=
0
;
if
(
lua_gettop
(
L
)
>=
7
)
sumpos
=
lua_tointeger
(
L
,
7
);
if
(
lua_gettop
(
L
)
>=
8
)
toplayer
=
lua_tointeger
(
L
,
8
);
if
(
lua_gettop
(
L
)
>=
9
)
zone
=
lua_tointeger
(
L
,
9
);
if
(
pcard
->
is_can_be_special_summoned
(
peffect
,
sumtype
,
sumpos
,
sumplayer
,
toplayer
,
nocheck
,
nolimit
,
zone
))
if
(
lua_gettop
(
L
)
>=
10
)
nozoneusedcheck
=
lua_toboolean
(
L
,
10
);
if
(
pcard
->
is_can_be_special_summoned
(
peffect
,
sumtype
,
sumpos
,
sumplayer
,
toplayer
,
nocheck
,
nolimit
,
zone
,
nozoneusedcheck
))
lua_pushboolean
(
L
,
1
);
else
lua_pushboolean
(
L
,
0
);
...
...
@@ -2192,6 +2195,13 @@ int32 scriptlib::card_set_counter_limit(lua_State *L) {
pcard
->
add_effect
(
peffect
);
return
0
;
}
int32
scriptlib
::
card_is_can_change_position
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
lua_pushboolean
(
L
,
pcard
->
is_capable_change_position_by_effect
(
pcard
->
pduel
->
game_field
->
core
.
reason_player
));
return
1
;
}
int32
scriptlib
::
card_is_can_turn_set
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
...
...
@@ -2578,7 +2588,12 @@ int32 scriptlib::card_check_unique_onfield(lua_State *L) {
uint32
check_location
=
LOCATION_ONFIELD
;
if
(
lua_gettop
(
L
)
>
2
)
check_location
=
lua_tointeger
(
L
,
3
)
&
LOCATION_ONFIELD
;
lua_pushboolean
(
L
,
pcard
->
pduel
->
game_field
->
check_unique_onfield
(
pcard
,
check_player
,
check_location
)
?
0
:
1
);
card
*
icard
=
0
;
if
(
lua_gettop
(
L
)
>
3
)
{
if
(
check_param
(
L
,
PARAM_TYPE_CARD
,
4
,
TRUE
))
icard
=
*
(
card
**
)
lua_touserdata
(
L
,
4
);
}
lua_pushboolean
(
L
,
pcard
->
pduel
->
game_field
->
check_unique_onfield
(
pcard
,
check_player
,
check_location
,
icard
)
?
0
:
1
);
return
1
;
}
int32
scriptlib
::
card_reset_negate_effect
(
lua_State
*
L
)
{
...
...
libdebug.cpp
View file @
e235487a
...
...
@@ -39,7 +39,7 @@ int32 scriptlib::debug_add_card(lua_State *L) {
if
(
pduel
->
game_field
->
is_location_useable
(
playerid
,
location
,
sequence
))
{
card
*
pcard
=
pduel
->
new_card
(
code
);
pcard
->
owner
=
owner
;
pcard
->
operation_param
=
position
<<
24
;
pcard
->
sendto_param
.
position
=
position
;
if
(
location
==
LOCATION_PZONE
)
{
int32
seq
=
pduel
->
game_field
->
core
.
duel_rule
>=
4
?
sequence
*
4
:
sequence
+
6
;
pduel
->
game_field
->
add_card
(
playerid
,
pcard
,
LOCATION_SZONE
,
seq
,
TRUE
);
...
...
libduel.cpp
View file @
e235487a
...
...
@@ -107,7 +107,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
peffect
->
flag
[
0
]
=
flag
|
EFFECT_FLAG_CANNOT_DISABLE
|
EFFECT_FLAG_PLAYER_TARGET
|
EFFECT_FLAG_FIELD_ONLY
;
peffect
->
s_range
=
1
;
peffect
->
o_range
=
0
;
peffect
->
reset_count
|=
count
&
0xff
;
peffect
->
reset_count
=
count
;
pduel
->
game_field
->
add_effect
(
peffect
,
playerid
);
interpreter
::
effect2value
(
L
,
peffect
);
return
1
;
...
...
@@ -1646,10 +1646,13 @@ int32 scriptlib::duel_check_location(lua_State *L) {
uint32
playerid
=
lua_tointeger
(
L
,
1
);
uint32
location
=
lua_tointeger
(
L
,
2
);
uint32
sequence
=
lua_tointeger
(
L
,
3
);
uint32
neglect_used
=
0
;
if
(
lua_gettop
(
L
)
>=
4
)
neglect_used
=
lua_toboolean
(
L
,
4
);
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
lua_pushboolean
(
L
,
pduel
->
game_field
->
is_location_useable
(
playerid
,
location
,
sequence
));
lua_pushboolean
(
L
,
pduel
->
game_field
->
is_location_useable
(
playerid
,
location
,
sequence
,
neglect_used
));
return
1
;
}
int32
scriptlib
::
duel_get_current_chain
(
lua_State
*
L
)
{
...
...
@@ -1660,12 +1663,13 @@ int32 scriptlib::duel_get_current_chain(lua_State *L) {
int32
scriptlib
::
duel_get_chain_info
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
uint32
c
=
lua_tointeger
(
L
,
1
);
uint32
flag
;
uint32
args
=
lua_gettop
(
L
)
-
1
;
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
chain
*
ch
=
pduel
->
game_field
->
get_chain
(
c
);
if
(
!
ch
)
return
0
;
for
(
uint32
i
=
0
;
i
<
args
;
++
i
)
{
flag
=
lua_tointeger
(
L
,
2
+
i
);
uint32
flag
=
lua_tointeger
(
L
,
2
+
i
);
switch
(
flag
)
{
case
CHAININFO_CHAIN_COUNT
:
lua_pushinteger
(
L
,
ch
->
chain_count
);
...
...
@@ -1685,6 +1689,9 @@ int32 scriptlib::duel_get_chain_info(lua_State *L) {
case
CHAININFO_TRIGGERING_SEQUENCE
:
lua_pushinteger
(
L
,
ch
->
triggering_sequence
);
break
;
case
CHAININFO_TRIGGERING_POSITION
:
lua_pushinteger
(
L
,
ch
->
triggering_position
);
break
;
case
CHAININFO_TARGET_CARDS
:
interpreter
::
group2value
(
L
,
ch
->
target_cards
);
break
;
...
...
@@ -1766,7 +1773,7 @@ int32 scriptlib::duel_skip_phase(lua_State *L) {
peffect
->
flag
[
0
]
=
EFFECT_FLAG_CANNOT_DISABLE
|
EFFECT_FLAG_PLAYER_TARGET
;
peffect
->
s_range
=
1
;
peffect
->
o_range
=
0
;
peffect
->
reset_count
|=
count
&
0xff
;
peffect
->
reset_count
=
count
;
peffect
->
value
=
value
;
pduel
->
game_field
->
add_effect
(
peffect
,
playerid
);
return
0
;
...
...
@@ -3634,7 +3641,7 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) {
ceffect
->
operation
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
}
ceffect
->
reset_flag
=
RESET_EVENT
+
0x1fe0000
+
RESET_PHASE
+
PHASE_END
+
RESET_SELF_TURN
+
RESET_OPPO_TURN
;
ceffect
->
reset_count
=
(
ceffect
->
reset_count
&
0xff00
)
|
0x1
;
ceffect
->
reset_count
=
0x1
;
ceffect
->
recharge
();
if
(
ceffect
->
type
&
EFFECT_TYPE_TRIGGER_F
)
{
ceffect
->
type
&=
~
EFFECT_TYPE_TRIGGER_F
;
...
...
libeffect.cpp
View file @
e235487a
...
...
@@ -145,7 +145,8 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) {
if
(
v
==
0
)
v
=
1
;
peffect
->
flag
[
0
]
|=
EFFECT_FLAG_COUNT_LIMIT
;
peffect
->
reset_count
|=
((
v
<<
12
)
&
0xf000
)
|
((
v
<<
8
)
&
0xf00
);
peffect
->
count_limit
=
v
;
peffect
->
count_limit_max
=
v
;
peffect
->
count_code
=
code
;
return
0
;
}
...
...
@@ -160,7 +161,7 @@ int32 scriptlib::effect_set_reset(lua_State *L) {
if
(
v
&
(
RESET_PHASE
)
&&
!
(
v
&
(
RESET_SELF_TURN
|
RESET_OPPO_TURN
)))
v
|=
(
RESET_SELF_TURN
|
RESET_OPPO_TURN
);
peffect
->
reset_flag
=
v
;
peffect
->
reset_count
=
(
peffect
->
reset_count
&
0xff00
)
|
(
c
&
0xff
)
;
peffect
->
reset_count
=
c
;
return
0
;
}
int32
scriptlib
::
effect_set_type
(
lua_State
*
L
)
{
...
...
@@ -537,7 +538,7 @@ int32 scriptlib::effect_is_activated(lua_State * L) {
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
lua_pushboolean
(
L
,
(
peffect
->
status
&
EFFECT_STATUS_ACTIVATED
));
lua_pushboolean
(
L
,
(
peffect
->
type
&
0x7f0
));
return
1
;
}
...
...
@@ -545,6 +546,6 @@ int32 scriptlib::effect_get_activate_location(lua_State *L) {
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
lua_pushinteger
(
L
,
peffect
->
s_range
);
lua_pushinteger
(
L
,
peffect
->
active_location
);
return
1
;
}
\ No newline at end of file
operations.cpp
View file @
e235487a
This diff is collapsed.
Click to expand it.
processor.cpp
View file @
e235487a
This diff is collapsed.
Click to expand it.
scriptlib.h
View file @
e235487a
...
...
@@ -223,6 +223,7 @@ public:
static
int32
card_get_counter
(
lua_State
*
L
);
static
int32
card_enable_counter_permit
(
lua_State
*
L
);
static
int32
card_set_counter_limit
(
lua_State
*
L
);
static
int32
card_is_can_change_position
(
lua_State
*
L
);
static
int32
card_is_can_turn_set
(
lua_State
*
L
);
static
int32
card_is_can_add_counter
(
lua_State
*
L
);
static
int32
card_is_can_remove_counter
(
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