Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help on Mages Might!

Is it possible to use the opposite mana on the shield your opponent is using.

I know its possible with hero.getEnemyHero() but the problem is I don’t understand how these kinds of code work. I already know that it returns a copy of my hero object which it could be used to get your enemy’s state, I am wondering how I can use this to actually use the state of the enemy.

Can anyone explain?

1 Like

Your own hero has all the methods listed down the center of the screen. The opponent, returned by hero.getEnemyHero() has all the same methods, but CodeCombat will only let you call some of them. hero.getActiveShield() is one of them.

Example:

opponent = hero.getEnemyHero()
shield = opponent.getActiveShield()
# Do something with shield.mana, which is one of "fire", "earth", "water"

For countering, you want to send the element the enemy shield type is weak against.

affinities = {
  "fire":  {"weak": "water", "strong": "earth"},
  "water": {"weak": "earth", "strong": "fire" },
  "earth": {"weak": "fire",  "strong": "water"},
}
2 Likes