MV Help on Boolean True or False

the latest code does not work at all. result is always false
i think we need to replace the "some" stuff,
because at the moment i dont see how this goes with every cardslot

it should be like this:
deck -> cardslot-> cardtype
and i think we did this:
deck-> cardtype
...
but could you first try out to add a "console.log" in order to figure out the exact data of "result"?

JavaScript:
    Game_Party.prototype.isCardOk = function(index) {
        // 41 = type 0 ; 42 = type 1 ; 43 = type 2 ; 44 = type 3 ; 45 = type 4
        var deck = this.deck(index);
            //"some" should ask if there is a cardtype in the deck)
            deck.some(function(cardType) {
                var result = true;
                // we use the "result var" to have better control over the "return" -usage
                if ((cardType == 0) && $gameSwitches.value(41)) result = false;
                if ((cardType == 1) && $gameSwitches.value(42)) result = false;
                if ((cardType == 2) && $gameSwitches.value(43)) result = false;
                if ((cardType == 3) && $gameSwitches.value(44)) result = false;
                if ((cardType == 4) && $gameSwitches.value(45)) result = false;
            });
        console.log(result); // ADDED this can be seen in console f8
        return result;
     };
------


i think instead of asking some, we should use "foreach" -> cards.meta.cardtype ..
this might be a bit more code, and i need to re-think ..
(i cant test most things myself properly that makes it a bit more difficult sry)
i got reference error : result is not defined

maybe we cant add var result inside the cardType function? so i placed it before the deck.some

and it's always false.

EDIT :
oh wait.. i think it's working

EDIT 2: so it's changes at times, but then it becomes false when it should be true.

1676466782165.png


i also found out, the if condition become invalid when i have the other decks cards allowed.. hmm it get's more complicated haha.
the latest code does not work at all. result is always false

i checked my logic table, i should use or || , not and

i reviewed my notes, the other way i was trying way before was checking note tags for switch required.. but i still think this is better.. i think we're very close to the solution.
i agree

JavaScript:
    Game_Party.prototype.isCardOk = function(index) {
        // 41 = type 0 ; 42 = type 1 ; 43 = type 2 ; 44 = type 3 ; 45 = type 4
        var deck = this.deck(index);
        $gameParty._cardResult = true;
            //"forEach" should ask forEach element in the deck)
            deck.forEach(function(element) {
                // we use the "$gameParty._cardResult" to have better control over the "return" -usage
                if ((element.meta.cardType == 0) && $gameSwitches.value(41)) $gameParty._cardResult = false;
                if ((element.meta.cardType == 1) && $gameSwitches.value(42)) $gameParty._cardResult = false;
                if ((element.meta.cardType == 2) && $gameSwitches.value(43)) $gameParty._cardResult = false;
                if ((element.meta.cardType == 3) && $gameSwitches.value(44)) $gameParty._cardResult = false;
                if ((element.meta.cardType == 4) && $gameSwitches.value(45)) $gameParty._cardResult = false;
            });
        console.log($gameParty._cardResult); // ADDED this can be seen in console f8
        return $gameParty._cardResult;
     };
try this, it uses "for each" and the "element" should be every card that is in any slot..
the result is stored in the global var "$gameParty._cardResult" , to make sure it can always be used.

edit
sry i had to edit a few times ,make sure to try the latest edited version

Original thread: https://forums.rpgmakerweb.com/threads/help-on-boolean-true-or-false.154881/