Kamalisk / arkhamdb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic Weakness randomizer can select invalid class-locked weaknesses

mikecheb opened this issue · comments

The Scarlet Keys introduced weaknesses which are only available to investigators of a specific class. The randomizer logic should be updated to prevent, for example, Pay Your Due (Rogue-only) from being selected for Agnes.

Presumably, this is where such logic would belong. Currently, the only filtering is for weaknesses in the user's collection:

ui.select_basic_weakness = function select_basic_weakness() {
// replace the random weakness card in the deck with a random weakness
var weaknesses = app.data.cards.find({"subtype_code" : "basicweakness"});
var filtered_weaknesses = [];
weaknesses.forEach(function (card){
//console.log(card);
if($("[name="+card.pack_code+"]").is(":checked") && card.code != "01000" && card.indeck < card.maxqty){
filtered_weaknesses.push(card);
}
});
if (filtered_weaknesses.length > 0){
var weakness = filtered_weaknesses[ Math.round(Math.random(0, 1) * (filtered_weaknesses.length-1)) ];
if ($(this) && $(this).data("random")){
ui.on_quantity_change($(this).data("random"), 0);
}
ui.on_quantity_change(weakness.code, weakness.indeck+1);
}
}

I might work on this if I find some time in the next week or two.