Skip to content

Deck Import finds the wrong Hero card #354

@phantom42

Description

@phantom42

The app.data.findOne({name: name}) brings back the first card with that name. But since there can be multiple cards with the same name, it does not always bring back the right card. Searching for "Bishop", for example, brings back his ally card from Gambit, not his hero card. Because the card's type_code is not 'hero', hero_code is never set and the import is rejected.

text.match(name_regexp).forEach(function (token) {
var qty = 1, name = token.trim(), card;
if(token[0] === '(') {
return;
}
if(name.match(/^(\d+)x ([^()]*)/)) {
qty = parseInt(RegExp.$1, 10);
name = RegExp.$2.trim();
}
console.log(name);
if(card = app.data.cards.findOne({ name: name })) {
if (card.type_code == "hero"){
hero_code = card.code;
hero_name = card.name;
} else {
slots[card.code] = qty;
}
}
else {
console.log('rejecting string ['+name+']');
}
})

if (!hero_code){
window.alert("Unable to locate hero");
return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions