當前位置: 首頁>>代碼示例>>Python>>正文


Python board.Board類代碼示例

本文整理匯總了Python中models.board.Board的典型用法代碼示例。如果您正苦於以下問題:Python Board類的具體用法?Python Board怎麽用?Python Board使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Board類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get

 def get(self,key):
     user = User()
     
     categroy = Category()       
     user_keys = user.allKey()
     category_keys = categroy.allKey()
     
     _data_user =  user.all(user_keys)
     _data_category = categroy.all(category_keys)        
     data = {}
     if key:
         board = Board()
         board.data = board.get(key)
         data['title']       = board.data['title']
         data['key']         = board.data['key']
         data['user']        = board.data['user']
         data['category']    = board.data['category']
         data['createTime']    = board.data['createTime']
         data['follow']    = board.data['follow']
     else:            
         data['title']       = ''
         data['key']         = ''
         data['user']        = ''
         data['category']    = ''            
     
     self.render('manager/board_new.html',data = data,data_user = _data_user,data_category = _data_category)
開發者ID:aviatorBeijing,項目名稱:ptpy,代碼行數:26,代碼來源:board.py

示例2: __init__

class BoardController:
  def __init__(self):
    self.board = Board(None)
    self.view  = ConsoleBoardView(self.board)

  def init_game(self):
  #  self.white_player = Core1Player(Board.WHITE)
    self.white_player = HumanPlayer(Board.WHITE)
    self.black_player = Core2Player(Board.BLACK)
  #  self.black_player = RandomPlayer(Board.BLACK)
    self.atual_player = self.black_player

    finish_game = 0

    self.view.update_view()
    

    while finish_game != 2:
      #raw_input("")
      atual_color = self.atual_player.color
      print 'Jogador: ' + atual_color +' ('+ self.atual_player.name() +')'

      if self.board.valid_moves(atual_color).__len__() > 0:
        self.board.play(self.atual_player.play(self.board.get_clone()), atual_color)
        self.view.update_view()
        finish_game = 0
      else:
        print 'Sem movimentos para o jogador: ' + atual_color
        finish_game += 1
      self.atual_player = self._opponent(self.atual_player)

    return self._end_game()


  def _end_game(self):
    score = self.board.score()
    print ''
    print'-----------------PLACAR DESTA RODADA---------------------'
    print self.white_player.name() , " = " , score[0]
    print self.black_player.name() , " = " , score[1]
    if score[0] > score[1]:
      print ""
      print 'Jogador ' + self.white_player.name() + ' Ganhou'
      return 1
    elif score[0] < score[1]:
      print ""
      print 'Jogador ' + self.black_player.name() + ' Ganhou'
      return 2
    else:
      print ""
      print 'Jogo terminou empatado'
      return 0
    print'---------------------------------------------'
    
    
  def _opponent(self, player):
    if player.color == Board.WHITE:
      return self.black_player

    return self.white_player
開發者ID:sevenleo,項目名稱:othello-reversi-python,代碼行數:60,代碼來源:board_controller.py

示例3: test_add_and_get_lists

    def test_add_and_get_lists(self):
        bid0 = Board.add("board0", "A")
        board0 = Board.get(bid0)
        bid1 = Board.add("board1", "A")

        lid0 = List.add("list0", bid0)
        lid1 = List.add("list1", bid1)
        assert lid0 in [_list.id for _list in board0.get_lists()]
        assert lid1 not in [_list.id for _list in board0.get_lists()]
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:9,代碼來源:test_board.py

示例4: test_get_lists_by_board_id

 def test_get_lists_by_board_id(self):
     bid0 = Board.add("board1", "A")
     bid1 = Board.add("board2", "A")
     lid0 = List.add("List0", bid0)
     list0 = List.get(lid0)
     lid1 = List.add("List1", bid1)
     list1 = List.get(lid1)
     assert lid0 in [_list.id for _list in List.get_lists_by_board_id(bid0)]
     assert lid1 not in [_list.id for _list in List.get_lists_by_board_id(bid0)]
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:9,代碼來源:test_list.py

示例5: move

def move():  # Computer is always X
    # Get board passed in as a json object
    data = request.data.decode("utf-8")
    board_inplay = json.loads(data)

    # Create board and get next move
    board = Board(board_inplay['board'])
    state, move = board.minimax('X')

    return jsonify({'move': move, 'state': state})
開發者ID:jimbach,項目名稱:tic-tac-toe_flask,代碼行數:10,代碼來源:tictactoe.py

示例6: test_add_and_get_users

 def test_add_and_get_users(self):
     bid0 = Board.add("board0", "A")
     board0 = Board.get(bid0)
     uid0 = User.add("test1", "password", "[email protected]")
     user0 = User.get(uid0)
     uid1 = User.add("test2", "password", "[email protected]")
     user1 = User.get(uid0)
     board0.add_user(user0)
     assert str(uid0) in board0.get_user_ids()
     assert str(uid1) not in board0.get_user_ids()
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:10,代碼來源:test_board.py

示例7: test_add_and_get_boards

    def test_add_and_get_boards(self):
        cid = User.add("test_user1", "password", "[email protected]")
        user = User.get(cid)

        bid0 = Board.add("board1", "A")
        bid1 = Board.add("board2", "A")
        board0 = Board.get(bid0)
        board1 = Board.get(bid1)
        user.add_board(board0)

        assert str(bid0) in user.get_board_ids()
        assert str(bid1) not in user.get_board_ids()
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:12,代碼來源:test_user.py

示例8: Play

    def Play(request):
        # FIXME: Data sent from client is not JSON.
        # Figure out how to actually send json.
        cell = eval(request.request.json["cell"])
        row, column = cell["location"]
        grid = eval(request.request.json["grid"])
        flag_event = request.request.json.get("flag_cell")

        board = Board(grid)
        board.handle_move(row, column, flag_event)

        return {"grid": board.grid, "winner": board.winner}
開發者ID:jzamb,項目名稱:minesweeper,代碼行數:12,代碼來源:views.py

示例9: api_board

def api_board(board_id=None):
    print "=======", request.form
    try:
        title = request.form['title']
    except:
        return jsonify({'code':400, 'message':'Invalid Request'})

    board_id = Board.add(title,'A')
    board = Board.get(board_id)
    board.add_user(current_user)
    current_user.add_board(board)
    List.add("To Do", board_id)
    List.add("Doing", board_id)
    List.add("Done", board_id)
    return jsonify({'board_id':board_id})
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:15,代碼來源:views.py

示例10: get

 def get(self,key):
     user_key = self.get_secure_cookie("user_key")
         
     board  = Board()
     query = {}
     query['q'] = "user:%s" % user_key            
     _data = board.solr(query)  
     
     thumb = Thumb()        
     pic = Pic() 
     
     pic_url = pic.get(key)['url']
     thumb_url = thumb.get(key)['url']
     
     self.render('repin.html',boards = _data,pic_url=pic_url,thumb_url=thumb_url)
開發者ID:aviatorBeijing,項目名稱:ptpy,代碼行數:15,代碼來源:pins.py

示例11: get

    def get(self, text_id):
        try:
            board = Board.get_board_by_text_id(text_id)
        except NoResultFound:
            return abort(404)

        #last_post = Post.query.order_by(Post.id.desc()).limit(1).subquery()
        #last_post_alias = aliased(Post, last_post)
        # threads = db.session.query(Thread, last_post_alias).filter_by(board_id=board.id).join(last_post_alias, Thread.id == last_post_alias.thread_id).order_by(Thread.id.desc()).all()
        threads = db.session.query(Thread).filter_by(board_id=board.id).order_by(Thread.id.desc()).all()

        #threads = db.session.query(Thread, Post)\
        #    .filter_by(board_id=board.id)\
        #    .order_by(Thread.id.desc())\
        #    .join(Post, Thread.id == Post.thread_id)\
        #    .all()

        #print(db.session.query(Thread, Post)
        #      .filter_by(board_id=board.id)
        #      .order_by(Thread.id.desc())
        #      .join(Post, Thread.id == Post.thread_id).statement)

        #for thread in threads:
        #    print(thread.__dict__)

        return render_template("forum_threads_view.jinja2", board=board, title=board.name, can_post=True,
                               threads=threads)
開發者ID:hansihe,項目名稱:FauxForum,代碼行數:27,代碼來源:board.py

示例12: test_get_user_ids

 def test_get_user_ids(self):
     uid0 = User.add("test1", "password", "[email protected]")
     bid0 = Board.add("board1", "A")
     lid0 = List.add("To Do", bid0)
     card_id = Card.add("card0", lid0, uid0)
     card = Card.get(card_id)
     assert str(uid0) in [user_id for user_id in card.get_user_ids()]
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:7,代碼來源:test_card.py

示例13: test_get_comments_by_card_id

    def test_get_comments_by_card_id(self):
        uid0 = User.add("test1", "password", "[email protected]")
        bid0 = Board.add("board1", "A")
        bid1 = Board.add("board2", "A")
        aid0 = Activity.add(bid0, uid0, "BLABLA")
        aid1 = Activity.add(bid0, uid0, "LA")
        aid2 = Activity.add(bid1, uid0, "HULA")

        activity0 = Activity.get(aid0)
        activity1 = Activity.get(aid1)
        activity2 = Activity.get(aid2)

        assert aid0 in [activity.id for activity in Activity.get_all(bid0)]
        assert aid1 in [activity.id for activity in Activity.get_all(bid0)]
        assert aid2 not in [activity.id for activity in Activity.get_all(bid0)]
        assert aid2 in [activity.id for activity in Activity.get_all(bid1)]
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:16,代碼來源:test_activity.py

示例14: get

    def get(self):
        user = users.get_current_user()

        if user:
            # Filter by the google appengine user id property.
            active_user = User.query(User.google_id == user.user_id()).fetch(1)

            if not active_user:
                # If we couldn't find a user it means that is the first time it uses the application.
                # We just need to create a new entity with the get_current_user() information.
                active_user = User(email=user.email(), username=user.nickname(), google_id=user.user_id())
                active_user.put()
                logging.info("New user created. Email address is: %s", active_user.email)
            else:
                active_user = active_user[0]

            token = channel.create_channel(str(active_user.key.id()))
            memcache.add(key=str(active_user.key.id()), value=token)

            template_vars = {
                'user': active_user,
                'token': token,
                'logout_url': users.create_logout_url('/welcome'),
                'boards': Board.query().order(Board.created_at)

            }
            template = JINJA_ENVIRONMENT.get_template('root.html')
            self.response.write(template.render(template_vars))
        else:
            self.redirect('/welcome')
開發者ID:bilby91,項目名稱:ganban,代碼行數:30,代碼來源:web.py

示例15: test_get_cards_by_list_id

 def test_get_cards_by_list_id(self):
     uid0 = User.add("test1", "password", "[email protected]")
     bid0 = Board.add("board1", "A")
     lid0 = List.add("To Do", bid0)
     card_id = Card.add("card0", lid0, uid0)
     card = Card.get(card_id)
     assert card_id in [card.id for card in Card.get_cards_by_list_id(lid0)]
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:7,代碼來源:test_card.py


注:本文中的models.board.Board類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。