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
48d588f6
Commit
48d588f6
authored
Mar 29, 2015
by
Fabio Bas
Browse files
Fix #670
Additionally, remove an unneeded split() + join() call on every card text
parent
49c1eec3
Changes
2
Hide whitespace changes
Inline
Side-by-side
oracle/src/oracleimporter.cpp
View file @
48d588f6
...
@@ -69,9 +69,9 @@ CardInfo *OracleImporter::addCard(const QString &setName,
...
@@ -69,9 +69,9 @@ CardInfo *OracleImporter::addCard(const QString &setName,
const
QString
&
cardType
,
const
QString
&
cardType
,
const
QString
&
cardPT
,
const
QString
&
cardPT
,
int
cardLoyalty
,
int
cardLoyalty
,
const
QString
List
&
cardText
)
const
QString
&
cardText
)
{
{
QString
fullC
ardText
=
cardText
.
join
(
"
\n
"
);
QString
List
c
ardText
Rows
=
cardText
.
split
(
"
\n
"
);
bool
splitCard
=
false
;
bool
splitCard
=
false
;
if
(
cardName
.
contains
(
'('
))
{
if
(
cardName
.
contains
(
'('
))
{
cardName
.
remove
(
QRegExp
(
"
\\
(.*
\\
)"
));
cardName
.
remove
(
QRegExp
(
"
\\
(.*
\\
)"
));
...
@@ -90,13 +90,13 @@ CardInfo *OracleImporter::addCard(const QString &setName,
...
@@ -90,13 +90,13 @@ CardInfo *OracleImporter::addCard(const QString &setName,
CardInfo
*
card
;
CardInfo
*
card
;
if
(
cards
.
contains
(
cardName
))
{
if
(
cards
.
contains
(
cardName
))
{
card
=
cards
.
value
(
cardName
);
card
=
cards
.
value
(
cardName
);
if
(
splitCard
&&
!
card
->
getText
().
contains
(
fullC
ardText
))
if
(
splitCard
&&
!
card
->
getText
().
contains
(
c
ardText
))
card
->
setText
(
card
->
getText
()
+
"
\n
---
\n
"
+
fullC
ardText
);
card
->
setText
(
card
->
getText
()
+
"
\n
---
\n
"
+
c
ardText
);
}
else
{
}
else
{
bool
mArtifact
=
false
;
bool
mArtifact
=
false
;
if
(
cardType
.
endsWith
(
"Artifact"
))
if
(
cardType
.
endsWith
(
"Artifact"
))
for
(
int
i
=
0
;
i
<
cardText
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
cardText
Rows
.
size
();
++
i
)
if
(
cardText
[
i
].
contains
(
"{T}"
)
&&
cardText
[
i
].
contains
(
"to your mana pool"
))
if
(
cardText
Rows
[
i
].
contains
(
"{T}"
)
&&
cardText
Rows
[
i
].
contains
(
"to your mana pool"
))
mArtifact
=
true
;
mArtifact
=
true
;
QStringList
colors
;
QStringList
colors
;
...
@@ -105,20 +105,21 @@ CardInfo *OracleImporter::addCard(const QString &setName,
...
@@ -105,20 +105,21 @@ CardInfo *OracleImporter::addCard(const QString &setName,
if
(
cardCost
.
contains
(
allColors
[
i
]))
if
(
cardCost
.
contains
(
allColors
[
i
]))
colors
<<
allColors
[
i
];
colors
<<
allColors
[
i
];
if
(
cardText
.
contains
(
cardName
+
" is white."
))
if
(
cardText
Rows
.
contains
(
cardName
+
" is white."
))
colors
<<
"W"
;
colors
<<
"W"
;
if
(
cardText
.
contains
(
cardName
+
" is blue."
))
if
(
cardText
Rows
.
contains
(
cardName
+
" is blue."
))
colors
<<
"U"
;
colors
<<
"U"
;
if
(
cardText
.
contains
(
cardName
+
" is black."
))
if
(
cardText
Rows
.
contains
(
cardName
+
" is black."
))
colors
<<
"B"
;
colors
<<
"B"
;
if
(
cardText
.
contains
(
cardName
+
" is red."
))
if
(
cardText
Rows
.
contains
(
cardName
+
" is red."
))
colors
<<
"R"
;
colors
<<
"R"
;
if
(
cardText
.
contains
(
cardName
+
" is green."
))
if
(
cardText
Rows
.
contains
(
cardName
+
" is green."
))
colors
<<
"G"
;
colors
<<
"G"
;
bool
cipt
=
(
cardText
.
contains
(
cardName
+
" enters the battlefield tapped."
));
bool
cipt
=
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
,
fullC
ardText
,
colors
,
cardLoyalty
,
cipt
);
card
=
new
CardInfo
(
this
,
cardName
,
isToken
,
cardCost
,
cmc
,
cardType
,
cardPT
,
c
ardText
,
colors
,
cardLoyalty
,
cipt
);
int
tableRow
=
1
;
int
tableRow
=
1
;
QString
mainCardType
=
card
->
getMainCardType
();
QString
mainCardType
=
card
->
getMainCardType
();
if
((
mainCardType
==
"Land"
)
||
mArtifact
)
if
((
mainCardType
==
"Land"
)
||
mArtifact
)
...
@@ -225,7 +226,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
...
@@ -225,7 +226,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
}
}
if
(
!
cardIsToken
)
{
if
(
!
cardIsToken
)
{
CardInfo
*
card
=
addCard
(
set
->
getShortName
(),
cardName
,
cardIsToken
,
cardId
,
cardCost
,
cmc
,
cardType
,
cardPT
,
cardLoyalty
,
cardText
.
split
(
"
\n
"
)
);
CardInfo
*
card
=
addCard
(
set
->
getShortName
(),
cardName
,
cardIsToken
,
cardId
,
cardCost
,
cmc
,
cardType
,
cardPT
,
cardLoyalty
,
cardText
);
if
(
!
set
->
contains
(
card
))
{
if
(
!
set
->
contains
(
card
))
{
card
->
addToSet
(
set
);
card
->
addToSet
(
set
);
...
...
oracle/src/oracleimporter.h
View file @
48d588f6
...
@@ -32,7 +32,7 @@ private:
...
@@ -32,7 +32,7 @@ private:
QVariantMap
setsMap
;
QVariantMap
setsMap
;
QString
dataDir
;
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
List
&
cardText
);
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
);
signals:
signals:
void
setIndexChanged
(
int
cardsImported
,
int
setIndex
,
const
QString
&
setName
);
void
setIndexChanged
(
int
cardsImported
,
int
setIndex
,
const
QString
&
setName
);
void
dataReadProgress
(
int
bytesRead
,
int
totalBytes
);
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