Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
MobiusMei
ygopro
Commits
8e1826a8
Commit
8e1826a8
authored
Nov 24, 2018
by
VanillaSalt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add search operator " and -
parent
dc47725f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
54 deletions
+86
-54
gframe/deck_con.cpp
gframe/deck_con.cpp
+86
-54
No files found.
gframe/deck_con.cpp
View file @
8e1826a8
...
...
@@ -775,42 +775,78 @@ void DeckBuilder::StartFilter() {
}
void
DeckBuilder
::
FilterCards
()
{
results
.
clear
();
struct
element_t
{
std
::
wstring
keyword
;
int
setcode
;
enum
class
type_t
{
all
,
name
,
setcode
}
type
;
bool
exclude
;
element_t
()
:
setcode
(
0
),
type
(
type_t
::
all
),
exclude
(
false
)
{}
};
const
wchar_t
*
pstr
=
mainGame
->
ebCardName
->
getText
();
std
::
wstring
str
=
std
::
wstring
(
pstr
);
std
::
vector
<
std
::
wstring
>
query_elements
;
std
::
vector
<
std
::
vector
<
std
::
wstring
>::
iterator
>
query_elements_track
;
size_t
element_start
=
0
;
while
(
mainGame
->
gameConf
.
search_multiple_keywords
)
{
size_t
element_end
=
str
.
find_first_of
(
mainGame
->
gameConf
.
search_multiple_keywords
==
1
?
L' '
:
L'+'
,
element_start
);
if
(
element_end
==
std
::
wstring
::
npos
)
break
;
size_t
length
=
element_end
-
element_start
;
if
(
length
>
0
)
{
query_elements
.
push_back
(
str
.
substr
(
element_start
,
length
));
std
::
vector
<
element_t
>
query_elements
;
if
(
mainGame
->
gameConf
.
search_multiple_keywords
)
{
const
wchar_t
separator
=
mainGame
->
gameConf
.
search_multiple_keywords
==
1
?
L' '
:
L'+'
;
const
wchar_t
minussign
=
L'-'
;
const
wchar_t
quotation
=
L'\"'
;
size_t
element_start
=
0
;
for
(;;)
{
element_start
=
str
.
find_first_not_of
(
separator
,
element_start
);
if
(
element_start
==
std
::
wstring
::
npos
)
break
;
element_t
element
;
if
(
str
[
element_start
]
==
minussign
)
{
element
.
exclude
=
true
;
element_start
++
;
}
if
(
element_start
>=
str
.
size
())
break
;
if
(
str
[
element_start
]
==
L'$'
)
{
element
.
type
=
element_t
::
type_t
::
name
;
element_start
++
;
}
else
if
(
str
[
element_start
]
==
L'@'
)
{
element
.
type
=
element_t
::
type_t
::
setcode
;
element_start
++
;
}
if
(
element_start
>=
str
.
size
())
break
;
wchar_t
delimiter
=
separator
;
if
(
str
[
element_start
]
==
quotation
)
{
delimiter
=
quotation
;
element_start
++
;
}
size_t
element_end
=
str
.
find_first_of
(
delimiter
,
element_start
);
if
(
element_end
!=
std
::
wstring
::
npos
)
{
size_t
length
=
element_end
-
element_start
;
element
.
keyword
=
str
.
substr
(
element_start
,
length
);
}
else
element
.
keyword
=
str
.
substr
(
element_start
);
element
.
setcode
=
dataManager
.
GetSetCode
(
element
.
keyword
.
c_str
());
query_elements
.
push_back
(
element
);
if
(
element_end
==
std
::
wstring
::
npos
)
break
;
element_start
=
element_end
+
1
;
}
else
}
}
else
{
element_t
element
;
size_t
element_start
=
0
;
if
(
str
[
element_start
]
==
L'$'
)
{
element
.
type
=
element_t
::
type_t
::
name
;
element_start
++
;
}
else
if
(
str
[
element_start
]
==
L'@'
)
{
element
.
type
=
element_t
::
type_t
::
setcode
;
element_start
++
;
}
if
(
element_start
<
str
.
size
())
{
element
.
setcode
=
dataManager
.
GetSetCode
(
element
.
keyword
.
c_str
());
element
.
keyword
=
str
.
substr
(
element_start
);
query_elements
.
push_back
(
element
);
}
}
query_elements
.
push_back
(
str
.
substr
(
element_start
));
std
::
unordered_map
<
std
::
wstring
,
unsigned
int
>
set_code_map
;
for
(
auto
elements_iterator
=
query_elements
.
begin
();
elements_iterator
!=
query_elements
.
end
();
elements_iterator
++
)
{
const
wchar_t
*
element_pointer
=
elements_iterator
->
c_str
();
if
(
element_pointer
[
0
]
==
L'@'
)
set_code_map
[
*
elements_iterator
]
=
dataManager
.
GetSetCode
(
&
element_pointer
[
1
]);
else
set_code_map
[
*
elements_iterator
]
=
dataManager
.
GetSetCode
(
&
element_pointer
[
0
]);
if
(
element_pointer
[
0
]
==
0
||
(
element_pointer
[
0
]
==
L'$'
&&
element_pointer
[
1
]
==
0
)
||
(
element_pointer
[
0
]
==
L'@'
&&
element_pointer
[
1
]
==
0
))
query_elements_track
.
push_back
(
elements_iterator
);
}
for
(
auto
elements_track_iterator
=
query_elements_track
.
begin
();
elements_track_iterator
!=
query_elements_track
.
end
();
elements_track_iterator
++
)
query_elements
.
erase
(
*
elements_track_iterator
);
unsigned
int
set_code
=
0
;
if
(
pstr
[
0
]
==
L'@'
)
set_code
=
dataManager
.
GetSetCode
(
&
pstr
[
1
]);
else
set_code
=
dataManager
.
GetSetCode
(
&
pstr
[
0
]);
if
(
pstr
[
0
]
==
0
||
(
pstr
[
0
]
==
L'$'
&&
pstr
[
1
]
==
0
)
||
(
pstr
[
0
]
==
L'@'
&&
pstr
[
1
]
==
0
))
pstr
=
0
;
auto
strpointer
=
dataManager
.
_strings
.
begin
();
for
(
code_pointer
ptr
=
dataManager
.
_datas
.
begin
();
ptr
!=
dataManager
.
_datas
.
end
();
++
ptr
,
++
strpointer
)
{
const
CardDataC
&
data
=
ptr
->
second
;
...
...
@@ -885,33 +921,29 @@ void DeckBuilder::FilterCards() {
continue
;
}
bool
is_target
=
true
;
for
(
auto
elements_iterator
=
query_elements
.
begin
();
elements_iterator
!=
query_elements
.
end
();
elements_iterator
++
)
{
const
wchar_t
*
element_pointer
=
elements_iterator
->
c_str
();
if
(
element_pointer
[
0
]
==
L'$'
)
{
if
(
!
CardNameContains
(
text
.
name
.
c_str
(),
&
element_pointer
[
1
])){
is_target
=
false
;
break
;
}
}
else
if
(
element_pointer
[
0
]
==
L'@'
&&
set_code_map
[
*
elements_iterator
])
{
if
(
!
check_set_code
(
data
,
set_code_map
[
*
elements_iterator
]))
{
is_target
=
false
;
break
;
}
for
(
auto
elements_iterator
=
query_elements
.
begin
();
elements_iterator
!=
query_elements
.
end
();
++
elements_iterator
)
{
bool
match
=
false
;
if
(
elements_iterator
->
type
==
element_t
::
type_t
::
name
)
{
match
=
CardNameContains
(
text
.
name
.
c_str
(),
elements_iterator
->
keyword
.
c_str
());
}
else
if
(
elements_iterator
->
type
==
element_t
::
type_t
::
setcode
)
{
match
=
elements_iterator
->
setcode
&&
check_set_code
(
data
,
elements_iterator
->
setcode
);
}
else
{
int
trycode
=
BufferIO
::
GetVal
(
elements_iterator
->
c_str
());
int
trycode
=
BufferIO
::
GetVal
(
elements_iterator
->
keyword
.
c_str
());
bool
tryresult
=
dataManager
.
GetData
(
trycode
,
0
);
if
(
!
tryresult
&&
!
CardNameContains
(
text
.
name
.
c_str
(),
elements_iterator
->
c_str
())
&&
text
.
text
.
find
(
elements_iterator
->
c_str
())
==
std
::
wstring
::
npos
&&
(
!
set_code_map
[
*
elements_iterator
]
||
!
check_set_code
(
data
,
set_code_map
[
*
elements_iterator
])))
{
is_target
=
false
;
break
;
}
if
(
tryresult
&&
data
.
code
!=
trycode
&&
!
(
data
.
alias
==
trycode
&&
(
data
.
alias
-
data
.
code
<
CARD_ARTWORK_VERSIONS_OFFSET
||
data
.
code
-
data
.
alias
<
CARD_ARTWORK_VERSIONS_OFFSET
)))
{
is_target
=
false
;
break
;
if
(
!
tryresult
)
{
match
=
CardNameContains
(
text
.
name
.
c_str
(),
elements_iterator
->
keyword
.
c_str
())
||
text
.
text
.
find
(
elements_iterator
->
keyword
)
!=
std
::
wstring
::
npos
||
(
elements_iterator
->
setcode
&&
check_set_code
(
data
,
elements_iterator
->
setcode
));
}
else
{
match
=
data
.
code
==
trycode
||
data
.
alias
==
trycode
;
}
}
if
(
elements_iterator
->
exclude
)
match
=
!
match
;
if
(
!
match
)
{
is_target
=
false
;
break
;
}
}
if
(
is_target
)
results
.
push_back
(
ptr
);
...
...
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