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
c1a7747c
Commit
c1a7747c
authored
Dec 14, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加当前卡组信用分与上限显示,并随着卡组变动即时更新
parent
35106b1a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
62 deletions
+122
-62
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+118
-58
mobile/src/main/java/ocgcore/data/LimitList.java
mobile/src/main/java/ocgcore/data/LimitList.java
+2
-3
mobile/src/main/res/layout/fragment_deck_cards.xml
mobile/src/main/res/layout/fragment_deck_cards.xml
+1
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/bean/DeckInfo.java
View file @
c1a7747c
...
@@ -348,7 +348,7 @@ public class DeckInfo {
...
@@ -348,7 +348,7 @@ public class DeckInfo {
}
}
public
List
<
Card
>
getAllCards
()
{
public
List
<
Card
>
getAllCards
()
{
if
(
allCards
.
size
()
==
0
)
{
if
(
allCards
.
isEmpty
()
)
{
allCards
.
addAll
(
mainCards
);
allCards
.
addAll
(
mainCards
);
allCards
.
addAll
(
extraCards
);
allCards
.
addAll
(
extraCards
);
allCards
.
addAll
(
sideCards
);
allCards
.
addAll
(
sideCards
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
c1a7747c
...
@@ -74,6 +74,7 @@ import java.util.Arrays;
...
@@ -74,6 +74,7 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
...
@@ -162,6 +163,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -162,6 +163,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
private
DeckItemTouchHelper
mDeckItemTouchHelper
;
private
DeckItemTouchHelper
mDeckItemTouchHelper
;
private
TextView
tv_deck
;
private
TextView
tv_deck
;
private
TextView
tv_result_count
;
private
TextView
tv_result_count
;
private
TextView
tv_credit_count
;
private
AppCompatSpinner
mLimitSpinner
;
private
AppCompatSpinner
mLimitSpinner
;
private
CardDetail
mCardDetail
;
private
CardDetail
mCardDetail
;
private
DialogPlus
mDialog
;
private
DialogPlus
mDialog
;
...
@@ -200,12 +202,10 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -200,12 +202,10 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
// 检查并预加载外部ydk文件
// 检查并预加载外部ydk文件
preLoadFile
();
preLoadFile
();
// 注册事件总线监听器
// 注册事件总线监听器
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
//加上判断
if
(!
EventBus
.
getDefault
().
isRegistered
(
this
))
{
//加上判断
EventBus
.
getDefault
().
register
(
this
);
EventBus
.
getDefault
().
register
(
this
);
}
}
// 显示新手引导
// 显示新手引导
showNewbieGuide
(
"deckmain"
);
showNewbieGuide
(
"deckmain"
);
return
layoutView
;
return
layoutView
;
...
@@ -250,6 +250,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -250,6 +250,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
// 查找顶部展示区域的文本控件
// 查找顶部展示区域的文本控件
tv_deck
=
layoutView
.
findViewById
(
R
.
id
.
tv_deck
);
tv_deck
=
layoutView
.
findViewById
(
R
.
id
.
tv_deck
);
tv_credit_count
=
layoutView
.
findViewById
(
R
.
id
.
tv_credit_count
);
tv_result_count
=
layoutView
.
findViewById
(
R
.
id
.
result_count
);
tv_result_count
=
layoutView
.
findViewById
(
R
.
id
.
result_count
);
// 初始化限制条件选择下拉框并设置背景颜色
// 初始化限制条件选择下拉框并设置背景颜色
...
@@ -309,7 +310,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -309,7 +310,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
// 卡组标题点击打开管理对话框
// 卡组标题点击打开管理对话框
tv_deck
.
setOnClickListener
(
v
->
{
tv_deck
.
setOnClickListener
(
v
->
{
new
DeckManageDialog
(
this
).
show
(
new
DeckManageDialog
(
this
).
show
(
get
Activity
().
getSupportFragmentManager
(),
"pagerDialog"
);
require
Activity
().
getSupportFragmentManager
(),
"pagerDialog"
);
});
});
// 初始化撤销/重做按钮
// 初始化撤销/重做按钮
...
@@ -320,9 +321,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -320,9 +321,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
btnUndo
.
setOnClickListener
(
v
->
undo
());
btnUndo
.
setOnClickListener
(
v
->
undo
());
btnRedo
.
setOnClickListener
(
v
->
redo
());
btnRedo
.
setOnClickListener
(
v
->
redo
());
// 初始化按钮状态
updateUndoRedoButtons
();
mContext
=
(
BaseActivity
)
getActivity
();
mContext
=
(
BaseActivity
)
getActivity
();
/**
/**
...
@@ -509,14 +507,17 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -509,14 +507,17 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
dialogPlus
.
setLeftButtonListener
((
dlg
,
v
)
->
{
dialogPlus
.
setLeftButtonListener
((
dlg
,
v
)
->
{
dlg
.
dismiss
();
dlg
.
dismiss
();
mDeckItemTouchHelper
.
remove
(
pos
);
mDeckItemTouchHelper
.
remove
(
pos
);
// 添加到历史记录
addDeckToHistory
(
mDeckAdapater
.
getCurrentState
());
});
});
dialogPlus
.
show
();
dialogPlus
.
show
();
}
else
{
}
else
{
// 直接显示删除头部视图
// 直接显示删除头部视图
mDeckAdapater
.
showHeadView
();
mDeckAdapater
.
showHeadView
();
mDeckItemTouchHelper
.
remove
(
pos
);
}
}
// 添加到历史记录
addDeckToHistory
(
mDeckAdapater
.
getCurrentState
());
}
}
@Override
@Override
...
@@ -677,6 +678,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -677,6 +678,8 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
// 设置并显示收藏夹
// 设置并显示收藏夹
mCardSearcher
.
showFavorites
(
false
);
mCardSearcher
.
showFavorites
(
false
);
// 初始化按钮状态
updateUndoRedoButtons
();
});
});
}
}
...
@@ -707,7 +710,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -707,7 +710,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
clearDeckHistory
();
clearDeckHistory
();
addDeckToHistory
(
deckInfo
);
addDeckToHistory
(
deckInfo
);
// 更新按钮状态
// 更新按钮状态
,初始化完毕后再执行,以便确保所有数据已加载
updateUndoRedoButtons
();
updateUndoRedoButtons
();
}
}
...
@@ -743,7 +746,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -743,7 +746,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
deckHistory
.
add
(
deckInfo
);
deckHistory
.
add
(
deckInfo
);
historyIndex
=
deckHistory
.
size
()
-
1
;
historyIndex
=
deckHistory
.
size
()
-
1
;
}
}
// 更新按钮状态
// 更新按钮状态
updateUndoRedoButtons
();
updateUndoRedoButtons
();
}
}
...
@@ -821,6 +823,42 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -821,6 +823,42 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
btnRedo
.
setVisibility
(
View
.
INVISIBLE
);
btnRedo
.
setVisibility
(
View
.
INVISIBLE
);
}
}
}
}
refreshDeckCreditCount
();
}
private
void
refreshDeckCreditCount
()
{
// 更新信用分显示 分三个部分判断和拼接文本
StringBuilder
creditText
=
new
StringBuilder
(
getString
(
R
.
string
.
deck_name
)
+
": "
);
try
{
LimitList
limitList
=
mDeckAdapater
.
getLimitList
();
// 检查是否有有效的信用分限制
if
(
limitList
.
getCreditLimits
()
!=
null
&&
!
limitList
.
getCreditLimits
().
isEmpty
())
{
// 获取信用分上限值
Integer
creditLimit
=
null
;
for
(
Integer
limit
:
limitList
.
getCreditLimits
().
values
())
{
if
(
limit
!=
null
)
{
creditLimit
=
limit
;
break
;
}
}
// 仅当信用分上限不为null且不为0时显示信用分信息
if
(
creditLimit
!=
null
&&
creditLimit
>
0
)
{
creditText
.
append
(
"("
)
.
append
(
getCreditCount
(
mDeckAdapater
.
getCurrentState
()))
.
append
(
"/"
)
.
append
(
creditLimit
)
.
append
(
")"
);
}
}
}
catch
(
Exception
e
)
{
// 记录异常日志
Log
.
e
(
TAG
,
"Error refreshing deck credit count"
,
e
);
}
tv_credit_count
.
setText
(
creditText
.
toString
());
}
}
...
@@ -1061,7 +1099,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -1061,7 +1099,7 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
}
}
/**
/**
* 添加主卡组卡片
* 添加主卡组卡片
,判断如果属于额外卡组则添加到额外卡组
*
*
* @param cardInfo 要添加的卡片信息
* @param cardInfo 要添加的卡片信息
* @return 添加成功返回true,否则返回false
* @return 添加成功返回true,否则返回false
...
@@ -1142,53 +1180,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -1142,53 +1180,6 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
return
false
;
return
false
;
}
}
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
GeneSys
))
{
// 检查GeneSys信用分限制
if
(
limitList
.
getCredits
()
!=
null
&&
limitList
.
getCreditLimits
()
!=
null
)
{
// 获取当前卡片的信用分值
Integer
cardCreditValue
=
limitList
.
getCredits
().
get
(
cardInfo
.
Alias
==
0
?
cardInfo
.
Code
:
cardInfo
.
Alias
);
if
(
cardCreditValue
!=
null
&&
cardCreditValue
>
0
)
{
// 计算当前卡组中所有GeneSys卡片的信用分总和
int
totalCredit
=
0
;
SparseArray
<
Integer
>
cardCounts
=
mDeckAdapater
.
getCardCount
();
for
(
int
i
=
0
;
i
<
cardCounts
.
size
();
i
++)
{
int
cardId
=
cardCounts
.
keyAt
(
i
);
int
cardQuantity
=
cardCounts
.
valueAt
(
i
);
// 检查这张卡是否是GeneSys卡
if
(
limitList
.
getCredits
().
containsKey
(
cardId
))
{
Integer
creditValue
=
limitList
.
getCredits
().
get
(
cardId
);
if
(
creditValue
!=
null
)
{
// 如果是当前要添加的卡片,需要考虑添加后的数量
if
(
cardId
==
cardInfo
.
Code
||
cardId
==
cardInfo
.
Alias
)
{
totalCredit
+=
creditValue
*
(
cardQuantity
+
1
);
}
else
{
totalCredit
+=
creditValue
*
cardQuantity
;
}
}
}
}
// 检查是否超过信用分上限
boolean
overLimit
=
false
;
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
limitList
.
getCreditLimits
().
entrySet
())
{
Integer
creditLimit
=
entry
.
getValue
();
if
(
creditLimit
!=
null
&&
totalCredit
>
creditLimit
)
{
overLimit
=
true
;
break
;
}
}
if
(
overLimit
)
{
YGOUtil
.
showTextToast
(
"超过总分上限:"
+
limitList
.
getCreditLimits
().
entrySet
());
return
false
;
}
}
}
}
if
(
count
!=
null
)
{
if
(
count
!=
null
)
{
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Limit
))
{
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
Limit
))
{
if
(
count
>=
1
)
{
if
(
count
>=
1
)
{
...
@@ -1200,6 +1191,51 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -1200,6 +1191,51 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
2
));
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
2
));
return
false
;
return
false
;
}
}
}
else
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
GeneSys
))
{
// 检查GeneSys信用分限制
if
(
limitList
.
getCredits
()
!=
null
&&
limitList
.
getCreditLimits
()
!=
null
)
{
// 获取当前卡片的信用分值
Integer
cardCreditValue
=
limitList
.
getCredits
().
get
(
cardInfo
.
Alias
==
0
?
cardInfo
.
Code
:
cardInfo
.
Alias
);
if
(
cardCreditValue
!=
null
&&
cardCreditValue
>
0
)
{
// 计算当前卡组中所有GeneSys卡片的信用分总和
int
totalCredit
=
0
;
SparseArray
<
Integer
>
cardCounts
=
mDeckAdapater
.
getCardCount
();
for
(
int
i
=
0
;
i
<
cardCounts
.
size
();
i
++)
{
int
cardId
=
cardCounts
.
keyAt
(
i
);
int
cardQuantity
=
cardCounts
.
valueAt
(
i
);
// 检查这张卡是否是GeneSys卡
if
(
limitList
.
getCredits
().
containsKey
(
cardId
))
{
Integer
creditValue
=
limitList
.
getCredits
().
get
(
cardId
);
if
(
creditValue
!=
null
)
{
// 如果是当前要添加的卡片,需要考虑添加后的数量
if
(
cardId
==
cardInfo
.
Code
||
cardId
==
cardInfo
.
Alias
)
{
totalCredit
+=
creditValue
*
(
cardQuantity
+
1
);
}
else
{
totalCredit
+=
creditValue
*
cardQuantity
;
}
}
}
}
// 检查是否超过信用分上限
boolean
overLimit
=
false
;
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
limitList
.
getCreditLimits
().
entrySet
())
{
Integer
creditLimit
=
entry
.
getValue
();
if
(
creditLimit
!=
null
&&
totalCredit
>=
creditLimit
)
{
overLimit
=
true
;
break
;
}
}
if
(
overLimit
)
{
YGOUtil
.
showTextToast
(
"超过总分上限:"
+
limitList
.
getCreditLimits
().
entrySet
());
return
false
;
}
}
}
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
3
));
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
3
));
return
false
;
return
false
;
...
@@ -1208,6 +1244,30 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -1208,6 +1244,30 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
return
true
;
return
true
;
}
}
private
int
getCreditCount
(
DeckInfo
deckinfo
)
{
// 处理空值情况
if
(
deckinfo
==
null
||
mDeckAdapater
==
null
||
mDeckAdapater
.
getLimitList
()
==
null
)
{
return
-
1
;
}
LimitList
limitList
=
mDeckAdapater
.
getLimitList
();
// 计算当前卡组中所有GeneSys卡片的信用分总和
int
totalCredit
=
0
;
List
<
Card
>
deck_info
=
deckinfo
.
getAllCards
();
for
(
int
i
=
0
;
i
<
deck_info
.
size
();
i
++)
{
int
cardId
=
deck_info
.
get
(
i
).
getGameCode
();
//如果有alias则返回alias,否则返回code
// 检查这张卡是否是GeneSys卡
if
(
limitList
.
getCredits
()
!=
null
&&
limitList
.
getCredits
().
containsKey
(
cardId
))
{
Integer
creditValue
=
limitList
.
getCredits
().
get
(
cardId
);
if
(
creditValue
!=
null
)
{
totalCredit
+=
creditValue
;
}
}
}
return
totalCredit
;
}
@Override
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
if
(
doMenu
(
item
.
getItemId
()))
{
if
(
doMenu
(
item
.
getItemId
()))
{
...
...
mobile/src/main/java/ocgcore/data/LimitList.java
View file @
c1a7747c
...
@@ -17,8 +17,8 @@ import ocgcore.enums.LimitType;
...
@@ -17,8 +17,8 @@ import ocgcore.enums.LimitType;
*/
*/
public
class
LimitList
{
public
class
LimitList
{
private
String
name
=
"?"
;
private
String
name
=
"?"
;
private
Map
<
String
,
Integer
>
credit_limits
;
private
Map
<
String
,
Integer
>
credit_limits
;
//GeneSys模式特有的总分值
private
Map
<
Integer
,
Integer
>
credits
;
private
Map
<
Integer
,
Integer
>
credits
;
//GeneSys模式特有的单张卡ID和其信用分
/**
/**
* 0
* 0
*/
*/
...
@@ -135,7 +135,6 @@ public class LimitList {
...
@@ -135,7 +135,6 @@ public class LimitList {
allList
.
addAll
(
forbidden
);
allList
.
addAll
(
forbidden
);
allList
.
addAll
(
limit
);
allList
.
addAll
(
limit
);
allList
.
addAll
(
semiLimit
);
allList
.
addAll
(
semiLimit
);
;
allList
.
addAll
(
credits
.
keySet
());
allList
.
addAll
(
credits
.
keySet
());
}
}
return
allList
;
return
allList
;
...
...
mobile/src/main/res/layout/fragment_deck_cards.xml
View file @
c1a7747c
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
android:src=
"@drawable/box_deck"
/>
android:src=
"@drawable/box_deck"
/>
<TextView
<TextView
android:id=
"@+id/tv_credit_count"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:layout_gravity=
"bottom"
...
...
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