# Attack munchkins, call brawlers and ignore burls.
# This function defines the hero's behaviour about enemies. def dealEnemy(enemy): # If enemy.type is "munchkin": if enemy.type == "munchkin": # Then attack it: hero.attack(enemy)
# Zostałeś uwięziony.Nie ruszaj się, to może być bolesne.
# Ta funkcja sprawdza czy wróg jest w zasięgu twojego ataku. def inAttackRange(enemy): distance = hero.distanceTo(enemy) # Prawie wszystkie miecze mają zasięg ataku równy 3 . if distance <= 3: return True else: return False
# Ogres are attacking a nearby settlement! # Be careful, though, for the ogres have sown the ground with poison. # Gather coins and defeat the ogres, but avoid the burls and poison!
while True: enemy = hero.findNearestEnemy() if enemy.type == "munchkin" or enemy.type == "thrower": hero.attack(enemy)
# Artyleria używa monet jako celu. # Posłużysz jako dalmierz dla artylerii.
# Napisz funkcję. def coinDistance(): # Znajdź najbliższą monetę. coin = hero.findNearestItem() # Jeśli jest tam moneta , zwróć dystans do niej. if coin:
# Move to the wizard and get their secret values. hero.moveXY(20, 24) secretA = hero.findNearestFriend().getSecretA() secretB = hero.findNearestFriend().getSecretB() secretC = hero.findNearestFriend().getSecretC()
# If ALL three values are true, take the high path. # Otherwise, take the low path. Save the 4th value. secretD = secretA and secretB and secretC if secretD: hero.moveXY(30, 33) else: hero.moveXY(30, 15)
# If ANY of the three values are true, take the left path. # Otherwise, go right. Save the 5th value. secretE = secretA or secretB or secretC if secretE: hero.moveXY(20, 24) else: hero.moveXY(40, 24)
# If ALL five values are true, take the high path. # Otherwise, take the low path. secretF = secretA and secretB and secretC if secretF: hero.moveXY(30, 33) else: hero.moveXY(30, 15)
Projektuję strony www Lublin na Joomla i WordPress
# Funkcja maybeBuildTrap definiuje dwa parametry! def maybeBuildTrap(x, y): # Użyj x i y jako współrzędnych, aby przejść do. hero.moveXY(x, y) enemy = hero.findNearestEnemy() if enemy: pass