def test_princessrescue(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 oldscore = P.getScore() if array[1][newb.princess] == 1: temprow = 1 tempcol = newb.princess P.changeposn(1,newb.princess) array[1][newb.princess] = 4 if P.getX() == 1 and P.getY() == newb.princess: P.score += 50 if P.level == 3: os.system("clear") assert P.getScore() == oldscore + 50 running = False
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_playercollectcoin(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 oldscore = P.getScore() temprow = ROWS-2 tempcol = 1 while True: if array[temprow][tempcol+1] == 3: break elif tempcol == COLS-4: temprow += 4 tempcol = P.getY() else: tempcol += 1 P.changeposn(temprow,tempcol) array[temprow][tempcol] = 4 if array[P.getX()][P.getY() + 1] == 3: P.changeposn(temprow,tempcol) array[temprow][tempcol] = 4 P.collectCoin() assert P.getScore() == oldscore + 5 running = False