Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro-core
Commits
323b138d
Commit
323b138d
authored
Jan 11, 2024
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Fluorohydride/ygopro-core
parents
cfe8df33
13b28cd3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
76 deletions
+73
-76
card.cpp
card.cpp
+42
-26
card.h
card.h
+11
-5
libcard.cpp
libcard.cpp
+17
-35
operations.cpp
operations.cpp
+3
-10
No files found.
card.cpp
View file @
323b138d
...
...
@@ -14,6 +14,14 @@
#include "ocgapi.h"
#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
}
};
bool
card_sort
::
operator
()(
void
*
const
&
p1
,
void
*
const
&
p2
)
const
{
card
*
c1
=
(
card
*
)
p1
;
card
*
c2
=
(
card
*
)
p2
;
...
...
@@ -411,55 +419,60 @@ uint32 card::get_info_location() {
return
c
+
(
l
<<
8
)
+
(
s
<<
16
)
+
(
ss
<<
24
);
}
}
// mapping of double-name cards
uint32
card
::
second_code
(
uint32
code
){
switch
(
code
){
case
CARD_MARINE_DOLPHIN
:
return
17955766u
;
case
CARD_TWINKLE_MOSS
:
return
17732278u
;
default:
return
0
;
// get the printed code on card
uint32
card
::
get_original_code
()
const
{
if
(
data
.
alias
&&
(
data
.
alias
<
data
.
code
+
CARD_ARTWORK_VERSIONS_OFFSET
)
&&
(
data
.
code
<
data
.
alias
+
CARD_ARTWORK_VERSIONS_OFFSET
))
return
data
.
alias
;
else
return
data
.
code
;
}
// get the original code in duel (can be different from printed code)
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
// for double-name card, it returns printed name
// for double-name card
s
, it returns printed name
uint32
card
::
get_code
()
{
if
(
assume_type
==
ASSUME_CODE
)
return
assume_value
;
if
(
temp
.
code
!=
0xffffffff
)
return
temp
.
code
;
effect_set
effects
;
uint32
code
=
data
.
code
;
temp
.
code
=
data
.
code
;
uint32
code
=
std
::
get
<
0
>
(
get_original_code_rule
())
;
temp
.
code
=
code
;
filter_effect
(
EFFECT_CHANGE_CODE
,
&
effects
);
if
(
effects
.
size
())
code
=
effects
.
get_last
()
->
get_value
(
this
);
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: the current second card name
// for double-name cards, it returns the name in description
uint32
card
::
get_another_code
()
{
uint32
code
=
get_code
();
if
(
code
!=
data
.
code
){
return
second_code
(
code
);
uint32
code1
=
get_code
();
if
(
is_affected_by_effect
(
EFFECT_CHANGE_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
;
filter_effect
(
EFFECT_ADD_CODE
,
&
eset
);
if
(
!
eset
.
size
())
return
0
;
return
code2
;
uint32
otcode
=
eset
.
get_last
()
->
get_value
(
this
);
if
(
code
!=
otcode
)
if
(
code
1
!=
otcode
)
return
otcode
;
return
0
;
}
...
...
@@ -2578,6 +2591,7 @@ void card::set_special_summon_status(effect* peffect) {
spsummon
.
defense
=
0
;
spsummon
.
setcode
.
clear
();
spsummon
.
reason_effect
=
nullptr
;
spsummon
.
reason_player
=
PLAYER_NONE
;
return
;
}
card
*
pcard
=
peffect
->
get_handler
();
...
...
@@ -2600,6 +2614,7 @@ void card::set_special_summon_status(effect* peffect) {
spsummon
.
setcode
.
push_back
((
uint32
)
eset
[
i
]
->
get_value
(
pcard
));
}
spsummon
.
reason_effect
=
peffect
;
spsummon
.
reason_player
=
peffect
->
get_handler_player
();
}
else
{
pcard
=
cait
->
triggering_effect
->
get_handler
();
spsummon
.
code
=
cait
->
triggering_state
.
code
;
...
...
@@ -2618,6 +2633,7 @@ void card::set_special_summon_status(effect* peffect) {
spsummon
.
setcode
.
push_back
((
uint32
)
eset
[
i
]
->
get_value
(
pcard
));
}
spsummon
.
reason_effect
=
cait
->
triggering_effect
;
spsummon
.
reason_player
=
cait
->
triggering_player
;
}
}
void
card
::
filter_effect
(
int32
code
,
effect_set
*
eset
,
uint8
sort
)
{
...
...
card.h
View file @
323b138d
...
...
@@ -99,6 +99,12 @@ struct material_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
{
public:
struct
effect_relation_hash
{
...
...
@@ -137,6 +143,8 @@ public:
uint8
location
{
0
};
uint8
sequence
{
0
};
};
static
const
std
::
unordered_map
<
uint32
,
uint32
>
second_code
;
int32
ref_handle
;
duel
*
pduel
;
card_data
data
;
...
...
@@ -206,7 +214,8 @@ public:
int32
get_infos
(
byte
*
buf
,
uint32
query_flag
,
int32
use_cache
=
TRUE
);
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_another_code
();
int32
is_set_card
(
uint32
set_code
);
...
...
@@ -417,10 +426,7 @@ public:
#define SUMMON_INFO_ATTACK 0x80
#define SUMMON_INFO_DEFENSE 0x100
#define SUMMON_INFO_REASON_EFFECT 0x200
//double-name cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define SUMMON_INFO_REASON_PLAYER 0x400
#define CARD_ARTWORK_VERSIONS_OFFSET 10
...
...
libcard.cpp
View file @
323b138d
...
...
@@ -24,40 +24,29 @@ int32 scriptlib::card_get_code(lua_State *L) {
}
return
1
;
}
// GetOriginalCode(): get the original code printed on card
// return: 1 int
int32
scriptlib
::
card_get_origin_code
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
if
(
pcard
->
data
.
alias
)
{
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
);
lua_pushinteger
(
L
,
pcard
->
get_original_code
());
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
)
{
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
effect_set
eset
;
pcard
->
filter_effect
(
EFFECT_ADD_CODE
,
&
eset
);
if
(
pcard
->
data
.
alias
&&
!
eset
.
size
())
lua_pushinteger
(
L
,
pcard
->
data
.
alias
);
auto
codes
=
pcard
->
get_original_code_rule
();
uint32
code1
=
std
::
get
<
0
>
(
codes
);
uint32
code2
=
std
::
get
<
1
>
(
codes
);
if
(
code2
)
{
lua_pushinteger
(
L
,
code1
);
lua_pushinteger
(
L
,
code2
);
return
2
;
}
else
{
lua_pushinteger
(
L
,
pcard
->
data
.
code
);
if
(
eset
.
size
())
{
uint32
otcode
=
eset
.
get_last
()
->
get_value
(
pcard
);
lua_pushinteger
(
L
,
otcode
);
return
2
;
}
lua_pushinteger
(
L
,
code1
);
return
1
;
}
return
1
;
}
int32
scriptlib
::
card_get_fusion_code
(
lua_State
*
L
)
{
check_param_count
(
L
,
1
);
...
...
@@ -921,6 +910,9 @@ int32 scriptlib::card_get_special_summon_info(lua_State *L) {
case
SUMMON_INFO_REASON_EFFECT
:
interpreter
::
effect2value
(
L
,
pcard
->
spsummon
.
reason_effect
);
break
;
case
SUMMON_INFO_REASON_PLAYER
:
lua_pushinteger
(
L
,
pcard
->
spsummon
.
reason_player
);
break
;
default:
lua_pushnil
(
L
);
break
;
...
...
@@ -967,19 +959,9 @@ int32 scriptlib::card_is_origin_code_rule(lua_State *L) {
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
uint32
code1
=
0
;
uint32
code2
=
0
;
effect_set
eset
;
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
);
}
auto
codes
=
pcard
->
get_original_code_rule
();
uint32
code1
=
std
::
get
<
0
>
(
codes
);
uint32
code2
=
std
::
get
<
1
>
(
codes
);
uint32
count
=
lua_gettop
(
L
)
-
1
;
uint32
result
=
FALSE
;
for
(
uint32
i
=
0
;
i
<
count
;
++
i
)
{
...
...
operations.cpp
View file @
323b138d
...
...
@@ -3931,16 +3931,9 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard
->
previous
.
defense
=
atk_def
.
second
;
}
}
else
{
effect_set
eset
;
pcard
->
filter_effect
(
EFFECT_ADD_CODE
,
&
eset
);
if
(
pcard
->
data
.
alias
&&
!
eset
.
size
())
pcard
->
previous
.
code
=
pcard
->
data
.
alias
;
else
pcard
->
previous
.
code
=
pcard
->
data
.
code
;
if
(
eset
.
size
())
pcard
->
previous
.
code2
=
eset
.
get_last
()
->
get_value
(
pcard
);
else
pcard
->
previous
.
code2
=
0
;
auto
codes
=
pcard
->
get_original_code_rule
();
pcard
->
previous
.
code
=
std
::
get
<
0
>
(
codes
);
pcard
->
previous
.
code2
=
std
::
get
<
1
>
(
codes
);
pcard
->
previous
.
type
=
pcard
->
data
.
type
;
pcard
->
previous
.
level
=
pcard
->
data
.
level
;
pcard
->
previous
.
rank
=
pcard
->
data
.
level
;
...
...
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