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

[SOLVED]What do paladins do in square shield?

I’ve been working on square shield, but I’m not sure what to do when the paladins arrive in their positions. Should they heal me, attack something, shield, heal me, heal themselves, defend their position, or is my code wrong and they automatically do whatever they’re supposed to do once they reach their position?

# Incoming yeti attack! Use your paladins to form a square!

def findByName(name, thangs):
    for i in range(len(thangs)):
        thang = thangs[i]
        if thang.id == name:
            return thang
    return None
friends = hero.findFriends()
# Celadia is in the top left corner.
celadia = findByName("Celadia", friends)
# Dedalia is in the top right corner.
dedalia = findByName("Dedalia", friends)
sideLength = celadia.distanceTo(dedalia)

# Illumina and Vaelia should finish forming a square!
vaelia = findByName("Vaelia", friends)
illumina = findByName("Illumina", friends)
vaeliaPos = {'x':celadia.pos.x, 'y':celadia.pos.y - sideLength}
illuminaPos = {'x':dedalia.pos.x, 'y':vaelia.pos.y}
# Command Vaelia to move to the bottom left corner of the square.
hero.command(vaelia, "move", vaeliaPos)

# Command Illumina to move to the bottom left corner of the square.
hero.command(illumina, "move", illuminaPos)

After this part of the code, I experimented with them shielding, healing, defending, etc.

Well, once you have the coding down pat…it’s all automatic:
image

Taking a look now.

1 Like

Ok…on review of your code, it all looks pretty good. However, vaelia should move based on dedalia’s coords and illumina should move based on celedia’s. Both moves need to take in to account the sideLength variable.

2 Likes

Do you need any more assistance at this level?

No, thank you very much!

1 Like