forked from External/mage
Tokens rework:
- added tokens database (now all tokens store in tokens-database.txt, related to #10139); - added sets/cards/tokens stats on app's start;
This commit is contained in:
parent
1dc7dcc94c
commit
24bd4315c6
8 changed files with 348 additions and 47 deletions
|
|
@ -16,10 +16,7 @@ import mage.abilities.keyword.*;
|
|||
import mage.cards.*;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.decks.importer.DeckImporter;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.CardScanner;
|
||||
import mage.cards.repository.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubType;
|
||||
|
|
@ -42,8 +39,6 @@ import org.junit.Assert;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.plugins.card.dl.sources.ScryfallImageSupportCards;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
import org.mage.plugins.card.images.DownloadPicturesService;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -1227,30 +1222,30 @@ public class VerifyCardDataTest {
|
|||
|
||||
|
||||
// tok file's data
|
||||
List<CardDownloadData> tokFileTokens = DownloadPicturesService.getTokenCardUrls();
|
||||
List<TokenInfo> tokFileTokens = TokenRepository.instance.getAllTokens();
|
||||
LinkedHashMap<String, String> tokDataClassesIndex = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, String> tokDataNamesIndex = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, List<CardDownloadData>> tokDataTokensBySetIndex = new LinkedHashMap<>();
|
||||
for (CardDownloadData tokData : tokFileTokens) {
|
||||
LinkedHashMap<String, List<TokenInfo>> tokDataTokensBySetIndex = new LinkedHashMap<>();
|
||||
for (TokenInfo tokData : tokFileTokens) {
|
||||
|
||||
String searchName;
|
||||
String setsList;
|
||||
|
||||
// by set
|
||||
List<CardDownloadData> tokensInSet = tokDataTokensBySetIndex.getOrDefault(tokData.getSet(), null);
|
||||
List<TokenInfo> tokensInSet = tokDataTokensBySetIndex.getOrDefault(tokData.getSetCode(), null);
|
||||
if (tokensInSet == null) {
|
||||
tokensInSet = new ArrayList<>();
|
||||
tokDataTokensBySetIndex.put(tokData.getSet(), tokensInSet);
|
||||
tokDataTokensBySetIndex.put(tokData.getSetCode(), tokensInSet);
|
||||
}
|
||||
tokensInSet.add(tokData);
|
||||
|
||||
// by class
|
||||
searchName = tokData.getAffectedClassName();
|
||||
searchName = tokData.getFullClassFileName();
|
||||
setsList = tokDataClassesIndex.getOrDefault(searchName, "");
|
||||
if (!setsList.isEmpty()) {
|
||||
setsList += ",";
|
||||
}
|
||||
setsList += tokData.getSet();
|
||||
setsList += tokData.getSetCode();
|
||||
tokDataClassesIndex.put(searchName, setsList);
|
||||
|
||||
// by name
|
||||
|
|
@ -1259,7 +1254,7 @@ public class VerifyCardDataTest {
|
|||
if (!setsList.isEmpty()) {
|
||||
setsList += ",";
|
||||
}
|
||||
setsList += tokData.getSet();
|
||||
setsList += tokData.getSetCode();
|
||||
tokDataNamesIndex.put(searchName, setsList);
|
||||
}
|
||||
|
||||
|
|
@ -1302,7 +1297,7 @@ public class VerifyCardDataTest {
|
|||
tokDataTokensBySetIndex.forEach((setCode, setTokens) -> {
|
||||
if (!allSetCodes.contains(setCode)) {
|
||||
errorsList.add("error, card-pictures-tok.txt contains unknown set code: "
|
||||
+ setCode + " - " + setTokens.stream().map(CardDownloadData::getName).collect(Collectors.joining(", ")));
|
||||
+ setCode + " - " + setTokens.stream().map(TokenInfo::getName).collect(Collectors.joining(", ")));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1323,7 +1318,7 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
// set uses tokens, but tok data miss it
|
||||
setsWithTokens.forEach((setCode, sourceCards) -> {
|
||||
List<CardDownloadData> setTokens = tokDataTokensBySetIndex.getOrDefault(setCode, null);
|
||||
List<TokenInfo> setTokens = tokDataTokensBySetIndex.getOrDefault(setCode, null);
|
||||
if (setTokens == null) {
|
||||
// it's not a problem -- just find set's cards without real tokens for image tests
|
||||
// Possible reasons:
|
||||
|
|
@ -1350,7 +1345,7 @@ public class VerifyCardDataTest {
|
|||
.map(card -> card.getName() + " - " + String.join(", ", card.getRules()))
|
||||
.noneMatch(s -> s.contains(needTokenName))) {
|
||||
warningsList.add("info, tok-data has un-used tokens: "
|
||||
+ token.getSet() + " - " + token.getName());
|
||||
+ token.getSetCode() + " - " + token.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1362,7 +1357,7 @@ public class VerifyCardDataTest {
|
|||
// - outdated set code in tokens database (must be fixed by new set code, another verify check it)
|
||||
// - promo set contains additional tokens for main set (it's ok and must be ignored, example: Saproling in E02)
|
||||
warningsList.add("warning, tok-data has tokens, but real set haven't cards with it: "
|
||||
+ setCode + " - " + setTokens.stream().map(CardDownloadData::getName).collect(Collectors.joining(", ")));
|
||||
+ setCode + " - " + setTokens.stream().map(TokenInfo::getName).collect(Collectors.joining(", ")));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue