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
d7b7a81d
Commit
d7b7a81d
authored
Sep 27, 2021
by
qq247321453
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异图同名卡
parent
3ebc0037
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
34 deletions
+80
-34
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
+1
-1
mobile/src/main/java/ocgcore/CardManager.java
mobile/src/main/java/ocgcore/CardManager.java
+50
-29
mobile/src/main/java/ocgcore/data/Card.java
mobile/src/main/java/ocgcore/data/Card.java
+28
-4
mobile/src/main/java/ocgcore/data/CardData.java
mobile/src/main/java/ocgcore/data/CardData.java
+1
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/utils/CardSort.java
View file @
d7b7a81d
...
...
@@ -62,7 +62,7 @@ public class CardSort implements Comparator<Card> {
return
1
;
}
//同名卡
if
(
c1
.
isAlias
(
c2
)){
if
(
c1
.
getCode
()
==
c2
.
getCode
(
)){
return
comp
(
c1
.
Code
,
c2
.
Code
);
}
int
sortKey1
=
getSortKey1
(
c1
);
...
...
mobile/src/main/java/ocgcore/CardManager.java
View file @
d7b7a81d
...
...
@@ -26,16 +26,16 @@ import java.util.zip.ZipInputStream;
import
cn.garymb.ygomobile.App
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
ocgcore.data.Card
;
import
ocgcore.enums.CardAttribute
;
import
ocgcore.enums.CardOt
;
public
class
CardManager
{
private
static
int
cdbNum
=
0
;
private
final
SparseArray
<
Card
>
cardDataHashMap
=
new
SparseArray
<>();
private
String
dbDir
,
exDbPath
;
private
static
final
String
TAG
=
IrrlichtBridge
.
TAG
;
/**
* @see DataManager#getCardManager()
...
...
@@ -138,39 +138,60 @@ public class CardManager {
public
void
loadCards
()
{
cardDataHashMap
.
clear
();
int
count
=
readAllCards
(
AppsSettings
.
get
().
getDataBaseFile
(),
cardDataHashMap
);
Log
.
i
(
"Irrlicht"
,
"load defualt cdb:"
+
count
);
if
(
TextUtils
.
isEmpty
(
exDbPath
))
return
;
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
File
dir
=
new
File
(
exDbPath
);
if
(
dir
.
exists
())
{
File
[]
files
=
dir
.
listFiles
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
File
file
=
new
File
(
dir
,
name
);
return
file
.
isFile
()
&&
((
name
.
endsWith
(
".cdb"
)
||
(
name
.
endsWith
(
".zip"
)
||
name
.
endsWith
(
".ypk"
))));
}
});
//读取全部卡片
if
(
files
!=
null
)
{
for
(
File
file
:
files
)
{
if
(
file
.
getName
().
endsWith
(
".cdb"
))
{
count
=
readAllCards
(
file
,
cardDataHashMap
);
}
else
if
(
file
.
getName
().
endsWith
(
".zip"
)
||
file
.
getName
().
endsWith
(
".ypk"
))
{
Log
.
e
(
"CardManager"
,
"读取压缩包"
);
try
{
for
(
File
file1
:
readZipCdb
(
file
.
getAbsolutePath
()))
{
count
=
readAllCards
(
file1
,
cardDataHashMap
);
Log
.
i
(
TAG
,
"load defualt cdb:"
+
count
);
if
(!
TextUtils
.
isEmpty
(
exDbPath
))
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
File
dir
=
new
File
(
exDbPath
);
if
(
dir
.
exists
())
{
File
[]
files
=
dir
.
listFiles
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
File
file
=
new
File
(
dir
,
name
);
return
file
.
isFile
()
&&
((
name
.
endsWith
(
".cdb"
)
||
(
name
.
endsWith
(
".zip"
)
||
name
.
endsWith
(
".ypk"
))));
}
});
//读取全部卡片
if
(
files
!=
null
)
{
for
(
File
file
:
files
)
{
if
(
file
.
getName
().
endsWith
(
".cdb"
))
{
count
=
readAllCards
(
file
,
cardDataHashMap
);
}
else
if
(
file
.
getName
().
endsWith
(
".zip"
)
||
file
.
getName
().
endsWith
(
".ypk"
))
{
Log
.
e
(
"CardManager"
,
"读取压缩包"
);
try
{
for
(
File
file1
:
readZipCdb
(
file
.
getAbsolutePath
()))
{
count
=
readAllCards
(
file1
,
cardDataHashMap
);
}
}
catch
(
IOException
e
)
{
Log
.
e
(
"CardManager"
,
"读取压缩包错误"
+
e
);
}
}
catch
(
IOException
e
)
{
Log
.
e
(
"CardManager"
,
"读取压缩包错误"
+
e
);
}
Log
.
i
(
TAG
,
"load "
+
count
+
" cdb:"
+
file
);
}
Log
.
i
(
"Irrlicht"
,
"load "
+
count
+
" cdb:"
+
file
);
}
}
}
}
buildAliasCards
();
}
private
void
buildAliasCards
()
{
int
N
=
getCount
();
for
(
int
i
=
0
;
i
<
N
;
i
++)
{
Card
c
=
cardDataHashMap
.
valueAt
(
i
);
if
(
c
.
Alias
==
0
){
continue
;
}
//规则同名,或者多图同名
Card
alias
=
getCard
(
c
.
Alias
);
if
(
alias
!=
null
)
{
if
(
c
.
isSame
(
alias
))
{
//多图同名,它们属性必定是一致
c
.
setRealCode
(
alias
.
Code
);
}
else
if
(
Math
.
abs
(
c
.
Alias
-
c
.
Code
)
<=
10
){
Log
.
w
(
TAG
,
c
.
Name
+
":"
+
c
.
Code
+
" is same card "
+
c
.
Alias
);
}
}
}
}
@WorkerThread
...
...
@@ -215,7 +236,7 @@ public class CardManager {
}
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
Log
.
e
(
"Irrlicht"
,
"read cards "
+
file
,
e
);
Log
.
e
(
TAG
,
"read cards "
+
file
,
e
);
}
finally
{
IOUtils
.
close
(
reader
);
IOUtils
.
close
(
db
);
...
...
mobile/src/main/java/ocgcore/data/Card.java
View file @
d7b7a81d
...
...
@@ -3,6 +3,7 @@ package ocgcore.data;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
android.text.TextUtils
;
import
androidx.annotation.NonNull
;
...
...
@@ -24,6 +25,8 @@ public class Card extends CardData implements Parcelable {
public
String
Name
;
public
String
Desc
;
public
int
RealCode
;
public
Card
()
{
}
...
...
@@ -32,6 +35,7 @@ public class Card extends CardData implements Parcelable {
if
(
card
!=
null
)
{
this
.
Name
=
card
.
Name
;
this
.
Desc
=
card
.
Desc
;
this
.
RealCode
=
card
.
RealCode
;
}
}
...
...
@@ -62,6 +66,7 @@ public class Card extends CardData implements Parcelable {
super
(
in
);
this
.
Name
=
in
.
readString
();
this
.
Desc
=
in
.
readString
();
this
.
RealCode
=
in
.
readInt
();
}
public
static
boolean
isType
(
long
Type
,
CardType
type
)
{
...
...
@@ -81,6 +86,18 @@ public class Card extends CardData implements Parcelable {
return
this
;
}
@Override
public
int
getCode
()
{
if
(
RealCode
>
0
){
return
RealCode
;
}
return
Code
;
//super.getCode();
}
public
void
setRealCode
(
int
realCode
)
{
RealCode
=
realCode
;
}
public
int
getStar
()
{
return
(
Level
&
0xff
);
}
...
...
@@ -135,10 +152,6 @@ public class Card extends CardData implements Parcelable {
return
false
;
}
public
boolean
isAlias
(
Card
c
){
return
c
.
Code
==
this
.
Code
||
c
.
Alias
==
this
.
Code
||
c
.
Code
==
this
.
Alias
;
}
public
boolean
containsName
(
String
key
){
return
Name
!=
null
&&
Name
.
contains
(
key
);
}
...
...
@@ -147,6 +160,16 @@ public class Card extends CardData implements Parcelable {
return
Desc
!=
null
&&
Desc
.
contains
(
key
);
}
/**
* 同样一张卡,不同卡图,它们属性应该是一样的
*/
public
boolean
isSame
(
Card
c
){
if
(
c
.
Code
==
this
.
Code
||
c
.
Alias
==
this
.
Code
||
c
.
Code
==
this
.
Alias
)
{
return
TextUtils
.
equals
(
c
.
Name
,
this
.
Name
)
&&
c
.
Type
==
this
.
Type
&&
c
.
Ot
==
this
.
Ot
;
}
return
false
;
}
@NonNull
@Override
public
String
toString
()
{
...
...
@@ -177,5 +200,6 @@ public class Card extends CardData implements Parcelable {
super
.
writeToParcel
(
dest
,
flags
);
dest
.
writeString
(
this
.
Name
);
dest
.
writeString
(
this
.
Desc
);
dest
.
writeInt
(
this
.
RealCode
);
}
}
mobile/src/main/java/ocgcore/data/CardData.java
View file @
d7b7a81d
...
...
@@ -102,6 +102,7 @@ public class CardData implements Parcelable {
* 同卡,不同卡图
*/
public
int
getCode
(){
//TODO 暂时的兼容做法
if
(
Alias
>
0
&&
Math
.
abs
(
Alias
-
Code
)
<=
10
)
{
return
Alias
;
}
else
{
...
...
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