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
xiaoye
ygopro-core
Commits
90a1b3bd
Commit
90a1b3bd
authored
Feb 20, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:purerosefallen/ygopro-core
parents
53c6e818
6ced1cc7
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
344 additions
and
243 deletions
+344
-243
card.cpp
card.cpp
+44
-26
card.h
card.h
+21
-9
common.h
common.h
+0
-4
duel.cpp
duel.cpp
+1
-1
effect.h
effect.h
+8
-1
field.h
field.h
+29
-18
libcard.cpp
libcard.cpp
+31
-41
libduel.cpp
libduel.cpp
+77
-63
libgroup.cpp
libgroup.cpp
+41
-0
operations.cpp
operations.cpp
+66
-69
processor.cpp
processor.cpp
+21
-11
scriptlib.h
scriptlib.h
+5
-0
No files found.
card.cpp
View file @
90a1b3bd
...
@@ -14,6 +14,14 @@
...
@@ -14,6 +14,14 @@
#include "ocgapi.h"
#include "ocgapi.h"
#include <algorithm>
#include <algorithm>
const
std
::
unordered_map
<
uint32
,
uint32
>
card
::
second_code
=
{
{
CARD_MARINE_DOLPHIN
,
17955766u
},
{
CARD_TWINKLE_MOSS
,
17732278u
},
{
CARD_TIMAEUS
,
10000050u
},
{
CARD_CRITIAS
,
10000060u
},
{
CARD_HERMOS
,
10000070u
}
};
//millux
//millux
uint32
card
::
get_ritual_type
()
{
uint32
card
::
get_ritual_type
()
{
if
(
current
.
location
==
LOCATION_SZONE
&&
(
data
.
type
&
TYPE_MONSTER
))
if
(
current
.
location
==
LOCATION_SZONE
&&
(
data
.
type
&
TYPE_MONSTER
))
...
@@ -456,55 +464,60 @@ uint32 card::get_info_location() {
...
@@ -456,55 +464,60 @@ uint32 card::get_info_location() {
return
c
+
(
l
<<
8
)
+
(
s
<<
16
)
+
(
ss
<<
24
);
return
c
+
(
l
<<
8
)
+
(
s
<<
16
)
+
(
ss
<<
24
);
}
}
}
}
// mapping of double-name cards
// get the printed code on card
uint32
card
::
second_code
(
uint32
code
){
uint32
card
::
get_original_code
()
const
{
switch
(
code
){
if
(
data
.
alias
&&
(
data
.
alias
<
data
.
code
+
CARD_ARTWORK_VERSIONS_OFFSET
)
&&
(
data
.
code
<
data
.
alias
+
CARD_ARTWORK_VERSIONS_OFFSET
))
case
CARD_MARINE_DOLPHIN
:
return
data
.
alias
;
return
17955766u
;
else
case
CARD_TWINKLE_MOSS
:
return
data
.
code
;
return
17732278u
;
}
default:
// get the original code in duel (can be different from printed code)
return
0
;
std
::
tuple
<
uint32
,
uint32
>
card
::
get_original_code_rule
()
const
{
auto
it
=
second_code
.
find
(
data
.
code
);
if
(
it
!=
second_code
.
end
())
{
return
std
::
make_tuple
(
data
.
code
,
it
->
second
);
}
else
{
if
(
data
.
alias
)
return
std
::
make_tuple
(
data
.
alias
,
0
);
else
return
std
::
make_tuple
(
data
.
code
,
0
);
}
}
}
}
// return: the current card name
// return: the current card name
// for double-name card, it returns printed name
// for double-name card
s
, it returns printed name
uint32
card
::
get_code
()
{
uint32
card
::
get_code
()
{
if
(
assume_type
==
ASSUME_CODE
)
if
(
assume_type
==
ASSUME_CODE
)
return
assume_value
;
return
assume_value
;
if
(
temp
.
code
!=
0xffffffff
)
if
(
temp
.
code
!=
0xffffffff
)
return
temp
.
code
;
return
temp
.
code
;
effect_set
effects
;
effect_set
effects
;
uint32
code
=
data
.
code
;
uint32
code
=
std
::
get
<
0
>
(
get_original_code_rule
())
;
temp
.
code
=
data
.
code
;
temp
.
code
=
code
;
filter_effect
(
EFFECT_CHANGE_CODE
,
&
effects
);
filter_effect
(
EFFECT_CHANGE_CODE
,
&
effects
);
if
(
effects
.
size
())
if
(
effects
.
size
())
code
=
effects
.
get_last
()
->
get_value
(
this
);
code
=
effects
.
get_last
()
->
get_value
(
this
);
temp
.
code
=
0xffffffff
;
temp
.
code
=
0xffffffff
;
if
(
code
==
data
.
code
)
{
if
(
data
.
alias
&&
!
is_affected_by_effect
(
EFFECT_ADD_CODE
))
code
=
data
.
alias
;
}
else
{
card_data
dat
;
read_card
(
code
,
&
dat
);
if
(
dat
.
alias
&&
!
second_code
(
code
))
code
=
dat
.
alias
;
}
return
code
;
return
code
;
}
}
// return: the current second card name
// return: the current second card name
// for double-name cards, it returns the name in description
// for double-name cards, it returns the name in description
uint32
card
::
get_another_code
()
{
uint32
card
::
get_another_code
()
{
uint32
code
=
get_code
();
uint32
code1
=
get_code
();
if
(
code
!=
data
.
code
){
if
(
is_affected_by_effect
(
EFFECT_CHANGE_CODE
))
{
return
second_code
(
code
);
auto
it
=
second_code
.
find
(
code1
);
if
(
it
!=
second_code
.
end
())
return
it
->
second
;
else
return
0
;
}
}
uint32
code2
=
std
::
get
<
1
>
(
get_original_code_rule
());
effect_set
eset
;
effect_set
eset
;
filter_effect
(
EFFECT_ADD_CODE
,
&
eset
);
filter_effect
(
EFFECT_ADD_CODE
,
&
eset
);
if
(
!
eset
.
size
())
if
(
!
eset
.
size
())
return
0
;
return
code2
;
uint32
otcode
=
eset
.
get_last
()
->
get_value
(
this
);
uint32
otcode
=
eset
.
get_last
()
->
get_value
(
this
);
if
(
code
!=
otcode
)
if
(
code
1
!=
otcode
)
return
otcode
;
return
otcode
;
return
0
;
return
0
;
}
}
...
@@ -2692,6 +2705,7 @@ void card::set_special_summon_status(effect* peffect) {
...
@@ -2692,6 +2705,7 @@ void card::set_special_summon_status(effect* peffect) {
spsummon
.
defense
=
0
;
spsummon
.
defense
=
0
;
spsummon
.
setcode
.
clear
();
spsummon
.
setcode
.
clear
();
spsummon
.
reason_effect
=
nullptr
;
spsummon
.
reason_effect
=
nullptr
;
spsummon
.
reason_player
=
PLAYER_NONE
;
return
;
return
;
}
}
card
*
pcard
=
peffect
->
get_handler
();
card
*
pcard
=
peffect
->
get_handler
();
...
@@ -2714,6 +2728,7 @@ void card::set_special_summon_status(effect* peffect) {
...
@@ -2714,6 +2728,7 @@ void card::set_special_summon_status(effect* peffect) {
spsummon
.
setcode
.
push_back
((
uint32
)
eset
[
i
]
->
get_value
(
pcard
));
spsummon
.
setcode
.
push_back
((
uint32
)
eset
[
i
]
->
get_value
(
pcard
));
}
}
spsummon
.
reason_effect
=
peffect
;
spsummon
.
reason_effect
=
peffect
;
spsummon
.
reason_player
=
peffect
->
get_handler_player
();
}
else
{
}
else
{
pcard
=
cait
->
triggering_effect
->
get_handler
();
pcard
=
cait
->
triggering_effect
->
get_handler
();
spsummon
.
code
=
cait
->
triggering_state
.
code
;
spsummon
.
code
=
cait
->
triggering_state
.
code
;
...
@@ -2732,6 +2747,7 @@ void card::set_special_summon_status(effect* peffect) {
...
@@ -2732,6 +2747,7 @@ void card::set_special_summon_status(effect* peffect) {
spsummon
.
setcode
.
push_back
((
uint32
)
eset
[
i
]
->
get_value
(
pcard
));
spsummon
.
setcode
.
push_back
((
uint32
)
eset
[
i
]
->
get_value
(
pcard
));
}
}
spsummon
.
reason_effect
=
cait
->
triggering_effect
;
spsummon
.
reason_effect
=
cait
->
triggering_effect
;
spsummon
.
reason_player
=
cait
->
triggering_player
;
}
}
}
}
void
card
::
filter_effect
(
int32
code
,
effect_set
*
eset
,
uint8
sort
)
{
void
card
::
filter_effect
(
int32
code
,
effect_set
*
eset
,
uint8
sort
)
{
...
@@ -3426,6 +3442,8 @@ int32 card::is_spsummonable_card() {
...
@@ -3426,6 +3442,8 @@ int32 card::is_spsummonable_card() {
int32
card
::
is_fusion_summonable_card
(
uint32
summon_type
)
{
int32
card
::
is_fusion_summonable_card
(
uint32
summon_type
)
{
if
(
!
(
data
.
type
&
TYPE_FUSION
))
if
(
!
(
data
.
type
&
TYPE_FUSION
))
return
FALSE
;
return
FALSE
;
if
((
data
.
type
&
TYPE_PENDULUM
)
&&
current
.
location
==
LOCATION_EXTRA
&&
(
current
.
position
&
POS_FACEUP
))
return
FALSE
;
summon_type
|=
SUMMON_TYPE_FUSION
;
summon_type
|=
SUMMON_TYPE_FUSION
;
effect_set
eset
;
effect_set
eset
;
filter_effect
(
EFFECT_SPSUMMON_CONDITION
,
&
eset
);
filter_effect
(
EFFECT_SPSUMMON_CONDITION
,
&
eset
);
...
...
card.h
View file @
90a1b3bd
...
@@ -99,6 +99,12 @@ struct material_info {
...
@@ -99,6 +99,12 @@ struct material_info {
};
};
const
material_info
null_info
;
const
material_info
null_info
;
constexpr
uint32
CARD_MARINE_DOLPHIN
=
78734254
;
constexpr
uint32
CARD_TWINKLE_MOSS
=
13857930
;
constexpr
uint32
CARD_TIMAEUS
=
1784686
;
constexpr
uint32
CARD_CRITIAS
=
11082056
;
constexpr
uint32
CARD_HERMOS
=
46232525
;
class
card
{
class
card
{
public:
public:
struct
effect_relation_hash
{
struct
effect_relation_hash
{
...
@@ -144,6 +150,8 @@ public:
...
@@ -144,6 +150,8 @@ public:
uint8
location
{
0
};
uint8
location
{
0
};
uint8
sequence
{
0
};
uint8
sequence
{
0
};
};
};
static
const
std
::
unordered_map
<
uint32
,
uint32
>
second_code
;
int32
ref_handle
;
int32
ref_handle
;
duel
*
pduel
;
duel
*
pduel
;
card_data
data
;
card_data
data
;
...
@@ -214,7 +222,8 @@ public:
...
@@ -214,7 +222,8 @@ public:
int32
get_infos
(
byte
*
buf
,
uint32
query_flag
,
int32
use_cache
=
TRUE
);
int32
get_infos
(
byte
*
buf
,
uint32
query_flag
,
int32
use_cache
=
TRUE
);
uint32
get_info_location
();
uint32
get_info_location
();
uint32
second_code
(
uint32
code
);
uint32
get_original_code
()
const
;
std
::
tuple
<
uint32
,
uint32
>
get_original_code_rule
()
const
;
uint32
get_code
();
uint32
get_code
();
uint32
get_another_code
();
uint32
get_another_code
();
int32
is_set_card
(
uint32
set_code
);
int32
is_set_card
(
uint32
set_code
);
...
@@ -386,10 +395,9 @@ public:
...
@@ -386,10 +395,9 @@ public:
int32
is_can_be_link_material
(
card
*
scard
);
int32
is_can_be_link_material
(
card
*
scard
);
};
};
//Summon Type
//Summon Type
in summon_info
#define SUMMON_TYPE_NORMAL 0x10000000
#define SUMMON_TYPE_NORMAL 0x10000000
#define SUMMON_TYPE_ADVANCE 0x11000000
#define SUMMON_TYPE_ADVANCE 0x11000000
#define SUMMON_TYPE_DUAL 0x12000000
#define SUMMON_TYPE_FLIP 0x20000000
#define SUMMON_TYPE_FLIP 0x20000000
#define SUMMON_TYPE_SPECIAL 0x40000000
#define SUMMON_TYPE_SPECIAL 0x40000000
#define SUMMON_TYPE_FUSION 0x43000000
#define SUMMON_TYPE_FUSION 0x43000000
...
@@ -399,8 +407,15 @@ public:
...
@@ -399,8 +407,15 @@ public:
#define SUMMON_TYPE_PENDULUM 0x4a000000
#define SUMMON_TYPE_PENDULUM 0x4a000000
#define SUMMON_TYPE_LINK 0x4c000000
#define SUMMON_TYPE_LINK 0x4c000000
#define SUMMON_TYPE_MAIN 0xf0000000
//Gemini Summon
#define SUMMON_TYPE_LOCATION 0x00ff0000
#define SUMMON_TYPE_DUAL 0x12000000
//bitfield blocks
#define SUMMON_VALUE_MAIN_TYPE 0xf0000000
#define SUMMON_VALUE_SUB_TYPE 0x0f000000
#define SUMMON_VALUE_LOCATION 0x00ff0000
#define SUMMON_VALUE_CUSTOM_TYPE 0x0000ffff
constexpr
uint32
DEFAULT_SUMMON_TYPE
=
SUMMON_VALUE_MAIN_TYPE
|
SUMMON_VALUE_SUB_TYPE
|
SUMMON_VALUE_CUSTOM_TYPE
;
//Counter
//Counter
#define COUNTER_WITHOUT_PERMIT 0x1000
#define COUNTER_WITHOUT_PERMIT 0x1000
...
@@ -427,10 +442,7 @@ public:
...
@@ -427,10 +442,7 @@ public:
#define SUMMON_INFO_ATTACK 0x80
#define SUMMON_INFO_ATTACK 0x80
#define SUMMON_INFO_DEFENSE 0x100
#define SUMMON_INFO_DEFENSE 0x100
#define SUMMON_INFO_REASON_EFFECT 0x200
#define SUMMON_INFO_REASON_EFFECT 0x200
#define SUMMON_INFO_REASON_PLAYER 0x400
//double-name cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define CARD_ARTWORK_VERSIONS_OFFSET 10
#define CARD_ARTWORK_VERSIONS_OFFSET 10
...
...
common.h
View file @
90a1b3bd
...
@@ -24,10 +24,6 @@ typedef signed char int8;
...
@@ -24,10 +24,6 @@ typedef signed char int8;
#define ADD_BIT(x,y) ((x)|=(y))
#define ADD_BIT(x,y) ((x)|=(y))
#define REMOVE_BIT(x,y) ((x)&=~(y))
#define REMOVE_BIT(x,y) ((x)&=~(y))
constexpr
bool
match_all
(
uint32
x
,
uint32
y
)
{
return
(
x
&
y
)
==
y
;
}
#define OPERATION_SUCCESS 1
#define OPERATION_SUCCESS 1
#define OPERATION_FAIL 0
#define OPERATION_FAIL 0
#define OPERATION_CANCELED -1
#define OPERATION_CANCELED -1
...
...
duel.cpp
View file @
90a1b3bd
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
#include "group.h"
#include "group.h"
#include "ocgapi.h"
#include "ocgapi.h"
inline
void
write_buffer_vector
(
std
::
vector
<
byte
>&
buffer
,
const
void
*
data
,
int
size
)
{
inline
void
write_buffer_vector
(
std
::
vector
<
byte
>&
buffer
,
const
void
*
&
data
,
int
size
)
{
if
(
size
>
0
)
{
if
(
size
>
0
)
{
const
auto
len
=
buffer
.
size
();
const
auto
len
=
buffer
.
size
();
buffer
.
resize
(
len
+
size
);
buffer
.
resize
(
len
+
size
);
...
...
effect.h
View file @
90a1b3bd
...
@@ -538,6 +538,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
...
@@ -538,6 +538,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_SUMMON_NEGATED 1114
#define EVENT_SUMMON_NEGATED 1114
#define EVENT_FLIP_SUMMON_NEGATED 1115
#define EVENT_FLIP_SUMMON_NEGATED 1115
#define EVENT_SPSUMMON_NEGATED 1116
#define EVENT_SPSUMMON_NEGATED 1116
#define EVENT_SPSUMMON_SUCCESS_G_P 1117
#define EVENT_CONTROL_CHANGED 1120
#define EVENT_CONTROL_CHANGED 1120
#define EVENT_EQUIP 1121
#define EVENT_EQUIP 1121
#define EVENT_ATTACK_ANNOUNCE 1130
#define EVENT_ATTACK_ANNOUNCE 1130
...
@@ -581,7 +582,13 @@ constexpr int32 HALF_DAMAGE = 0x80000001;
...
@@ -581,7 +582,13 @@ constexpr int32 HALF_DAMAGE = 0x80000001;
#define CODE_PHASE 3 // header + phase_id (12 bits)
#define CODE_PHASE 3 // header + phase_id (12 bits)
#define CODE_VALUE 4 // numeric value, max = 4095
#define CODE_VALUE 4 // numeric value, max = 4095
const
std
::
unordered_set
<
uint32
>
continuous_event
({
EVENT_ADJUST
,
EVENT_BREAK_EFFECT
,
EVENT_TURN_END
});
const
std
::
unordered_set
<
uint32
>
continuous_event
{
EVENT_ADJUST
,
EVENT_BREAK_EFFECT
,
EVENT_TURN_END
,
EVENT_PRE_BATTLE_DAMAGE
,
EVENT_SPSUMMON_SUCCESS_G_P
,
};
bool
is_continuous_event
(
uint32
code
);
bool
is_continuous_event
(
uint32
code
);
#endif
/* EFFECT_H_ */
#endif
/* EFFECT_H_ */
field.h
View file @
90a1b3bd
...
@@ -22,6 +22,10 @@
...
@@ -22,6 +22,10 @@
#define MAX_COIN_COUNT 20
#define MAX_COIN_COUNT 20
//summon action type
#define SUMMON_IN_IDLE 0
#define SUMMON_IN_CHAIN 1
class
card
;
class
card
;
struct
card_data
;
struct
card_data
;
class
duel
;
class
duel
;
...
@@ -140,12 +144,16 @@ struct processor_unit {
...
@@ -140,12 +144,16 @@ struct processor_unit {
uint16
step
{
0
};
uint16
step
{
0
};
effect
*
peffect
{
nullptr
};
effect
*
peffect
{
nullptr
};
group
*
ptarget
{
nullptr
};
group
*
ptarget
{
nullptr
};
int32
arg1
{
0
};
u
int32
arg1
{
0
};
int32
arg2
{
0
};
u
int32
arg2
{
0
};
int32
arg3
{
0
};
u
int32
arg3
{
0
};
int32
arg4
{
0
};
u
int32
arg4
{
0
};
void
*
ptr1
{
nullptr
};
void
*
ptr1
{
nullptr
};
void
*
ptr2
{
nullptr
};
void
*
ptr2
{
nullptr
};
int32
value1
{
0
};
int32
value2
{
0
};
int32
value3
{
0
};
int32
value4
{
0
};
};
};
union
return_value
{
union
return_value
{
int8
bvalue
[
64
];
int8
bvalue
[
64
];
...
@@ -174,7 +182,8 @@ struct processor {
...
@@ -174,7 +182,8 @@ struct processor {
processor_list
units
;
processor_list
units
;
processor_list
subunits
;
processor_list
subunits
;
processor_unit
reserved
;
processor_unit
damage_step_reserved
;
processor_unit
summon_reserved
;
card_vector
select_cards
;
card_vector
select_cards
;
card_vector
unselect_cards
;
card_vector
unselect_cards
;
card_vector
summonable_cards
;
card_vector
summonable_cards
;
...
@@ -553,9 +562,9 @@ public:
...
@@ -553,9 +562,9 @@ public:
void
draw
(
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
int32
count
);
void
draw
(
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
int32
count
);
void
damage
(
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
card
*
reason_card
,
uint32
playerid
,
int32
amount
,
uint32
is_step
=
FALSE
);
void
damage
(
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
card
*
reason_card
,
uint32
playerid
,
int32
amount
,
uint32
is_step
=
FALSE
);
void
recover
(
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
int32
amount
,
uint32
is_step
=
FALSE
);
void
recover
(
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
int32
amount
,
uint32
is_step
=
FALSE
);
void
summon
(
uint32
sumplayer
,
card
*
target
,
effect
*
proc
,
uint32
ignore_count
,
uint32
min_tribute
,
uint32
zone
=
0x1f
);
void
summon
(
uint32
sumplayer
,
card
*
target
,
effect
*
proc
,
uint32
ignore_count
,
uint32
min_tribute
,
uint32
zone
=
0x1f
,
uint32
action_type
=
SUMMON_IN_IDLE
);
void
mset
(
uint32
setplayer
,
card
*
target
,
effect
*
proc
,
uint32
ignore_count
,
uint32
min_tribute
,
uint32
zone
=
0x1f
);
void
mset
(
uint32
setplayer
,
card
*
target
,
effect
*
proc
,
uint32
ignore_count
,
uint32
min_tribute
,
uint32
zone
=
0x1f
,
uint32
action_type
=
SUMMON_IN_IDLE
);
void
special_summon_rule
(
uint32
sumplayer
,
card
*
target
,
uint32
summon_type
);
void
special_summon_rule
(
uint32
sumplayer
,
card
*
target
,
uint32
summon_type
,
uint32
action_type
=
SUMMON_IN_IDLE
);
void
special_summon
(
card_set
*
target
,
uint32
sumtype
,
uint32
sumplayer
,
uint32
playerid
,
uint32
nocheck
,
uint32
nolimit
,
uint32
positions
,
uint32
zone
);
void
special_summon
(
card_set
*
target
,
uint32
sumtype
,
uint32
sumplayer
,
uint32
playerid
,
uint32
nocheck
,
uint32
nolimit
,
uint32
positions
,
uint32
zone
);
void
special_summon_step
(
card
*
target
,
uint32
sumtype
,
uint32
sumplayer
,
uint32
playerid
,
uint32
nocheck
,
uint32
nolimit
,
uint32
positions
,
uint32
zone
);
void
special_summon_step
(
card
*
target
,
uint32
sumtype
,
uint32
sumplayer
,
uint32
playerid
,
uint32
nocheck
,
uint32
nolimit
,
uint32
positions
,
uint32
zone
);
void
special_summon_complete
(
effect
*
reason_effect
,
uint8
reason_player
);
void
special_summon_complete
(
effect
*
reason_effect
,
uint8
reason_player
);
...
@@ -571,6 +580,12 @@ public:
...
@@ -571,6 +580,12 @@ public:
void
operation_replace
(
int32
type
,
int32
step
,
group
*
targets
);
void
operation_replace
(
int32
type
,
int32
step
,
group
*
targets
);
void
select_tribute_cards
(
card
*
target
,
uint8
playerid
,
uint8
cancelable
,
int32
min
,
int32
max
,
uint8
toplayer
,
uint32
zone
);
void
select_tribute_cards
(
card
*
target
,
uint8
playerid
,
uint8
cancelable
,
int32
min
,
int32
max
,
uint8
toplayer
,
uint32
zone
);
// summon
int32
summon
(
uint16
step
,
uint8
sumplayer
,
card
*
target
,
effect
*
proc
,
uint8
ignore_count
,
uint8
min_tribute
,
uint32
zone
,
uint32
action_type
);
int32
mset
(
uint16
step
,
uint8
setplayer
,
card
*
ptarget
,
effect
*
proc
,
uint8
ignore_count
,
uint8
min_tribute
,
uint32
zone
,
uint32
action_type
);
int32
flip_summon
(
uint16
step
,
uint8
sumplayer
,
card
*
target
,
uint32
action_type
);
int32
special_summon_rule
(
uint16
step
,
uint8
sumplayer
,
card
*
target
,
uint32
summon_type
,
uint32
action_type
);
int32
remove_counter
(
uint16
step
,
uint32
reason
,
card
*
pcard
,
uint8
rplayer
,
uint8
s
,
uint8
o
,
uint16
countertype
,
uint16
count
);
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
);
int32
remove_overlay_card
(
uint16
step
,
uint32
reason
,
card
*
pcard
,
uint8
rplayer
,
uint8
s
,
uint8
o
,
uint16
min
,
uint16
max
);
int32
get_control
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
group
*
targets
,
uint8
playerid
,
uint16
reset_phase
,
uint8
reset_count
,
uint32
zone
);
int32
get_control
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
group
*
targets
,
uint8
playerid
,
uint16
reset_phase
,
uint8
reset_count
,
uint32
zone
);
...
@@ -581,12 +596,8 @@ public:
...
@@ -581,12 +596,8 @@ public:
int32
draw
(
uint16
step
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
playerid
,
int32
count
);
int32
draw
(
uint16
step
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
playerid
,
int32
count
);
int32
damage
(
uint16
step
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
card
*
reason_card
,
uint8
playerid
,
int32
amount
,
uint32
is_step
);
int32
damage
(
uint16
step
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
card
*
reason_card
,
uint8
playerid
,
int32
amount
,
uint32
is_step
);
int32
recover
(
uint16
step
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
playerid
,
int32
amount
,
uint32
is_step
);
int32
recover
(
uint16
step
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
playerid
,
int32
amount
,
uint32
is_step
);
int32
summon
(
uint16
step
,
uint8
sumplayer
,
card
*
target
,
effect
*
proc
,
uint8
ignore_count
,
uint8
min_tribute
,
uint32
zone
);
int32
flip_summon
(
uint16
step
,
uint8
sumplayer
,
card
*
target
);
int32
mset
(
uint16
step
,
uint8
setplayer
,
card
*
ptarget
,
effect
*
proc
,
uint8
ignore_count
,
uint8
min_tribute
,
uint32
zone
);
int32
sset
(
uint16
step
,
uint8
setplayer
,
uint8
toplayer
,
card
*
ptarget
,
effect
*
reason_effect
,
uint32
zone
=
0xff
);
int32
sset
(
uint16
step
,
uint8
setplayer
,
uint8
toplayer
,
card
*
ptarget
,
effect
*
reason_effect
,
uint32
zone
=
0xff
);
int32
sset_g
(
uint16
step
,
uint8
setplayer
,
uint8
toplayer
,
group
*
ptarget
,
uint8
confirm
,
effect
*
reason_effect
,
uint32
zone
=
0xff
);
int32
sset_g
(
uint16
step
,
uint8
setplayer
,
uint8
toplayer
,
group
*
ptarget
,
uint8
confirm
,
effect
*
reason_effect
,
uint32
zone
=
0xff
);
int32
special_summon_rule
(
uint16
step
,
uint8
sumplayer
,
card
*
target
,
uint32
summon_type
);
int32
special_summon_step
(
uint16
step
,
group
*
targets
,
card
*
target
,
uint32
zone
);
int32
special_summon_step
(
uint16
step
,
group
*
targets
,
card
*
target
,
uint32
zone
);
int32
special_summon
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
group
*
targets
,
uint32
zone
);
int32
special_summon
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
group
*
targets
,
uint32
zone
);
int32
destroy_replace
(
uint16
step
,
group
*
targets
,
card
*
target
,
uint8
battle
);
int32
destroy_replace
(
uint16
step
,
group
*
targets
,
card
*
target
,
uint8
battle
);
...
@@ -750,17 +761,17 @@ public:
...
@@ -750,17 +761,17 @@ public:
#define PROCESSOR_DESTROY_REPLACE 56
#define PROCESSOR_DESTROY_REPLACE 56
#define PROCESSOR_RELEASE_REPLACE 57
#define PROCESSOR_RELEASE_REPLACE 57
#define PROCESSOR_SENDTO_REPLACE 58
#define PROCESSOR_SENDTO_REPLACE 58
#define PROCESSOR_SUMMON_RULE 60
#define PROCESSOR_SUMMON_RULE 60
//arg1, arg2
#define PROCESSOR_SPSUMMON_RULE 61
#define PROCESSOR_SPSUMMON_RULE 61
//arg1, arg2, arg3
#define PROCESSOR_SPSUMMON 62
#define PROCESSOR_SPSUMMON 62
#define PROCESSOR_FLIP_SUMMON 63
#define PROCESSOR_FLIP_SUMMON 63
//arg1, arg2
#define PROCESSOR_MSET 64
#define PROCESSOR_MSET 64
//arg1, arg2
#define PROCESSOR_SSET 65
#define PROCESSOR_SSET 65
#define PROCESSOR_SPSUMMON_STEP 66
#define PROCESSOR_SPSUMMON_STEP 66
#define PROCESSOR_SSET_G 67
#define PROCESSOR_SSET_G 67
#define PROCESSOR_DRAW 70
#define PROCESSOR_DRAW 70
#define PROCESSOR_DAMAGE 71
#define PROCESSOR_DAMAGE 71
//arg1, arg2, arg3
#define PROCESSOR_RECOVER 72
#define PROCESSOR_RECOVER 72
//arg1, arg2, arg3
#define PROCESSOR_EQUIP 73
#define PROCESSOR_EQUIP 73
#define PROCESSOR_GET_CONTROL 74
#define PROCESSOR_GET_CONTROL 74
#define PROCESSOR_SWAP_CONTROL 75
#define PROCESSOR_SWAP_CONTROL 75
...
...
libcard.cpp
View file @
90a1b3bd
...
@@ -147,40 +147,29 @@ int32 scriptlib::card_get_code(lua_State *L) {
...
@@ -147,40 +147,29 @@ int32 scriptlib::card_get_code(lua_State *L) {
}
}
return
1
;
return
1
;
}
}
// GetOriginalCode(): get the original code printed on card
// return: 1 int
int32
scriptlib
::
card_get_origin_code
(
lua_State
*
L
)
{
int32
scriptlib
::
card_get_origin_code
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
pcard
->
data
.
alias
)
{
lua_pushinteger
(
L
,
pcard
->
get_original_code
());
if
((
pcard
->
data
.
alias
<
pcard
->
data
.
code
+
CARD_ARTWORK_VERSIONS_OFFSET
)
&&
(
pcard
->
data
.
code
<
pcard
->
data
.
alias
+
CARD_ARTWORK_VERSIONS_OFFSET
))
lua_pushinteger
(
L
,
pcard
->
data
.
alias
);
else
lua_pushinteger
(
L
,
pcard
->
data
.
code
);
}
else
lua_pushinteger
(
L
,
pcard
->
data
.
code
);
return
1
;
return
1
;
}
}
// GetOriginalCodeRule(): get the original code in duel (can be different from printed code)
// return: 1-2 int
int32
scriptlib
::
card_get_origin_code_rule
(
lua_State
*
L
)
{
int32
scriptlib
::
card_get_origin_code_rule
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
effect_set
eset
;
auto
codes
=
pcard
->
get_original_code_rule
();
pcard
->
filter_effect
(
EFFECT_ADD_CODE
,
&
eset
);
uint32
code1
=
std
::
get
<
0
>
(
codes
);
if
(
pcard
->
data
.
alias
&&
!
eset
.
size
())
uint32
code2
=
std
::
get
<
1
>
(
codes
);
lua_pushinteger
(
L
,
pcard
->
data
.
alias
);
if
(
code2
)
{
else
{
lua_pushinteger
(
L
,
code1
);
lua_pushinteger
(
L
,
pcard
->
data
.
code
);
lua_pushinteger
(
L
,
code2
);
if
(
eset
.
size
())
{
uint32
otcode
=
eset
.
get_last
()
->
get_value
(
pcard
);
lua_pushinteger
(
L
,
otcode
);
return
2
;
return
2
;
}
}
}
else
{
lua_pushinteger
(
L
,
code1
);
return
1
;
return
1
;
}
}
}
int32
scriptlib
::
card_get_fusion_code
(
lua_State
*
L
)
{
int32
scriptlib
::
card_get_fusion_code
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param_count
(
L
,
1
);
...
@@ -989,7 +978,7 @@ int32 scriptlib::card_get_summon_type(lua_State *L) {
...
@@ -989,7 +978,7 @@ int32 scriptlib::card_get_summon_type(lua_State *L) {
check_param_count
(
L
,
1
);
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
lua_pushinteger
(
L
,
pcard
->
get_summon_info
()
&
0xff00ffff
);
lua_pushinteger
(
L
,
pcard
->
get_summon_info
()
&
DEFAULT_SUMMON_TYPE
);
return
1
;
return
1
;
}
}
int32
scriptlib
::
card_get_summon_location
(
lua_State
*
L
)
{
int32
scriptlib
::
card_get_summon_location
(
lua_State
*
L
)
{
...
@@ -1044,6 +1033,9 @@ int32 scriptlib::card_get_special_summon_info(lua_State *L) {
...
@@ -1044,6 +1033,9 @@ int32 scriptlib::card_get_special_summon_info(lua_State *L) {
case
SUMMON_INFO_REASON_EFFECT
:
case
SUMMON_INFO_REASON_EFFECT
:
interpreter
::
effect2value
(
L
,
pcard
->
spsummon
.
reason_effect
);
interpreter
::
effect2value
(
L
,
pcard
->
spsummon
.
reason_effect
);
break
;
break
;
case
SUMMON_INFO_REASON_PLAYER
:
lua_pushinteger
(
L
,
pcard
->
spsummon
.
reason_player
);
break
;
default:
default:
lua_pushnil
(
L
);
lua_pushnil
(
L
);
break
;
break
;
...
@@ -1090,19 +1082,9 @@ int32 scriptlib::card_is_origin_code_rule(lua_State *L) {
...
@@ -1090,19 +1082,9 @@ int32 scriptlib::card_is_origin_code_rule(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
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
uint32
code1
=
0
;
auto
codes
=
pcard
->
get_original_code_rule
();
uint32
code2
=
0
;
uint32
code1
=
std
::
get
<
0
>
(
codes
);
effect_set
eset
;
uint32
code2
=
std
::
get
<
1
>
(
codes
);
pcard
->
filter_effect
(
EFFECT_ADD_CODE
,
&
eset
);
if
(
pcard
->
data
.
alias
&&
!
eset
.
size
()){
code1
=
pcard
->
data
.
alias
;
code2
=
0
;
}
else
{
code1
=
pcard
->
data
.
code
;
if
(
eset
.
size
())
code2
=
eset
.
get_last
()
->
get_value
(
pcard
);
}
uint32
count
=
lua_gettop
(
L
)
-
1
;
uint32
count
=
lua_gettop
(
L
)
-
1
;
uint32
result
=
FALSE
;
uint32
result
=
FALSE
;
for
(
uint32
i
=
0
;
i
<
count
;
++
i
)
{
for
(
uint32
i
=
0
;
i
<
count
;
++
i
)
{
...
@@ -1382,7 +1364,7 @@ int32 scriptlib::card_is_non_attribute(lua_State *L) {
...
@@ -1382,7 +1364,7 @@ int32 scriptlib::card_is_non_attribute(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
uint32
tattrib
=
(
uint32
)
lua_tointeger
(
L
,
2
);
uint32
tattrib
=
(
uint32
)
lua_tointeger
(
L
,
2
);
if
(
pcard
->
get_attribute
()
&
(
ATTRIBUTE_ALL
-
tattrib
))
if
(
pcard
->
get_attribute
()
&
(
ATTRIBUTE_ALL
&
~
tattrib
))
lua_pushboolean
(
L
,
1
);
lua_pushboolean
(
L
,
1
);
else
else
lua_pushboolean
(
L
,
0
);
lua_pushboolean
(
L
,
0
);
...
@@ -1422,7 +1404,7 @@ int32 scriptlib::card_is_summon_type(lua_State *L) {
...
@@ -1422,7 +1404,7 @@ int32 scriptlib::card_is_summon_type(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
uint32
ttype
=
(
uint32
)
lua_tointeger
(
L
,
2
);
uint32
ttype
=
(
uint32
)
lua_tointeger
(
L
,
2
);
if
(((
pcard
->
get_summon_info
()
&
0xff00ffff
)
&
ttype
)
==
ttype
)
if
(((
pcard
->
get_summon_info
()
&
DEFAULT_SUMMON_TYPE
)
&
ttype
)
==
ttype
)
lua_pushboolean
(
L
,
1
);
lua_pushboolean
(
L
,
1
);
else
else
lua_pushboolean
(
L
,
0
);
lua_pushboolean
(
L
,
0
);
...
@@ -2273,6 +2255,10 @@ int32 scriptlib::card_is_msetable(lua_State *L) {
...
@@ -2273,6 +2255,10 @@ int32 scriptlib::card_is_msetable(lua_State *L) {
check_param_count
(
L
,
3
);
check_param_count
(
L
,
3
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
pcard
->
pduel
->
game_field
->
core
.
effect_damage_step
)
{
lua_pushboolean
(
L
,
FALSE
);
return
1
;
}
uint32
p
=
pcard
->
pduel
->
game_field
->
core
.
reason_player
;
uint32
p
=
pcard
->
pduel
->
game_field
->
core
.
reason_player
;
uint32
ign
=
lua_toboolean
(
L
,
2
);
uint32
ign
=
lua_toboolean
(
L
,
2
);
effect
*
peffect
=
nullptr
;
effect
*
peffect
=
nullptr
;
...
@@ -2321,7 +2307,7 @@ int32 scriptlib::card_is_synchro_summonable(lua_State *L) {
...
@@ -2321,7 +2307,7 @@ int32 scriptlib::card_is_synchro_summonable(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
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
!
(
pcard
->
data
.
type
&
TYPE_SYNCHRO
))
{
if
(
!
(
pcard
->
data
.
type
&
TYPE_SYNCHRO
)
||
pcard
->
pduel
->
game_field
->
core
.
effect_damage_step
)
{
lua_pushboolean
(
L
,
FALSE
);
lua_pushboolean
(
L
,
FALSE
);
return
1
;
return
1
;
}
}
...
@@ -2357,7 +2343,7 @@ int32 scriptlib::card_is_xyz_summonable(lua_State *L) {
...
@@ -2357,7 +2343,7 @@ int32 scriptlib::card_is_xyz_summonable(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
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
!
(
pcard
->
data
.
type
&
TYPE_XYZ
))
{
if
(
!
(
pcard
->
data
.
type
&
TYPE_XYZ
)
||
pcard
->
pduel
->
game_field
->
core
.
effect_damage_step
)
{
lua_pushboolean
(
L
,
FALSE
);
lua_pushboolean
(
L
,
FALSE
);
return
1
;
return
1
;
}
}
...
@@ -2385,7 +2371,7 @@ int32 scriptlib::card_is_link_summonable(lua_State *L) {
...
@@ -2385,7 +2371,7 @@ int32 scriptlib::card_is_link_summonable(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
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
!
(
pcard
->
data
.
type
&
TYPE_LINK
))
{
if
(
!
(
pcard
->
data
.
type
&
TYPE_LINK
)
||
pcard
->
pduel
->
game_field
->
core
.
effect_damage_step
)
{
lua_pushboolean
(
L
,
FALSE
);
lua_pushboolean
(
L
,
FALSE
);
return
1
;
return
1
;
}
}
...
@@ -2421,6 +2407,10 @@ int32 scriptlib::card_is_can_be_summoned(lua_State *L) {
...
@@ -2421,6 +2407,10 @@ int32 scriptlib::card_is_can_be_summoned(lua_State *L) {
check_param_count
(
L
,
3
);
check_param_count
(
L
,
3
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
pcard
->
pduel
->
game_field
->
core
.
effect_damage_step
)
{
lua_pushboolean
(
L
,
FALSE
);
return
1
;
}
uint32
p
=
pcard
->
pduel
->
game_field
->
core
.
reason_player
;
uint32
p
=
pcard
->
pduel
->
game_field
->
core
.
reason_player
;
uint32
ign
=
lua_toboolean
(
L
,
2
);
uint32
ign
=
lua_toboolean
(
L
,
2
);
effect
*
peffect
=
nullptr
;
effect
*
peffect
=
nullptr
;
...
...
libduel.cpp
View file @
90a1b3bd
This diff is collapsed.
Click to expand it.
libgroup.cpp
View file @
90a1b3bd
...
@@ -401,6 +401,46 @@ int32 scriptlib::group_random_select(lua_State *L) {
...
@@ -401,6 +401,46 @@ int32 scriptlib::group_random_select(lua_State *L) {
interpreter
::
group2value
(
L
,
newgroup
);
interpreter
::
group2value
(
L
,
newgroup
);
return
1
;
return
1
;
}
}
int32
scriptlib
::
group_cancelable_select
(
lua_State
*
L
)
{
check_action_permission
(
L
);
check_param_count
(
L
,
5
);
check_param
(
L
,
PARAM_TYPE_GROUP
,
1
);
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
field
::
card_set
cset
(
pgroup
->
container
);
if
(
check_param
(
L
,
PARAM_TYPE_CARD
,
5
,
TRUE
))
{
card
*
pexception
=
*
(
card
**
)
lua_touserdata
(
L
,
5
);
cset
.
erase
(
pexception
);
}
else
if
(
check_param
(
L
,
PARAM_TYPE_GROUP
,
5
,
TRUE
))
{
group
*
pexgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
5
);
for
(
auto
&
pcard
:
pexgroup
->
container
)
cset
.
erase
(
pcard
);
}
duel
*
pduel
=
pgroup
->
pduel
;
uint32
playerid
=
(
uint32
)
lua_tointeger
(
L
,
2
);
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
uint32
min
=
(
uint32
)
lua_tointeger
(
L
,
3
);
uint32
max
=
(
uint32
)
lua_tointeger
(
L
,
4
);
pduel
->
game_field
->
core
.
select_cards
.
clear
();
for
(
auto
&
pcard
:
cset
)
{
pduel
->
game_field
->
core
.
select_cards
.
push_back
(
pcard
);
}
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_CARD
,
0
,
0
,
0
,
playerid
+
0x10000
,
min
+
(
max
<<
16
));
return
lua_yieldk
(
L
,
0
,
(
lua_KContext
)
pduel
,
[](
lua_State
*
L
,
int32
status
,
lua_KContext
ctx
)
{
duel
*
pduel
=
(
duel
*
)
ctx
;
if
(
pduel
->
game_field
->
returns
.
bvalue
[
0
]
==
-
1
)
{
lua_pushnil
(
L
);
}
else
{
group
*
pgroup
=
pduel
->
new_group
();
for
(
int32
i
=
0
;
i
<
pduel
->
game_field
->
returns
.
bvalue
[
0
];
++
i
)
{
card
*
pcard
=
pduel
->
game_field
->
core
.
select_cards
[
pduel
->
game_field
->
returns
.
bvalue
[
i
+
1
]];
pgroup
->
container
.
insert
(
pcard
);
}
interpreter
::
group2value
(
L
,
pgroup
);
}
return
1
;
});
}
int32
scriptlib
::
group_is_exists
(
lua_State
*
L
)
{
int32
scriptlib
::
group_is_exists
(
lua_State
*
L
)
{
check_param_count
(
L
,
4
);
check_param_count
(
L
,
4
);
check_param
(
L
,
PARAM_TYPE_GROUP
,
1
);
check_param
(
L
,
PARAM_TYPE_GROUP
,
1
);
...
@@ -893,6 +933,7 @@ static const struct luaL_Reg grouplib[] = {
...
@@ -893,6 +933,7 @@ static const struct luaL_Reg grouplib[] = {
{
"Select"
,
scriptlib
::
group_select
},
{
"Select"
,
scriptlib
::
group_select
},
{
"SelectUnselect"
,
scriptlib
::
group_select_unselect
},
{
"SelectUnselect"
,
scriptlib
::
group_select_unselect
},
{
"RandomSelect"
,
scriptlib
::
group_random_select
},
{
"RandomSelect"
,
scriptlib
::
group_random_select
},
{
"CancelableSelect"
,
scriptlib
::
group_cancelable_select
},
{
"IsExists"
,
scriptlib
::
group_is_exists
},
{
"IsExists"
,
scriptlib
::
group_is_exists
},
{
"CheckWithSumEqual"
,
scriptlib
::
group_check_with_sum_equal
},
{
"CheckWithSumEqual"
,
scriptlib
::
group_check_with_sum_equal
},
{
"SelectWithSumEqual"
,
scriptlib
::
group_select_with_sum_equal
},
{
"SelectWithSumEqual"
,
scriptlib
::
group_select_with_sum_equal
},
...
...
operations.cpp
View file @
90a1b3bd
This diff is collapsed.
Click to expand it.
processor.cpp
View file @
90a1b3bd
...
@@ -364,14 +364,14 @@ uint32 field::process() {
...
@@ -364,14 +364,14 @@ uint32 field::process() {
return
pduel
->
message_buffer
.
size
();
return
pduel
->
message_buffer
.
size
();
}
}
case
PROCESSOR_SUMMON_RULE
:
{
case
PROCESSOR_SUMMON_RULE
:
{
if
(
summon
(
it
->
step
,
it
->
arg1
&
0xff
,
(
card
*
)
it
->
ptarget
,
it
->
peffect
,
(
it
->
arg1
>>
8
)
&
0xff
,
(
it
->
arg1
>>
16
)
&
0xff
,
(
it
->
arg1
>>
24
)
&
0xff
))
if
(
summon
(
it
->
step
,
it
->
arg1
&
0xff
,
(
card
*
)
it
->
ptarget
,
it
->
peffect
,
(
it
->
arg1
>>
8
)
&
0xff
,
(
it
->
arg1
>>
16
)
&
0xff
,
(
it
->
arg1
>>
24
)
&
0xff
,
it
->
arg2
))
core
.
units
.
pop_front
();
core
.
units
.
pop_front
();
else
else
++
it
->
step
;
++
it
->
step
;
return
pduel
->
message_buffer
.
size
();
return
pduel
->
message_buffer
.
size
();
}
}
case
PROCESSOR_SPSUMMON_RULE
:
{
case
PROCESSOR_SPSUMMON_RULE
:
{
if
(
special_summon_rule
(
it
->
step
,
it
->
arg1
,
(
card
*
)
it
->
ptarget
,
it
->
arg2
))
if
(
special_summon_rule
(
it
->
step
,
it
->
arg1
,
(
card
*
)
it
->
ptarget
,
it
->
arg2
,
it
->
arg3
))
core
.
units
.
pop_front
();
core
.
units
.
pop_front
();
else
else
++
it
->
step
;
++
it
->
step
;
...
@@ -385,14 +385,14 @@ uint32 field::process() {
...
@@ -385,14 +385,14 @@ uint32 field::process() {
return
pduel
->
message_buffer
.
size
();
return
pduel
->
message_buffer
.
size
();
}
}
case
PROCESSOR_FLIP_SUMMON
:
{
case
PROCESSOR_FLIP_SUMMON
:
{
if
(
flip_summon
(
it
->
step
,
it
->
arg1
,
(
card
*
)(
it
->
ptarget
)))
if
(
flip_summon
(
it
->
step
,
it
->
arg1
,
(
card
*
)(
it
->
ptarget
)
,
it
->
arg2
))
core
.
units
.
pop_front
();
core
.
units
.
pop_front
();
else
else
++
it
->
step
;
++
it
->
step
;
return
pduel
->
message_buffer
.
size
();
return
pduel
->
message_buffer
.
size
();
}
}
case
PROCESSOR_MSET
:
{
case
PROCESSOR_MSET
:
{
if
(
mset
(
it
->
step
,
it
->
arg1
&
0xff
,
(
card
*
)
it
->
ptarget
,
it
->
peffect
,
(
it
->
arg1
>>
8
)
&
0xff
,
(
it
->
arg1
>>
16
)
&
0xff
,
(
it
->
arg1
>>
24
)
&
0xff
))
if
(
mset
(
it
->
step
,
it
->
arg1
&
0xff
,
(
card
*
)
it
->
ptarget
,
it
->
peffect
,
(
it
->
arg1
>>
8
)
&
0xff
,
(
it
->
arg1
>>
16
)
&
0xff
,
(
it
->
arg1
>>
24
)
&
0xff
,
it
->
arg2
))
core
.
units
.
pop_front
();
core
.
units
.
pop_front
();
else
else
++
it
->
step
;
++
it
->
step
;
...
@@ -1312,6 +1312,10 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
...
@@ -1312,6 +1312,10 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
card
*
phandler
=
peffect
->
get_handler
();
card
*
phandler
=
peffect
->
get_handler
();
if
(
phandler
->
is_has_relation
(
*
clit
))
//work around: position and control should be refreshed before raising event
if
(
phandler
->
is_has_relation
(
*
clit
))
//work around: position and control should be refreshed before raising event
clit
->
set_triggering_state
(
phandler
);
clit
->
set_triggering_state
(
phandler
);
if
(
clit
->
triggering_player
!=
phandler
->
current
.
controler
&&
!
peffect
->
is_flag
(
EFFECT_FLAG_EVENT_PLAYER
))
{
clit
->
triggering_player
=
phandler
->
current
.
controler
;
clit
->
set_triggering_state
(
phandler
);
}
uint8
tp
=
clit
->
triggering_player
;
uint8
tp
=
clit
->
triggering_player
;
if
(
check_trigger_effect
(
*
clit
)
&&
peffect
->
is_chainable
(
tp
)
&&
peffect
->
is_activateable
(
tp
,
clit
->
evt
,
TRUE
))
{
if
(
check_trigger_effect
(
*
clit
)
&&
peffect
->
is_chainable
(
tp
)
&&
peffect
->
is_activateable
(
tp
,
clit
->
evt
,
TRUE
))
{
if
(
tp
==
core
.
current_player
)
if
(
tp
==
core
.
current_player
)
...
@@ -1369,6 +1373,10 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
...
@@ -1369,6 +1373,10 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
clit
->
triggering_player
=
phandler
->
current
.
controler
;
clit
->
triggering_player
=
phandler
->
current
.
controler
;
clit
->
set_triggering_state
(
phandler
);
clit
->
set_triggering_state
(
phandler
);
}
}
if
(
clit
->
triggering_player
!=
phandler
->
current
.
controler
&&
!
peffect
->
is_flag
(
EFFECT_FLAG_EVENT_PLAYER
))
{
clit
->
triggering_player
=
phandler
->
current
.
controler
;
clit
->
set_triggering_state
(
phandler
);
}
uint8
tp
=
clit
->
triggering_player
;
uint8
tp
=
clit
->
triggering_player
;
if
(
check_nonpublic_trigger
(
*
clit
)
&&
check_trigger_effect
(
*
clit
)
if
(
check_nonpublic_trigger
(
*
clit
)
&&
check_trigger_effect
(
*
clit
)
&&
peffect
->
is_chainable
(
tp
)
&&
peffect
->
is_activateable
(
tp
,
clit
->
evt
,
TRUE
)
&&
peffect
->
is_chainable
(
tp
)
&&
peffect
->
is_activateable
(
tp
,
clit
->
evt
,
TRUE
)
...
@@ -1630,8 +1638,8 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
...
@@ -1630,8 +1638,8 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
chain
newchain
;
chain
newchain
;
if
(
core
.
ignition_priority_chains
.
size
())
if
(
core
.
ignition_priority_chains
.
size
())
core
.
select_chains
.
swap
(
core
.
ignition_priority_chains
);
core
.
select_chains
.
swap
(
core
.
ignition_priority_chains
);
for
(
const
auto
*
ev_list
:
{
&
core
.
point_event
,
&
core
.
instant_event
})
{
for
(
const
auto
&
ev_list
:
{
core
.
point_event
,
core
.
instant_event
})
{
for
(
const
auto
&
ev
:
*
ev_list
)
{
for
(
const
auto
&
ev
:
ev_list
)
{
auto
pr
=
effects
.
activate_effect
.
equal_range
(
ev
.
event_code
);
auto
pr
=
effects
.
activate_effect
.
equal_range
(
ev
.
event_code
);
for
(
auto
eit
=
pr
.
first
;
eit
!=
pr
.
second
;)
{
for
(
auto
eit
=
pr
.
first
;
eit
!=
pr
.
second
;)
{
effect
*
peffect
=
eit
->
second
;
effect
*
peffect
=
eit
->
second
;
...
@@ -3124,7 +3132,7 @@ int32 field::process_battle_command(uint16 step) {
...
@@ -3124,7 +3132,7 @@ int32 field::process_battle_command(uint16 step) {
process_single_event
();
process_single_event
();
process_instant_event
();
process_instant_event
();
if
(
core
.
effect_damage_step
)
{
if
(
core
.
effect_damage_step
)
{
core
.
reserved
.
ptr1
=
core
.
units
.
begin
()
->
ptarget
;
core
.
damage_step_
reserved
.
ptr1
=
core
.
units
.
begin
()
->
ptarget
;
return
TRUE
;
return
TRUE
;
}
}
core
.
units
.
begin
()
->
step
=
32
;
core
.
units
.
begin
()
->
step
=
32
;
...
@@ -3309,7 +3317,7 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) {
...
@@ -3309,7 +3317,7 @@ int32 field::process_damage_step(uint16 step, uint32 new_attack) {
infos
.
phase
=
PHASE_DAMAGE_CAL
;
infos
.
phase
=
PHASE_DAMAGE_CAL
;
add_process
(
PROCESSOR_BATTLE_COMMAND
,
26
,
0
,
0
,
0
,
0
);
add_process
(
PROCESSOR_BATTLE_COMMAND
,
26
,
0
,
0
,
0
,
0
);
core
.
units
.
begin
()
->
step
=
2
;
core
.
units
.
begin
()
->
step
=
2
;
core
.
reserved
=
core
.
units
.
front
();
core
.
damage_step_
reserved
=
core
.
units
.
front
();
return
TRUE
;
return
TRUE
;
}
}
case
2
:
{
case
2
:
{
...
@@ -4496,7 +4504,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
...
@@ -4496,7 +4504,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
return
FALSE
;
return
FALSE
;
}
}
if
(
core
.
summoning_card
)
if
(
core
.
summoning_card
)
core
.
subunits
.
push_back
(
core
.
reserved
);
core
.
subunits
.
push_back
(
core
.
summon_
reserved
);
core
.
summoning_card
=
0
;
core
.
summoning_card
=
0
;
core
.
units
.
begin
()
->
step
=
-
1
;
core
.
units
.
begin
()
->
step
=
-
1
;
return
FALSE
;
return
FALSE
;
...
@@ -4520,8 +4528,10 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
...
@@ -4520,8 +4528,10 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
core
.
chain_limit_p
.
clear
();
core
.
chain_limit_p
.
clear
();
core
.
effect_count_code_chain
.
clear
();
core
.
effect_count_code_chain
.
clear
();
reset_chain
();
reset_chain
();
if
(
core
.
summoning_card
||
core
.
effect_damage_step
==
1
)
if
(
core
.
summoning_card
)
core
.
subunits
.
push_back
(
core
.
reserved
);
core
.
subunits
.
push_back
(
core
.
summon_reserved
);
if
(
core
.
effect_damage_step
==
1
)
core
.
subunits
.
push_back
(
core
.
damage_step_reserved
);
core
.
summoning_card
=
0
;
core
.
summoning_card
=
0
;
return
FALSE
;
return
FALSE
;
}
}
...
...
scriptlib.h
View file @
90a1b3bd
...
@@ -11,6 +11,10 @@
...
@@ -11,6 +11,10 @@
#include "common.h"
#include "common.h"
#include "interpreter.h"
#include "interpreter.h"
constexpr
bool
match_all
(
uint32
x
,
uint32
y
)
{
return
(
x
&
y
)
==
y
;
}
class
scriptlib
{
class
scriptlib
{
public:
public:
static
int32
check_param
(
lua_State
*
L
,
int32
param_type
,
int32
index
,
int32
retfalse
=
FALSE
);
static
int32
check_param
(
lua_State
*
L
,
int32
param_type
,
int32
index
,
int32
retfalse
=
FALSE
);
...
@@ -390,6 +394,7 @@ public:
...
@@ -390,6 +394,7 @@ public:
static
int32
group_select
(
lua_State
*
L
);
static
int32
group_select
(
lua_State
*
L
);
static
int32
group_select_unselect
(
lua_State
*
L
);
static
int32
group_select_unselect
(
lua_State
*
L
);
static
int32
group_random_select
(
lua_State
*
L
);
static
int32
group_random_select
(
lua_State
*
L
);
static
int32
group_cancelable_select
(
lua_State
*
L
);
static
int32
group_is_exists
(
lua_State
*
L
);
static
int32
group_is_exists
(
lua_State
*
L
);
static
int32
group_check_with_sum_equal
(
lua_State
*
L
);
static
int32
group_check_with_sum_equal
(
lua_State
*
L
);
static
int32
group_select_with_sum_equal
(
lua_State
*
L
);
static
int32
group_select_with_sum_equal
(
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