Hi, I am experiencing a problem with this level.
Firstly, the wining conditions shouldnt be vague as collec the optimal ammount of coins. That is what? 30? 70? I know that maybe they are randomised, but it makes the whole level confusing.
Second thing, I perssume, the diamonds have greater value than low-cost coins and my hero will collect diamonds. So you should state if players should be going around them or not.
And the last issue:
The coins are disappering usually too fast. Even when I applied my other weapons to battle (lighting attack) it seems that sometimes, the coins are there for less than tree seconds, other times for much more time.
my code looks like this:
# Claim the coins while defeating the marauding ogres.
def findMostHealth(enemies):
target = None
targetHealth = 0
enemyIndex = 0
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.health > targetHealth:
target = enemy
targetHealth = enemy.health
enemyIndex += 1
return target
def valueOverDistance(item):
return item.value / hero.distanceTo(item)
# Return the item with the highest valueOverDistance(item)
def findBestItem(items):
bestItem = None
bestValue = 0
itemsIndex = 0
# Loop over the items array.
# Find the item with the highest valueOverDistance()
while itemsIndex < len(items):
item = items[itemsIndex]
if item.value > bestValue:
bestItem = item
bestValue = item.value
itemsIndex += 1
return bestItem
while True:
enemies = hero.findEnemies()
enemy = findMostHealth(enemies)
coins = hero.findItems()
coin = None
coin = findBestItem(coins)
if coin:
hero.moveXY(coin.pos.x, coin.pos.y)
if enemy and enemy.health > 15:
while enemy.health > 0:
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
elif hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)