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
5e482939
Commit
5e482939
authored
Dec 14, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正不在卡组里的卡能绕过信用分上限检查的问题
封装方法,优化写法
parent
5f5e03cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
56 deletions
+27
-56
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
...ava/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
+27
-56
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerFragment.java
View file @
5e482939
...
@@ -1192,77 +1192,48 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
...
@@ -1192,77 +1192,48 @@ 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
))
{
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
// 检查GeneSys信用分限制
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
3
));
if
(
limitList
.
getCredits
()
!=
null
&&
limitList
.
getCreditLimits
()
!=
null
)
{
return
false
;
// 获取当前卡片的信用分值
}
Integer
cardCreditValue
=
limitList
.
getCredits
().
get
(
cardInfo
.
Alias
==
0
?
cardInfo
.
Code
:
cardInfo
.
Alias
);
}
//检查卡片(也要判断不在卡组时,所以count是可以为null的情况)意图加入卡组是否会超限制,超过则return false
if
(
cardCreditValue
!=
null
&&
cardCreditValue
>
0
)
{
if
(
limitList
.
check
(
cardInfo
,
LimitType
.
GeneSys
))
{
// 检查GeneSys信用分限制
// 计算当前卡组中所有GeneSys卡片的信用分总和
// 获取当前卡片的信用分值
int
totalCredit
=
0
;
Integer
cardCreditValue
=
limitList
.
getCredits
().
get
(
cardInfo
.
Alias
==
0
?
cardInfo
.
Code
:
cardInfo
.
Alias
);
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
;
}
}
}
}
// 检查是否超过信用分上限
if
(
cardCreditValue
!=
null
&&
cardCreditValue
>
0
)
{
//genesys表中的卡需要进行检查,否则就是纯普通卡只需遵循最大3的规则
boolean
overLimit
=
false
;
// 检查是否超过信用分上限
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
limitList
.
getCreditLimits
().
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
limitList
.
getCreditLimits
().
entrySet
())
{
Integer
creditLimit
=
entry
.
getValue
();
if
(
creditLimit
!=
null
&&
totalCredit
>=
creditLimit
)
{
Integer
creditLimit
=
entry
.
getValue
();
//获取总分上限数,一般是100,但可能不同genesys表给的上限分不同
overLimit
=
true
;
break
;
int
totalCredit
=
getCreditCount
(
mDeckAdapater
.
getCurrentState
())
+
cardCreditValue
;
//计算目前卡组信用分合计+当前卡的信用分的和,用于下面和上限值比较
}
}
// 计算当前卡组中所有GeneSys卡片的信用分总和
if
(
overLimit
)
{
if
(
creditLimit
!=
null
&&
totalCredit
>
creditLimit
)
{
// 遍历获取第一个非空的信用分上限值
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_credit_max
,
creditLimit
));
Integer
creditLimit
=
null
;
return
false
;
for
(
Integer
limit
:
limitList
.
getCreditLimits
().
values
())
{
if
(
limit
!=
null
)
{
creditLimit
=
limit
;
break
;
}
}
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_credit_max
,
creditLimit
));
return
false
;
}
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
3
));
return
false
;
}
}
}
}
}
}
else
if
(
count
>=
Constants
.
CARD_MAX_COUNT
)
{
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_card_max
,
3
));
return
false
;
}
}
}
}
return
true
;
return
true
;
}
}
/**
* 获取指定卡组中所有GeneSys卡片的信用分总和
*
* @param deckinfo 卡组信息对象,包含卡组中的所有卡片信息
* @return 返回卡组中所有GeneSys卡片的信用分总和,如果输入参数为空或获取限制列表失败则返回-1
*/
private
int
getCreditCount
(
DeckInfo
deckinfo
)
{
private
int
getCreditCount
(
DeckInfo
deckinfo
)
{
// 处理空值情况
// 处理空值情况
if
(
deckinfo
==
null
||
mDeckAdapater
==
null
||
mDeckAdapater
.
getLimitList
()
==
null
)
{
if
(
deckinfo
==
null
||
mDeckAdapater
==
null
||
mDeckAdapater
.
getLimitList
()
==
null
)
{
return
-
1
;
return
-
1
;
}
}
LimitList
limitList
=
mDeckAdapater
.
getLimitList
();
LimitList
limitList
=
mDeckAdapater
.
getLimitList
();
// 计算当前卡组中所有GeneSys卡片的信用分总和
// 计算当前卡组中所有GeneSys卡片的信用分总和
int
totalCredit
=
0
;
int
totalCredit
=
0
;
List
<
Card
>
deck_info
=
deckinfo
.
getAllCards
();
List
<
Card
>
deck_info
=
deckinfo
.
getAllCards
();
...
...
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