Problem with Spring Thunder[SOLVED]

Hello, it’s been an hour that I’m trying to sovle Spring Thunder level.
I use the python code.
Here’s my code :


#Certaines pièces et gemmes attirent les éclairs.
#Le héros devrait seulement ramasser les pièces en argent et les gemmes bleues.

while True:
item = hero.findNearestItem()
# Une pièce en argent vaut 2
# Vérifie si le type de l’objet est “coin”
# L’objet AND est égal à 2.
if item.type == “coin” and item.value == 2:
hero.moveXY(item.pos.x, item.pos.y)
# Une gemme bleue a une valeur de 10.
# Verifie si le type de l’objet est une “gem”
# L’objet AND est égal à 10.
if item.type == 10 and item.type == “gem”:
hero.moveXY(item.pos.x, item.pos.y)


Sry for not using a a nice way to post the code, I don’t know how to do it.

So my problem is that the player don’t want to go to the blue gems, it only goes for the coins. I figured out that it’s only the value 10 which causes problems as if I only put the gems condition, the hero goes for all the gems.

Help please, I’m stuck

edit : I think that there no values attribute to the blue gems as it don’t even go for it when the condition is item.type > 0

The item’s type would be “gem”. You’re looking for its value. So: item.value == …
For your information, you can put three ``` (backticks, not quotes) on a new line before and after your code and it formats it (as long as you have the indentation included.)
Danny

1 Like

Ok thanks.
I feel a bit dumb put i’m gratefull.

2 Likes

Btw @Hvitr2199

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.