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
b3802551
Commit
b3802551
authored
Sep 03, 2021
by
qq247321453
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
卡片排序
parent
81e1ba03
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
130 deletions
+100
-130
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
+3
-7
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
.../src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
+8
-49
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckAdapater.java
.../java/cn/garymb/ygomobile/ui/cards/deck/DeckAdapater.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
+84
-73
mobile/src/main/java/ocgcore/data/Card.java
mobile/src/main/java/ocgcore/data/Card.java
+4
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
View file @
b3802551
...
@@ -255,10 +255,6 @@ public class DeckInfo {
...
@@ -255,10 +255,6 @@ public class DeckInfo {
}
}
}
}
private
boolean
comp
(
Card
c1
,
Card
c2
)
{
return
CardSort
.
ASC
.
compare
(
c1
,
c2
)
<
0
;
}
public
void
sortAll
()
{
public
void
sortAll
()
{
sortMain
();
sortMain
();
sortExtra
();
sortExtra
();
...
@@ -281,9 +277,9 @@ public class DeckInfo {
...
@@ -281,9 +277,9 @@ public class DeckInfo {
int
len
=
cards
.
size
();
int
len
=
cards
.
size
();
for
(
int
i
=
0
;
i
<
len
-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
-
1
;
i
++)
{
for
(
int
j
=
0
;
j
<
len
-
1
-
i
;
j
++)
{
for
(
int
j
=
0
;
j
<
len
-
1
-
i
;
j
++)
{
Card
d
1
=
cards
.
get
(
j
);
Card
c
1
=
cards
.
get
(
j
);
Card
d
2
=
cards
.
get
(
j
+
1
);
Card
c
2
=
cards
.
get
(
j
+
1
);
if
(
comp
(
d1
,
d2
)
)
{
if
(
CardSort
.
FULL_ASC
.
compare
(
c1
,
c2
)
>
0
)
{
Collections
.
swap
(
cards
,
j
,
j
+
1
);
Collections
.
swap
(
cards
,
j
,
j
+
1
);
}
}
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
View file @
b3802551
...
@@ -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,16 @@ public class CardLoader implements ICardSearcher {
...
@@ -125,34 +125,16 @@ 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
<
c
ount
;
i
++)
{
for
(
int
i
=
0
;
i
<
c
ards
.
size
()
;
i
++)
{
Card
card
=
cards
.
valueAt
(
i
);
Card
card
=
cards
.
valueAt
(
i
);
if
(
searchInfo
==
null
||
searchInfo
.
check
(
card
))
{
if
(
searchInfo
==
null
||
searchInfo
.
check
(
card
))
{
if
(
searchInfo
!=
null
&&
card
.
Name
.
equalsIgnoreCase
(
searchInfo
.
keyWord1
))
{
list
.
add
(
card
);
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 +152,8 @@ public class CardLoader implements ICardSearcher {
...
@@ -170,31 +152,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/ui/cards/deck/DeckAdapater.java
View file @
b3802551
...
@@ -162,7 +162,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
...
@@ -162,7 +162,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
if
(
d1
.
getType
()
==
d2
.
getType
())
{
if
(
d1
.
getType
()
==
d2
.
getType
())
{
Card
c1
=
d1
.
getCardInfo
();
Card
c1
=
d1
.
getCardInfo
();
Card
c2
=
d2
.
getCardInfo
();
Card
c2
=
d2
.
getCardInfo
();
return
CardSort
.
ASC
.
compare
(
c1
,
c2
)
<
0
;
return
CardSort
.
FULL_ASC
.
compare
(
c1
,
c2
)
>
0
;
}
}
return
(
d1
.
getType
().
ordinal
()
-
d2
.
getType
().
ordinal
())
>
0
;
return
(
d1
.
getType
().
ordinal
()
-
d2
.
getType
().
ordinal
())
>
0
;
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
View file @
b3802551
...
@@ -7,15 +7,50 @@ import ocgcore.enums.CardType;
...
@@ -7,15 +7,50 @@ import ocgcore.enums.CardType;
public
class
CardSort
implements
Comparator
<
Card
>
{
public
class
CardSort
implements
Comparator
<
Card
>
{
public
static
final
CardSort
ASC
=
new
CardSort
();
public
static
final
CardSort
ASC
=
new
CardSort
(
false
);
public
static
final
CardSort
FULL_ASC
=
new
CardSort
(
true
);
public
CardSort
()
{
private
final
boolean
full
;
private
CardSort
(
boolean
full
)
{
this
.
full
=
full
;
}
}
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
;
private
static
final
int
SORT_OTHER
=
999
;
private
static
final
int
SORT_MONSTER
=
1
;
private
static
final
int
SORT_LINK
=
2
;
private
static
final
int
SORT_SPELL
=
3
;
private
static
final
int
SORT_TRAP
=
4
;
private
static
final
int
SORT_FUSION
=
10
;
private
static
final
int
SORT_SYNCHRO
=
11
;
private
static
final
int
SORT_XYZ
=
12
;
private
int
getSortKey1
(
Card
c1
){
if
(
c1
.
isType
(
CardType
.
Link
))
{
return
SORT_LINK
;
}
else
if
(
c1
.
isType
(
CardType
.
Monster
))
{
return
SORT_MONSTER
;
}
else
if
(
c1
.
isType
(
CardType
.
Spell
))
{
return
SORT_SPELL
;
}
else
if
(
c1
.
isType
(
CardType
.
Trap
))
{
return
SORT_TRAP
;
}
else
{
return
SORT_OTHER
;
}
}
private
int
getSortKey2
(
Card
c1
){
if
(
c1
.
isType
(
CardType
.
Fusion
))
{
return
SORT_FUSION
;
}
else
if
(
c1
.
isType
(
CardType
.
Synchro
))
{
return
SORT_SYNCHRO
;
}
else
if
(
c1
.
isType
(
CardType
.
Xyz
))
{
return
SORT_XYZ
;
}
else
{
return
SORT_OTHER
;
}
}
}
@Override
@Override
...
@@ -26,89 +61,57 @@ public class CardSort implements Comparator<Card> {
...
@@ -26,89 +61,57 @@ public class CardSort implements Comparator<Card> {
if
(
c2
==
null
)
{
if
(
c2
==
null
)
{
return
1
;
return
1
;
}
}
// boolean log = c1.Code == 74003290||c2.Code == 74003290;
//同名卡
if
(
c1
.
isType
(
CardType
.
Spell
))
{
if
(
c1
.
isAlias
(
c2
)){
if
(
c2
.
isType
(
CardType
.
Monster
))
{
return
comp
(
c1
.
Code
,
c2
.
Code
);
//怪兽在前面
}
return
-
1
;
int
sortKey1
=
getSortKey1
(
c1
);
}
int
sortKey2
=
getSortKey1
(
c2
);
if
(
c2
.
isType
(
CardType
.
Trap
))
{
if
(
sortKey1
!=
sortKey2
){
//陷阱在前面
return
Integer
.
compare
(
sortKey1
,
sortKey2
);
return
1
;
}
}
if
(
sortKey1
==
SORT_SPELL
||
sortKey2
==
SORT_TRAP
){
long
type1
=
c1
.
Type
^
CardType
.
Spell
.
value
();
long
type1
,
type2
;
long
type2
=
c2
.
Type
^
CardType
.
Spell
.
value
();
if
(
sortKey1
==
SORT_SPELL
){
int
rs
=
comp
(
type1
,
type2
);
type1
=
c1
.
Type
^
CardType
.
Spell
.
value
();
if
(
rs
==
0
)
{
type2
=
c2
.
Type
^
CardType
.
Spell
.
value
();
return
comp
(
c1
.
Code
,
c2
.
Code
);
}
else
{
}
else
{
return
rs
;
type1
=
c1
.
Type
^
CardType
.
Trap
.
value
();
type2
=
c2
.
Type
^
CardType
.
Trap
.
value
();
}
}
}
else
if
(
c1
.
isType
(
CardType
.
Trap
))
{
//怪兽魔法在前面
if
(
c2
.
isType
(
CardType
.
Monster
)
||
c2
.
isType
(
CardType
.
Spell
))
{
return
-
1
;
}
long
type1
=
c1
.
Type
^
CardType
.
Trap
.
value
();
long
type2
=
c2
.
Type
^
CardType
.
Trap
.
value
();
int
rs
=
comp
(
type1
,
type2
);
int
rs
=
comp
(
type1
,
type2
);
if
(
rs
==
0
)
{
if
(
rs
==
0
)
{
return
comp
(
c1
.
Code
,
c2
.
Code
);
return
comp
(
c1
.
Code
,
c2
.
Code
);
}
else
{
}
else
{
return
rs
;
return
rs
;
}
}
}
else
if
(
c1
.
isType
(
CardType
.
Monster
))
{
}
else
if
(
sortKey1
==
SORT_OTHER
){
//魔法陷阱在后面
return
comp
(
c1
.
Code
,
c2
.
Code
);
if
(
c2
.
isType
(
CardType
.
Spell
))
{
}
else
if
(
sortKey1
==
SORT_LINK
){
//怪兽在前面
//高星的在前面
return
1
;
return
Integer
.
compare
(
c2
.
getStar
(),
c1
.
getStar
());
}
}
else
{
if
(
c2
.
isType
(
CardType
.
Trap
))
{
//monster
//陷阱在前面
if
(
full
)
{
return
2
;
sortKey1
=
getSortKey2
(
c1
);
}
sortKey2
=
getSortKey2
(
c2
);
if
(
sortKey1
!=
sortKey2
)
{
//超量,同调,融合
//需要反转
//1,2,3
return
Integer
.
compare
(
sortKey1
,
sortKey2
);
if
(
c1
.
isType
(
CardType
.
Xyz
))
{
if
(
c2
.
isType
(
CardType
.
Synchro
))
{
return
-
1
;
}
if
(
c2
.
isType
(
CardType
.
Fusion
))
{
return
-
2
;
}
if
(
c2
.
isType
(
CardType
.
Link
))
{
return
1
;
}
}
else
if
(
c1
.
isType
(
CardType
.
Synchro
))
{
if
(
c2
.
isType
(
CardType
.
Xyz
))
{
return
1
;
}
if
(
c2
.
isType
(
CardType
.
Fusion
))
{
return
-
1
;
}
if
(
c2
.
isType
(
CardType
.
Link
))
{
return
2
;
}
}
else
if
(
c1
.
isType
(
CardType
.
Fusion
))
{
if
(
c2
.
isType
(
CardType
.
Xyz
))
{
return
2
;
}
if
(
c2
.
isType
(
CardType
.
Synchro
))
{
return
1
;
}
if
(
c2
.
isType
(
CardType
.
Link
))
{
return
3
;
}
}
}
}
int
rs
=
comp
(
c1
.
getStar
(),
c2
.
getStar
());
//高星的在前面
int
rs
=
comp
(
c2
.
getStar
(),
c1
.
getStar
());
if
(
rs
!=
0
)
{
if
(
rs
!=
0
)
{
return
rs
;
return
rs
;
}
}
rs
=
comp
(
c1
.
Attack
,
c2
.
Attack
);
//高攻击的在前面
rs
=
comp
(
c2
.
Attack
,
c1
.
Attack
);
if
(
rs
!=
0
)
{
if
(
rs
!=
0
)
{
return
rs
;
return
rs
;
}
}
rs
=
comp
(
c1
.
Defense
,
c2
.
Defense
);
//高防御的在前面
rs
=
comp
(
c2
.
Defense
,
c1
.
Defense
);
if
(
rs
!=
0
)
{
if
(
rs
!=
0
)
{
return
rs
;
return
rs
;
}
}
...
@@ -128,4 +131,12 @@ public class CardSort implements Comparator<Card> {
...
@@ -128,4 +131,12 @@ public class CardSort implements Comparator<Card> {
}
}
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
);
}
}
}
mobile/src/main/java/ocgcore/data/Card.java
View file @
b3802551
...
@@ -129,6 +129,10 @@ public class Card extends CardData implements Parcelable {
...
@@ -129,6 +129,10 @@ public class Card extends CardData implements Parcelable {
return
false
;
return
false
;
}
}
public
boolean
isAlias
(
Card
c
){
return
c
.
Code
==
this
.
Code
||
c
.
Alias
==
this
.
Code
||
c
.
Code
==
this
.
Alias
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Card{"
+
return
"Card{"
+
...
...
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