コード例 #1
0
ファイル: board.py プロジェクト: amecolli/Do-NT-a-Favor
	def specialSwitch(self,c1,c2): #aka really sad switch
		i = randint(0,len(self.NT)-1) #randomly choose an NT to process
		row,col = self.NT[i].row,self.NT[i].col
		j = feed.index(c1.dscp)
		if c1.spec==c2.spec: #replace a random player with the element
			self.board[row][col] = a.Accm(row,col,j)
			self.NT.pop(i)
			if len(self.NT)==0: self.gameover = True
		else: #boost the player to the top
			self.board[self.row-1+self.scroll][col]=self.board[row][col]
			self.board[row][col].locate(self.row-1+self.scroll,col)
			self.board[row][col]=a.Accm(row,col,j)
		self.tempboard=copy.deepcopy(self.board)
		self.eliminateFill(c1.row,c1.col,c2.row-c1.row,c2.col-c1.col,2)
コード例 #2
0
 def scrollBoard(self):
     for newR in range(self.scroll + self.row - len(self.board)):
         self.board.append([None] * self.col)
     for row in range(self.row, self.row + self.scroll):
         for col in range(self.col):
             i = randint(0, len(feed) - 1)
             self.board[row][col] = a.Accm(row, col, i)
     #self.tempboard = copy.deepcopy(self.board)
     self.update()
コード例 #3
0
ファイル: board.py プロジェクト: amecolli/Do-NT-a-Favor
	def movePlayer(self):
		for NT in reversed(self.NT):
			NT.feed(self.board,self.special,self.scroll)
			if NT.row == self.row-1: #reaches the end
				self.accmed.append(NT) #achievement+1
				self.board[NT.row][NT.col]=a.Accm(NT.row,NT.col,
														randint(0,len(feed)-1))
				self.NT.remove(NT)
				self.initPlayer()
コード例 #4
0
ファイル: board.py プロジェクト: amecolli/Do-NT-a-Favor
	def verticalEliminateFill(self,x0,y0,drow,dcol,l):
		x1,y1 = x0+(l-1)*drow,y0+(l-1)*dcol #the other end
		d = self.partialDrop(x0,y0,drow,dcol,l)	#drop NT & special
		for j in range(min(x0,x1)+d,self.row-(l-d)+self.scroll):
			#deal with non-NT and non-special elems
			self.board[j][y0] = self.board[j+(l-d)][y0]
			self.board[j][y0].locate(j,y0)
			if (self.board[j+(l-d)][y0].dscp!="NT" 
				and self.board[j+(l-d)][y0].spec!=None):
				self.relocateSpecial(j+(l-d),y0,j,y0)
		for row in range(self.row-(l-d)+self.scroll,self.row+self.scroll):
			#generate new ones at the top
			self.board[row][y0] = a.Accm(row,y0,randint(0,len(feed)-1))
コード例 #5
0
ファイル: nt.py プロジェクト: amecolli/Do-NT-a-Favor
 def drop(self, board, prevrow, prevcol, special):
     for r in range(prevrow,
                    len(board) - 1):  #drop the element in the prevcol
         board[r][prevcol] = board[r +
                                   1][prevcol]  #become the elem right above
         board[r][prevcol].locate(r, prevcol)
         if board[r][prevcol].dscp != "NT" and board[r][
                 prevcol].spec != None:
             for accm in reversed(special):
                 if accm.row == r + 1 and accm.col == prevcol:
                     accm.locate(r, prevcol)
                     break  #each one at a time
     #generate a new one at the top after dropping elems
     board[len(board) - 1][prevcol] = a.Accm(
         len(board) - 1, prevcol, randint(0,
                                          len(feed) - 1))
コード例 #6
0
ファイル: board.py プロジェクト: amecolli/Do-NT-a-Favor
	def refreshBoard(self):
		#Note: the popup won't last long,but so the player know it's refreshing
		msg = Label(text='Refreshing...')
		popup = Popup(title='No More Moves',content=msg,
			size_hint=(.8,.5),auto_dismiss=False,background='img/2.jpg')
		popup.open()
		#since it's only used in the survival mode, self.scroll can be ignored
		for row in range(self.row):
			for col in range(self.col):
				#keep the NT and the specials
				if (self.board[row][col].dscp=="NT" 
					or self.board[row][col].spec!=None): continue
				self.board[row][col] = a.Accm(row,col,randint(0,len(feed)-1))
		self.tempboard = copy.deepcopy(self.board) #reset the tempboard
		self.update() #graphically show it
		popup.dismiss() #close the popup
コード例 #7
0
ファイル: board.py プロジェクト: amecolli/Do-NT-a-Favor
	def init(self,snum):
		self.margin = cwidth/13
		self.cellHeight,self.cellWidth = cwidth/13,cwidth/13
		self.col,self.row = 6,8
		self.selectedNT = snum
		#all the partial lists for further operation
		self.switch,self.cancel,self.NT,self.special,self.accmed =[],[],[],[],[]
		self.eliminating,self.pause,self.gameover = False, False, False
		self.timerCount,self.limit,self.target = 0,360,3
		self.board = [[None]*self.col for row in range(self.row)]
		self.scroll = 0
		self.startToEliminate = False
		for row in range(self.row):
			for col in range(self.col):
				i = randint(0,len(feed)-1)
				self.board[row][col] = a.Accm(row,col,i)
		self.initPlayer()
		self.tempboard = copy.deepcopy(self.board) #for elimination animation
		self.initDraw()
		Clock.schedule_interval(self.timerFired,.5)
コード例 #8
0
ファイル: board.py プロジェクト: amecolli/Do-NT-a-Favor
	def horizontalEliminateFill(self,x0,y0,drow,dcol,l):
		x1,y1 = x0+(l-1)*drow,y0+(l-1)*dcol #the other end
		ref = self.board[x0][y0].dscp
		for i in range(l): #loop over each elem in the row
			col = y0+i*dcol
			if self.board[x0][col].dscp=="NT" or  self.board[x0][col].dscp!=ref:
				continue
			elif self.board[x0][col].spec!=None:#keep unused special
				special = self.board[x0][col]
				if not special.used: #activiated/just created, not used
					if not special.seen: #just created
						special.seen = True
						continue
					else: #activated, this is the time to use
						special.used = True
						self.special.append(special) 
			for row in range(x0,self.row-1+self.scroll):
				self.board[row][col] = self.board[row+1][col]
				self.board[row][col].locate(row,col)
				if (self.board[row+1][col].dscp!="NT"
					and self.board[row+1][col].spec!=None):
					self.relocateSpecial(row+1,col,row,col)
			self.board[self.row+self.scroll-1][col]=a.Accm(self.row-1+self.scroll,
													col,randint(0,len(feed)-1))