Commit 2a26ebc5 authored by qq247321453's avatar qq247321453

读取字符串改动

parent d94847e8
...@@ -122,18 +122,11 @@ public interface Constants { ...@@ -122,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 = 1239;
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;
......
...@@ -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,8 +112,12 @@ class CardSearchInfo { ...@@ -111,8 +112,12 @@ class CardSearchInfo {
} }
} }
} }
if (ot > 0) { if (ot > CardOt.ALL.getId()) {
if (card.Ot.getId() != ot) { if(ot == CardOt.NO_EXCLUSIVE.getId()){
if(card.Ot == CardOt.OCG.getId() || card.Ot == CardOt.TCG.getId()){
return false;
}
} else if (card.Ot != ot) {
return false; return false;
} }
} }
...@@ -136,7 +141,7 @@ class CardSearchInfo { ...@@ -136,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;
} }
...@@ -145,46 +150,52 @@ class CardSearchInfo { ...@@ -145,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;
......
...@@ -102,6 +102,9 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i ...@@ -102,6 +102,9 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, ViewHolder> i
@Override @Override
public void onBindViewHolder(ViewHolder holder, int position) { public void onBindViewHolder(ViewHolder holder, int position) {
Card item = getItem(position); Card item = getItem(position);
if(item == null){
return;
}
imageLoader.bindImage(holder.cardImage, item.Code); imageLoader.bindImage(holder.cardImage, item.Code);
holder.cardName.setText(item.Name); holder.cardName.setText(item.Name);
if (item.isType(CardType.Monster)) { if (item.isType(CardType.Monster)) {
......
...@@ -278,7 +278,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder { ...@@ -278,7 +278,7 @@ public class CardDetail extends BaseAdapterPlus.BaseViewHolder {
type.setText(CardUtils.getAllTypeString(cardInfo, mStringManager).replace("/", "|")); type.setText(CardUtils.getAllTypeString(cardInfo, mStringManager).replace("/", "|"));
attrView.setText(mStringManager.getAttributeString(cardInfo.Attribute)); attrView.setText(mStringManager.getAttributeString(cardInfo.Attribute));
otView.setText(mStringManager.getOtString(cardInfo.Ot.getId(), cardInfo.Ot.name())); otView.setText(mStringManager.getOtString(cardInfo.Ot));
long[] sets = cardInfo.getSetCode(); long[] sets = cardInfo.getSetCode();
setName.setText(""); setName.setText("");
int index = 0; int index = 0;
......
...@@ -233,7 +233,7 @@ public class CardSearcher implements View.OnClickListener { ...@@ -233,7 +233,7 @@ public class CardSearcher implements View.OnClickListener {
pScale.setVisibility(View.INVISIBLE); pScale.setVisibility(View.INVISIBLE);
LinkMarkerButton.setVisibility(View.INVISIBLE); LinkMarkerButton.setVisibility(View.INVISIBLE);
resetMonster(); resetMonster();
} else if (value == CardType.Spell.value()) { } else if (value == CardType.Spell.getId()) {
layout_monster.setVisibility(View.INVISIBLE); layout_monster.setVisibility(View.INVISIBLE);
raceSpinner.setVisibility(View.GONE); raceSpinner.setVisibility(View.GONE);
typeSpellSpinner.setVisibility(View.VISIBLE); typeSpellSpinner.setVisibility(View.VISIBLE);
...@@ -241,7 +241,7 @@ public class CardSearcher implements View.OnClickListener { ...@@ -241,7 +241,7 @@ public class CardSearcher implements View.OnClickListener {
pScale.setVisibility(View.INVISIBLE); pScale.setVisibility(View.INVISIBLE);
LinkMarkerButton.setVisibility(View.INVISIBLE); LinkMarkerButton.setVisibility(View.INVISIBLE);
resetMonster(); resetMonster();
} else if (value == CardType.Trap.value()) { } else if (value == CardType.Trap.getId()) {
layout_monster.setVisibility(View.INVISIBLE); layout_monster.setVisibility(View.INVISIBLE);
raceSpinner.setVisibility(View.GONE); raceSpinner.setVisibility(View.GONE);
typeSpellSpinner.setVisibility(View.GONE); typeSpellSpinner.setVisibility(View.GONE);
...@@ -328,21 +328,14 @@ public class CardSearcher implements View.OnClickListener { ...@@ -328,21 +328,14 @@ public class CardSearcher implements View.OnClickListener {
}*/ }*/
private void initOtSpinners(Spinner spinner) { private void initOtSpinners(Spinner spinner) {
CardOt[] ots = CardOt.values();
List<SimpleSpinnerItem> items = new ArrayList<>(); List<SimpleSpinnerItem> items = new ArrayList<>();
items.add(new SimpleSpinnerItem(0, getString(R.string.label_ot))); items.add(new SimpleSpinnerItem(0, getString(R.string.label_ot)));
for (CardOt item : ots) { for (CardOt item : CardOt.values()) {
if (item.ordinal() != 0) { if (item != CardOt.ALL) {
items.add(new SimpleSpinnerItem(item.ordinal(), items.add(new SimpleSpinnerItem(item.getId(),
mStringManager.getOtString(item.ordinal(), item.toString())) mStringManager.getOtString(item.getId())));
);
} }
}/* }
items.add(new SimpleSpinnerItem(1,"OCG"));
items.add(new SimpleSpinnerItem(2,"TCG"));
items.add(new SimpleSpinnerItem(3,"OCG&TCG"));
items.add(new SimpleSpinnerItem(4,"DIY"));
items.add(new SimpleSpinnerItem(8,"简中"));*/
SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext); SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext);
adapter.setColor(Color.WHITE); adapter.setColor(Color.WHITE);
adapter.setColor(Color.WHITE); adapter.setColor(Color.WHITE);
...@@ -362,13 +355,12 @@ public class CardSearcher implements View.OnClickListener { ...@@ -362,13 +355,12 @@ public class CardSearcher implements View.OnClickListener {
LimitType[] eitems = LimitType.values(); LimitType[] eitems = LimitType.values();
List<SimpleSpinnerItem> items = new ArrayList<>(); List<SimpleSpinnerItem> items = new ArrayList<>();
for (LimitType item : eitems) { for (LimitType item : eitems) {
long val = item.value(); if (item == LimitType.None) {
if (val == 0) { items.add(new SimpleSpinnerItem(item.getId(), getString(R.string.label_limit)));
items.add(new SimpleSpinnerItem(val, getString(R.string.label_limit))); } else if (item == LimitType.All) {
} else if (val == LimitType.All.value()) { items.add(new SimpleSpinnerItem(item.getId(), getString(R.string.all)));
items.add(new SimpleSpinnerItem(val, getString(R.string.all)));
} else { } else {
items.add(new SimpleSpinnerItem(val, mStringManager.getLimitString(val))); items.add(new SimpleSpinnerItem(item.getId(), mStringManager.getLimitString(item.getId())));
} }
} }
SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext); SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext);
...@@ -453,11 +445,10 @@ public class CardSearcher implements View.OnClickListener { ...@@ -453,11 +445,10 @@ public class CardSearcher implements View.OnClickListener {
} }
List<SimpleSpinnerItem> items = new ArrayList<>(); List<SimpleSpinnerItem> items = new ArrayList<>();
for (CardType item : eitems) { for (CardType item : eitems) {
long val = item.value(); if (item == CardType.None) {
if (val == 0) { items.add(new SimpleSpinnerItem(item.getId(), getString(R.string.label_type)));
items.add(new SimpleSpinnerItem(val, getString(R.string.label_type)));
} else { } else {
items.add(new SimpleSpinnerItem(val, mStringManager.getTypeString(val))); items.add(new SimpleSpinnerItem(item.getId(), mStringManager.getTypeString(item.getId())));
} }
} }
SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext); SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext);
...@@ -470,11 +461,10 @@ public class CardSearcher implements View.OnClickListener { ...@@ -470,11 +461,10 @@ public class CardSearcher implements View.OnClickListener {
CardAttribute[] attributes = CardAttribute.values(); CardAttribute[] attributes = CardAttribute.values();
List<SimpleSpinnerItem> items = new ArrayList<>(); List<SimpleSpinnerItem> items = new ArrayList<>();
for (CardAttribute item : attributes) { for (CardAttribute item : attributes) {
long val = item.value(); if (item == CardAttribute.None) {
if (val == 0) { items.add(new SimpleSpinnerItem(CardAttribute.None.getId(), getString(R.string.label_attr)));
items.add(new SimpleSpinnerItem(val, getString(R.string.label_attr)));
} else { } else {
items.add(new SimpleSpinnerItem(val, mStringManager.getAttributeString(val))); items.add(new SimpleSpinnerItem(item.getId(), mStringManager.getAttributeString(item.getId())));
} }
} }
SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext); SimpleSpinnerAdapter adapter = new SimpleSpinnerAdapter(mContext);
......
...@@ -73,11 +73,11 @@ public class CardSort implements Comparator<Card> { ...@@ -73,11 +73,11 @@ public class CardSort implements Comparator<Card> {
if(sortKey1 == SORT_SPELL || sortKey2 == SORT_TRAP){ if(sortKey1 == SORT_SPELL || sortKey2 == SORT_TRAP){
long type1, type2; long type1, type2;
if(sortKey1 == SORT_SPELL){ if(sortKey1 == SORT_SPELL){
type1 = c1.Type ^ CardType.Spell.value(); type1 = c1.Type ^ CardType.Spell.getId();
type2 = c2.Type ^ CardType.Spell.value(); type2 = c2.Type ^ CardType.Spell.getId();
} else { } else {
type1 = c1.Type ^ CardType.Trap.value(); type1 = c1.Type ^ CardType.Trap.getId();
type2 = c2.Type ^ CardType.Trap.value(); type2 = c2.Type ^ CardType.Trap.getId();
} }
int rs = comp(type1, type2); int rs = comp(type1, type2);
if (rs == 0) { if (rs == 0) {
...@@ -123,7 +123,7 @@ public class CardSort implements Comparator<Card> { ...@@ -123,7 +123,7 @@ public class CardSort implements Comparator<Card> {
if (rs != 0) { if (rs != 0) {
return rs; return rs;
} }
rs = comp(c1.Ot.getId(), c2.Ot.getId()); rs = comp(c1.Ot, c2.Ot);
if (rs != 0) { if (rs != 0) {
return rs; return rs;
} }
......
...@@ -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,7 @@ import cn.garymb.ygomobile.App; ...@@ -28,6 +28,7 @@ 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; import ocgcore.enums.CardOt;
...@@ -192,7 +193,7 @@ public class CardManager { ...@@ -192,7 +193,7 @@ public class CardManager {
do { do {
Card cardData = new Card(); Card cardData = new Card();
cardData.Code = reader.getInt(0); cardData.Code = reader.getInt(0);
cardData.Ot = CardOt.of(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);
......
...@@ -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,71 @@ public class StringManager implements Closeable { ...@@ -195,71 +201,71 @@ 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;
}
public String getLimitString(long value) { try {
// String str = String str = mSystem.get(index);
// Log.d("kk", value + "=" + str); if (TextUtils.isEmpty(str)) {
return getSystemString((int) (Constants.STRING_LIMIT_START + value)); return def;
}
return StringUtils.toDBC(str);
} catch (Exception e) {
return def;
}
} }
public String getTypeString(long value) { public String getLimitString(long id) {
return getSystemString(Constants.STRING_TYPE_START, value); LimitType value = LimitType.valueOf(id);
if(value == null){
return String.valueOf(id);
}
return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getAttributeString(long value) { public String getTypeString(long id) {
return getSystemString(Constants.STRING_ATTRIBUTE_START, value); CardType value = CardType.valueOf(id);
if(value == null){
return String.valueOf(id);
}
return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getRaceString(long value) { public String getAttributeString(long id) {
String race = getSystemString(Constants.STRING_RACE_START, value); CardAttribute value = CardAttribute.valueOf(id);
if (TextUtils.isEmpty(race)) { if(value == null){
return String.format("0x%X", value); return String.valueOf(id);
} }
return race; return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getOtString(int ot, String def) { public String getRaceString(long id) {
if (ot == CardOt.All.ordinal()) { CardRace value = CardRace.valueOf(id);
return "-"; if(value == null){
} return String.format("0x%x", id);
try {
String str = getSystemString(Constants.STRING_OT_START + ot);
if (TextUtils.isEmpty(str)) {
return def;//String.valueOf(CardOt.values()[ot]);
}
return StringUtils.toDBC(str);
} catch (Exception e) {
return def;
} }
return getSystemString(value.getLanguageIndex(), value.name());
} }
public String getCategoryString(long value) { public String getOtString(int ot) {
return getSystemString(Constants.STRING_CATEGORY_START, value); CardOt value = CardOt.valueOf(ot);
if(value == null){
return String.valueOf(ot);
}
return getSystemString(value.getLanguageIndex(), value.name());
} }
public int value2Index(long type) { public String getCategoryString(long id) {
//0 1 2 3 4 CardCategory value = CardCategory.valueOf(id);
//1 2 4 8 16 if(value == null){
int i = 0; return String.valueOf(id);
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) {
......
...@@ -63,7 +63,7 @@ public class Card extends CardData implements Parcelable { ...@@ -63,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) {
...@@ -88,11 +88,11 @@ public class Card extends CardData implements Parcelable { ...@@ -88,11 +88,11 @@ public class Card extends CardData implements Parcelable {
} }
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() {
......
...@@ -3,6 +3,7 @@ package ocgcore.data; ...@@ -3,6 +3,7 @@ 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; import ocgcore.enums.CardOt;
public class CardData implements Parcelable{ public class CardData implements Parcelable{
...@@ -14,7 +15,7 @@ public class CardData implements Parcelable{ ...@@ -14,7 +15,7 @@ public class CardData implements Parcelable{
Code = code; Code = code;
} }
public int Code; public int Code;
public CardOt Ot; public int Ot;
public int Alias; public int Alias;
public long SetCode; public long SetCode;
public long Type; public long Type;
...@@ -54,7 +55,7 @@ public class CardData implements Parcelable{ ...@@ -54,7 +55,7 @@ public class CardData implements Parcelable{
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.Code); dest.writeInt(this.Code);
dest.writeInt(this.Ot.getId()); 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);
...@@ -70,7 +71,7 @@ public class CardData implements Parcelable{ ...@@ -70,7 +71,7 @@ public class CardData implements Parcelable{
protected CardData(Parcel in) { protected CardData(Parcel in) {
this.Code = in.readInt(); this.Code = in.readInt();
this.Ot = CardOt.of(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();
......
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(0), ALL(0),
OCG(1), OCG(1, 1240),
TCG(2), TCG(2, 1241),
NO_EXCLUSIVE(3), NO_EXCLUSIVE(3, 1242),
CUSTOM(4), CUSTOM(4, 1243),
SC_OCG(8), SC_OCG(8);
UNKNOWN(999);/*简中*/
private final int value; private final int value;
//1240
private final int lang_index;
CardOt(int value) {
this(value, 0);
}
private CardOt(int value) { CardOt(int value, int lang_index) {
this.value = value; this.value = value;
this.lang_index = lang_index;
}
public int getLanguageIndex() {
return lang_index;
} }
public int getId(){ public int getId() {
return value; return value;
} }
public static CardOt of(int value){ public static @Nullable CardOt valueOf(int value) {
for(CardOt cardOt: values()){ for (CardOt cardOt : values()) {
if(cardOt.value == value){ if (cardOt.value == value) {
return cardOt; return cardOt;
} }
} }
return UNKNOWN; 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