Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
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
fallenstardust
YGOMobile
Commits
699bccdb
Commit
699bccdb
authored
Sep 03, 2021
by
qq247321453
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
81e1ba03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
111 deletions
+90
-111
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
.../src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
+8
-52
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
+82
-59
No files found.
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
View file @
699bccdb
...
@@ -17,13 +17,13 @@ import cn.garymb.ygomobile.Constants;
...
@@ -17,13 +17,13 @@ import cn.garymb.ygomobile.Constants;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.CardSort
;
import
ocgcore.CardManager
;
import
ocgcore.CardManager
;
import
ocgcore.DataManager
;
import
ocgcore.DataManager
;
import
ocgcore.LimitManager
;
import
ocgcore.LimitManager
;
import
ocgcore.StringManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
import
ocgcore.enums.CardType
;
import
ocgcore.enums.LimitType
;
import
ocgcore.enums.LimitType
;
public
class
CardLoader
implements
ICardSearcher
{
public
class
CardLoader
implements
ICardSearcher
{
...
@@ -125,34 +125,13 @@ public class CardLoader implements ICardSearcher {
...
@@ -125,34 +125,13 @@ public class CardLoader implements ICardSearcher {
}
}
Dialog
wait
=
DialogPlus
.
show
(
context
,
null
,
context
.
getString
(
R
.
string
.
searching
));
Dialog
wait
=
DialogPlus
.
show
(
context
,
null
,
context
.
getString
(
R
.
string
.
searching
));
VUiKit
.
defer
().
when
(()
->
{
VUiKit
.
defer
().
when
(()
->
{
List
<
Card
>
tmp
=
new
ArrayList
<
Card
>();
List
<
Card
>
monster
=
new
ArrayList
<
Card
>();
List
<
Card
>
spell
=
new
ArrayList
<
Card
>();
List
<
Card
>
trap
=
new
ArrayList
<
Card
>();
SparseArray
<
Card
>
cards
=
mCardManager
.
getAllCards
();
SparseArray
<
Card
>
cards
=
mCardManager
.
getAllCards
();
int
count
=
cards
.
size
();
List
<
Card
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
cards
.
size
();
i
++)
{
Card
card
=
cards
.
valueAt
(
i
);
list
.
add
(
cards
.
valueAt
(
i
));
if
(
searchInfo
==
null
||
searchInfo
.
check
(
card
))
{
if
(
searchInfo
!=
null
&&
card
.
Name
.
equalsIgnoreCase
(
searchInfo
.
keyWord1
))
{
tmp
.
add
(
card
);
}
else
if
(
card
.
isType
(
CardType
.
Monster
))
{
monster
.
add
(
card
);
}
else
if
(
card
.
isType
(
CardType
.
Spell
))
{
spell
.
add
(
card
);
}
else
if
(
card
.
isType
(
CardType
.
Trap
))
{
trap
.
add
(
card
);
}
}
}
}
Collections
.
sort
(
tmp
,
ASCode
);
Collections
.
sort
(
list
,
CardSort
.
ASC
);
Collections
.
sort
(
monster
,
ASC
);
return
list
;
Collections
.
sort
(
spell
,
ASCode
);
Collections
.
sort
(
trap
,
ASCode
);
tmp
.
addAll
(
monster
);
tmp
.
addAll
(
spell
);
tmp
.
addAll
(
trap
);
return
tmp
;
}).
fail
((
e
)
->
{
}).
fail
((
e
)
->
{
if
(
mCallBack
!=
null
)
{
if
(
mCallBack
!=
null
)
{
ArrayList
<
Card
>
noting
=
new
ArrayList
<
Card
>();
ArrayList
<
Card
>
noting
=
new
ArrayList
<
Card
>();
...
@@ -170,31 +149,8 @@ public class CardLoader implements ICardSearcher {
...
@@ -170,31 +149,8 @@ public class CardLoader implements ICardSearcher {
@Override
@Override
public
List
<
Card
>
sort
(
List
<
Card
>
cards
){
public
List
<
Card
>
sort
(
List
<
Card
>
cards
){
List
<
Card
>
tmp
=
new
ArrayList
<
Card
>();
Collections
.
sort
(
cards
,
CardSort
.
ASC
);
List
<
Card
>
monster
=
new
ArrayList
<
Card
>();
return
cards
;
List
<
Card
>
spell
=
new
ArrayList
<
Card
>();
List
<
Card
>
trap
=
new
ArrayList
<
Card
>();
int
count
=
cards
.
size
();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Card
card
=
cards
.
get
(
i
);
if
(
card
.
isType
(
CardType
.
Monster
))
{
monster
.
add
(
card
);
}
else
if
(
card
.
isType
(
CardType
.
Spell
))
{
spell
.
add
(
card
);
}
else
if
(
card
.
isType
(
CardType
.
Trap
))
{
trap
.
add
(
card
);
}
else
{
tmp
.
add
(
card
);
}
}
Collections
.
sort
(
tmp
,
ASCode
);
Collections
.
sort
(
monster
,
ASC
);
Collections
.
sort
(
spell
,
ASCode
);
Collections
.
sort
(
trap
,
ASCode
);
tmp
.
addAll
(
monster
);
tmp
.
addAll
(
spell
);
tmp
.
addAll
(
trap
);
return
tmp
;
}
}
private
static
final
Comparator
<
Card
>
ASCode
=
(
o1
,
o2
)
->
o1
.
Code
-
o2
.
Code
;
private
static
final
Comparator
<
Card
>
ASCode
=
(
o1
,
o2
)
->
o1
.
Code
-
o2
.
Code
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
View file @
699bccdb
...
@@ -13,9 +13,7 @@ public class CardSort implements Comparator<Card> {
...
@@ -13,9 +13,7 @@ public class CardSort implements Comparator<Card> {
}
}
private
int
comp
(
long
l1
,
long
l2
)
{
private
int
comp
(
long
l1
,
long
l2
)
{
if
(
l1
==
l2
)
return
0
;
return
Long
.
compare
(
l1
,
l2
);
if
(
l1
>
l2
)
return
1
;
return
-
1
;
}
}
@Override
@Override
...
@@ -31,8 +29,7 @@ public class CardSort implements Comparator<Card> {
...
@@ -31,8 +29,7 @@ public class CardSort implements Comparator<Card> {
if
(
c2
.
isType
(
CardType
.
Monster
))
{
if
(
c2
.
isType
(
CardType
.
Monster
))
{
//怪兽在前面
//怪兽在前面
return
-
1
;
return
-
1
;
}
}
else
if
(
c2
.
isType
(
CardType
.
Trap
))
{
if
(
c2
.
isType
(
CardType
.
Trap
))
{
//陷阱在前面
//陷阱在前面
return
1
;
return
1
;
}
}
...
@@ -59,73 +56,99 @@ public class CardSort implements Comparator<Card> {
...
@@ -59,73 +56,99 @@ public class CardSort implements Comparator<Card> {
}
}
}
else
if
(
c1
.
isType
(
CardType
.
Monster
))
{
}
else
if
(
c1
.
isType
(
CardType
.
Monster
))
{
//魔法陷阱在后面
//魔法陷阱在后面
if
(
c2
.
isType
(
CardType
.
Spell
))
{
if
(
c2
.
isType
(
CardType
.
Spell
)
||
c2
.
isType
(
CardType
.
Trap
)
)
{
//怪兽在前面
//怪兽在前面
return
1
;
return
1
;
}
}
if
(
c2
.
isType
(
CardType
.
Trap
))
{
if
(
isSameType
(
c1
,
c2
,
CardType
.
Fusion
)
//陷阱在前面
||
isSameType
(
c1
,
c2
,
CardType
.
Synchro
)
return
2
;
||
isSameType
(
c1
,
c2
,
CardType
.
Xyz
)
}
||
isSameType
(
c1
,
c2
,
CardType
.
Link
)
||
(!
isSpecialType
(
c1
)
&&
!
isSpecialType
(
c2
)))
{
//超量,同调,融合
int
rs
=
comp
(
c1
.
getStar
(),
c2
.
getStar
());
//1,2,3
if
(
rs
!=
0
)
{
if
(
c1
.
isType
(
CardType
.
Xyz
))
{
return
rs
;
if
(
c2
.
isType
(
CardType
.
Synchro
))
{
return
-
1
;
}
}
if
(
c2
.
isType
(
CardType
.
Fusion
))
{
rs
=
comp
(
c1
.
Attack
,
c2
.
Attack
);
return
-
2
;
if
(
rs
!=
0
)
{
}
if
(
c2
.
isType
(
CardType
.
Link
))
{
return
rs
;
return
1
;
}
}
}
else
if
(
c1
.
isType
(
CardType
.
Synchro
))
{
rs
=
comp
(
c1
.
Defense
,
c2
.
Defense
);
if
(
c2
.
isType
(
CardType
.
Xyz
)
)
{
if
(
rs
!=
0
)
{
return
1
;
return
rs
;
}
}
if
(
c2
.
isType
(
CardType
.
Fusion
))
{
return
-
1
;
rs
=
comp
(
c1
.
Attribute
,
c2
.
Attribute
);
if
(
rs
!=
0
)
{
return
rs
;
}
}
if
(
c2
.
isType
(
CardType
.
Link
))
{
rs
=
comp
(
c1
.
Race
,
c2
.
Race
);
return
2
;
if
(
rs
!=
0
)
{
return
rs
;
}
}
}
else
if
(
c1
.
isType
(
CardType
.
Fusion
))
{
rs
=
comp
(
c1
.
Ot
,
c2
.
Ot
);
if
(
c2
.
isType
(
CardType
.
Xyz
)
)
{
if
(
rs
!=
0
)
{
return
2
;
return
rs
;
}
}
if
(
c2
.
isType
(
CardType
.
Synchro
))
{
}
return
1
;
else
{
//超量,同调,融合
//Fusion,Synchro,Xyz,Link
//1 ,2 ,3 ,4
if
(
c1
.
isType
(
CardType
.
Xyz
))
{
if
(
c2
.
isType
(
CardType
.
Synchro
))
{
return
-
1
;
}
else
if
(
c2
.
isType
(
CardType
.
Fusion
))
{
return
-
2
;
}
else
if
(
c2
.
isType
(
CardType
.
Link
))
{
return
1
;
}
else
{
return
2
;
}
}
}
if
(
c2
.
isType
(
CardType
.
Link
))
{
else
if
(
c1
.
isType
(
CardType
.
Synchro
))
{
return
3
;
if
(
c2
.
isType
(
CardType
.
Fusion
))
{
return
-
1
;
}
else
if
(
c2
.
isType
(
CardType
.
Xyz
))
{
return
1
;
}
else
if
(
c2
.
isType
(
CardType
.
Link
))
{
return
2
;
}
else
{
return
3
;
}
}
else
if
(
c1
.
isType
(
CardType
.
Fusion
))
{
if
(
c2
.
isType
(
CardType
.
Synchro
))
{
return
1
;
}
else
if
(
c2
.
isType
(
CardType
.
Xyz
))
{
return
2
;
}
else
if
(
c2
.
isType
(
CardType
.
Link
))
{
return
3
;
}
else
{
return
4
;
}
}
else
if
(
c1
.
isType
(
CardType
.
Link
))
{
if
(
c2
.
isType
(
CardType
.
Xyz
))
{
return
-
3
;
}
else
if
(
c2
.
isType
(
CardType
.
Synchro
))
{
return
-
2
;
}
else
if
(
c2
.
isType
(
CardType
.
Fusion
))
{
return
-
1
;
}
else
{
return
1
;
}
}
}
}
int
rs
=
comp
(
c1
.
getStar
(),
c2
.
getStar
());
if
(
rs
!=
0
)
{
return
rs
;
}
rs
=
comp
(
c1
.
Attack
,
c2
.
Attack
);
if
(
rs
!=
0
)
{
return
rs
;
}
rs
=
comp
(
c1
.
Defense
,
c2
.
Defense
);
if
(
rs
!=
0
)
{
return
rs
;
}
rs
=
comp
(
c1
.
Attribute
,
c2
.
Attribute
);
if
(
rs
!=
0
)
{
return
rs
;
}
rs
=
comp
(
c1
.
Race
,
c2
.
Race
);
if
(
rs
!=
0
)
{
return
rs
;
}
rs
=
comp
(
c1
.
Ot
,
c2
.
Ot
);
if
(
rs
!=
0
)
{
return
rs
;
}
}
}
}
return
comp
(
c1
.
Code
,
c2
.
Code
);
return
comp
(
c1
.
Code
,
c2
.
Code
);
}
}
private
boolean
isSameType
(
Card
c1
,
Card
c2
,
CardType
type
){
return
c1
.
isType
(
type
)
&&
c2
.
isType
(
type
);
}
private
boolean
isSpecialType
(
Card
c1
)
{
return
c1
.
isType
(
CardType
.
Fusion
)
||
c1
.
isType
(
CardType
.
Synchro
)
||
c1
.
isType
(
CardType
.
Xyz
)
||
c1
.
isType
(
CardType
.
Link
);
}
}
}
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