Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add speed/strength/control/synergy metadata to "description" #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/com/blueraja/magicduelsimporter/magicassist/Deck.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ public class Deck {
private final String _name;
private Map<CardData, Integer> _cards = new HashMap<>();

private float scoreSpeed;
private float scoreStrength;
private float scoreControl;
private float scoreSynergy;
private int onlineDeckNumber;

public Deck(String name) {
_name = name;
}
Expand Down Expand Up @@ -45,4 +51,49 @@ public int getCardCount(CardData cardData) {
public String getName() {
return _name;
}

public float getScoreSpeed() {
return scoreSpeed;
}

public void setScoreSpeed(float scoreSpeed) {
this.scoreSpeed = scoreSpeed;
}

public float getScoreStrength() {
return scoreStrength;
}

public void setScoreStrength(float scoreStrength) {
this.scoreStrength = scoreStrength;
}

public float getScoreControl() {
return scoreControl;
}

public void setScoreControl(float scoreControl) {
this.scoreControl = scoreControl;
}

public float getScoreSynergy() {
return scoreSynergy;
}

public void setScoreSynergy(float scoreSynergy) {
this.scoreSynergy = scoreSynergy;
}

public int getOnlineDeckNumber() {
return onlineDeckNumber;
}

public void setOnlineDeckNumber(int onlineDeckNumber) {
this.onlineDeckNumber = onlineDeckNumber;
}

public String getDescription() {
return String.format("Speed: %.3f\nStrength: %.3f\nControl: %.3f\nSynergy: %.3f\nOnline Deck Number: %d",
getScoreSpeed(), getScoreStrength(), getScoreControl(), getScoreSynergy(), getOnlineDeckNumber());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ private void addMetadata(Deck deck, Document doc, Element rootElement, boolean i
typeElement.setTextContent(isCollection ? "collection" : "deck");
rootElement.appendChild(typeElement);

Element commentElement = doc.createElement("comment");
commentElement.setTextContent(isCollection ? "Magic Duels collection." : deck.getDescription());
rootElement.appendChild((commentElement));

Element propertiesElement = doc.createElement("properties");
rootElement.appendChild(propertiesElement);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public Iterable<Deck> getDecks() throws IOException {
for (int deckPos=0; deckPos<32; deckPos++) {
MagicDuelsDeck magicDuelsDeck = profile.readDeck(deckPos);
Deck deck = new Deck(magicDuelsDeck.name);

deck.setScoreSpeed(magicDuelsDeck.values[0]);
deck.setScoreStrength(magicDuelsDeck.values[1]);
deck.setScoreControl(magicDuelsDeck.values[2]);
deck.setScoreSynergy(magicDuelsDeck.values[3]);
deck.setOnlineDeckNumber(magicDuelsDeck.onlineDeckNumber);

for (int i=0; i<100; i++) {
int cardId = magicDuelsDeck.cards[0][i];
int numCards = magicDuelsDeck.cards[1][i];
Expand Down