#`switch` statement being drunk? or am i?

6 messages · Page 1 of 1 (latest)

delicate jetty
#
                console.log(`Puzzle for rock: ${global.regiPuzzleIndex['rock']}`)
                switch (global.regiPuzzleIndex["rock"]) {
                    case 1:
                        global.partyOf(player).forEach(pokemon => {
                            console.log(`DEF stat of ${pokemon.getDisplayName()}: ${pokemon.getDefence()}`)
                            if(pokemon.getDefence() >= 150
                                && pokemon.moveSet.getMoves().stream().anyMatch(move => move.name == 'sandstorm'))
                                passes = true
                        })
                        break;
                    case 2:

                        break;
                    case 3:

                        break;
                    case 4:

                        break;
                    case 5:

                        break;
                    default: 
                        console.log(global.regiPuzzleIndex["rock"], global.regiPuzzleIndex["rock"] == 1)
                        throw regiIndexError('rock');
                }```
it's always going to default
even though my logging and **math just before that** say it should not be?
this is specifically after using my debug command that sets them to all the same, specific value. which is parsing them as `Arguments.INTEGER` for the record, it works fine before i use it, is this some js type shite?
`/setregipuzzles 1`
```//log output from after debug command
[21:26:19] [INFO] rock = 1
[21:26:19] [INFO] ice = 1
[21:26:19] [INFO] steel = 1
[21:26:19] [INFO] eleki = 1
[21:26:19] [INFO] drago = 1

//log output from switch
[21:32:32] [INFO] Puzzle for rock: 1
[21:32:32] [INFO] 1
[21:32:32] [INFO] true
torn pastureBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

delicate jetty
#

oh my god it is some type shit

#
console.log(global.regiPuzzleIndex["rock"], 
  global.regiPuzzleIndex["rock"] == 1,
  typeof 1,
  typeof global.regiPuzzleIndex["rock"]
)
[21:41:53] [INFO] 1
[21:41:53] [INFO] true
[21:41:53] [INFO] number
[21:41:53] [INFO] object```
#

not sure how to deal with this so i guess i need some advice on that front

#

ok well parseInt(value) worked