def test_playerspawndetails(self): P = Player("Hello",1,ROWS - 2, COLS, 1, 0) newb = Board() array = [] pathexists = False testofthree = False numofcoins = 0 while True: pathexists,numofcoins,testofthree = newb.init(COLS,ROWS,array,P) if pathexists == True: break assert ( P.getScore() == 0 and P.getLife() == 3 and P.getLevel() == 1 ) #Tests if player score,lives and level is initialized correctly
def test_donkeyplayerlife(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 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 ) oldlife = P.getLife() note = -1 tempindex = 0 for i in dobjectarr: if i != 0: if i.getdir() == 1: P.changeposn(i.getX(), i.getY() + 1) mainarr[i.getX()][i.getY() + 1] = 4 else: P.changeposn(i.getX(), i.getY() - 1) mainarr[i.getX()][i.getY() - 1] = 4 if i.checkCollision(mainarr) == True: i.killDonkey(mainarr, P) note = 1 running = False break else: i.donkeyWalk(mainarr) tempindex += 1 assert P.getLife() == oldlife if note != -1: dobjectarr[tempindex] = 0 P.score += 25 note = -1