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
da075384
Commit
da075384
authored
Nov 28, 2024
by
wind2009
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
de861f43
7440a4ba
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
829 additions
and
754 deletions
+829
-754
card.cpp
card.cpp
+226
-227
card.h
card.h
+21
-10
common.h
common.h
+11
-11
duel.cpp
duel.cpp
+4
-3
duel.h
duel.h
+4
-0
effect.cpp
effect.cpp
+6
-1
effect.h
effect.h
+29
-18
effectset.h
effectset.h
+1
-8
field.cpp
field.cpp
+48
-41
field.h
field.h
+17
-17
libcard.cpp
libcard.cpp
+30
-6
libdebug.cpp
libdebug.cpp
+1
-1
libduel.cpp
libduel.cpp
+51
-58
libeffect.cpp
libeffect.cpp
+90
-68
operations.cpp
operations.cpp
+137
-144
playerop.cpp
playerop.cpp
+6
-5
premake/dll.lua
premake/dll.lua
+1
-1
processor.cpp
processor.cpp
+132
-135
scriptlib.h
scriptlib.h
+14
-0
No files found.
card.cpp
View file @
da075384
This diff is collapsed.
Click to expand it.
card.h
View file @
da075384
...
...
@@ -30,6 +30,9 @@ using effect_container = std::multimap<uint32, effect*>;
using
effect_indexer
=
std
::
unordered_map
<
effect
*
,
effect_container
::
iterator
>
;
using
effect_collection
=
std
::
unordered_set
<
effect
*>
;
using
effect_filter
=
bool
(
*
)(
card
*
self
,
effect
*
peffect
);
using
effect_filter_target
=
bool
(
*
)(
card
*
self
,
effect
*
peffect
,
card
*
target
);
struct
card_state
{
uint32
code
{
0
};
uint32
code2
{
0
};
...
...
@@ -56,7 +59,7 @@ struct card_state {
uint8
reason_player
{
PLAYER_NONE
};
effect
*
reason_effect
{
nullptr
};
bool
is_location
(
int32
loc
)
const
;
bool
is_location
(
u
int32
loc
)
const
;
bool
is_main_mzone
()
const
{
return
location
==
LOCATION_MZONE
&&
sequence
>=
0
&&
sequence
<=
4
;
}
...
...
@@ -210,10 +213,13 @@ public:
effect_indexer
indexer
;
effect_relation
relate_effect
;
effect_set_v
immune_effect
;
effect_collection
initial_effect
;
effect_collection
owning_effect
;
explicit
card
(
duel
*
pd
);
~
card
()
=
default
;
static
bool
card_operation_sort
(
card
*
c1
,
card
*
c2
);
static
bool
check_card_setcode
(
uint32
code
,
uint32
value
);
bool
is_extra_deck_monster
()
const
{
return
!!
(
data
.
type
&
TYPES_EXTRA_DECK
);
}
int32
get_infos
(
byte
*
buf
,
uint32
query_flag
,
int32
use_cache
=
TRUE
);
...
...
@@ -222,7 +228,6 @@ public:
std
::
tuple
<
uint32
,
uint32
>
get_original_code_rule
()
const
;
uint32
get_code
();
uint32
get_another_code
();
static
bool
check_card_setcode
(
uint32
code
,
uint32
value
);
int32
is_set_card
(
uint32
set_code
);
int32
is_origin_set_card
(
uint32
set_code
);
int32
is_pre_set_card
(
uint32
set_code
);
...
...
@@ -258,14 +263,14 @@ public:
uint32
get_lscale
();
uint32
get_rscale
();
uint32
get_link_marker
();
int32
is_link_marker
(
uint32
dir
);
u
int32
is_link_marker
(
uint32
dir
);
uint32
get_linked_zone
();
void
get_linked_cards
(
card_set
*
cset
);
uint32
get_mutual_linked_zone
();
void
get_mutual_linked_cards
(
card_set
*
cset
);
int32
is_link_state
();
int32
is_extra_link_state
();
int32
is_position
(
int32
pos
)
;
int32
is_position
(
uint32
pos
)
const
;
void
set_status
(
uint32
status
,
int32
enabled
);
int32
get_status
(
uint32
status
)
const
;
int32
is_status
(
uint32
status
)
const
;
...
...
@@ -274,13 +279,13 @@ public:
int32
is_all_column
();
uint8
get_select_sequence
(
uint8
*
deck_seq_pointer
);
uint32
get_select_info_location
(
uint8
*
deck_seq_pointer
);
int32
is_treated_as_not_on_field
();
int32
is_treated_as_not_on_field
()
const
;
void
equip
(
card
*
target
,
uint32
send_msg
=
TRUE
);
void
unequip
();
int32
get_union_count
();
int32
get_old_union_count
();
void
xyz_overlay
(
c
ard_set
*
materials
);
void
xyz_overlay
(
c
onst
card_set
&
materials
);
void
xyz_add
(
card
*
mat
);
void
xyz_remove
(
card
*
mat
);
void
apply_field_effect
();
...
...
@@ -320,9 +325,11 @@ public:
void
clear_card_target
();
void
set_special_summon_status
(
effect
*
peffect
);
void
filter_effect
(
int32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
void
filter_single_continuous_effect
(
int32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
void
filter_self_effect
(
int32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
template
<
typename
T
>
void
filter_effect_container
(
const
effect_container
&
container
,
uint32
code
,
effect_filter
f
,
T
&
eset
);
void
filter_effect
(
uint32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
void
filter_single_continuous_effect
(
uint32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
void
filter_self_effect
(
uint32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
void
filter_immune_effect
();
void
filter_disable_related_cards
();
int32
filter_summon_procedure
(
uint8
playerid
,
effect_set
*
eset
,
uint8
ignore_count
,
uint8
min_tribute
,
uint32
zone
);
...
...
@@ -331,7 +338,9 @@ public:
int32
check_set_procedure
(
effect
*
proc
,
uint8
playerid
,
uint8
ignore_count
,
uint8
min_tribute
,
uint32
zone
);
void
filter_spsummon_procedure
(
uint8
playerid
,
effect_set
*
eset
,
uint32
summon_type
,
material_info
info
=
null_info
);
void
filter_spsummon_procedure_g
(
uint8
playerid
,
effect_set
*
eset
);
effect
*
is_affected_by_effect
(
int32
code
);
effect
*
find_effect
(
const
effect_container
&
container
,
uint32
code
,
effect_filter
f
);
effect
*
find_effect_with_target
(
const
effect_container
&
container
,
uint32
code
,
effect_filter_target
f
,
card
*
target
);
effect
*
is_affected_by_effect
(
uint32
code
);
effect
*
is_affected_by_effect
(
int32
code
,
card
*
target
);
int32
fusion_check
(
group
*
fusion_m
,
card
*
cg
,
uint32
chkf
,
uint8
not_material
);
void
fusion_select
(
uint8
playerid
,
group
*
fusion_m
,
card
*
cg
,
uint32
chkf
,
uint8
not_material
);
...
...
@@ -392,6 +401,8 @@ public:
int32
is_can_be_ritual_material
(
card
*
scard
);
int32
is_can_be_xyz_material
(
card
*
scard
);
int32
is_can_be_link_material
(
card
*
scard
);
int32
is_original_effect_property
(
int32
filter
);
int32
is_effect_property
(
int32
filter
);
};
//Summon Type in summon_info
...
...
common.h
View file @
da075384
...
...
@@ -49,17 +49,17 @@ typedef signed char int8;
#define CURRENT_RULE 5
//Locations
#define LOCATION_DECK 0x01
//
#define LOCATION_HAND 0x02
//
#define LOCATION_MZONE 0x04
//
#define LOCATION_SZONE 0x08
//
#define LOCATION_GRAVE 0x10
//
#define LOCATION_REMOVED 0x20
//
#define LOCATION_EXTRA 0x40
//
#define LOCATION_OVERLAY 0x80
//
#define LOCATION_ONFIELD
0x0c //
#define LOCATION_FZONE 0x100
//
#define LOCATION_PZONE 0x200
//
#define LOCATION_DECK 0x01
U
#define LOCATION_HAND 0x02
U
#define LOCATION_MZONE 0x04
U
#define LOCATION_SZONE 0x08
U
#define LOCATION_GRAVE 0x10
U
#define LOCATION_REMOVED 0x20
U
#define LOCATION_EXTRA 0x40
U
#define LOCATION_OVERLAY 0x80
U
#define LOCATION_ONFIELD
(LOCATION_MZONE | LOCATION_SZONE)
#define LOCATION_FZONE 0x100
U
#define LOCATION_PZONE 0x200
U
//For redirect
#define LOCATION_DECKBOT 0x10001 //Return to deck bottom
#define LOCATION_DECKSHF 0x20001 //Return to deck and shuffle
...
...
duel.cpp
View file @
da075384
...
...
@@ -98,9 +98,10 @@ void duel::delete_effect(effect* peffect) {
delete
peffect
;
}
int32
duel
::
read_buffer
(
byte
*
buf
)
{
if
(
message_buffer
.
size
())
std
::
memcpy
(
buf
,
message_buffer
.
data
(),
message_buffer
.
size
());
return
(
int32
)
message_buffer
.
size
();
auto
size
=
buffer_size
();
if
(
size
)
std
::
memcpy
(
buf
,
message_buffer
.
data
(),
size
);
return
(
int32
)
size
;
}
void
duel
::
release_script_group
()
{
for
(
auto
&
pgroup
:
sgroups
)
{
...
...
duel.h
View file @
da075384
...
...
@@ -13,6 +13,7 @@
#include "mtrandom.h"
#include <set>
#include <unordered_set>
#include <vector>
class
card
;
class
group
;
...
...
@@ -40,6 +41,9 @@ public:
~
duel
();
void
clear
();
uint32
buffer_size
()
const
{
return
(
uint32
)
message_buffer
.
size
()
&
PROCESSOR_BUFFER_LEN
;
}
card
*
new_card
(
uint32
code
);
group
*
new_group
();
group
*
new_group
(
card
*
pcard
);
...
...
effect.cpp
View file @
da075384
...
...
@@ -622,6 +622,11 @@ int32 effect::is_hand_trigger() const {
int32
effect
::
is_initial_single
()
const
{
return
(
type
&
EFFECT_TYPE_SINGLE
)
&&
is_flag
(
EFFECT_FLAG_SINGLE_RANGE
)
&&
is_flag
(
EFFECT_FLAG_INITIAL
);
}
int32
effect
::
is_monster_effect
()
const
{
if
(
range
&
(
LOCATION_SZONE
|
LOCATION_FZONE
|
LOCATION_PZONE
))
return
FALSE
;
return
TRUE
;
}
//return: this can be reset by reset_level or not
//RESET_DISABLE is valid only when owner == handler
int32
effect
::
reset
(
uint32
reset_level
,
uint32
reset_type
)
{
...
...
@@ -858,7 +863,7 @@ uint32 effect::get_active_type(uint8 uselast) {
}
else
return
owner
->
get_type
();
}
int32
effect
::
get_code_type
()
const
{
code_type
effect
::
get_code_type
()
const
{
// start from the highest bit
if
(
code
&
0xf0000000
)
return
CODE_CUSTOM
;
...
...
effect.h
View file @
da075384
...
...
@@ -11,9 +11,7 @@
#include "common.h"
#include "field.h"
#include "effectset.h"
#include <stdlib.h>
#include <vector>
#include <map>
class
card
;
class
duel
;
...
...
@@ -22,8 +20,11 @@ class effect;
struct
tevent
;
struct
effect_set
;
struct
effect_set_v
;
enum
effect_flag
:
uint32
;
enum
effect_flag2
:
uint32
;
enum
effect_flag
:
uint64
;
enum
effect_flag2
:
uint64
;
enum
code_type
:
int32
;
bool
is_continuous_event
(
uint32
code
);
class
effect
{
public:
...
...
@@ -34,7 +35,6 @@ public:
uint8
effect_owner
{
PLAYER_NONE
};
uint32
description
{
0
};
uint32
code
{
0
};
uint32
flag
[
2
]{};
uint32
id
{
0
};
uint32
type
{
0
};
uint16
copy_id
{
0
};
...
...
@@ -43,18 +43,19 @@ public:
uint16
o_range
{
0
};
uint8
count_limit
{
0
};
uint8
count_limit_max
{
0
};
uint16
status
{
0
};
int32
reset_count
{
0
};
uint32
reset_flag
{
0
};
uint32
count_code
{
0
};
uint32
category
{
0
};
uint64
category
{
0
};
uint64
flag
[
2
]{};
uint32
hint_timing
[
2
]{};
uint32
card_type
{
0
};
uint32
active_type
{
0
};
uint16
active_location
{
0
};
uint16
active_sequence
{
0
};
card
*
active_handler
{
nullptr
};
uint16
status
{
0
};
std
::
vector
<
uint32
>
label
;
std
::
vector
<
lua_Integer
>
label
;
int32
label_object
{
0
};
int32
condition
{
0
};
int32
cost
{
0
};
...
...
@@ -90,6 +91,7 @@ public:
int32
is_chainable
(
uint8
tp
);
int32
is_hand_trigger
()
const
;
int32
is_initial_single
()
const
;
int32
is_monster_effect
()
const
;
int32
reset
(
uint32
reset_level
,
uint32
reset_type
);
void
dec_count
(
uint8
playerid
=
PLAYER_NONE
);
void
recharge
();
...
...
@@ -113,7 +115,7 @@ public:
void
set_activate_location
();
void
set_active_type
();
uint32
get_active_type
(
uint8
uselast
=
TRUE
);
int32
get_code_type
()
const
;
code_type
get_code_type
()
const
;
bool
is_flag
(
effect_flag
x
)
const
{
return
!!
(
flag
[
0
]
&
x
);
...
...
@@ -156,6 +158,8 @@ public:
#define RESET_OVERLAY 0x04000000
#define RESET_MSCHANGE 0x08000000
constexpr
uint32
RESETS_STANDARD
=
RESET_TOFIELD
|
RESET_LEAVE
|
RESET_TODECK
|
RESET_TOHAND
|
RESET_TEMP_REMOVE
|
RESET_REMOVE
|
RESET_TOGRAVE
|
RESET_TURN_SET
;
//========== Types ==========
#define EFFECT_TYPE_SINGLE 0x0001 //
#define EFFECT_TYPE_FIELD 0x0002 //
...
...
@@ -177,7 +181,7 @@ constexpr uint32 EFFECT_TYPES_TRIGGER_LIKE = EFFECT_TYPE_ACTIVATE | EFFECT_TYPE_
constexpr
uint32
EFFECT_TYPES_CHAIN_LINK
=
EFFECT_TYPES_TRIGGER_LIKE
|
EFFECT_TYPE_FLIP
|
EFFECT_TYPE_IGNITION
;
//========== Flags ==========
enum
effect_flag
:
uint
32
{
enum
effect_flag
:
uint
64
{
EFFECT_FLAG_INITIAL
=
0x0001
,
EFFECT_FLAG_FUNC_VALUE
=
0x0002
,
EFFECT_FLAG_COUNT_LIMIT
=
0x0004
,
...
...
@@ -191,7 +195,7 @@ enum effect_flag : uint32 {
EFFECT_FLAG_CANNOT_DISABLE
=
0x0400
,
EFFECT_FLAG_PLAYER_TARGET
=
0x0800
,
EFFECT_FLAG_BOTH_SIDE
=
0x1000
,
// EFFECT_FLAG_COPY_INHERIT
= 0x2000,
EFFECT_FLAG_COPY
=
0x2000
,
EFFECT_FLAG_DAMAGE_STEP
=
0x4000
,
EFFECT_FLAG_DAMAGE_CAL
=
0x8000
,
EFFECT_FLAG_DELAY
=
0x10000
,
...
...
@@ -211,7 +215,7 @@ enum effect_flag : uint32 {
// EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY
=
0x80000000
,
};
enum
effect_flag2
:
uint
32
{
enum
effect_flag2
:
uint
64
{
EFFECT_FLAG2_REPEAT_UPDATE
=
0x0001
,
EFFECT_FLAG2_COF
=
0x0002
,
EFFECT_FLAG2_WICKED
=
0x0004
,
...
...
@@ -220,7 +224,7 @@ enum effect_flag2 : uint32 {
constexpr
effect_flag
operator
|
(
effect_flag
flag1
,
effect_flag
flag2
)
{
return
static_cast
<
effect_flag
>
(
static_cast
<
uint32
>
(
flag1
)
|
static_cast
<
uint32
>
(
flag2
));
}
constexpr
uint32
INTERNAL_FLAGS
=
EFFECT_FLAG_INITIAL
|
EFFECT_FLAG_FUNC_VALUE
|
EFFECT_FLAG_COUNT_LIMIT
|
EFFECT_FLAG_FIELD_ONLY
|
EFFECT_FLAG_ABSOLUTE_TARGET
;
constexpr
uint32
INTERNAL_FLAGS
=
EFFECT_FLAG_INITIAL
|
EFFECT_FLAG_
COPY
|
EFFECT_FLAG_
FUNC_VALUE
|
EFFECT_FLAG_COUNT_LIMIT
|
EFFECT_FLAG_FIELD_ONLY
|
EFFECT_FLAG_ABSOLUTE_TARGET
;
//========== Codes ==========
#define EFFECT_IMMUNE_EFFECT 1 //
#define EFFECT_DISABLE 2 //
...
...
@@ -563,10 +567,12 @@ constexpr int32 HALF_DAMAGE = 0x80000001;
#define MAX_CARD_ID 0xfffffff
// The type of effect code
#define CODE_CUSTOM 1 // header + id (28 bits)
#define CODE_COUNTER 2 // header + counter_id (16 bits)
#define CODE_PHASE 3 // header + phase_id (12 bits)
#define CODE_VALUE 4 // numeric value, max = 4095
enum
code_type
:
int32
{
CODE_CUSTOM
=
1
,
// header + id (28 bits)
CODE_COUNTER
,
// header + counter_id (16 bits)
CODE_PHASE
,
// header + phase_id (12 bits)
CODE_VALUE
,
// numeric value, max = 4095
};
const
std
::
unordered_set
<
uint32
>
continuous_event
{
EVENT_ADJUST
,
...
...
@@ -575,6 +581,11 @@ const std::unordered_set<uint32> continuous_event{
EVENT_PRE_BATTLE_DAMAGE
,
EVENT_SPSUMMON_SUCCESS_G_P
,
};
bool
is_continuous_event
(
uint32
code
);
const
std
::
unordered_set
<
uint32
>
affect_summoning_effect
{
EFFECT_CANNOT_DISABLE_SUMMON
,
EFFECT_CANNOT_DISABLE_SPSUMMON
,
EVENT_BE_PRE_MATERIAL
,
};
#endif
/* EFFECT_H_ */
effectset.h
View file @
da075384
...
...
@@ -26,10 +26,6 @@ struct effect_set {
void
remove_item
(
int
index
)
{
if
(
index
<
0
||
index
>=
count
)
return
;
if
(
index
==
count
-
1
)
{
--
count
;
return
;
}
for
(
int
i
=
index
;
i
<
count
-
1
;
++
i
)
container
[
i
]
=
container
[
i
+
1
];
--
count
;
...
...
@@ -86,10 +82,7 @@ struct effect_set_v {
return
(
int
)
container
.
size
();
}
void
sort
()
{
int
count
=
(
int
)
container
.
size
();
if
(
count
<
2
)
return
;
std
::
sort
(
container
.
begin
(),
container
.
begin
()
+
count
,
effect_sort_id
);
std
::
sort
(
container
.
begin
(),
container
.
end
(),
effect_sort_id
);
}
effect
*
const
&
get_last
()
const
{
assert
(
container
.
size
());
...
...
field.cpp
View file @
da075384
...
...
@@ -486,7 +486,21 @@ void field::set_control(card* pcard, uint8 playerid, uint16 reset_phase, uint8 r
pcard
->
current
.
controler
=
playerid
;
}
card
*
field
::
get_field_card
(
uint8
playerid
,
uint32
general_location
,
uint8
sequence
)
{
int32
field
::
get_pzone_sequence
(
uint8
pseq
)
const
{
if
(
core
.
duel_rule
>=
NEW_MASTER_RULE
)
{
if
(
!
pseq
)
return
0
;
else
return
4
;
}
else
{
if
(
!
pseq
)
return
6
;
else
return
7
;
}
}
card
*
field
::
get_field_card
(
uint8
playerid
,
uint32
general_location
,
uint8
sequence
)
const
{
if
(
!
check_playerid
(
playerid
))
return
nullptr
;
switch
(
general_location
)
{
...
...
@@ -512,12 +526,9 @@ card* field::get_field_card(uint8 playerid, uint32 general_location, uint8 seque
break
;
}
case
LOCATION_PZONE
:
{
if
(
sequence
==
0
)
{
card
*
pcard
=
player
[
playerid
].
list_szone
[
core
.
duel_rule
>=
NEW_MASTER_RULE
?
0
:
6
];
return
(
pcard
&&
pcard
->
current
.
pzone
)
?
pcard
:
0
;
}
else
if
(
sequence
==
1
)
{
card
*
pcard
=
player
[
playerid
].
list_szone
[
core
.
duel_rule
>=
NEW_MASTER_RULE
?
4
:
7
];
return
(
pcard
&&
pcard
->
current
.
pzone
)
?
pcard
:
0
;
if
(
sequence
==
0
||
sequence
==
1
)
{
card
*
pcard
=
player
[
playerid
].
list_szone
[
get_pzone_sequence
(
sequence
)];
return
(
pcard
&&
pcard
->
current
.
pzone
)
?
pcard
:
nullptr
;
}
else
return
nullptr
;
break
;
...
...
@@ -567,33 +578,28 @@ int32 field::is_location_useable(uint8 playerid, uint32 general_location, uint8
if
(
general_location
==
LOCATION_MZONE
)
{
if
(
sequence
>=
(
int32
)
player
[
playerid
].
list_mzone
.
size
())
return
FALSE
;
if
(
flag
&
(
0x1
u
<<
sequence
))
if
(
flag
&
(
0x1
U
<<
sequence
))
return
FALSE
;
if
(
sequence
>=
5
)
{
uint32
oppo
=
player
[
1
-
playerid
].
disabled_location
|
player
[
1
-
playerid
].
used_location
;
if
(
oppo
&
(
0x1
u
<<
(
11
-
sequence
)))
if
(
oppo
&
(
0x1
U
<<
(
11
-
sequence
)))
return
FALSE
;
}
}
else
if
(
general_location
==
LOCATION_SZONE
)
{
if
(
sequence
>=
player
[
playerid
].
szone_size
)
return
FALSE
;
if
(
flag
&
(
0x100
u
<<
sequence
))
if
(
flag
&
(
0x100
U
<<
sequence
))
return
FALSE
;
}
else
if
(
general_location
==
LOCATION_FZONE
)
{
if
(
sequence
>=
1
)
return
FALSE
;
if
(
flag
&
(
0x100
u
<<
(
5
+
sequence
)))
if
(
flag
&
(
0x100
U
<<
(
5
+
sequence
)))
return
FALSE
;
}
else
if
(
general_location
==
LOCATION_PZONE
)
{
if
(
sequence
>=
2
)
return
FALSE
;
if
(
core
.
duel_rule
>=
NEW_MASTER_RULE
)
{
if
(
flag
&
(
0x100u
<<
(
sequence
*
4
)))
return
FALSE
;
}
else
{
if
(
flag
&
(
0x100u
<<
(
6
+
sequence
)))
return
FALSE
;
}
if
(
flag
&
(
0x100U
<<
get_pzone_sequence
(
sequence
)))
return
FALSE
;
}
return
TRUE
;
}
...
...
@@ -798,11 +804,11 @@ int32 field::get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason) {
}
uint32
field
::
get_linked_zone
(
int32
playerid
)
{
uint32
zones
=
0
;
for
(
auto
&
pcard
:
player
[
playerid
].
list_mzone
)
{
for
(
const
auto
&
pcard
:
player
[
playerid
].
list_mzone
)
{
if
(
pcard
)
zones
|=
pcard
->
get_linked_zone
()
&
0xff
;
zones
|=
pcard
->
get_linked_zone
()
&
0xff
ff
;
}
for
(
auto
&
pcard
:
player
[
1
-
playerid
].
list_mzone
)
{
for
(
const
auto
&
pcard
:
player
[
1
-
playerid
].
list_mzone
)
{
if
(
pcard
)
zones
|=
pcard
->
get_linked_zone
()
>>
16
;
}
...
...
@@ -866,19 +872,19 @@ int32 field::check_extra_link(int32 playerid) {
if
(
!
player
[
playerid
].
list_mzone
[
5
]
||
!
player
[
playerid
].
list_mzone
[
6
])
return
FALSE
;
card
*
pcard
=
player
[
playerid
].
list_mzone
[
5
];
uint32
checked
=
1u
<<
5
;
uint32
checked
=
0x
1u
<<
5
;
uint32
linked_zone
=
pcard
->
get_mutual_linked_zone
();
while
(
true
)
{
if
((
linked_zone
>>
6
)
&
1
)
if
((
linked_zone
>>
6
)
&
0x1U
)
return
TRUE
;
int32
checking
=
(
int32
)(
linked_zone
&
~
checked
)
;
uint32
checking
=
linked_zone
&
~
checked
;
if
(
!
checking
)
return
FALSE
;
int32
rightmost
=
checking
&
(
-
checking
);
checked
|=
(
uint32
)
rightmost
;
if
(
rightmost
<
0x10000
)
{
u
int32
rightmost
=
checking
&
(
-
checking
);
checked
|=
rightmost
;
if
(
rightmost
<
0x10000
U
)
{
for
(
int32
i
=
0
;
i
<
7
;
++
i
)
{
if
(
rightmost
&
1
)
{
if
(
rightmost
&
0x1U
)
{
pcard
=
player
[
playerid
].
list_mzone
[
i
];
linked_zone
|=
pcard
->
get_mutual_linked_zone
();
break
;
...
...
@@ -888,7 +894,7 @@ int32 field::check_extra_link(int32 playerid) {
}
else
{
rightmost
>>=
16
;
for
(
int32
i
=
0
;
i
<
7
;
++
i
)
{
if
(
rightmost
&
1
)
{
if
(
rightmost
&
0x1U
)
{
pcard
=
player
[
1
-
playerid
].
list_mzone
[
i
];
uint32
zone
=
pcard
->
get_mutual_linked_zone
();
linked_zone
|=
(
zone
<<
16
)
|
(
zone
>>
16
);
...
...
@@ -1161,6 +1167,8 @@ void field::tag_swap(uint8 playerid) {
pduel
->
write_buffer32
(
pcard
->
data
.
code
|
(
pcard
->
is_position
(
POS_FACEUP
)
?
0x80000000
:
0
));
}
void
field
::
add_effect
(
effect
*
peffect
,
uint8
owner_player
)
{
if
(
!
peffect
)
return
;
if
(
effects
.
indexer
.
find
(
peffect
)
!=
effects
.
indexer
.
end
())
return
;
effect_container
::
iterator
it
;
...
...
@@ -1332,7 +1340,7 @@ void field::add_effect_code(uint32 code, uint32 playerid) {
count_map
=
&
core
.
effect_count_code_duel
;
else
if
(
code
&
EFFECT_COUNT_CODE_CHAIN
)
count_map
=
&
core
.
effect_count_code_chain
;
++
(
*
count_map
)[
code
+
(
playerid
<<
30
)]
;
(
*
count_map
)[
code
+
(
playerid
<<
30
)]
++
;
}
uint32
field
::
get_effect_code
(
uint32
code
,
uint32
playerid
)
{
auto
*
count_map
=
&
core
.
effect_count_code
;
...
...
@@ -1502,7 +1510,7 @@ int32 field::filter_matching_card(lua_State* L, int32 findex, uint8 self, uint32
}
if
(
location
&
LOCATION_PZONE
)
{
for
(
int32
i
=
0
;
i
<
2
;
++
i
)
{
card
*
pcard
=
player
[
self
].
list_szone
[
core
.
duel_rule
>=
NEW_MASTER_RULE
?
i
*
4
:
i
+
6
];
card
*
pcard
=
player
[
self
].
list_szone
[
get_pzone_sequence
(
i
)
];
if
(
pcard
&&
pcard
->
current
.
pzone
&&
!
pcard
->
is_treated_as_not_on_field
()
&&
pcard
!=
pexception
&&
!
(
pexgroup
&&
pexgroup
->
has_card
(
pcard
))
&&
pduel
->
lua
->
check_filter
(
L
,
pcard
,
findex
,
extraargs
)
...
...
@@ -1628,7 +1636,7 @@ int32 field::filter_field_card(uint8 self, uint32 location1, uint32 location2, g
}
if
(
location
&
LOCATION_PZONE
)
{
for
(
int32
i
=
0
;
i
<
2
;
++
i
)
{
card
*
pcard
=
player
[
self
].
list_szone
[
core
.
duel_rule
>=
NEW_MASTER_RULE
?
i
*
4
:
i
+
6
];
card
*
pcard
=
player
[
self
].
list_szone
[
get_pzone_sequence
(
i
)
];
if
(
pcard
&&
pcard
->
current
.
pzone
)
{
result
.
insert
(
pcard
);
}
...
...
@@ -1654,7 +1662,7 @@ int32 field::filter_field_card(uint8 self, uint32 location1, uint32 location2, g
}
if
(
pgroup
)
pgroup
->
container
.
insert
(
result
.
begin
(),
result
.
end
());
return
result
.
size
();
return
(
int32
)
result
.
size
();
}
effect
*
field
::
is_player_affected_by_effect
(
uint8
playerid
,
uint32
code
)
{
auto
rg
=
effects
.
aura_effect
.
equal_range
(
code
);
...
...
@@ -1919,11 +1927,11 @@ void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set
}
material_all
->
insert
(
material_base
->
begin
(),
material_base
->
end
());
}
void
field
::
ritual_release
(
c
ard_set
*
material
)
{
void
field
::
ritual_release
(
c
onst
card_set
&
material
)
{
card_set
rel
;
card_set
rem
;
card_set
tgy
;
for
(
auto
&
pcard
:
*
material
)
{
for
(
const
auto
&
pcard
:
material
)
{
if
(
pcard
->
current
.
location
==
LOCATION_GRAVE
)
rem
.
insert
(
pcard
);
else
if
(
pcard
->
current
.
location
==
LOCATION_OVERLAY
||
pcard
->
current
.
location
==
LOCATION_EXTRA
)
...
...
@@ -1931,9 +1939,9 @@ void field::ritual_release(card_set* material) {
else
rel
.
insert
(
pcard
);
}
send_to
(
&
tgy
,
core
.
reason_effect
,
REASON_RITUAL
+
REASON_EFFECT
+
REASON_MATERIAL
,
core
.
reason_player
,
PLAYER_NONE
,
LOCATION_GRAVE
,
0
,
POS_FACEUP
);
release
(
&
rel
,
core
.
reason_effect
,
REASON_RITUAL
+
REASON_EFFECT
+
REASON_MATERIAL
,
core
.
reason_player
);
send_to
(
&
rem
,
core
.
reason_effect
,
REASON_RITUAL
+
REASON_EFFECT
+
REASON_MATERIAL
,
core
.
reason_player
,
PLAYER_NONE
,
LOCATION_REMOVED
,
0
,
POS_FACEUP
);
send_to
(
tgy
,
core
.
reason_effect
,
REASON_RITUAL
+
REASON_EFFECT
+
REASON_MATERIAL
,
core
.
reason_player
,
PLAYER_NONE
,
LOCATION_GRAVE
,
0
,
POS_FACEUP
);
release
(
rel
,
core
.
reason_effect
,
REASON_RITUAL
+
REASON_EFFECT
+
REASON_MATERIAL
,
core
.
reason_player
);
send_to
(
rem
,
core
.
reason_effect
,
REASON_RITUAL
+
REASON_EFFECT
+
REASON_MATERIAL
,
core
.
reason_player
,
PLAYER_NONE
,
LOCATION_REMOVED
,
0
,
POS_FACEUP
);
}
void
field
::
get_xyz_material
(
lua_State
*
L
,
card
*
scard
,
int32
findex
,
uint32
lv
,
int32
maxc
,
group
*
mg
)
{
core
.
xmaterial_lst
.
clear
();
...
...
@@ -2116,6 +2124,8 @@ int32 field::adjust_grant_effect() {
effect
*
geffect
=
(
effect
*
)
peffect
->
get_label_object
();
if
(
geffect
->
type
&
EFFECT_TYPE_GRANT
)
continue
;
if
(
geffect
->
code
==
EFFECT_UNIQUE_CHECK
)
continue
;
card_set
cset
;
if
(
peffect
->
is_available
())
filter_affected_cards
(
peffect
,
&
cset
);
...
...
@@ -2130,9 +2140,6 @@ int32 field::adjust_grant_effect() {
if
(
!
pcard
->
is_affect_by_effect
(
peffect
)
||
!
cset
.
count
(
pcard
))
remove_set
.
insert
(
pcard
);
}
//X gains an effect from itself will break card::remove_effect
if
(
!
peffect
->
is_flag
(
EFFECT_FLAG_FIELD_ONLY
))
add_set
.
erase
(
peffect
->
handler
);
for
(
auto
&
pcard
:
add_set
)
{
effect
*
ceffect
=
geffect
->
clone
();
ceffect
->
owner
=
pcard
;
...
...
field.h
View file @
da075384
...
...
@@ -16,8 +16,6 @@
#include <set>
#include <map>
#include <list>
#include <array>
#include <functional>
#include <unordered_map>
#include <unordered_set>
...
...
@@ -128,10 +126,10 @@ struct field_effect {
};
struct
field_info
{
int32
field_id
{
1
};
int16
copy_id
{
1
};
int16
turn_id
{};
int16
turn_id_by_player
[
2
]{};
int16
card_id
{
1
};
u
int16
copy_id
{
1
};
u
int16
turn_id
{};
u
int16
turn_id_by_player
[
2
]{};
u
int16
card_id
{
1
};
uint16
phase
{};
uint8
turn_player
{};
uint8
priorities
[
2
]{};
...
...
@@ -390,7 +388,9 @@ public:
void
swap_card
(
card
*
pcard1
,
card
*
pcard2
,
uint8
new_sequence1
,
uint8
new_sequence2
);
void
swap_card
(
card
*
pcard1
,
card
*
pcard2
);
void
set_control
(
card
*
pcard
,
uint8
playerid
,
uint16
reset_phase
,
uint8
reset_count
);
card
*
get_field_card
(
uint8
playerid
,
uint32
general_location
,
uint8
sequence
);
int32
get_pzone_sequence
(
uint8
pseq
)
const
;
card
*
get_field_card
(
uint8
playerid
,
uint32
general_location
,
uint8
sequence
)
const
;
int32
is_location_useable
(
uint8
playerid
,
uint32
general_location
,
uint8
sequence
)
const
;
int32
get_useable_count
(
card
*
pcard
,
uint8
playerid
,
uint8
location
,
uint8
uplayer
,
uint32
reason
,
uint32
zone
=
0xff
,
uint32
*
list
=
nullptr
);
int32
get_useable_count_fromex
(
card
*
pcard
,
uint8
playerid
,
uint8
uplayer
,
uint32
zone
=
0xff
,
uint32
*
list
=
nullptr
);
...
...
@@ -441,7 +441,7 @@ public:
int32
get_draw_count
(
uint8
playerid
);
void
get_ritual_material
(
uint8
playerid
,
effect
*
peffect
,
card_set
*
material
,
uint8
no_level
=
FALSE
);
void
get_fusion_material
(
uint8
playerid
,
card_set
*
material_all
,
card_set
*
material_base
,
uint32
location
);
void
ritual_release
(
c
ard_set
*
material
);
void
ritual_release
(
c
onst
card_set
&
material
);
void
get_xyz_material
(
lua_State
*
L
,
card
*
scard
,
int32
findex
,
uint32
lv
,
int32
maxc
,
group
*
mg
);
void
get_overlay_group
(
uint8
self
,
uint8
s
,
uint8
o
,
card_set
*
pset
);
int32
get_overlay_count
(
uint8
self
,
uint8
s
,
uint8
o
);
...
...
@@ -527,7 +527,7 @@ public:
int32
execute_operation
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
int32
execute_target
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
void
raise_event
(
card
*
event_card
,
uint32
event_code
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
event_player
,
uint32
event_value
);
void
raise_event
(
c
ard_set
*
event_cards
,
uint32
event_code
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
event_player
,
uint32
event_value
);
void
raise_event
(
c
onst
card_set
&
event_cards
,
uint32
event_code
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
event_player
,
uint32
event_value
);
void
raise_single_event
(
card
*
trigger_card
,
card_set
*
event_cards
,
uint32
event_code
,
effect
*
reason_effect
,
uint32
reason
,
uint8
reason_player
,
uint8
event_player
,
uint32
event_value
);
int32
check_event
(
uint32
code
,
tevent
*
pe
=
nullptr
);
int32
check_event_c
(
effect
*
peffect
,
uint8
playerid
,
int32
neglect_con
,
int32
neglect_cost
,
int32
copy_info
,
tevent
*
pe
=
nullptr
);
...
...
@@ -564,9 +564,9 @@ public:
void
change_target_param
(
uint8
chaincount
,
int32
param
);
void
remove_counter
(
uint32
reason
,
card
*
pcard
,
uint32
rplayer
,
uint32
s
,
uint32
o
,
uint32
countertype
,
uint32
count
);
void
remove_overlay_card
(
uint32
reason
,
card
*
pcard
,
uint32
rplayer
,
uint32
s
,
uint32
o
,
uint16
min
,
uint16
max
);
void
get_control
(
c
ard_set
*
targets
,
effect
*
reason_effect
,
uint32
reason_player
,
uint32
playerid
,
uint32
reset_phase
,
uint32
reset_count
,
uint32
zone
);
void
get_control
(
c
onst
card_set
&
targets
,
effect
*
reason_effect
,
uint32
reason_player
,
uint32
playerid
,
uint32
reset_phase
,
uint32
reset_count
,
uint32
zone
);
void
get_control
(
card
*
target
,
effect
*
reason_effect
,
uint32
reason_player
,
uint32
playerid
,
uint32
reset_phase
,
uint32
reset_count
,
uint32
zone
);
void
swap_control
(
effect
*
reason_effect
,
uint32
reason_player
,
c
ard_set
*
targets1
,
card_set
*
targets2
,
uint32
reset_phase
,
uint32
reset_count
);
void
swap_control
(
effect
*
reason_effect
,
uint32
reason_player
,
c
onst
card_set
&
targets1
,
const
card_set
&
targets2
,
uint32
reset_phase
,
uint32
reset_count
);
void
swap_control
(
effect
*
reason_effect
,
uint32
reason_player
,
card
*
pcard1
,
card
*
pcard2
,
uint32
reset_phase
,
uint32
reset_count
);
void
equip
(
uint32
equip_player
,
card
*
equip_card
,
card
*
target
,
uint32
up
,
uint32
is_step
);
void
draw
(
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
int32
count
);
...
...
@@ -575,17 +575,17 @@ public:
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
,
uint32
action_type
=
SUMMON_IN_IDLE
);
void
special_summon_rule
(
uint32
sumplayer
,
card
*
target
,
uint32
summon_type
,
uint32
action_type
=
SUMMON_IN_IDLE
);
void
special_summon
(
c
ard_set
*
target
,
uint32
sumtype
,
uint32
sumplayer
,
uint32
playerid
,
uint32
nocheck
,
uint32
nolimit
,
uint32
positions
,
uint32
zone
);
void
special_summon
(
c
onst
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_complete
(
effect
*
reason_effect
,
uint8
reason_player
);
void
destroy
(
card_set
*
targets
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
=
2
,
uint32
destination
=
0
,
uint32
sequence
=
0
);
void
destroy
(
card_set
&
targets
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
=
2
,
uint32
destination
=
0
,
uint32
sequence
=
0
);
void
destroy
(
card
*
target
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
=
2
,
uint32
destination
=
0
,
uint32
sequence
=
0
);
void
release
(
c
ard_set
*
targets
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
);
void
release
(
c
onst
card_set
&
targets
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
);
void
release
(
card
*
target
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
);
void
send_to
(
c
ard_set
*
targets
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
uint32
destination
,
uint32
sequence
,
uint32
position
,
uint8
send_activating
=
FALSE
);
void
send_to
(
c
onst
card_set
&
targets
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
uint32
destination
,
uint32
sequence
,
uint32
position
,
uint8
send_activating
=
FALSE
);
void
send_to
(
card
*
target
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
uint32
destination
,
uint32
sequence
,
uint32
position
,
uint8
send_activating
=
FALSE
);
void
move_to_field
(
card
*
target
,
uint32
move_player
,
uint32
playerid
,
uint32
destination
,
uint32
positions
,
uint32
enable
=
FALSE
,
uint32
ret
=
0
,
uint32
pzone
=
FALSE
,
uint32
zone
=
0xff
);
void
change_position
(
c
ard_set
*
targets
,
effect
*
reason_effect
,
uint32
reason_player
,
uint32
au
,
uint32
ad
,
uint32
du
,
uint32
dd
,
uint32
flag
,
uint32
enable
=
FALSE
);
void
change_position
(
c
onst
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
);
void
select_tribute_cards
(
card
*
target
,
uint8
playerid
,
uint8
cancelable
,
int32
min
,
int32
max
,
uint8
toplayer
,
uint32
zone
);
...
...
@@ -629,7 +629,7 @@ public:
int32
toss_dice
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
uint8
playerid
,
uint8
count1
,
uint8
count2
);
int32
rock_paper_scissors
(
uint16
step
,
uint8
repeat
);
bool
check_response
(
int32
vector_size
,
int32
min_len
,
int32
max_len
)
const
;
bool
check_response
(
size_t
vector_size
,
int32
min_len
,
int32
max_len
)
const
;
int32
select_battle_command
(
uint16
step
,
uint8
playerid
);
int32
select_idle_command
(
uint16
step
,
uint8
playerid
);
int32
select_effect_yes_no
(
uint16
step
,
uint8
playerid
,
uint32
description
,
card
*
pcard
);
...
...
libcard.cpp
View file @
da075384
...
...
@@ -393,10 +393,14 @@ int32 scriptlib::card_get_current_scale(lua_State *L) {
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
pcard
->
current
.
pzone
&&
pcard
->
current
.
sequence
==
(
pcard
->
pduel
->
game_field
->
core
.
duel_rule
>=
NEW_MASTER_RULE
?
0
:
6
))
lua_pushinteger
(
L
,
pcard
->
get_lscale
());
if
(
pcard
->
current
.
pzone
)
{
if
(
pcard
->
current
.
sequence
==
pcard
->
pduel
->
game_field
->
get_pzone_sequence
(
0
))
lua_pushinteger
(
L
,
pcard
->
get_lscale
());
else
lua_pushinteger
(
L
,
pcard
->
get_rscale
());
}
else
lua_pushinteger
(
L
,
pcard
->
get_rscale
()
);
lua_pushinteger
(
L
,
pcard
->
data
.
lscale
);
return
1
;
}
int32
scriptlib
::
card_is_link_marker
(
lua_State
*
L
)
{
...
...
@@ -1345,6 +1349,24 @@ int32 scriptlib::card_is_tuner(lua_State* L) {
lua_pushboolean
(
L
,
pcard
->
is_tuner
(
scard
));
return
1
;
}
int32
scriptlib
::
card_is_original_effect_property
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_FUNCTION
,
2
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
int32
filter
=
interpreter
::
get_function_handle
(
L
,
2
);
lua_pushboolean
(
L
,
pcard
->
is_original_effect_property
(
filter
));
return
1
;
}
int32
scriptlib
::
card_is_effect_property
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_FUNCTION
,
2
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
int32
filter
=
interpreter
::
get_function_handle
(
L
,
2
);
lua_pushboolean
(
L
,
pcard
->
is_effect_property
(
filter
));
return
1
;
}
int32
scriptlib
::
card_set_status
(
lua_State
*
L
)
{
check_param_count
(
L
,
3
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
...
...
@@ -1871,10 +1893,10 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
int32
reset
=
(
int32
)
lua_tointeger
(
L
,
3
);
uint32
flag
=
(
uint32
)
lua_tointeger
(
L
,
4
);
int32
count
=
(
int32
)
lua_tointeger
(
L
,
5
);
int32
lab
=
0
;
lua_Integer
lab
=
0
;
int32
desc
=
0
;
if
(
lua_gettop
(
L
)
>=
6
)
lab
=
(
int32
)
lua_tointeger
(
L
,
6
);
lab
=
lua_tointeger
(
L
,
6
);
if
(
lua_gettop
(
L
)
>=
7
)
desc
=
(
int32
)
lua_tointeger
(
L
,
7
);
if
(
count
==
0
)
...
...
@@ -1918,7 +1940,7 @@ int32 scriptlib::card_set_flag_effect_label(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
uint32
code
=
(
lua_tointeger
(
L
,
2
)
&
MAX_CARD_ID
)
|
EFFECT_FLAG_EFFECT
;
int32
lab
=
(
int32
)
lua_tointeger
(
L
,
3
);
auto
lab
=
lua_tointeger
(
L
,
3
);
auto
eit
=
pcard
->
single_effect
.
find
(
code
);
if
(
eit
==
pcard
->
single_effect
.
end
())
lua_pushboolean
(
L
,
FALSE
);
...
...
@@ -3515,6 +3537,8 @@ static const struct luaL_Reg cardlib[] = {
{
"IsStatus"
,
scriptlib
::
card_is_status
},
{
"IsNotTuner"
,
scriptlib
::
card_is_not_tuner
},
{
"IsTuner"
,
scriptlib
::
card_is_tuner
},
{
"IsOriginalEffectProperty"
,
scriptlib
::
card_is_original_effect_property
},
{
"IsEffectProperty"
,
scriptlib
::
card_is_effect_property
},
{
"SetStatus"
,
scriptlib
::
card_set_status
},
{
"IsDualState"
,
scriptlib
::
card_is_dual_state
},
{
"EnableDualState"
,
scriptlib
::
card_enable_dual_state
},
...
...
libdebug.cpp
View file @
da075384
...
...
@@ -43,7 +43,7 @@ int32 scriptlib::debug_add_card(lua_State *L) {
position
=
POS_FACEDOWN_DEFENSE
;
pcard
->
sendto_param
.
position
=
position
;
if
(
location
==
LOCATION_PZONE
)
{
int32
seq
=
pduel
->
game_field
->
core
.
duel_rule
>=
NEW_MASTER_RULE
?
sequence
*
4
:
sequence
+
6
;
int32
seq
=
pduel
->
game_field
->
get_pzone_sequence
(
sequence
)
;
pduel
->
game_field
->
add_card
(
playerid
,
pcard
,
LOCATION_SZONE
,
seq
,
TRUE
);
}
else
{
pduel
->
game_field
->
add_card
(
playerid
,
pcard
,
location
,
sequence
);
...
...
libduel.cpp
View file @
da075384
This diff is collapsed.
Click to expand it.
libeffect.cpp
View file @
da075384
...
...
@@ -12,6 +12,61 @@
#include "effect.h"
#include "group.h"
int32
scriptlib
::
get_effect_property
(
lua_State
*
L
,
effect_member
type
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
lua_Integer
value
{};
if
(
peffect
)
{
switch
(
type
)
{
case
MEMBER_CATEGORY
:
value
=
peffect
->
category
;
break
;
case
MEMBER_CODE
:
value
=
peffect
->
code
;
break
;
case
MEMBER_DESCRIPTION
:
value
=
peffect
->
description
;
break
;
case
MEMBER_ID
:
value
=
peffect
->
id
;
break
;
case
MEMBER_RANGE
:
value
=
peffect
->
range
;
break
;
case
MEMBER_TYPE
:
value
=
peffect
->
type
;
break
;
}
}
lua_pushinteger
(
L
,
value
);
return
1
;
}
int32
scriptlib
::
is_effect_has_property
(
lua_State
*
L
,
effect_member
type
)
{
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
uint64
value
{};
if
(
peffect
)
{
switch
(
type
)
{
case
MEMBER_CATEGORY
:
value
=
peffect
->
category
;
break
;
case
MEMBER_RANGE
:
value
=
peffect
->
range
;
break
;
case
MEMBER_TYPE
:
value
=
peffect
->
type
;
break
;
}
}
uint64
x
=
lua_tointeger
(
L
,
2
);
if
(
value
&
x
)
lua_pushboolean
(
L
,
1
);
else
lua_pushboolean
(
L
,
0
);
return
1
;
}
int32
scriptlib
::
effect_new
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
...
...
@@ -52,11 +107,7 @@ int32 scriptlib::effect_reset(lua_State *L) {
return
0
;
}
int32
scriptlib
::
effect_get_field_id
(
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
->
id
);
return
1
;
return
get_effect_property
(
L
,
MEMBER_ID
);
}
int32
scriptlib
::
effect_set_description
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
...
...
@@ -147,19 +198,27 @@ int32 scriptlib::effect_set_type(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
uint32
v
=
(
uint32
)
lua_tointeger
(
L
,
2
);
if
(
v
&
EFFECT_TYPE_ACTIVATE
)
{
v
=
EFFECT_TYPE_FIELD
|
EFFECT_TYPE_ACTIVATE
;
peffect
->
range
=
LOCATION_SZONE
+
LOCATION_FZONE
+
LOCATION_HAND
;
}
else
if
(
v
&
EFFECT_TYPE_FLIP
)
{
peffect
->
code
=
EVENT_FLIP
;
if
(
v
&
EFFECT_TYPE_TRIGGER_O
)
{
v
=
EFFECT_TYPE_SINGLE
|
EFFECT_TYPE_FLIP
|
EFFECT_TYPE_TRIGGER_O
;
peffect
->
flag
[
0
]
|=
EFFECT_FLAG_DELAY
;
}
else
{
v
=
EFFECT_TYPE_SINGLE
|
EFFECT_TYPE_FLIP
|
EFFECT_TYPE_TRIGGER_F
;
}
}
else
if
(
v
&
(
EFFECT_TYPE_IGNITION
|
EFFECT_TYPE_QUICK_O
|
EFFECT_TYPE_QUICK_F
))
{
v
|=
EFFECT_TYPE_FIELD
;
}
if
(
v
&
(
EFFECT_TYPES_CHAIN_LINK
|
EFFECT_TYPE_CONTINUOUS
))
v
|=
EFFECT_TYPE_ACTIONS
;
else
v
&=
~
EFFECT_TYPE_ACTIONS
;
if
(
v
&
(
EFFECT_TYPE_ACTIVATE
|
EFFECT_TYPE_IGNITION
|
EFFECT_TYPE_QUICK_O
|
EFFECT_TYPE_QUICK_F
))
v
|=
EFFECT_TYPE_FIELD
;
if
(
v
&
EFFECT_TYPE_ACTIVATE
)
peffect
->
range
=
LOCATION_SZONE
+
LOCATION_FZONE
+
LOCATION_HAND
;
if
(
v
&
EFFECT_TYPE_FLIP
)
{
peffect
->
code
=
EVENT_FLIP
;
if
(
!
(
v
&
EFFECT_TYPE_TRIGGER_O
))
v
|=
EFFECT_TYPE_TRIGGER_F
;
}
peffect
->
type
=
v
;
return
0
;
}
...
...
@@ -179,8 +238,7 @@ int32 scriptlib::effect_set_label(lua_State *L) {
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
peffect
->
label
.
clear
();
for
(
int32
i
=
2
;
i
<=
lua_gettop
(
L
);
++
i
)
{
uint32
v
=
(
uint32
)
lua_tointeger
(
L
,
i
);
peffect
->
label
.
push_back
(
v
);
peffect
->
label
.
push_back
(
lua_tointeger
(
L
,
i
));
}
return
0
;
}
...
...
@@ -303,34 +361,13 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) {
return
0
;
}
int32
scriptlib
::
effect_get_description
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
if
(
peffect
)
{
lua_pushinteger
(
L
,
peffect
->
description
);
return
1
;
}
return
0
;
return
get_effect_property
(
L
,
MEMBER_DESCRIPTION
);
}
int32
scriptlib
::
effect_get_code
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
if
(
peffect
)
{
lua_pushinteger
(
L
,
peffect
->
code
);
return
1
;
}
return
0
;
return
get_effect_property
(
L
,
MEMBER_CODE
);
}
int32
scriptlib
::
effect_get_type
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
if
(
peffect
)
{
lua_pushinteger
(
L
,
peffect
->
type
);
return
1
;
}
return
0
;
return
get_effect_property
(
L
,
MEMBER_TYPE
);
}
int32
scriptlib
::
effect_get_property
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
...
...
@@ -376,14 +413,10 @@ int32 scriptlib::effect_get_label_object(lua_State *L) {
}
}
int32
scriptlib
::
effect_get_category
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
if
(
peffect
)
{
lua_pushinteger
(
L
,
peffect
->
category
);
return
1
;
}
return
0
;
return
get_effect_property
(
L
,
MEMBER_CATEGORY
);
}
int32
scriptlib
::
effect_get_range
(
lua_State
*
L
)
{
return
get_effect_property
(
L
,
MEMBER_RANGE
);
}
int32
scriptlib
::
effect_get_owner
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
...
...
@@ -473,8 +506,8 @@ int32 scriptlib::effect_is_has_property(lua_State *L) {
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
uint
32
tflag1
=
(
uint32
)
lua_tointeger
(
L
,
2
);
uint
32
tflag2
=
(
uint32
)
lua_tointeger
(
L
,
3
);
uint
64
tflag1
=
lua_tointeger
(
L
,
2
);
uint
64
tflag2
=
lua_tointeger
(
L
,
3
);
if
(
peffect
&&
(
!
tflag1
||
(
peffect
->
flag
[
0
]
&
tflag1
))
&&
(
!
tflag2
||
(
peffect
->
flag
[
1
]
&
tflag2
)))
lua_pushboolean
(
L
,
1
);
else
...
...
@@ -482,26 +515,13 @@ int32 scriptlib::effect_is_has_property(lua_State *L) {
return
1
;
}
int32
scriptlib
::
effect_is_has_category
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
uint32
tcate
=
(
uint32
)
lua_tointeger
(
L
,
2
);
if
(
peffect
&&
(
peffect
->
category
&
tcate
))
lua_pushboolean
(
L
,
1
);
else
lua_pushboolean
(
L
,
0
);
return
1
;
return
is_effect_has_property
(
L
,
MEMBER_CATEGORY
);
}
int32
scriptlib
::
effect_is_has_type
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
uint32
ttype
=
(
uint32
)
lua_tointeger
(
L
,
2
);
if
(
peffect
&&
(
peffect
->
type
&
ttype
))
lua_pushboolean
(
L
,
1
);
else
lua_pushboolean
(
L
,
0
);
return
1
;
return
is_effect_has_property
(
L
,
MEMBER_TYPE
);
}
int32
scriptlib
::
effect_is_has_range
(
lua_State
*
L
)
{
return
is_effect_has_property
(
L
,
MEMBER_RANGE
);
}
int32
scriptlib
::
effect_is_activatable
(
lua_State
*
L
)
{
check_param_count
(
L
,
2
);
...
...
@@ -615,6 +635,7 @@ static const struct luaL_Reg effectlib[] = {
{
"GetLabel"
,
scriptlib
::
effect_get_label
},
{
"GetLabelObject"
,
scriptlib
::
effect_get_label_object
},
{
"GetCategory"
,
scriptlib
::
effect_get_category
},
{
"GetRange"
,
scriptlib
::
effect_get_range
},
{
"GetOwner"
,
scriptlib
::
effect_get_owner
},
{
"GetHandler"
,
scriptlib
::
effect_get_handler
},
{
"GetCondition"
,
scriptlib
::
effect_get_condition
},
...
...
@@ -629,6 +650,7 @@ static const struct luaL_Reg effectlib[] = {
{
"IsHasProperty"
,
scriptlib
::
effect_is_has_property
},
{
"IsHasCategory"
,
scriptlib
::
effect_is_has_category
},
{
"IsHasType"
,
scriptlib
::
effect_is_has_type
},
{
"IsHasRange"
,
scriptlib
::
effect_is_has_range
},
{
"IsActivatable"
,
scriptlib
::
effect_is_activatable
},
{
"IsActivated"
,
scriptlib
::
effect_is_activated
},
{
"IsCostChecked"
,
scriptlib
::
effect_is_cost_checked
},
...
...
operations.cpp
View file @
da075384
This diff is collapsed.
Click to expand it.
playerop.cpp
View file @
da075384
...
...
@@ -14,14 +14,14 @@
#include <algorithm>
#include <stack>
bool
field
::
check_response
(
int32
vector_size
,
int32
min_len
,
int32
max_len
)
const
{
bool
field
::
check_response
(
size_t
vector_size
,
int32
min_len
,
int32
max_len
)
const
{
const
int32
len
=
returns
.
bvalue
[
0
];
if
(
len
<
min_len
||
len
>
max_len
)
return
false
;
std
::
set
<
uint8
>
index_set
;
for
(
int32
i
=
0
;
i
<
len
;
++
i
)
{
uint8
index
=
returns
.
bvalue
[
1
+
i
];
if
(
index
>=
vector_size
||
index_set
.
count
(
index
))
{
if
(
index
>=
(
int32
)
vector_size
||
index_set
.
count
(
index
))
{
return
false
;
}
index_set
.
insert
(
index
);
...
...
@@ -787,7 +787,7 @@ int32 field::sort_card(int16 step, uint8 playerid) {
int32
field
::
announce_race
(
int16
step
,
uint8
playerid
,
int32
count
,
int32
available
)
{
if
(
step
==
0
)
{
int32
scount
=
0
;
for
(
int32
ft
=
0x1
;
ft
<
(
1
<<
RACES_COUNT
);
ft
<<=
1
)
{
for
(
uint32
ft
=
0x1
;
ft
<
(
0x1U
<<
RACES_COUNT
);
ft
<<=
1
)
{
if
(
ft
&
available
)
++
scount
;
}
...
...
@@ -803,8 +803,9 @@ int32 field::announce_race(int16 step, uint8 playerid, int32 count, int32 availa
}
else
{
int32
rc
=
returns
.
ivalue
[
0
];
int32
sel
=
0
;
for
(
int32
ft
=
0x1
;
ft
<
(
1
<<
RACES_COUNT
);
ft
<<=
1
)
{
if
(
!
(
ft
&
rc
))
continue
;
for
(
uint32
ft
=
0x1
;
ft
<
(
0x1U
<<
RACES_COUNT
);
ft
<<=
1
)
{
if
(
!
(
ft
&
rc
))
continue
;
if
(
!
(
ft
&
available
))
{
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
...
...
premake/dll.lua
View file @
da075384
...
...
@@ -37,7 +37,7 @@ workspace "ocgcoredll"
filter
{
"configurations:Release"
,
"action:vs*"
}
flags
{
"LinkTimeOptimization"
}
staticruntime
"On"
disablewarnings
{
"4
267"
,
"4
334"
}
disablewarnings
{
"4334"
}
filter
"action:vs*"
buildoptions
{
"/utf-8"
}
...
...
processor.cpp
View file @
da075384
This diff is collapsed.
Click to expand it.
scriptlib.h
View file @
da075384
...
...
@@ -17,6 +17,14 @@ constexpr bool match_all(uint32 x, uint32 y) {
class
scriptlib
{
public:
enum
effect_member
:
int32
{
MEMBER_CATEGORY
,
MEMBER_CODE
,
MEMBER_DESCRIPTION
,
MEMBER_ID
,
MEMBER_RANGE
,
MEMBER_TYPE
,
};
static
int32
check_param
(
lua_State
*
L
,
int32
param_type
,
int32
index
,
int32
retfalse
=
FALSE
);
static
int32
check_param_count
(
lua_State
*
L
,
int32
count
);
static
int32
check_action_permission
(
lua_State
*
L
);
...
...
@@ -143,6 +151,8 @@ public:
static
int32
card_is_status
(
lua_State
*
L
);
static
int32
card_is_not_tuner
(
lua_State
*
L
);
static
int32
card_is_tuner
(
lua_State
*
L
);
static
int32
card_is_original_effect_property
(
lua_State
*
L
);
static
int32
card_is_effect_property
(
lua_State
*
L
);
static
int32
card_set_status
(
lua_State
*
L
);
static
int32
card_is_dual_state
(
lua_State
*
L
);
static
int32
card_enable_dual_state
(
lua_State
*
L
);
...
...
@@ -299,6 +309,8 @@ public:
static
void
open_cardlib
(
lua_State
*
L
);
//Effect functions
static
int32
get_effect_property
(
lua_State
*
L
,
effect_member
type
);
static
int32
is_effect_has_property
(
lua_State
*
L
,
effect_member
type
);
static
int32
effect_new
(
lua_State
*
L
);
static
int32
effect_newex
(
lua_State
*
L
);
static
int32
effect_clone
(
lua_State
*
L
);
...
...
@@ -330,6 +342,7 @@ public:
static
int32
effect_get_label
(
lua_State
*
L
);
static
int32
effect_get_label_object
(
lua_State
*
L
);
static
int32
effect_get_category
(
lua_State
*
L
);
static
int32
effect_get_range
(
lua_State
*
L
);
static
int32
effect_get_owner
(
lua_State
*
L
);
static
int32
effect_get_handler
(
lua_State
*
L
);
static
int32
effect_get_owner_player
(
lua_State
*
L
);
...
...
@@ -343,6 +356,7 @@ public:
static
int32
effect_is_active_type
(
lua_State
*
L
);
static
int32
effect_is_has_property
(
lua_State
*
L
);
static
int32
effect_is_has_category
(
lua_State
*
L
);
static
int32
effect_is_has_range
(
lua_State
*
L
);
static
int32
effect_is_has_type
(
lua_State
*
L
);
static
int32
effect_is_activatable
(
lua_State
*
L
);
static
int32
effect_is_activated
(
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