本文整理汇总了Python中models.board.Board类的典型用法代码示例。如果您正苦于以下问题:Python Board类的具体用法?Python Board怎么用?Python Board使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Board类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: __init__
class BoardController:
def __init__(self):
self.board = Board(None)
self.view = ConsoleBoardView(self.board)
def init_game(self):
self.white_player = CornerPlayer(Board.WHITE)
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
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)
self._end_game()
def _end_game(self):
score = self.board.score()
if score[0] > score[1]:
print ""
print 'Jogador ' + Board.WHITE + ' Ganhou'
elif score[0] < score[1]:
print ""
print 'Jogador ' + Board.BLACK + ' Ganhou'
else:
print ""
print 'Jogo terminou empatado'
def _opponent(self, player):
if player.color == Board.WHITE:
return self.black_player
return self.white_player
开发者ID:mateusgreg,项目名称:TabuleiroOthello,代码行数:47,代码来源:board_controller.py
示例17: test_get_and_test_description
def test_get_and_test_description(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)
card.set_description('desc')
assert 'desc' in card.get_description()
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:8,代码来源:test_card.py
示例18: test_add_and_get
def test_add_and_get(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
aid0 = Activity.add(bid0, uid0, "BLABLA")
activity0 = Activity.get(aid0)
assert bid0 == activity0.board_id
assert uid0 == activity0.user_id
assert "BLABLA" == activity0.content
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:8,代码来源:test_activity.py
示例19: test_set_and_get_card
def test_set_and_get_card(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.title == 'card0'
assert card.list_id == lid0
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:8,代码来源:test_card.py
示例20: get
def get(self, board_text_id):
try:
board = Board.get_board_by_text_id(board_text_id)
except NoResultFound:
return abort(404)
form = ThreadPostForm()
return render_template("forum_thread_post.jinja2", board=board, form=form)
开发者ID:hansihe,项目名称:FauxForum,代码行数:9,代码来源:thread.py
注:本文中的models.board.Board类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论