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


Python Game.total_time方法代码示例

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


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

示例1: add_update_game_interact

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import total_time [as 别名]
def add_update_game_interact(request):
    
    game_id = request.POST.get('game_id')
    name = request.POST.get('name')
    rows = request.POST.get('rows')
    columns = request.POST.get('columns')
    groups_num = request.POST.get('groups_num')
    panels_per_group = request.POST.get('panels_per_group')
    wait_time = request.POST.get('wait_time')
    total_time = request.POST.get('total_time')
    warning_time = request.POST.get('warning_time')
    switch_cost = request.POST.get('switch_cost')
    
    #parse to int
    try:
        rows = int(rows)
        columns = int(columns)
        groups_num = int(groups_num)
        panels_per_group = int(panels_per_group)
        wait_time = int(wait_time)
    except:
        return HttpResponse('Error')

    try:
        game = Game.objects.get(pk = game_id)
    except:
        game = Game()
        game.create_time = datetime.now()
    
    needInitGroupsPanels = True
    if game.rows and game.columns and game.groups_num \
            and game.panels_per_group \
            and game.rows * game.columns==rows*columns \
            and game.groups_num==groups_num and game.panels_per_group==panels_per_group:
        needInitGroupsPanels = False

    game.name = name
    game.rows = rows
    game.columns = columns
    game.groups_num = groups_num
    game.panels_per_group = panels_per_group
    game.wait_time = wait_time
    game.total_time = total_time
    game.warning_time = warning_time
    game.switch_cost = switch_cost
    
    game.save()


    #initial Groups and Panels
    if needInitGroupsPanels:
        Group.objects.filter(game = game).delete()
        for i in range(groups_num):
            group = Group()
            group.game = game
            group.name = "Group %d" % (i+1) 
            group.save()
            for j in range(panels_per_group):
                panel = Panel()
                panel.group = group
                panel.game = game
                panel.name = "Panel %d" % (j+1)
                panel.progress = '0' * rows * columns
                panel.save()



    nextUrl = reverse('mine.views.mine_admin_view')
    return HttpResponseRedirect(nextUrl)
开发者ID:gamblegear,项目名称:djmatt,代码行数:71,代码来源:interact.py


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