Commit 953529a3 authored by fallenstardust's avatar fallenstardust

新cdb数据解析归类

parent 39b7dbec
...@@ -114,9 +114,6 @@ public interface Constants { ...@@ -114,9 +114,6 @@ public interface Constants {
String PREF_READ_EX = "pref_settings_read_ex"; String PREF_READ_EX = "pref_settings_read_ex";
boolean DEF_PREF_READ_EX = false; boolean DEF_PREF_READ_EX = false;
String PREF_DECK_MANAGER_V2 = "pref_settings_deck_manager_v2";
boolean DEF_PREF_DECK_MANAGER_V2 = false;
String PREF_KEEP_SCALE = "pref_settings_keep_scale"; String PREF_KEEP_SCALE = "pref_settings_keep_scale";
boolean DEF_PREF_KEEP_SCALE = false; boolean DEF_PREF_KEEP_SCALE = false;
...@@ -125,18 +122,11 @@ public interface Constants { ...@@ -125,18 +122,11 @@ public interface Constants {
int REQUEST_CHOOSE_IMG = 0x1000 + 0x21; int REQUEST_CHOOSE_IMG = 0x1000 + 0x21;
int REQUEST_CHOOSE_FOLDER = 0x1000 + 0x22; int REQUEST_CHOOSE_FOLDER = 0x1000 + 0x22;
int REQUEST_SETTINGS_CODE = 0x1000 + 0x23; int REQUEST_SETTINGS_CODE = 0x1000 + 0x23;
int STRING_TYPE_START = 1050;
int STRING_ATTRIBUTE_START = 1010;
int STRING_RACE_START = 1020;
int STRING_OT_START = 1480;
int UNSORT_TIMES = 0x80; int UNSORT_TIMES = 0x80;
int CARD_RESULT_GRAVITY = Gravity.LEFT; int CARD_RESULT_GRAVITY = Gravity.LEFT;
int CARD_SEARCH_GRAVITY = Gravity.RIGHT; int CARD_SEARCH_GRAVITY = Gravity.RIGHT;
int STRING_LIMIT_START = 1315;
int STRING_CATEGORY_START = 1100;
int DEFAULT_CARD_COUNT = 500; int DEFAULT_CARD_COUNT = 500;
int DECK_WIDTH_MAX_COUNT = 15; int DECK_WIDTH_MAX_COUNT = 15;
int DECK_WIDTH_COUNT = 10; int DECK_WIDTH_COUNT = 10;
...@@ -145,10 +135,8 @@ public interface Constants { ...@@ -145,10 +135,8 @@ public interface Constants {
int DECK_SIDE_MAX = 15; int DECK_SIDE_MAX = 15;
int DECK_EXTRA_COUNT = (DECK_SIDE_MAX / DECK_WIDTH_COUNT * DECK_WIDTH_COUNT < DECK_SIDE_MAX) ? DECK_WIDTH_COUNT * 2 : DECK_WIDTH_COUNT; int DECK_EXTRA_COUNT = (DECK_SIDE_MAX / DECK_WIDTH_COUNT * DECK_WIDTH_COUNT < DECK_SIDE_MAX) ? DECK_WIDTH_COUNT * 2 : DECK_WIDTH_COUNT;
int DECK_SIDE_COUNT = DECK_EXTRA_COUNT; int DECK_SIDE_COUNT = DECK_EXTRA_COUNT;
String URL_DONATE_CN= "https://afdian.net/@ygomobile";
String URL_DONATE= "https://www.paypal.me/ygomobile1";
String URL_HELP = "http://note.youdao.com/noteshare?id=8ae2dc824b7dc04a95a4665a938e2251"; String URL_HELP = "http://note.youdao.com/noteshare?id=8ae2dc824b7dc04a95a4665a938e2251";
String URL_MASTERRULE_CN = "https://ocg-rule.readthedocs.io/zh_CN/master/"; String URL_MASTER_RULE_CN = "https://ocg-rule.readthedocs.io/zh_CN/master/";
String WIKI_SEARCH_URL = "https://www.ourocg.cn/S.aspx?key="; String WIKI_SEARCH_URL = "https://www.ourocg.cn/S.aspx?key=";
String SERVER_FILE = "server_list.xml"; String SERVER_FILE = "server_list.xml";
...@@ -169,7 +157,7 @@ public interface Constants { ...@@ -169,7 +157,7 @@ public interface Constants {
/*** /***
* 长按删除 * 长按删除
*/ */
long LONG_PRESS_DRAG = 600; long LONG_PRESS_DRAG = 800;
/*** /***
* adb shell am start -n cn.garymb.ygomobile/cn.garymb.ygomobile.ui.home.MainActivity -a ygomobile.intent.action.DECK --es android.intent.extra.TEXT 青眼白龙.ydk * adb shell am start -n cn.garymb.ygomobile/cn.garymb.ygomobile.ui.home.MainActivity -a ygomobile.intent.action.DECK --es android.intent.extra.TEXT 青眼白龙.ydk
* <p> * <p>
...@@ -222,4 +210,8 @@ public interface Constants { ...@@ -222,4 +210,8 @@ public interface Constants {
//打开ydk,是否复制到文件夹 //打开ydk,是否复制到文件夹
boolean COPY_YDK_FILE = false; boolean COPY_YDK_FILE = false;
String TAG = "ygo-java";
String DEF_ENCODING = "utf-8";
} }
...@@ -5,6 +5,7 @@ import android.text.TextUtils; ...@@ -5,6 +5,7 @@ import android.text.TextUtils;
import java.util.List; import java.util.List;
import ocgcore.data.Card; import ocgcore.data.Card;
import ocgcore.enums.CardOt;
import ocgcore.enums.CardType; import ocgcore.enums.CardType;
class CardSearchInfo { class CardSearchInfo {
...@@ -111,19 +112,18 @@ class CardSearchInfo { ...@@ -111,19 +112,18 @@ class CardSearchInfo {
} }
} }
} }
if (ot > 0) { if (ot > CardOt.ALL.getId()) {
if (ot == 8) {//8为简中的位数 if(ot == CardOt.NO_EXCLUSIVE.getId()){
if((ot&card.Ot) !=ot) if(card.Ot == CardOt.OCG.getId() || card.Ot == CardOt.TCG.getId()){
return false;
} else {
if (ot != card.Ot) {
return false; return false;
} }
} else if ((card.Ot & ot) == 0) {
return false;
} }
} }
if (pscale != -1) { if (pscale != -1) {
if (!card.isType(CardType.Pendulum) || card.LScale != pscale && card.RScale != pscale) { if (!card.isType(CardType.Pendulum) || card.LeftScale != pscale && card.RightScale != pscale) {
return false; return false;
} }
} }
...@@ -141,7 +141,7 @@ class CardSearchInfo { ...@@ -141,7 +141,7 @@ class CardSearchInfo {
if (types.length > 0) { if (types.length > 0) {
boolean st = false; boolean st = false;
for (long cardType : types) { for (long cardType : types) {
if (cardType == CardType.Spell.value() || cardType == CardType.Trap.value()) { if (cardType == CardType.Spell.getId() || cardType == CardType.Trap.getId()) {
st = true; st = true;
break; break;
} }
...@@ -150,46 +150,52 @@ class CardSearchInfo { ...@@ -150,46 +150,52 @@ class CardSearchInfo {
for (long type : types) { for (long type : types) {
if (type > 0) { if (type > 0) {
if (st) { if (st) {
//效果以外
if (type == CardType.Non_Effect.getId()) {
if (card.isType(CardType.Effect)) {
return false;
}
}
//魔法 //魔法
if (type == CardType.Normal.value()) { else if (type == CardType.Normal.getId()) {
//通常 //通常
if (card.isType(CardType.Normal)) { if (card.isType(CardType.Normal)) {
//带通常的魔法陷阱 //带通常的魔法陷阱
if (card.Type != (CardType.Spell.value() | CardType.Normal.value()) if (card.Type != (CardType.Spell.getId() | CardType.Normal.getId())
&& card.Type != (CardType.Trap.value() | CardType.Normal.value())) { && card.Type != (CardType.Trap.getId() | CardType.Normal.getId())) {
return false; return false;
} }
} else { } else {
//只有魔法/陷阱 //只有魔法/陷阱
if (card.Type != CardType.Spell.value() && card.Type != CardType.Trap.value()) if (card.Type != CardType.Spell.getId() && card.Type != CardType.Trap.getId())
return false; return false;
} }
continue; continue;
} }
} else { } else {
//排除通常怪兽里的token卡 //排除通常怪兽里的token卡
if (type == CardType.Normal.value()) { if (type == CardType.Normal.getId()) {
if ((card.Type & CardType.Token.value()) == CardType.Token.value()) if ((card.Type & CardType.Token.getId()) == CardType.Token.getId())
return false; return false;
} }
} }
//效果怪兽 //效果怪兽
if (type == CardType.Effect.value()) { if (type == CardType.Effect.getId()) {
if ((card.Type & CardType.Effect.value()) == CardType.Effect.value()) { if ((card.Type & CardType.Effect.getId()) == CardType.Effect.getId()) {
//如果是融合/仪式/同调/超量/连接 //如果是融合/仪式/同调/超量/连接
if ((card.Type & CardType.Fusion.value()) == CardType.Fusion.value() if ((card.Type & CardType.Fusion.getId()) == CardType.Fusion.getId()
|| (card.Type & CardType.Ritual.value()) == CardType.Ritual.value() || (card.Type & CardType.Ritual.getId()) == CardType.Ritual.getId()
|| (card.Type & CardType.Synchro.value()) == CardType.Synchro.value() || (card.Type & CardType.Synchro.getId()) == CardType.Synchro.getId()
|| (card.Type & CardType.Xyz.value()) == CardType.Xyz.value() || (card.Type & CardType.Xyz.getId()) == CardType.Xyz.getId()
|| (card.Type & CardType.Link.value()) == CardType.Link.value() || (card.Type & CardType.Link.getId()) == CardType.Link.getId()
) )
return false; return false;
} else { } else {
return false; return false;
} }
} else if (type == CardType.Non_Effect.value()) { } else if (type == CardType.Non_Effect.getId()) {
//非效果怪兽 //非效果怪兽
if ((card.Type & CardType.Effect.value()) == CardType.Effect.value()) if ((card.Type & CardType.Effect.getId()) == CardType.Effect.getId())
return false; return false;
} else if ((card.Type & type) != type) { } else if ((card.Type & type) != type) {
return false; return false;
......
...@@ -101,15 +101,15 @@ public class DeckLoader { ...@@ -101,15 +101,15 @@ public class DeckLoader {
IOUtils.close(in); IOUtils.close(in);
} }
DeckInfo deckInfo = new DeckInfo(); DeckInfo deckInfo = new DeckInfo();
SparseArray<Card> tmp = cardLoader.readCards(deck.getMainlist(), limitList, true); SparseArray<Card> tmp = cardLoader.readCards(deck.getMainlist(), true);
for (Integer id : deck.getMainlist()) { for (Integer id : deck.getMainlist()) {
deckInfo.addMainCards(tmp.get(id)); deckInfo.addMainCards(tmp.get(id));
} }
tmp = cardLoader.readCards(deck.getExtraList(), limitList, true); tmp = cardLoader.readCards(deck.getExtraList(), true);
for (Integer id : deck.getExtraList()) { for (Integer id : deck.getExtraList()) {
deckInfo.addExtraCards(tmp.get(id)); deckInfo.addExtraCards(tmp.get(id));
} }
tmp = cardLoader.readCards(deck.getSideList(), limitList, true); tmp = cardLoader.readCards(deck.getSideList(), true);
// Log.i("kk", "desk:" + tmp.size()+"/"+side.size()); // Log.i("kk", "desk:" + tmp.size()+"/"+side.size());
for (Integer id : deck.getSideList()) { for (Integer id : deck.getSideList()) {
deckInfo.addSideCards(tmp.get(id)); deckInfo.addSideCards(tmp.get(id));
......
...@@ -14,7 +14,7 @@ public class CardUtils { ...@@ -14,7 +14,7 @@ public class CardUtils {
if (card.isType(CardType.Spell)) { if (card.isType(CardType.Spell)) {
for (CardType type : cardTypes) { for (CardType type : cardTypes) {
if (card.isType(type)) { if (card.isType(type)) {
stringBuilder.append(stringManager.getTypeString(type.value())); stringBuilder.append(stringManager.getTypeString(type.getId()));
// break; // break;
} }
} }
...@@ -22,7 +22,7 @@ public class CardUtils { ...@@ -22,7 +22,7 @@ public class CardUtils {
} else if (card.isType(CardType.Trap)) { } else if (card.isType(CardType.Trap)) {
for (CardType type : cardTypes) { for (CardType type : cardTypes) {
if (card.isType(type)) { if (card.isType(type)) {
stringBuilder.append(stringManager.getTypeString(type.value())); stringBuilder.append(stringManager.getTypeString(type.getId()));
} }
// break; // break;
} }
...@@ -35,10 +35,10 @@ public class CardUtils { ...@@ -35,10 +35,10 @@ public class CardUtils {
} else { } else {
isFrst = false; isFrst = false;
} }
String str = stringManager.getTypeString(type.value()); String str = stringManager.getTypeString(type.getId());
if (TextUtils.isEmpty(str)) { if (TextUtils.isEmpty(str)) {
stringBuilder.append("0x"); stringBuilder.append("0x");
stringBuilder.append(String.format("%X", type.value())); stringBuilder.append(String.format("%X", type.getId()));
} else { } else {
stringBuilder.append(str); stringBuilder.append(str);
} }
...@@ -47,4 +47,24 @@ public class CardUtils { ...@@ -47,4 +47,24 @@ public class CardUtils {
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
public int value2Index(long type) {
//0 1 2 3 4
//1 2 4 8 16
int i = 0;
long start;
do {
start = (long) Math.pow(2, i);
if (start == type) {
return i;
} else if (start > type) {
return -1;
}
i++;
}
while (start < type);
return i;
}
} }
...@@ -28,6 +28,8 @@ import cn.garymb.ygomobile.App; ...@@ -28,6 +28,8 @@ import cn.garymb.ygomobile.App;
import cn.garymb.ygomobile.AppsSettings; import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.utils.IOUtils; import cn.garymb.ygomobile.utils.IOUtils;
import ocgcore.data.Card; import ocgcore.data.Card;
import ocgcore.enums.CardAttribute;
import ocgcore.enums.CardOt;
public class CardManager { public class CardManager {
...@@ -35,7 +37,12 @@ public class CardManager { ...@@ -35,7 +37,12 @@ public class CardManager {
private final SparseArray<Card> cardDataHashMap = new SparseArray<>(); private final SparseArray<Card> cardDataHashMap = new SparseArray<>();
private String dbDir, exDbPath; private String dbDir, exDbPath;
public CardManager(String dbDir, String exPath) { /**
* @see DataManager#getCardManager()
* @param dbDir
* @param exPath
*/
CardManager(String dbDir, String exPath) {
this.dbDir = dbDir; this.dbDir = dbDir;
this.exDbPath = exPath; this.exDbPath = exPath;
} }
...@@ -110,7 +117,13 @@ public class CardManager { ...@@ -110,7 +117,13 @@ public class CardManager {
} }
public Card getCard(int code) { public Card getCard(int code) {
return cardDataHashMap.get(Integer.valueOf(code)); Card card = cardDataHashMap.get(code);
if(card == null){
card = new Card(code);
cardDataHashMap.put(code, new Card(code));
return card;
}
return card;
} }
public int getCount() { public int getCount() {
...@@ -182,12 +195,12 @@ public class CardManager { ...@@ -182,12 +195,12 @@ public class CardManager {
cardData.Code = reader.getInt(0); cardData.Code = reader.getInt(0);
cardData.Ot = reader.getInt(1); cardData.Ot = reader.getInt(1);
cardData.Alias = reader.getInt(2); cardData.Alias = reader.getInt(2);
cardData.Setcode = reader.getLong(3); cardData.SetCode = reader.getLong(3);
cardData.Type = reader.getLong(4); cardData.Type = reader.getLong(4);
int levelInfo = reader.getInt(5); int levelInfo = reader.getInt(5);
cardData.Level = levelInfo & 0xff; cardData.Level = levelInfo & 0xff;
cardData.LScale = (levelInfo >> 24) & 0xff; cardData.LeftScale = (levelInfo >> 24) & 0xff;
cardData.RScale = (levelInfo >> 16) & 0xff; cardData.RightScale = (levelInfo >> 16) & 0xff;
cardData.Race = reader.getLong(6); cardData.Race = reader.getLong(6);
cardData.Attribute = reader.getInt(7); cardData.Attribute = reader.getInt(7);
cardData.Attack = reader.getInt(8); cardData.Attack = reader.getInt(8);
......
...@@ -22,7 +22,7 @@ public class DataManager { ...@@ -22,7 +22,7 @@ public class DataManager {
private final StringManager mStringManager; private final StringManager mStringManager;
private final LimitManager mLimitManager; private final LimitManager mLimitManager;
private CardManager mCardManager; private final CardManager mCardManager;
private DataManager() { private DataManager() {
mStringManager = new StringManager(); mStringManager = new StringManager();
...@@ -40,10 +40,6 @@ public class DataManager { ...@@ -40,10 +40,6 @@ public class DataManager {
return mLimitManager; return mLimitManager;
} }
public static ConfigManager openConfig(File conf) {
return new ConfigManager(conf);
}
public CardManager getCardManager() { public CardManager getCardManager() {
return mCardManager; return mCardManager;
} }
......
...@@ -11,6 +11,7 @@ import java.io.FileInputStream; ...@@ -11,6 +11,7 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -22,7 +23,12 @@ import cn.garymb.ygomobile.Constants; ...@@ -22,7 +23,12 @@ import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.utils.IOUtils; import cn.garymb.ygomobile.utils.IOUtils;
import cn.garymb.ygomobile.utils.StringUtils; import cn.garymb.ygomobile.utils.StringUtils;
import ocgcore.data.CardSet; import ocgcore.data.CardSet;
import ocgcore.enums.CardAttribute;
import ocgcore.enums.CardCategory;
import ocgcore.enums.CardOt; import ocgcore.enums.CardOt;
import ocgcore.enums.CardRace;
import ocgcore.enums.CardType;
import ocgcore.enums.LimitType;
public class StringManager implements Closeable { public class StringManager implements Closeable {
private static final String PRE_SYSTEM = "!system"; private static final String PRE_SYSTEM = "!system";
...@@ -125,7 +131,7 @@ public class StringManager implements Closeable { ...@@ -125,7 +131,7 @@ public class StringManager implements Closeable {
FileInputStream inputStream = null; FileInputStream inputStream = null;
try { try {
inputStream = new FileInputStream(file); inputStream = new FileInputStream(file);
in = new InputStreamReader(inputStream, "utf-8"); in = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(in); BufferedReader reader = new BufferedReader(in);
String line = null; String line = null;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
...@@ -195,71 +201,86 @@ public class StringManager implements Closeable { ...@@ -195,71 +201,86 @@ public class StringManager implements Closeable {
return 0; return 0;
} }
public String getSystemString(int key) { /**
return mSystem.get(Integer.valueOf(key)); * @param index 索引
} * @param def 默认值
*/
public String getSystemString(int start, long value) { public String getSystemString(Integer index, String def){
return getSystemString(start + value2Index(value)); if(index <= 0){
return def;
}
try {
String str = mSystem.get(index);
if (TextUtils.isEmpty(str)) {
return def;
}
return StringUtils.toDBC(str);
} catch (Exception e) {
return def;
}
} }
public String getLimitString(long value) { public String getLimitString(long id) {
// String str = LimitType value = LimitType.valueOf(id);
// Log.d("kk", value + "=" + str); if(value == null){
return getSystemString((int) (Constants.STRING_LIMIT_START + value)); return String.valueOf(id);
}
return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getTypeString(long value) { public String getTypeString(long id) {
return getSystemString(Constants.STRING_TYPE_START, value); CardType value = CardType.valueOf(id);
if(value == null){
return String.valueOf(id);
}
return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getAttributeString(long value) { public String getAttributeString(long id) {
return getSystemString(Constants.STRING_ATTRIBUTE_START, value); CardAttribute value = CardAttribute.valueOf(id);
if(value == null){
return String.valueOf(id);
}
return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getRaceString(long value) { public String getRaceString(long id) {
String race = getSystemString(Constants.STRING_RACE_START, value); CardRace value = CardRace.valueOf(id);
if (TextUtils.isEmpty(race)) { if(value == null){
return String.format("0x%X", value); return String.format("0x%x", id);
} }
return race; return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getOtString(int ot, String def) { public String getOtString(int ot, boolean full) {
if (ot == CardOt.All.ordinal()) { if(!full || ot == 0){
return "-"; CardOt value = CardOt.valueOf(ot);
if(value == null){
return String.valueOf(ot);
}
return getSystemString(value.getLanguageIndex(), value.name());
} }
try { StringBuilder stringBuilder = new StringBuilder();
String str = getSystemString(Constants.STRING_OT_START + ot); boolean first = true;
if (TextUtils.isEmpty(str)) { for(CardOt _ot : CardOt.values()){
return def;//String.valueOf(CardOt.values()[ot]); if((_ot.getId() & ot) != 0){
if(first){
first = false;
} else {
stringBuilder.append("|");
}
stringBuilder.append(getSystemString(_ot.getLanguageIndex(), _ot.name()));
} }
return StringUtils.toDBC(str);
} catch (Exception e) {
return def;
} }
return stringBuilder.toString();
} }
public String getCategoryString(long value) { public String getCategoryString(long id) {
return getSystemString(Constants.STRING_CATEGORY_START, value); CardCategory value = CardCategory.valueOf(id);
} if(value == null){
return String.valueOf(id);
public int value2Index(long type) {
//0 1 2 3 4
//1 2 4 8 16
int i = 0;
long start;
do {
start = (long) Math.pow(2, i);
if (start == type) {
return i;
} else if (start > type) {
return -1;
}
i++;
} }
while (start < type); return getSystemString(value.getLanguageIndex(), value.name());
return i;
} }
private long toNumber(String str) { private long toNumber(String str) {
......
...@@ -35,6 +35,7 @@ public class Card extends CardData implements Parcelable { ...@@ -35,6 +35,7 @@ public class Card extends CardData implements Parcelable {
public Card(int code) { public Card(int code) {
super(code); super(code);
this.Name = "Unknown";
} }
public Card(CardData cardData) { public Card(CardData cardData) {
...@@ -42,15 +43,15 @@ public class Card extends CardData implements Parcelable { ...@@ -42,15 +43,15 @@ public class Card extends CardData implements Parcelable {
if (cardData != null) { if (cardData != null) {
this.Code = cardData.Code; this.Code = cardData.Code;
this.Alias = cardData.Alias; this.Alias = cardData.Alias;
this.Setcode = cardData.Setcode; this.SetCode = cardData.SetCode;
this.Type = cardData.Type; this.Type = cardData.Type;
this.Level = cardData.Level; this.Level = cardData.Level;
this.Attribute = cardData.Attribute; this.Attribute = cardData.Attribute;
this.Race = cardData.Race; this.Race = cardData.Race;
this.Attack = cardData.Attack; this.Attack = cardData.Attack;
this.Defense = cardData.Defense; this.Defense = cardData.Defense;
this.LScale = cardData.LScale; this.LeftScale = cardData.LeftScale;
this.RScale = cardData.RScale; this.RightScale = cardData.RightScale;
this.Category = cardData.Category; this.Category = cardData.Category;
} }
} }
...@@ -62,7 +63,7 @@ public class Card extends CardData implements Parcelable { ...@@ -62,7 +63,7 @@ public class Card extends CardData implements Parcelable {
} }
public static boolean isType(long Type, CardType type) { public static boolean isType(long Type, CardType type) {
return ((Type & type.value()) != 0); return ((Type & type.getId()) != 0);
} }
public static boolean isSpellTrap(long Type) { public static boolean isSpellTrap(long Type) {
...@@ -82,12 +83,16 @@ public class Card extends CardData implements Parcelable { ...@@ -82,12 +83,16 @@ public class Card extends CardData implements Parcelable {
return (Level & 0xff); return (Level & 0xff);
} }
public int getLinkNumber(){
return getStar();
}
public boolean isType(CardType type) { public boolean isType(CardType type) {
return ((Type & type.value()) != 0); return ((Type & type.getId()) != 0);
} }
public boolean onlyType(CardType type) { public boolean onlyType(CardType type) {
return (Type == type.value()); return (Type == type.getId());
} }
public boolean isSpellTrap() { public boolean isSpellTrap() {
...@@ -101,17 +106,17 @@ public class Card extends CardData implements Parcelable { ...@@ -101,17 +106,17 @@ public class Card extends CardData implements Parcelable {
public long[] getSetCode() { public long[] getSetCode() {
long[] setcodes = new long[SETCODE_MAX]; long[] setcodes = new long[SETCODE_MAX];
for (int i = 0, k = 0; i < SETCODE_MAX; k += 0x10, i++) { for (int i = 0, k = 0; i < SETCODE_MAX; k += 0x10, i++) {
setcodes[i] = (Setcode >> k) & 0xffff; setcodes[i] = (SetCode >> k) & 0xffff;
} }
return setcodes; return setcodes;
} }
public void setSetCode(long[] setcodes) { public void setSetCode(long[] setcodes) {
int i = 0; int i = 0;
this.Setcode = 0; this.SetCode = 0;
if (setcodes != null) { if (setcodes != null) {
for (long sc : setcodes) { for (long sc : setcodes) {
this.Setcode += (sc << i); this.SetCode += (sc << i);
i += 0x10; i += 0x10;
} }
} }
...@@ -128,20 +133,24 @@ public class Card extends CardData implements Parcelable { ...@@ -128,20 +133,24 @@ 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{" +
"Code=" + Code + "Code=" + Code +
", Alias=" + Alias + ", Alias=" + Alias +
", Setcode=" + Setcode + ", Setcode=" + SetCode +
", Type=" + Type + ", Type=" + Type +
", Level=" + Level + ", Level=" + Level +
", Attribute=" + Attribute + ", Attribute=" + Attribute +
", Race=" + Race + ", Race=" + Race +
", Attack=" + Attack + ", Attack=" + Attack +
", Defense=" + Defense + ", Defense=" + Defense +
", LScale=" + LScale + ", LScale=" + LeftScale +
", RScale=" + RScale + ", RScale=" + RightScale +
", Name='" + Name + '\'' + ", Name='" + Name + '\'' +
", Desc='" + Desc + '\'' + ", Desc='" + Desc + '\'' +
'}'; '}';
......
...@@ -3,6 +3,9 @@ package ocgcore.data; ...@@ -3,6 +3,9 @@ package ocgcore.data;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import ocgcore.enums.CardAttribute;
import ocgcore.enums.CardOt;
public class CardData implements Parcelable{ public class CardData implements Parcelable{
public CardData() { public CardData() {
...@@ -11,19 +14,18 @@ public class CardData implements Parcelable{ ...@@ -11,19 +14,18 @@ public class CardData implements Parcelable{
public CardData(int code) { public CardData(int code) {
Code = code; Code = code;
} }
public int Code; public int Code;
public int Ot; public int Ot;
public int Alias; public int Alias;
public long Setcode; public long SetCode;
public long Type; public long Type;
public int Level; public int Level;
public int Attribute; public int Attribute;
public long Race; public long Race;
public int Attack; public int Attack;
public int Defense; public int Defense;
public int LScale; public int LeftScale;
public int RScale; public int RightScale;
public long Category; public long Category;
@Override @Override
...@@ -32,15 +34,15 @@ public class CardData implements Parcelable{ ...@@ -32,15 +34,15 @@ public class CardData implements Parcelable{
"Code=" + Code + "Code=" + Code +
", Ot=" + Ot + ", Ot=" + Ot +
", Alias=" + Alias + ", Alias=" + Alias +
", Setcode=" + Setcode + ", Setcode=" + SetCode +
", Type=" + Type + ", Type=" + Type +
", Level=" + Level + ", Level=" + Level +
", Attribute=" + Attribute + ", Attribute=" + Attribute +
", Race=" + Race + ", Race=" + Race +
", Attack=" + Attack + ", Attack=" + Attack +
", Defense=" + Defense + ", Defense=" + Defense +
", LScale=" + LScale + ", LScale=" + LeftScale +
", RScale=" + RScale + ", RScale=" + RightScale +
", Category=" + Category + ", Category=" + Category +
'}'; '}';
} }
...@@ -55,15 +57,15 @@ public class CardData implements Parcelable{ ...@@ -55,15 +57,15 @@ public class CardData implements Parcelable{
dest.writeInt(this.Code); dest.writeInt(this.Code);
dest.writeInt(this.Ot); dest.writeInt(this.Ot);
dest.writeInt(this.Alias); dest.writeInt(this.Alias);
dest.writeLong(this.Setcode); dest.writeLong(this.SetCode);
dest.writeLong(this.Type); dest.writeLong(this.Type);
dest.writeInt(this.Level); dest.writeInt(this.Level);
dest.writeInt(this.Attribute); dest.writeInt(this.Attribute);
dest.writeLong(this.Race); dest.writeLong(this.Race);
dest.writeInt(this.Attack); dest.writeInt(this.Attack);
dest.writeInt(this.Defense); dest.writeInt(this.Defense);
dest.writeInt(this.LScale); dest.writeInt(this.LeftScale);
dest.writeInt(this.RScale); dest.writeInt(this.RightScale);
dest.writeLong(this.Category); dest.writeLong(this.Category);
} }
...@@ -71,15 +73,15 @@ public class CardData implements Parcelable{ ...@@ -71,15 +73,15 @@ public class CardData implements Parcelable{
this.Code = in.readInt(); this.Code = in.readInt();
this.Ot = in.readInt(); this.Ot = in.readInt();
this.Alias = in.readInt(); this.Alias = in.readInt();
this.Setcode = in.readLong(); this.SetCode = in.readLong();
this.Type = in.readLong(); this.Type = in.readLong();
this.Level = in.readInt(); this.Level = in.readInt();
this.Attribute = in.readInt(); this.Attribute = in.readInt();
this.Race = in.readLong(); this.Race = in.readLong();
this.Attack = in.readInt(); this.Attack = in.readInt();
this.Defense = in.readInt(); this.Defense = in.readInt();
this.LScale = in.readInt(); this.LeftScale = in.readInt();
this.RScale = in.readInt(); this.RightScale = in.readInt();
this.Category = in.readLong(); this.Category = in.readLong();
} }
...@@ -94,4 +96,5 @@ public class CardData implements Parcelable{ ...@@ -94,4 +96,5 @@ public class CardData implements Parcelable{
return new CardData[size]; return new CardData[size];
} }
}; };
} }
package ocgcore.enums; package ocgcore.enums;
import androidx.annotation.Nullable;
public enum CardAttribute { public enum CardAttribute {
None(0), None(0),
Earth(0x01), Earth(0x01, 1010),
Water(0x02), Water(0x02, 1011),
Fire(0x04), Fire(0x04, 1012),
Wind(0x08), Wind(0x08, 1013),
Light(0x10), Light(0x10, 1014),
Dark(0x20), Dark(0x20, 1015),
Divine(0x40); Divine(0x40, 1016);
private long value = 0;
private final int lang_index;
private int value = 0; public int getLanguageIndex() {
return lang_index;
}
CardAttribute(long value){
this(value, 0);
}
private CardAttribute(int value) { CardAttribute(long value, int lang_index) {
this.value = value; this.value = value;
this.lang_index = lang_index;
} }
public static CardAttribute valueOf(int value) { public static @Nullable CardAttribute valueOf(long value) {
CardAttribute[] attributes = CardAttribute.values(); CardAttribute[] attributes = CardAttribute.values();
for (CardAttribute attribute : attributes) { for (CardAttribute attribute : attributes) {
if (attribute.value() == value) { if (attribute.getId() == value) {
return attribute; return attribute;
} }
} }
return null; return null;
} }
public int value() { public long getId() {
return this.value; return this.value;
} }
} }
\ No newline at end of file
...@@ -2,42 +2,53 @@ package ocgcore.enums; ...@@ -2,42 +2,53 @@ package ocgcore.enums;
public enum CardCategory { public enum CardCategory {
None(0), None(0),
DESTROY(0x1),//破坏效果 DESTROY(0x1, 1100),//破坏效果
RELEASE(0x2),//解放效果 RELEASE(0x2, 1101),//解放效果
REMOVE(0x4),//除外效果 REMOVE(0x4, 1102),//除外效果
TOHAND(0x8),//加入手牌效果 TOHAND(0x8, 1103),//加入手牌效果
TODECK(0x10),//回卡组效果 TODECK(0x10, 1104),//回卡组效果
TOGRAVE(0x20),//送去墓地效果 TOGRAVE(0x20, 1105),//送去墓地效果
DECKDES(0x40),//卡组破坏效果 DECKDES(0x40, 1106),//卡组破坏效果
HANDES(0x80),//手牌破坏效果 HANDES(0x80, 1107),//手牌破坏效果
SUMMON(0x100),//含召唤的效果 SUMMON(0x100, 1108),//含召唤的效果
SPECIAL_SUMMON(0x200),//含特殊召唤的效果 SPECIAL_SUMMON(0x200, 1109),//含特殊召唤的效果
TOKEN(0x400),//含衍生物效果 TOKEN(0x400, 1110),//含衍生物效果
FLIP(0x800),//含翻转效果 FLIP(0x800, 1111),//含翻转效果
POSITION(0x1000),//改变表示形式效果 POSITION(0x1000, 1112),//改变表示形式效果
CONTROL(0x2000),//改变控制权效果 CONTROL(0x2000, 1113),//改变控制权效果
DISABLE(0x4000),//使效果无效效果 DISABLE(0x4000, 1114),//使效果无效效果
DISABLE_SUMMON(0x8000),//无效召唤效果 DISABLE_SUMMON(0x8000, 1115),//无效召唤效果
DRAW(0x10000),//抽卡效果 DRAW(0x10000, 1116),//抽卡效果
SEARCH(0x20000),//检索卡组效果 SEARCH(0x20000, 1117),//检索卡组效果
EQUIP(0x40000),//装备效果 EQUIP(0x40000, 1118),//装备效果
DAMAGE(0x80000),//伤害效果 DAMAGE(0x80000, 1119),//伤害效果
RECOVER(0x100000),//回复效果 RECOVER(0x100000, 1120),//回复效果
ATKCHANGE(0x200000),//改变攻击效果 ATKCHANGE(0x200000, 1121),//改变攻击效果
DEFCHANGE(0x400000),//改变防御效果 DEFCHANGE(0x400000, 1122),//改变防御效果
COUNTER(0x800000),//指示物效果 COUNTER(0x800000, 1123),//指示物效果
COIN(0x1000000),//硬币效果 COIN(0x1000000, 1124),//硬币效果
DICE(0x2000000),//骰子效果 DICE(0x2000000, 1125),//骰子效果
LEAVE_GRAVE(0x4000000),//离开墓地效果 LEAVE_GRAVE(0x4000000, 1126),//离开墓地效果
LVCHANGE(0x8000000),//改变等级效果 LVCHANGE(0x8000000, 1127),//改变等级效果
NEGATE(0x10000000),//使发动无效效果 NEGATE(0x10000000, 1128),//融合相关
ANNOUNCE(0x20000000),//發動時宣言卡名的效果 ANNOUNCE(0x20000000, 1129),//同调相关
FUSION_SUMMON(0x40000000), FUSION_SUMMON(0x40000000, 1130),//超量相关
NEGATE_EFFECT(0x80000000L);//效果无效 NEGATE_EFFECT(0x80000000L, 1131);//效果无效
private long value = 0; private long value = 0;
private final int lang_index;
public int getLanguageIndex() {
return lang_index;
}
CardCategory(long value){
this(value, 0);
}
private CardCategory(long value) { CardCategory(long value, int lang_index) {
this.value = value; this.value = value;
this.lang_index = lang_index;
} }
public static CardCategory valueOf(long value) { public static CardCategory valueOf(long value) {
......
package ocgcore.enums; package ocgcore.enums;
import androidx.annotation.Nullable;
public enum CardOt { public enum CardOt {
All, ALL(0, 1486),
OCG, OCG(1, 1481),
TCG, TCG(2, 1482),
SC_OCG, CUSTOM(4, 1484),
CUSTOM, SC_OCG(8, 1483),
OCG_TCG NO_EXCLUSIVE(3, 1485);
private final int value;
//1240
private final int lang_index;
CardOt(int value) {
this(value, 0);
}
CardOt(int value, int lang_index) {
this.value = value;
this.lang_index = lang_index;
}
public int getLanguageIndex() {
return lang_index;
}
public int getId() {
return value;
}
public static @Nullable CardOt valueOf(int value) {
for (CardOt cardOt : values()) {
if (cardOt.value == value) {
return cardOt;
}
}
return null;
}
} }
package ocgcore.enums; package ocgcore.enums;
import androidx.annotation.Nullable;
public enum CardRace { public enum CardRace {
None(0), None(0),
Warrior(0x1), Warrior(0x1, 1020),
BestWarrior(0x8000), BestWarrior(0x8000, 1021),
SpellCaster(0x2), SpellCaster(0x2, 1022),
Fairy(0x4), Fairy(0x4, 1023),
Fiend(0x8), Fiend(0x8, 1024),
Zombie(0x10), Zombie(0x10, 1025),
Machine(0x20), Machine(0x20, 1026),
Aqua(0x40), Aqua(0x40, 1027),
Pyro(0x80), Pyro(0x80, 1028),
Rock(0x100), Rock(0x100, 1029),
WindBeast(0x200), WindBeast(0x200, 1030),
Plant(0x400), Plant(0x400, 1031),
Insect(0x800), Insect(0x800, 1032),
Thunder(0x1000), Thunder(0x1000, 1033),
Dragon(0x2000), Dragon(0x2000, 1034),
Beast(0x4000), Beast(0x4000, 1035),
Dinosaur(0x10000), Dinosaur(0x10000, 1036),
Fish(0x20000), Fish(0x20000, 1037),
SeaSerpent(0x40000), SeaSerpent(0x40000, 1038),
Reptile(0x80000), Reptile(0x80000, 1039),
Psycho(0x100000), Psycho(0x100000, 1040),
DivineBeast(0x200000), DivineBeast(0x200000, 1041),
Creatorgod(0x400000), Creatorgod(0x400000, 1042),
Wyrm(0x800000), Wyrm(0x800000, 1043),
Cyberse(0x1000000); Cyberse(0x1000000, 1044);
private long value = 0; private long value = 0;
private final int lang_index;
public int getLanguageIndex() {
return lang_index;
}
CardRace(long value){
this(value, 0);
}
private CardRace(long value) { CardRace(long value, int lang_index) {
this.value = value; this.value = value;
this.lang_index = lang_index;
} }
public static CardRace valueOf(long value) { public static @Nullable CardRace valueOf(long value) {
CardRace[] attributes = CardRace.values(); CardRace[] attributes = CardRace.values();
for (CardRace attribute : attributes) { for (CardRace attribute : attributes) {
if (attribute.value() == value) { if (attribute.value() == value) {
......
package ocgcore.enums; package ocgcore.enums;
import androidx.annotation.Nullable;
public enum CardType { public enum CardType {
None(0), None(0),
Normal(0x10), Monster(0x1, 1050),
Effect(0x20), Spell(0x2, 1051),
Fusion(0x40), Trap(0x4, 1052),
Ritual(0x80), UNK1(0x8, 1053),
Synchro(0x2000), Normal(0x10, 1054),
Pendulum(0x1000000L), Effect(0x20, 1055),
Xyz(0x800000L), Fusion(0x40, 1056),
Link(0x4000000L), Ritual(0x80, 1057),
Non_Effect(0x8000000L), TrapMonster(0x100, 1058),
Spirit(0x200, 1059),
Spirit(0x200), Union(0x400, 1060),
Union(0x400), Dual(0x800, 1061),
Dual(0x800), Tuner(0x1000, 1062),
Tuner(0x1000), Synchro(0x2000, 1063),
Flip(0x200000), Token(0x4000, 1064),
Toon(0x400000), UNK2(0x8000, 1065),
Sp_Summon(0x2000000), QuickPlay(0x10000, 1066),
Continuous(0x20000, 1067),
QuickPlay(0x10000), Equip(0x40000, 1068),
Continuous(0x20000), Field(0x80000, 1069),
Equip(0x40000), Counter(0x100000, 1070),
Field(0x80000), Flip(0x200000, 1071),
Counter(0x100000), Toon(0x400000, 1072),
Xyz(0x800000, 1073),
Monster(0x1), Pendulum(0x1000000, 1074),
Spell(0x2), Sp_Summon(0x2000000, 1075),
TrapMonster(0x100), Link(0x4000000, 1076),
Trap(0x4), Non_Effect(0x8000000, 1077);
Token(0x4000);
private long value = 0; private long value = 0;
private final int lang_index;
public int getLanguageIndex() {
return lang_index;
}
CardType(long value){
this(value, 0);
}
private CardType(long value) { CardType(long value, int lang_index) {
this.value = value; this.value = value;
this.lang_index = lang_index;
} }
public static CardType valueOf(long value) { public static @Nullable CardType valueOf(long value) {
CardType[] attributes = CardType.values(); CardType[] attributes = CardType.values();
for (CardType attribute : attributes) { for (CardType attribute : attributes) {
if (attribute.value() == value) { if (attribute.getId() == value) {
return attribute; return attribute;
} }
} }
return null; return null;
} }
public long value() { public long getId() {
return this.value; return this.value;
} }
} }
package ocgcore.enums; package ocgcore.enums;
import androidx.annotation.Nullable;
public enum LimitType { public enum LimitType {
None(0), None(0),
All(999), All(999, 1310),
Forbidden(1), Forbidden(1, 1316),
Limit(2), Limit(2, 1317),
SemiLimit(3); SemiLimit(3, 1318);
private long value = 0; private long value = 0;
private final int lang_index;
public int getLanguageIndex() {
return lang_index;
}
LimitType(long value){
this(value, 0);
}
private LimitType(long value) { LimitType(long value, int lang_index) {
this.value = value; this.value = value;
this.lang_index = lang_index;
} }
public static LimitType valueOf(long value) { public static @Nullable LimitType valueOf(long value) {
LimitType[] attributes = LimitType.values(); LimitType[] attributes = LimitType.values();
for (LimitType attribute : attributes) { for (LimitType attribute : attributes) {
if (attribute.value() == value) { if (attribute.getId() == value) {
return attribute; return attribute;
} }
} }
return null; return null;
} }
public long value() { public long getId() {
return this.value; return this.value;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment