Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-core
Commits
76e26b16
You need to sign in or sign up before continuing.
Commit
76e26b16
authored
Nov 29, 2015
by
VanillaSalt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
counter
parent
ca04a9a0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
19 deletions
+55
-19
card.cpp
card.cpp
+38
-14
card.h
card.h
+1
-1
libcard.cpp
libcard.cpp
+1
-1
libdebug.cpp
libdebug.cpp
+15
-3
No files found.
card.cpp
View file @
76e26b16
...
...
@@ -166,7 +166,7 @@ uint32 card::get_infos(byte* buf, int32 query_flag, int32 use_cache) {
if
(
query_flag
&
QUERY_COUNTERS
)
{
*
p
++
=
counters
.
size
();
for
(
auto
cmit
=
counters
.
begin
();
cmit
!=
counters
.
end
();
++
cmit
)
*
p
++
=
cmit
->
first
+
(
cmit
->
second
<<
16
);
*
p
++
=
cmit
->
first
+
(
(
cmit
->
second
[
0
]
+
cmit
->
second
[
1
])
<<
16
);
}
if
(
query_flag
&
QUERY_OWNER
)
*
p
++
=
owner
;
...
...
@@ -1155,7 +1155,7 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) {
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer8
(
cmit
->
second
);
pduel
->
write_buffer8
(
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]
);
counters
.
erase
(
cmit
);
}
}
...
...
@@ -1249,14 +1249,16 @@ void card::reset(uint32 id, uint32 reset_type) {
if
(
id
&
RESET_DISABLE
)
{
for
(
auto
cmit
=
counters
.
begin
();
cmit
!=
counters
.
end
();)
{
auto
rm
=
cmit
++
;
if
(
rm
->
first
&
COUNTER_NEED_ENABLE
)
{
if
(
rm
->
second
[
1
]
>
0
)
{
pduel
->
write_buffer8
(
MSG_REMOVE_COUNTER
);
pduel
->
write_buffer16
(
rm
->
first
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer8
(
rm
->
second
);
counters
.
erase
(
rm
);
pduel
->
write_buffer8
(
rm
->
second
[
1
]);
rm
->
second
[
1
]
=
0
;
if
(
rm
->
second
[
0
]
==
0
)
counters
.
erase
(
rm
);
}
}
}
...
...
@@ -1397,9 +1399,21 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
int32
card
::
add_counter
(
uint8
playerid
,
uint16
countertype
,
uint16
count
)
{
if
(
!
is_can_add_counter
(
playerid
,
countertype
,
count
))
return
FALSE
;
counters
[
countertype
]
+=
count
;
uint16
cttype
=
countertype
;
if
((
countertype
&
COUNTER_NEED_ENABLE
)
&&
!
(
countertype
&
COUNTER_NEED_PERMIT
))
cttype
&=
0xfff
;
auto
pr
=
counters
.
insert
(
std
::
make_pair
(
cttype
,
counter_map
::
mapped_type
()));
auto
cmit
=
pr
.
first
;
if
(
pr
.
second
)
{
cmit
->
second
[
0
]
=
0
;
cmit
->
second
[
1
]
=
0
;
}
if
(
!
(
countertype
&
COUNTER_NEED_ENABLE
))
cmit
->
second
[
0
]
+=
count
;
else
cmit
->
second
[
1
]
+=
count
;
pduel
->
write_buffer8
(
MSG_ADD_COUNTER
);
pduel
->
write_buffer16
(
c
ounter
type
);
pduel
->
write_buffer16
(
c
t
type
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
sequence
);
...
...
@@ -1410,9 +1424,16 @@ int32 card::remove_counter(uint16 countertype, uint16 count) {
auto
cmit
=
counters
.
find
(
countertype
);
if
(
cmit
==
counters
.
end
())
return
FALSE
;
if
(
cmit
->
second
<=
count
)
counters
.
erase
(
cmit
);
else
cmit
->
second
-=
count
;
if
(
cmit
->
second
[
1
]
<=
count
)
{
uint16
remains
=
count
;
remains
-=
cmit
->
second
[
1
];
cmit
->
second
[
1
]
=
0
;
if
(
cmit
->
second
[
0
]
<=
remains
)
counters
.
erase
(
cmit
);
else
cmit
->
second
[
0
]
-=
remains
;
}
else
{
cmit
->
second
[
1
]
-=
count
;
}
pduel
->
write_buffer8
(
MSG_REMOVE_COUNTER
);
pduel
->
write_buffer16
(
countertype
);
pduel
->
write_buffer8
(
current
.
controler
);
...
...
@@ -1431,12 +1452,15 @@ int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count)
return
FALSE
;
if
((
countertype
&
COUNTER_NEED_PERMIT
)
&&
!
is_affected_by_effect
(
EFFECT_COUNTER_PERMIT
+
(
countertype
&
0xffff
)))
return
FALSE
;
uint16
cttype
=
countertype
;
if
((
countertype
&
COUNTER_NEED_ENABLE
)
&&
!
(
countertype
&
COUNTER_NEED_PERMIT
))
cttype
&=
0xfff
;
int32
limit
=
-
1
;
int32
cur
=
0
;
auto
cmit
=
counters
.
find
(
c
ounter
type
);
auto
cmit
=
counters
.
find
(
c
t
type
);
if
(
cmit
!=
counters
.
end
())
cur
=
cmit
->
second
;
filter_effect
(
EFFECT_COUNTER_LIMIT
+
c
ounter
type
,
&
eset
);
cur
=
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]
;
filter_effect
(
EFFECT_COUNTER_LIMIT
+
c
t
type
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
limit
=
eset
[
i
]
->
get_value
();
if
(
limit
>
0
&&
(
cur
+
count
>
limit
))
...
...
@@ -1447,7 +1471,7 @@ int32 card::get_counter(uint16 countertype) {
auto
cmit
=
counters
.
find
(
countertype
);
if
(
cmit
==
counters
.
end
())
return
0
;
return
cmit
->
second
;
return
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]
;
}
void
card
::
set_material
(
card_set
*
materials
)
{
if
(
!
materials
)
{
...
...
card.h
View file @
76e26b16
...
...
@@ -84,7 +84,7 @@ public:
typedef
std
::
unordered_map
<
effect
*
,
effect_container
::
iterator
>
effect_indexer
;
typedef
std
::
unordered_map
<
effect
*
,
uint32
>
effect_relation
;
typedef
std
::
unordered_map
<
card
*
,
uint32
>
relation_map
;
typedef
std
::
map
<
uint16
,
uint16
>
counter_map
;
typedef
std
::
map
<
uint16
,
std
::
array
<
uint16
,
2
>
>
counter_map
;
typedef
std
::
unordered_map
<
uint16
,
card
*>
attacker_map
;
int32
scrtype
;
int32
ref_handle
;
...
...
libcard.cpp
View file @
76e26b16
...
...
@@ -1771,7 +1771,7 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
controler
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
pcard
->
pduel
->
write_buffer8
(
cmit
->
second
);
pcard
->
pduel
->
write_buffer8
(
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]
);
}
pcard
->
counters
.
clear
();
return
0
;
...
...
libdebug.cpp
View file @
76e26b16
...
...
@@ -109,9 +109,21 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
uint32
ctype
=
lua_tointeger
(
L
,
2
);
uint32
ccount
=
lua_tointeger
(
L
,
3
);
pcard
->
counters
[
ctype
]
+=
ccount
;
uint32
countertype
=
lua_tointeger
(
L
,
2
);
uint32
count
=
lua_tointeger
(
L
,
3
);
uint16
cttype
=
countertype
;
if
((
countertype
&
COUNTER_NEED_ENABLE
)
&&
!
(
countertype
&
COUNTER_NEED_PERMIT
))
cttype
&=
0xfff
;
auto
pr
=
pcard
->
counters
.
insert
(
std
::
make_pair
(
cttype
,
card
::
counter_map
::
mapped_type
()));
auto
cmit
=
pr
.
first
;
if
(
pr
.
second
)
{
cmit
->
second
[
0
]
=
0
;
cmit
->
second
[
1
]
=
0
;
}
if
(
!
(
countertype
&
COUNTER_NEED_ENABLE
))
cmit
->
second
[
0
]
+=
count
;
else
cmit
->
second
[
1
]
+=
count
;
return
0
;
}
int32
scriptlib
::
debug_reload_field_begin
(
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