当前位置: 首页>>代码示例>>Python>>正文


Python Team.by_id方法代码示例

本文整理汇总了Python中models.Team.Team.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Team.by_id方法的具体用法?Python Team.by_id怎么用?Python Team.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Team.Team的用法示例。


在下文中一共展示了Team.by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_id [as 别名]
 def post(self, *args, **kwargs):
     game_objects = {
         'game_level': GameLevel,
         'corporation': Corporation,
         'flag': Flag,
         'box': Box,
         'hint': Hint,
     }
     obj_name = self.get_argument('obj', '')
     uuid = self.get_argument('uuid', '')
     if obj_name in game_objects.keys():
         obj = game_objects[obj_name].by_uuid(uuid)
         if obj is not None:
             self.write(obj.to_dict())
         else:
             self.write({'Error': 'Invalid uuid.'})
     elif obj_name == "stats":
         flag = Flag.by_uuid(uuid)
         if flag is not None:
             if options.banking:
                 flaginfo = [{"name": flag.name, "token": flag.token, "price": "$" + str(flag.value)}]
             else:
                 flaginfo = [{"name": flag.name, "token": flag.token, "price": str(flag.value) + " points"}]
             captures = []
             for item in Flag.captures(flag.id):
                 team = Team.by_id(item[0])
                 if team:
                     captures.append({"name": team.name})
             attempts = []
             for item in Penalty.by_flag_id(flag.id):
                 team = Team.by_id(item.team_id)
                 if team:
                     attempts.append({"name": team.name, "token": item.token})
             hints = []
             for item in Hint.taken_by_flag(flag.id):
                 team = Team.by_id(item.team_id)
                 hint = Hint.by_id(item.hint_id)
                 if team:
                     if options.banking:
                         hints.append({"name": team.name, "price": "$" + str(hint.price)})
                     else:
                         hints.append({"name": team.name, "price": str(hint.price) + " points"})
             obj = {
                 "flag": flaginfo,
                 "captures": captures, 
                 "attempts": attempts, 
                 "hints": hints,
                 }
             self.write(obj)
         else:
             self.write({'Error': 'Invalid uuid.'})
     else:
         self.write({'Error': 'Invalid object type.'})
     self.finish()
开发者ID:moloch--,项目名称:RootTheBox,代码行数:56,代码来源:AdminGameObjectHandlers.py

示例2: post

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_id [as 别名]
 def post(self, *args, **kwargs):
     ''' Called to purchase an item '''
     uuid = self.get_argument('uuid', '')
     item = MarketItem.by_uuid(uuid)
     if not item is None:
         user = self.get_current_user()
         team = Team.by_id(user.team.id)  # Refresh object
         if user.has_item(item.name):
             self.render('market/view.html',
                         user=user,
                         errors=["You have already purchased this item."]
                         )
         elif team.money < item.price:
             message = "You only have $%d" % (team.money,)
             self.render('market/view.html', user=user, errors=[message])
         else:
             logging.info("%s (%s) purchased '%s' for $%d" % (
                 user.handle, team.name, item.name, item.price
             ))
             self.purchase_item(team, item)
             self.event_manager.item_purchased(user, item)
             self.redirect('/user/market')
     else:
         self.render('market/view.html',
                     user=self.get_current_user(),
                     errors=["Item does not exist."]
                     )
开发者ID:AnarKyx01,项目名称:RootTheBox,代码行数:29,代码来源:MarketHandlers.py


注:本文中的models.Team.Team.by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。