def test_fireballexit(self): starttime = time.time() P = Player("Hello",1,ROWS - 2, COLS, 1, 0) newb = Board() mainarr = [] while True: pathexists,numofcoins,testofthree = newb.init(COLS,ROWS,mainarr,P) if pathexists == True: break numofdonkeys,numofball,upint = levelVar(P) numofball = 1 #One ball is enough for testing dindexarr = [0,0,0] dlenarr = [0,0,0] #global dobjectarr dobjectarr = [0,0,0] #global fbarr fbarr = [0,0,0,0,0,0,0,0] #global currball currball = 0 #global counter counter = 0 dindexarr,dlenarr,counter = createDonkeys(dindexarr,dlenarr,counter,numofdonkeys,newb,mainarr,COLS,dobjectarr,upint) ball1time = time.time() tempcount = 0 P.changeposn(ROWS-2,7) mainarr[ROWS-2][7] = 4 running = True while running: #Main while loop for i in dobjectarr: if i != 0: i.donkeyWalk(mainarr) ball2time = time.time() dobjectarr,ball1time,currball,fbarr = createBalls(ball1time, ball2time, currball, numofball, dobjectarr, COLS, fbarr,upint, mainarr) for i in fbarr: if i != 0: x,y = i.getPosition() if y == 1 and x == ROWS-2: updateBalls(mainarr,fbarr,ROWS,COLS,dobjectarr) assert mainarr[ROWS-2][1] != 6 running = False mainarr,fbarr = updateBalls(mainarr,fbarr,ROWS,COLS,dobjectarr)
def test_directionchange(self): starttime = time.time() P = Player("Hello",1,ROWS - 2, COLS, 1, 0) newb = Board() mainarr = [] while True: pathexists,numofcoins,testofthree = newb.init(COLS,ROWS,mainarr,P) if pathexists == True: break numofdonkeys,numofball,upint = levelVar(P) numofball = 1 dindexarr = [0,0,0] dlenarr = [0,0,0] #global dobjectarr dobjectarr = [0,0,0] #global fbarr fbarr = [0,0,0,0,0,0,0,0] #global currball currball = 0 #global counter counter = 0 dindexarr,dlenarr,counter = createDonkeys(dindexarr,dlenarr,counter,numofdonkeys,newb,mainarr,COLS,dobjectarr,upint) ball1time = time.time() P.changeposn(ROWS-2,7) mainarr[ROWS-2][7] = 4 running = True while running: #Main while loop for i in dobjectarr: if i != 0: i.donkeyWalk(mainarr) ball2time = time.time() dobjectarr,ball1time,currball,fbarr = createBalls(ball1time, ball2time, currball, numofball, dobjectarr, COLS, fbarr,upint, mainarr) tempcount = 0 for i in fbarr: if i != 0: olddirection = i.getDirection() if i.getY()+1 == COLS-1 or i.getY() - 1 == 0: mainarr,fbarr = updateBalls(mainarr,fbarr,ROWS,COLS,dobjectarr) assert i.getDirection() != olddirection running = False mainarr,fbarr = updateBalls(mainarr,fbarr,ROWS,COLS,dobjectarr)