本文整理汇总了Python中models.Player.all方法的典型用法代码示例。如果您正苦于以下问题:Python Player.all方法的具体用法?Python Player.all怎么用?Python Player.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def reset(response):
for player in Player.all().filter('isStarred', False):
player.delete()
for player in Player.all().filter('isStarred', True):
response.out.write('full')
player.status = 'waiting'
player.put()
示例2: get
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def get(self):
isPlayer = login.isPlayer()
isAdmin = login.isAdmin()
if not isAdmin and not isPlayer:
self.response.set_status(500, message='You must log in')
self.response.out.write('You must log in')
return
logging.info(self.request)
if self.request.get('currentUser'):
user = users.get_current_user()
player = Player.all()
player = player.filter('email =', user.email()).get()
if player:
self.response.out.write(playerToJSON(player, isAdmin))
else:
self.response.set_status(500, message='You\'re not a player')
self.response.out.write('You\'re not a player')
return
else:
players = Player.all()
self.response.out.write(playersToJSON(players, isAdmin))
示例3: post
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def post(self):
if login.isAdmin():
for player in Player.all().filter('isStarred', False):
player.delete()
for player in Player.all().filter('isStarred', True):
player.status = 'waiting'
player.put()
#send message to clients
result = playersToJSON(Player.all(), True)
self.response.out.write(result)
sendMessage(result)
示例4: get
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def get(self):
user = users.get_current_user()
players = Player.all().filter('user =', user).fetch(100)
result = []
for player in players:
s = None
for p in (player.sessions_as1, player.sessions_as2, player.sessions_as3):
if p.count() > 0:
s = p[0]
break
if not s:
continue
line = {}
line['id'] = s.key().id()
line['hostedby'] = s.player_1.user.nickname()
line['started'] = s.started
line['lastmove'] = s.modified
if s.state in ('hosted', 'ready'):
line['turn'] = s.dealer.user.nickname()
else:
line['turn'] = s.turn.user.nickname()
line['state'] = s.state
result.append(line)
domain = self.request.headers.get('host', 'no host')
self.response.out.write(render('sessions.html', options({'sessions': result, 'domain': domain})))
示例5: post
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def post(self):
regulars = self.request.get('regulars')
subs = self.request.get('subs')
players = memcache.get('players')
if not players:
players = Player.all()
players.order("lname")
players.order("fname")
memcache.set("players", players)
email_sender = "Esri Hockey <[email protected]>"
allRegulars = self.request.get('allRegulars')
allSubs = self.request.get('allSubs')
email_to = GetEmailList(regulars=allRegulars, subs=allSubs)
logging.info(email_to)
email_subject = self.request.get("subject")
email_body = self.request.get("body")
if len(email_to) < 1:
values = { "message" : "Specify regulars or subs.", "email_body":email_body, "email_subject":email_subject}
path = os.path.join(os.path.dirname(__file__), 'templates/email.html')
self.response.out.write(template.render(path, values))
return
#for player in players:
# if player.inThisWeek:
# if regulars and not player.sub:
# mail.send_mail(sender=email_sender, to=player.email, subject=email_subject, body=email_body)
mail.send_mail(sender=email_sender, to=email_to, subject=email_subject, body=email_body)
示例6: isPlayer
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def isPlayer():
user = users.get_current_user()
if not user:
return False
else:
player = Player.all().filter('email =', user.email()).get()
return player != None
示例7: kill
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def kill():
try:
msg = request.json["msg"].upper()
killer = Player.all().filter('username =', request.json["username"]).get()
game = Game.get_by_id(int(request.json["game_id"]))
old_game_history_success = GameHistory.all()\
.filter('game =', game)\
.filter('killer =', killer)\
.filter('is_complete =', False).get()
if msg == old_game_history_success.confirm_msg:
will_be_last_kill = None
if GameHistory.all().filter("game =", game).filter("is_complete =", False).count() == 2:
will_be_last_kill = True
old_target = old_game_history_success.target
old_game_history_success.is_complete = True
old_game_history_success.put()
old_game_history_failure = GameHistory.all()\
.filter('game =', game)\
.filter('killer =', old_target)\
.filter('is_complete =', False).get()
old_game_history_failure.is_complete = True
old_game_history_failure.put()
if will_be_last_kill:
game_player = GamePlayer.all().filter('game =', game).filter('player =', killer).get()
game_player.is_winner = True
game_player.put()
return jsonify({"success": True, "info": "Your enemy has been slain! "})
new_target = old_game_history_failure.target
GameHistory(killer=killer, target=new_target, game=game, is_complete=False, confirm_msg=msg_generator()).put()
return jsonify({"success": True, "info": "Your enemy has been slain! "})
else:
return jsonify({"success": False, "info": "The message is incorrect. Are you trying to game the system?!"})
except: # TODO: please handle exceptions in a more proper way
return jsonify({"success": False, "info": "Something is fundamentally wrong. ", "Data received by server": str(request.data)})
示例8: post
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def post(self):
game_name = self.request.get('game_name')
game_key = db.Key.from_path('Game', game_name)
game = db.get(game_key)
user = users.get_current_user()
logging.info('Player {0} playing move for game: {1}'.format(game, user.nickname()))
move_type = self.request.get('move_type')
selected_cards = self.request.get('selected_cards')
players = Player.all().ancestor(game).run()
for player in players:
if player.user == user:
this_player = player
if not this_player:
raise Exception("Player not found: {0}".format(user.nickname()))
gamestate = {
"players": players,
"current_hand": this_player.cards,
"player_turn": game.player_turn
}
for player in players:
channel.send_message("{0}:{1}".format(game_name, player.user.user_id()),
json.dumps(gamestate))
示例9: updateCurrentGames
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def updateCurrentGames():
games = memcache.get("gamedates")
if not games:
games = GameDate.all()
games.order("date")
current_games = []
deletedGame = False
now = localTime()
datetimenow = datetime.datetime(month=now.month, year=now.year, day=now.day)
for game in games:
# if game.date.month <= now.month and game.date.day < now.day and game.date.year <= now.year:
if game.date < datetimenow:
game.delete()
deletedGame = True
else:
current_games.append(game)
# when we delete a game, we should also
# reset all players to be OUT and NOT goalie
if deletedGame:
players = Player.all()
for player in players:
player.inThisWeek = False
if not player.sub:
player.goalie = False
player.team = ""
player.put()
memcache.set("players", players)
comments = Comment.all()
for comment in comments:
comment.delete()
return current_games
示例10: __init__
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def __init__(self):
players = Player.all()
self.player_opponents = {}
logging.info("Initializing RPI Calculator.")
logging.info("Finding opponents for all players.")
for player in players:
self.player_opponents[hash(player)] = self._get_opponents_for_player(player)
示例11: get
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def get(self):
solids = Player.all()
solids.filter('solid =', True)
solids.filter('growth >', 0.0)
for solid in solids:
solid.payoutgrowth()
示例12: users
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def users():
us = Player.all()
users = {}
for u in us:
users[u.username] = {'username': u.username, 'email': u.email, 'creation_date': u.creation_date,
'player_id': u.key().id()}
return jsonify(**users)
示例13: get
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def get(self):
solids = Player.all()
solids.filter('solid =', True)
solids.filter('taxes >', 0.0)
for solid in solids:
solid.payoutdividendamount() #this in turn calls task: dividendpayer
示例14: GetAllPlayers
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def GetAllPlayers():
players = memcache.get("players")
if not players:
players = Player.all()
players.order("lname")
players.order("fname")
memcache.set("players", players)
return players
示例15: get
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import all [as 别名]
def get(self):
players = Player.all()
for player in players:
player.team = None
player.put()
values = { "message" : "Rosters have been reset."}
path = os.path.join(os.path.dirname(__file__), 'templates/admin_success.html')
self.response.out.write(template.render(path, values))