def goUp(self): goingToPos = Position.Position(self.pos.line - 1, self.pos.column) self.willStepOnObject(goingToPos) if self.lmanager.charAtPosition( goingToPos) != "*" and self.pos.line > 0: self.lmanager.updatePersoPositionInLaby(self.pos, goingToPos) self.pos = goingToPos else: pass
def buildAvailPositionList(self): positionList = [] for line in self.laby: for x in range(0, len(line)): if line[x] == " ": indexOfCurrentLine = self.laby.index(line) positionList.append( Position.Position(indexOfCurrentLine, x)) return positionList
def goRight(self): goingToPos = Position.Position(self.pos.line, self.pos.column + 1) self.willStepOnObject(goingToPos) if self.lmanager.charAtPosition( goingToPos) != "*" and self.pos.column < len( self.lmanager.laby[self.pos.line]) - 1: self.lmanager.updatePersoPositionInLaby(self.pos, goingToPos) self.pos = goingToPos else: pass
def nbInGameObjets(self): gameObjetList = [] for line in self.laby: for i in range(0, len(line)): if line[i] != "*" and line[i] != "X" and line[ i] != " " and line[i] != "8": indexOfCurrentLine = self.laby.index(line) gameObjetList.append( Position.Position(indexOfCurrentLine, i)) return str(3 - len(gameObjetList))
def findInitPosition(self): for line in self.laby: for x in line: if x == '8': return Position.Position(self.laby.index(line), line.index(x))