Instructions on how to search only for monsters whose sum of ATK and DEF equal a specific value in the Deck Constructor
Posted: Sat Aug 12, 2023 10:30 pm
There is currently an official card called Card of the Soul which lets you add from your deck to your hand a monster whose sum of ATK and DEF equal your life point total. However, there was until now no easy way to know exactly which cards you could search with this depending on said life point total.
After going through some of duelingbook's code to see how searching in the Deck Constructor works, I managed to make a javascript command that lets you input any number from 1 to 9999 to search only for monsters whose sum of ATK and DEF match that number.
Create a new bookmark, name it whatever you want (I choose to name mine "search sum of ATK and DEF"), and in the URL/Address box, copy and paste this code:
Save your bookmark.

Go to the Deck Constructor, click the bookmark, input your value, and either hit Enter or click OK. To change pages, use the OK and Cancel buttons on that same bookmark, not the arrows on the Deck Constructor itself. Clicking either of the arrows, or the Search button, in the Deck Constructor will reset the search, bringing back all cards.

You can combine this with the Deck Constructor's own search parameters. For example, you can search only for WIND Winged Beast monsters whose sum of ATK and DEF equal 3500.

This currently doesn't work with custom cards, Goat Format Only cards, or Speed Duel Only cards.
After going through some of duelingbook's code to see how searching in the Deck Constructor works, I managed to make a javascript command that lets you input any number from 1 to 9999 to search only for monsters whose sum of ATK and DEF match that number.
Create a new bookmark, name it whatever you want (I choose to name mine "search sum of ATK and DEF"), and in the URL/Address box, copy and paste this code:
Code: Select all
javascript:function searchCardsE3(LifePointsToAddUpTo) {
var arrows = "";
arrows += ~~($('#search').find('.arrow1 img').attr("src").indexOf("red") >= 0);
arrows += ~~($('#search').find('.arrow2 img').attr("src").indexOf("red") >= 0);
arrows += ~~($('#search').find('.arrow3 img').attr("src").indexOf("red") >= 0);
arrows += ~~($('#search').find('.arrow4 img').attr("src").indexOf("red") >= 0);
arrows += ~~($('#search').find('.arrow5 img').attr("src").indexOf("red") >= 0);
arrows += ~~($('#search').find('.arrow6 img').attr("src").indexOf("red") >= 0);
arrows += ~~($('#search').find('.arrow7 img').attr("src").indexOf("red") >= 0);
arrows += ~~($('#search').find('.arrow8 img').attr("src").indexOf("red") >= 0);
var order = $('#search').find('.order_cb').val();
saved_search = {
"name": $('#search').find('.name_txt').val().trim(),
"effect": $('#search').find('.desc_txt').val(),
"card_type": $('#search').find('.card_cb').val(),
"monster_color": $('#search').find('.card2_cb').val(),
"type": str($('#search').find('.type_cb').val()),
"ability": $('#search').find('.type2_cb').val(),
"attribute": $('#search').find('.attrib_cb').val(),
"level_low": $('#search').find('.lvll_txt').val(),
"level_high": $('#search').find('.lvlh_txt').val(),
"atk_low": $('#search').find('.atkl_txt').val(),
"atk_high": $('#search').find('.atkh_txt').val(),
"def_low": $('#search').find('.defl_txt').val(),
"def_high": $('#search').find('.defh_txt').val(),
"limit": $('#search').find('.limit_cb').val(),
"order": order != "Alpha" ? order : null,
"pendulum": ~~($('#search').find('.pendulum_cb').prop("checked")),
"scale_low": $('#search').find('.scalel_txt').val(),
"scale_high": $('#search').find('.scaleh_txt').val(),
"tcg": ~~($('#search').find('.tcg_cb').prop("checked")),
"ocg": ~~($('#search').find('.ocg_cb').prop("checked")),
"ocg_list": ~~($('#' + currentLabel + ' .ocg_limit_rb').prop("checked")),
"arrows": arrows.includes("1") ? arrows : null,
"custom": ~~($('#search').find('.custom_cb').val()),
};
pageNumber = 1;
if ($('#search .name_txt').val().length >= 3 || $('#search .desc_txt').val().length >= 3) {
update_search = false;
}
if (LifePointsToAddUpTo >= 1) {
searchCards3(LifePointsToAddUpTo);
}
else {searchCards3(LifePointsToAddUpTo2);
}
}
function searchCards3(LifePointsToAddUpTo3) {
if (saved_search == null) {
log('g');
return;
}
log('h');
if (LifePointsToAddUpTo3) {
showDim();
$('#dim').css("pointer-events", "none");
}
if (awaiting_cards) {
return;
}
awaiting_cards = true;
var search = {"action":"Search cards", "search":saved_search, "page":~~pageNumber};
if (!cards_fingerprint || saved_search.custom != 0 && saved_search.custom != 6) {
filterObject(search.search);
Send(search);
return;
}
console.log(search);
console.log(search.search);
searching = true;
var name = saved_search.name;
var effect = saved_search.effect;
var card_type = saved_search.card_type;
var monster_color = saved_search.monster_color;
var type = str(saved_search.type);
var ability = saved_search.ability;
var attribute = saved_search.attribute;
var level_low = saved_search.level_low;
var level_high = saved_search.level_high;
var atk_low = saved_search.atk_low;
var atk_high = saved_search.atk_high;
var def_low = saved_search.def_low;
var def_high = saved_search.def_high;
var limit = saved_search.limit;
var order = saved_search.order ?? "Alpha";
var pendulum = saved_search.pendulum;
var scale_low = saved_search.scale_low;
var scale_high = saved_search.scale_high;
var tcg = saved_search.tcg;
var ocg = saved_search.ocg;
var ocg_list = saved_search.ocg_list;
var arrows = saved_search.arrows ?? "00000000";
var custom_cards = saved_search.custom;
var total = 0;
var page = pageNumber;
page = (20 * page) - 20;
var full_search = false;
var cards = [];
if (name.length >= 3 || effect.length >= 3) {
}
var names = name.toLowerCase().split('*');
var effects = effect.toLowerCase().split('*');
var cards0 = Cards.slice();
switch(order) {
case "Date":
case "Release Date":
cards0.sort(sortCardsByDate);
break;
case "Updated":
case "Last Updated":
cards0.sort(sortCardsByUpdated);
break;
case "Alpha":
cards0.sort(sortCards);
break;
default:
case "New First":
cards0.reverse();
break;
}
outerloop:
for (var i = 0; i < cards0.length; i++) {
if (cards0[i].name == null) {
continue;
}
if (cards0[i].name == "") {
continue;
}
if (cards0[i].hidden == 1) {
continue;
}
if (saved_search.custom == 0 && cards0[i].rush) {
continue;
}
if (saved_search.custom == 6 && !cards0[i].rush) {
continue;
}
for (var j = 0; j < names.length; j++) {
if (cards0[i].name_lowercase.indexOf(names[j]) < 0) {
continue outerloop;
}
}
for (var j = 0; j < effects.length; j++) {
if (cards0[i].effect_lowercase.indexOf(effects[j]) < 0 && (!cards0[i].pendulum_effect || cards0[i].pendulum_effect_lowercase.indexOf(effects[j]) < 0)) {
continue outerloop;
}
}
if (full_search == true) {
cards.push(cards0[i]);
total++;
continue;
}
if (card_type != "") {
if (cards0[i].card_type.indexOf(card_type) < 0) {
continue;
}
}
if (monster_color != "") {
if (monster_color == "Pendulum") {
if (!cards0[i].pendulum) {
continue;
}
}
else if (!cards0[i].monster_color || cards0[i].monster_color.indexOf(monster_color) < 0) {
continue;
}
}
if (type != "") {
if (cards0[i].type != type) {
continue;
}
}
if (ability != "") {
if (!cards0[i].ability || cards0[i].ability.indexOf(ability) < 0) {
continue;
}
}
if (attribute != "") {
if (cards0[i].attribute.indexOf(attribute) < 0) {
continue;
}
}
if (level_low != "") {
if (cards0[i].card_type != "Monster" || cards0[i].level < parseInt(level_low)) {
continue;
}
}
if (level_high != "") {
if (cards0[i].card_type != "Monster" || cards0[i].level > parseInt(level_high)) {
continue;
}
}
if (atk_low != "") {
if (atk_low == "?") {
if (cards0[i].atk != "?") {
continue;
}
}
else {
if (cards0[i].atk == "?") {
continue;
}
if (cards0[i].card_type != "Monster" || cards0[i].atk < parseInt(atk_low)) {
continue;
}
}
}
if (atk_high != "") {
if (atk_high == "?") {
if (cards0[i].atk != "?") {
continue;
}
}
else {
if (cards0[i].atk == "?") {
continue;
}
if (cards0[i].card_type != "Monster" || cards0[i].atk > parseInt(atk_high)) {
continue;
}
}
}
if (def_low != "") {
if (def_low == "?") {
if (cards0[i].def != "?") {
continue;
}
}
else {
if (cards0[i].def == "?") {
continue;
}
if (cards0[i].card_type != "Monster" || cards0[i].def < parseInt(def_low)) {
continue;
}
}
}
if (def_high != "") {
if (def_high == "?") {
if (cards0[i].def != "?") {
continue;
}
}
else {
if (cards0[i].def == "?") {
continue;
}
if (cards0[i].card_type != "Monster" || cards0[i].def > parseInt(def_high)) {
continue;
}
}
}
if (LifePointsToAddUpTo3 >= 1) {
if (Number(cards0[i].atk) + Number(cards0[i].def) != LifePointsToAddUpTo3) {
continue;
}
}
if (pendulum) {
if (!cards0[i].pendulum) {
continue;
}
}
if (scale_low != "") {
if (!cards0[i].pendulum || cards0[i].scale < parseInt(scale_low)) {
continue;
}
}
if (scale_high != "") {
if (!cards0[i].pendulum || cards0[i].scale > parseInt(scale_high)) {
continue;
}
}
if (tcg == 1 || ocg == 1) {
if (tcg == 1 && cards0[i].tcg == 0) {
continue;
}
if (ocg == 1 && cards0[i].ocg == 0) {
continue;
}
}
if (limit != "") {
if (saved_search.custom == 6) {
if (cards0[i].ocg_limit == null) {
cards0[i].ocg_limit = 3;
}
if (cards0[i].ocg_limit != parseInt(limit)) {
if (cards0[i].rush != 2) {
continue;
}
}
}
else if (ocg_list == 1) {
if (cards0[i].ocg_limit == null) {
cards0[i].ocg_limit = 3;
}
if (cards0[i].ocg_limit != parseInt(limit)) {
continue;
}
}
else {
if (cards0[i].tcg_limit == null) {
cards0[i].tcg_limit = 3;
}
if (cards0[i].tcg_limit != parseInt(limit)) {
continue;
}
}
}
if (arrows != "00000000") {
if (!cards0[i].arrows) {
continue;
}
if (arrows.substring(0, 1) == "1" && cards0[i].arrows.substring(0, 1) != "1") {
continue;
}
if (arrows.substring(1, 2) == "1" && cards0[i].arrows.substring(1, 2) != "1") {
continue;
}
if (arrows.substring(2, 3) == "1" && cards0[i].arrows.substring(2, 3) != "1") {
continue;
}
if (arrows.substring(3, 4) == "1" && cards0[i].arrows.substring(3, 4) != "1") {
continue;
}
if (arrows.substring(4, 5) == "1" && cards0[i].arrows.substring(4, 5) != "1") {
continue;
}
if (arrows.substring(5, 6) == "1" && cards0[i].arrows.substring(5, 6) != "1") {
continue;
}
if (arrows.substring(6, 7) == "1" && cards0[i].arrows.substring(6, 7) != "1") {
continue;
}
if (arrows.substring(7, 8) == "1" && cards0[i].arrows.substring(7, 8) != "1") {
continue;
}
}
total++;
if ((total > page && total <= page + 20) && full_search == false) {
cards.push(cards0[i]);
}
}
var result = {
"action":"Search cards",
"cards":cards,
"total":total,
};
searchCardsResponse(result);
}
{let lifepoint = prompt("Enter the lifepoints you want the sum of ATK and DEF to add up to.\nClick OK while leaving the box blank to go to previous page if any exists.\nClick Cancel to go to next page if any exists.");
if (lifepoint == "") {
if (pageNumber > 1) {
pageNumber--;
searchCards3(LifePointsToAddUpTo2);
}
}
else if (lifepoint == null) {
if ((pageNumber * 20) < totalCardsSearched) {
pageNumber++;
searchCards3(LifePointsToAddUpTo2);
}
}
else if (lifepoint >= 1) {
var LifePointsToAddUpTo2 = lifepoint;
searchCardsE3(lifepoint);
}
}
Save your bookmark.

Go to the Deck Constructor, click the bookmark, input your value, and either hit Enter or click OK. To change pages, use the OK and Cancel buttons on that same bookmark, not the arrows on the Deck Constructor itself. Clicking either of the arrows, or the Search button, in the Deck Constructor will reset the search, bringing back all cards.

You can combine this with the Deck Constructor's own search parameters. For example, you can search only for WIND Winged Beast monsters whose sum of ATK and DEF equal 3500.

This currently doesn't work with custom cards, Goat Format Only cards, or Speed Duel Only cards.