Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
da84bb33
Commit
da84bb33
authored
Jun 11, 2015
by
Fabio Bas
Browse files
Import related cards in the card database
parent
50b908c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
da84bb33
...
...
@@ -482,13 +482,15 @@ CardInfo::CardInfo(CardDatabase *_db,
const
QString
&
_powtough
,
const
QString
&
_text
,
const
QStringList
&
_colors
,
const
QStringList
&
_relatedCards
,
int
_loyalty
,
bool
_cipt
,
int
_tableRow
,
const
SetList
&
_sets
,
const
QStringMap
&
_customPicURLs
,
const
QStringMap
&
_customPicURLsHq
,
MuidMap
_muIds
)
MuidMap
_muIds
)
:
db
(
_db
),
name
(
_name
),
isToken
(
_isToken
),
...
...
@@ -499,6 +501,7 @@ CardInfo::CardInfo(CardDatabase *_db,
powtough
(
_powtough
),
text
(
_text
),
colors
(
_colors
),
relatedCards
(
_relatedCards
),
loyalty
(
_loyalty
),
customPicURLs
(
_customPicURLs
),
customPicURLsHq
(
_customPicURLsHq
),
...
...
@@ -685,6 +688,10 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
for
(
int
i
=
0
;
i
<
colors
.
size
();
i
++
)
xml
.
writeTextElement
(
"color"
,
colors
[
i
]);
const
QStringList
&
related
=
info
->
getRelatedCards
();
for
(
int
i
=
0
;
i
<
related
.
size
();
i
++
)
xml
.
writeTextElement
(
"related"
,
related
[
i
]);
xml
.
writeTextElement
(
"manacost"
,
info
->
getManaCost
());
xml
.
writeTextElement
(
"cmc"
,
info
->
getCmc
());
xml
.
writeTextElement
(
"type"
,
info
->
getCardType
());
...
...
@@ -852,7 +859,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
break
;
if
(
xml
.
name
()
==
"card"
)
{
QString
name
,
manacost
,
cmc
,
type
,
pt
,
text
;
QStringList
colors
;
QStringList
colors
,
relatedCards
;
QStringMap
customPicURLs
,
customPicURLsHq
;
MuidMap
muids
;
SetList
sets
;
...
...
@@ -890,6 +897,8 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
}
}
else
if
(
xml
.
name
()
==
"color"
)
colors
<<
xml
.
readElementText
();
else
if
(
xml
.
name
()
==
"related"
)
relatedCards
<<
xml
.
readElementText
();
else
if
(
xml
.
name
()
==
"tablerow"
)
tableRow
=
xml
.
readElementText
().
toInt
();
else
if
(
xml
.
name
()
==
"cipt"
)
...
...
@@ -901,7 +910,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
}
if
(
isToken
==
tokens
)
{
addCard
(
new
CardInfo
(
this
,
name
,
isToken
,
manacost
,
cmc
,
type
,
pt
,
text
,
colors
,
loyalty
,
cipt
,
tableRow
,
sets
,
customPicURLs
,
customPicURLsHq
,
muids
));
addCard
(
new
CardInfo
(
this
,
name
,
isToken
,
manacost
,
cmc
,
type
,
pt
,
text
,
colors
,
relatedCards
,
loyalty
,
cipt
,
tableRow
,
sets
,
customPicURLs
,
customPicURLsHq
,
muids
));
}
}
}
...
...
cockatrice/src/carddatabase.h
View file @
da84bb33
...
...
@@ -138,6 +138,7 @@ private:
bool
cipt
;
int
tableRow
;
QString
pixmapCacheKey
;
QStringList
relatedCards
;
public:
CardInfo
(
CardDatabase
*
_db
,
const
QString
&
_name
=
QString
(),
...
...
@@ -148,13 +149,15 @@ public:
const
QString
&
_powtough
=
QString
(),
const
QString
&
_text
=
QString
(),
const
QStringList
&
_colors
=
QStringList
(),
const
QStringList
&
_relatedCards
=
QStringList
(),
int
_loyalty
=
0
,
bool
_cipt
=
false
,
int
_tableRow
=
0
,
const
SetList
&
_sets
=
SetList
(),
const
QStringMap
&
_customPicURLs
=
QStringMap
(),
const
QStringMap
&
_customPicURLsHq
=
QStringMap
(),
MuidMap
muids
=
MuidMap
());
MuidMap
muids
=
MuidMap
()
);
~
CardInfo
();
const
QString
&
getName
()
const
{
return
name
;
}
const
QString
&
getSimpleName
()
const
{
return
simpleName
;
}
...
...
@@ -174,6 +177,7 @@ public:
void
setText
(
const
QString
&
_text
)
{
text
=
_text
;
emit
cardInfoChanged
(
this
);
}
void
setColors
(
const
QStringList
&
_colors
)
{
colors
=
_colors
;
emit
cardInfoChanged
(
this
);
}
const
QStringList
&
getColors
()
const
{
return
colors
;
}
const
QStringList
&
getRelatedCards
()
const
{
return
relatedCards
;
}
QString
getCustomPicURL
(
const
QString
&
set
)
const
{
return
customPicURLs
.
value
(
set
);
}
QString
getCustomPicURLHq
(
const
QString
&
set
)
const
{
return
customPicURLsHq
.
value
(
set
);
}
int
getMuId
(
const
QString
&
set
)
const
{
return
muIds
.
value
(
set
);
}
...
...
oracle/src/oracleimporter.cpp
View file @
da84bb33
...
...
@@ -65,7 +65,9 @@ CardInfo *OracleImporter::addCard(const QString &setName,
const
QString
&
cardPT
,
int
cardLoyalty
,
const
QString
&
cardText
,
const
QStringList
&
colors
)
const
QStringList
&
colors
,
const
QStringList
&
relatedCards
)
{
QStringList
cardTextRows
=
cardText
.
split
(
"
\n
"
);
bool
splitCard
=
false
;
...
...
@@ -97,7 +99,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
bool
cipt
=
cardText
.
contains
(
"Hideaway"
)
||
(
cardText
.
contains
(
cardName
+
" enters the battlefield tapped"
)
&&
!
cardText
.
contains
(
cardName
+
" enters the battlefield tapped unless"
));
card
=
new
CardInfo
(
this
,
cardName
,
isToken
,
cardCost
,
cmc
,
cardType
,
cardPT
,
cardText
,
colors
,
cardLoyalty
,
cipt
);
card
=
new
CardInfo
(
this
,
cardName
,
isToken
,
cardCost
,
cmc
,
cardType
,
cardPT
,
cardText
,
colors
,
relatedCards
,
cardLoyalty
,
cipt
);
int
tableRow
=
1
;
QString
mainCardType
=
card
->
getMainCardType
();
if
((
mainCardType
==
"Land"
)
||
mArtifact
)
...
...
@@ -147,6 +149,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
QString
cardPT
;
QString
cardText
;
QStringList
colors
;
QStringList
relatedCards
;
int
cardId
;
int
cardLoyalty
;
bool
cardIsToken
=
false
;
...
...
@@ -169,7 +172,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
cardLoyalty
=
0
;
// determine which subcard is the first one in the split
QStringList
names
=
map
.
contains
(
"names"
)
?
map
.
value
(
"names"
).
toStringList
()
:
QStringList
(
""
);
QStringList
names
=
map
.
contains
(
"names"
)
?
map
.
value
(
"names"
).
toStringList
()
:
QStringList
();
if
(
names
.
count
()
>
0
&&
map
.
contains
(
"name"
)
&&
0
==
QString
::
compare
(
map
.
value
(
"name"
).
toString
(),
names
.
at
(
0
)))
...
...
@@ -204,6 +207,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
extractColors
(
card2
->
value
(
"colors"
).
toStringList
(),
colors
);
colors
.
removeDuplicates
();
relatedCards
=
QStringList
();
}
else
{
// first card of a pair; enqueue for later merging
// Conditional on cardId because promo prints have no muid - see #640
...
...
@@ -222,6 +226,8 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
cardId
=
map
.
contains
(
"multiverseid"
)
?
map
.
value
(
"multiverseid"
).
toInt
()
:
0
;
cardLoyalty
=
map
.
contains
(
"loyalty"
)
?
map
.
value
(
"loyalty"
).
toInt
()
:
0
;
cardIsToken
=
map
.
value
(
"layout"
)
==
"token"
;
relatedCards
=
map
.
contains
(
"names"
)
?
map
.
value
(
"names"
).
toStringList
()
:
QStringList
();
relatedCards
.
removeAll
(
cardName
);
colors
.
clear
();
extractColors
(
map
.
value
(
"colors"
).
toStringList
(),
colors
);
...
...
@@ -233,7 +239,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
}
if
(
!
cardIsToken
)
{
CardInfo
*
card
=
addCard
(
set
->
getShortName
(),
cardName
,
cardIsToken
,
cardId
,
cardCost
,
cmc
,
cardType
,
cardPT
,
cardLoyalty
,
cardText
,
colors
);
CardInfo
*
card
=
addCard
(
set
->
getShortName
(),
cardName
,
cardIsToken
,
cardId
,
cardCost
,
cmc
,
cardType
,
cardPT
,
cardLoyalty
,
cardText
,
colors
,
relatedCards
);
if
(
!
set
->
contains
(
card
))
{
card
->
addToSet
(
set
);
...
...
oracle/src/oracleimporter.h
View file @
da84bb33
...
...
@@ -29,7 +29,7 @@ private:
QVariantMap
setsMap
;
QString
dataDir
;
CardInfo
*
addCard
(
const
QString
&
setName
,
QString
cardName
,
bool
isToken
,
int
cardId
,
QString
&
cardCost
,
QString
&
cmc
,
const
QString
&
cardType
,
const
QString
&
cardPT
,
int
cardLoyalty
,
const
QString
&
cardText
,
const
QStringList
&
colors
);
CardInfo
*
addCard
(
const
QString
&
setName
,
QString
cardName
,
bool
isToken
,
int
cardId
,
QString
&
cardCost
,
QString
&
cmc
,
const
QString
&
cardType
,
const
QString
&
cardPT
,
int
cardLoyalty
,
const
QString
&
cardText
,
const
QStringList
&
colors
,
const
QStringList
&
relatedCards
);
signals:
void
setIndexChanged
(
int
cardsImported
,
int
setIndex
,
const
QString
&
setName
);
void
dataReadProgress
(
int
bytesRead
,
int
totalBytes
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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