# I need help in the one wizard

**URL:** <https://discourse.codecombat.com/t/i-need-help-in-the-one-wizard/29489>\
**Category:** Level Help\
**Created:** [June 30, 2021, 6:56pm UTC](https://discourse.codecombat.com/t/i-need-help-in-the-one-wizard/29489 "2021-06-30T18:56:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saga1828](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@saga1828](https://discourse.codecombat.com/u/saga1828)\
**Post date:** [June 30, 2021, 6:56pm UTC](https://discourse.codecombat.com/t/i-need-help-in-the-one-wizard/29489/1 "2021-06-30T18:56:13Z")

</div>

this is my code

while(true) {  
var enemy = hero.findNearestEnemy();

if (enemy){  
var distance = hero.distanceTo(enemy);}  
if (enemy.type == “ogre”) {  
hero.moveXY(10, 36);  
}

```
    else if (distance < 10 && hero.canCast("chain-lightning", enemy)){
        hero.cast("chain-lightning", enemy);}
        
    else if (hero.canCast("lightning-bolt"), enemy){
        hero.cast("lightning-bolt", enemy);}
        
    
        
     if (hero.canCast("regen") && hero.health < 50){
        hero.cast("regen", hero);}
    else if (enemy){
        hero.attack(enemy);}

```

}

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/2/c/2c847f80985253d4e591c8c3dced0fbd0a0e6e31.jpeg)

---

<div class="post-metadata">

**Author:** ![TEO](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/teo/32/23025_2.png) [@TEO](https://discourse.codecombat.com/u/TEO)\
**Post date:** [July 1, 2021, 12:10am UTC](https://discourse.codecombat.com/t/i-need-help-in-the-one-wizard/29489/2 "2021-07-01T00:10:24Z")

</div>

please format **all** your code correctly  
what seems to be the problem?
