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


Python Member.user_name方法代码示例

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


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

示例1: makerobogame

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import user_name [as 别名]
def makerobogame(request):
  
    fb_id = ROBOT1
    request.session['fb_id'] = fb_id
 
    # make robot player 1
    try:
        m_from = Member.objects.get( fb_id=ROBOT1 )
    except Member.DoesNotExist:
        m_from   = Member(fb_id=ROBOT1)
        m_from.user_name     =  'Robo1'
        m_from.fb_first_name =  'Robo1'
        m_from.fb_last_name  =  'Robo1'
        m_from.save()
    # make robot player 2
    try:
        m_to = Member.objects.get( fb_id=ROBOT2 )
    except Member.DoesNotExist:
        m_to   = Member(fb_id=ROBOT2)
        m_to.user_name     =  'Robo2'
        m_to.fb_first_name =  'Robo2'
        m_to.fb_last_name  =  'Robo2'
        m_to.save()

    # name is set
    request_from = 'Robo1'
    request_to   = 'Robo2'
    gamename = "%s_%s_%s" % ( request_from, request_to, time.asctime(time.gmtime()) ) 
    r = Room(name=gamename)
    r.fb_request_id = ROBOREQUEST
    r.save()

    g = Game(room=r)
    # game name and room name duplicated 
    g.name = gamename
    g.save()

    p = Player(member=m_from)  # player in game, link to member 
    p.game=g		       # game 
    p.turn=0                   # static order of player in game
    p.save()

    request.session['player_id'] = p.turn

    # TODO assumes two player game - generalize
    p = Player( member = m_to )
    p.game=g
    p.turn=1
    p.save()

    return HttpResponse( simplejson.dumps( { "gamename": gamename } ), mimetype='application/javascript' )
开发者ID:cliffmeyer,项目名称:lupalo,代码行数:53,代码来源:views.py


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