And I think that error is from this line if hero.gold >= hero.costOf(buildType):I could be wrong. Also this is the hero Iâm using
And here is what my hero is using-
I donât think that you can create/modify/play around with a list called hero.buildTypes, because itâs already reserved by the game. Otherwise, you might be able to âcreateâ a build type (like Ritic or something), and just build it with the hammer (convenient!). Go for hero.buildTypes1 or hero.bTypes or something like that.
I think thatâs what the error message means; hope it helps.
The error message is still that bTypes (or whatever) is protected property? Could it be referencing some other part of the code where youâre still using buildTypes?
Iâve only just started the mountain island, so Iâm not familiar with the buildTypes method, as Iâve never used it. But, could the issue be this section of code?
@Minh Iâm not up to Cloudrip at all (still in the desert), but looking over your code, Iâm a bit stuck on this part:
hero.buildTypes = ["decoy", "arrow-tower"]
buildType = buildTypes[len(hero.built) % len(buildTypes)]
if hero.gold >= buildType:
(some problems with the formatting there...)
I'm assuming that you took @user1's edit, and that's what took out the error message.
This should mean that you have a list with two strings, decoy and arrow-tower. You then make a new variable, `buildType`, which should be the modulo (`%`) of the length of some function called `hero.built` and the length of buildTypes. What is `hero.built`? I'm assuming it's a built-in function that shows what the hero has built already, but I don't know it. Perhaps this is part of the problem?
Also, the line `buildType = buildTypes[len(hero.built) % len(buildTypes)]` is, essentially supposed to be yielding the value of the object you want to build (I think), since that's what you're comparing to `hero.gold` in the next line (the last one I quoted). I'm not figuring out how it should be doing that, though, perhaps because I'm a total newbie, though perhaps part of the problem is there; if you're code isn't returning the right number there, I would assume the hero won't be building at the right times.
Hope something in here helps.
I donât really understand this part of the code buildType = buildTypes[len(hero.built) % len(buildTypes)].hero.buildTypes = ["decoy", "arrow-tower"]is ment to be buildTypes = ["decoy", "arrow-tower"]. This part of the code buildTypes = ["decoy", "arrow-tower"] mean you can list what you you want to build and if you have enough gold it will build the first one in the list and if you have enough gold again it will build the second one in the list and so on. (Sorry it take me a long time to reply because I sometime not on CodeCombat Discourse for a long time and tell me if you donât understand somethings because I can try to be clearer.)
I hope this help you understand a little bit more about my code.
Just donât use hero. anything useless youâre accessing a list or variable because it might bug out the preprogramed stuff. Just use a normal list I donât see why not.