# standard headers from creatures import Dragon from util import * class Bounce(Dragon): # self.Actions # GetBreath # GetFlyingDirection # GetFlyingPosition # ScanHorizon [Range] # SetFlyingDirection [self.Direction.East, self.Direction.NorthEast, etc.] # self.Direction.ToString(), self.Direction.FromString() # BreatheFire [Power] # Fly [distance] def action(self): fdir = doMpi(self,self.Actions.GetFlyingDirection,[]) pos = doMpi(self,self.Actions.GetFlyingPosition,[]) x, y = pos.x, pos.y bx,by = doMpi(self,self.Actions.GetBoard,[]) ox, oy = -1, -1 while not (x == ox and y == oy): ox,oy = x,y doMpi(self,self.Actions.Fly,[1]) pos = doMpi(self,self.Actions.GetFlyingPosition,[]) x, y = pos.x, pos.y # Find the closest enemy result = doMpi(self,self.Actions.ScanHorizon,[3]) tl = 0 for en in result: (ex,ey) = en['coords'] tl = fireAt(self,fdir,x,y,ex,ey) if tl == 0: # fireAt wasn't called doMpi(self,self.Actions.SetFlyingDirection,[self.Direction.randomDir()]) elif len(tl) <= 3: # easy hit for action in fl: doMpi(self,action[0],action[1]) doMpi(self,self.Actions.BreatheFire,[10]) else: doMpi(self,self.Actions.SetFlyingDirection,[self.Direction.randomDir()])