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


Python Game.game_id方法代码示例

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


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

示例1: create_new_game

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import game_id [as 别名]
def create_new_game(players, name):
    import uuid
    from models import Game
    from constants import default_counter
    from constants import win_types
    game = Game()
    game.game_name = name
    game.game_id = str(uuid.uuid1())
    game.players = players
    game.current_player = random.randint(0, len(players) - 1)
    game.data = json.dumps(create_world_data())
    game.move_counter = default_counter
    game.major_arcana = []
    arcana = get_major_arcana()
    for i in range(len(players)):
        num = random.randint(0, len(arcana) - 1)
        game.major_arcana.append(arcana[num])
        del arcana[num]
    
    goals = get_goals()
    game.goals = []
    for i in game.major_arcana:
        for goal in win_types[i]:
            num = random.randint(0, len(goals[goal]) - 1)
            game.goals.append(goals[goal][num])
            del goals[goal][num]

    game.put()
开发者ID:Ultixan,项目名称:A-Mind-Beside-Itself,代码行数:30,代码来源:util.py

示例2: get_game

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import game_id [as 别名]
def get_game(game_id):
    game = db.GqlQuery('SELECT * from Game ' +
        'WHERE game_id = :1',
        game_id)
    if game.count() < 1:
        game = Game()
        import uuid
        grid = []
        for i in range(0, 10):
            row = []
            for j in range(0, 10):
                row.append(randint(0,3))
            grid.append(row)
        game.tiles = json.dumps(grid)
        player = {
            'heartrate': 50,
            'heartbeats': max_beats,
            'x': 5,
            'y': 5,
            'abilities':[ 0, 0, 0, 0 ],
            'stupid':False
        }
        monsters = {}
        for monster in elements.keys():
            monsters[monster] = {
                'x': -1,
                'y': -1
            }
        powerups = []
        active_monsters = []
        game.player = json.dumps(player)
        game.monsters = json.dumps(monsters)
        game.active_monsters = json.dumps(active_monsters)
        game.powerups = json.dumps(powerups)
        game.game_id = game_id
        game.turn_count = 0
        game.is_dead = 0
        game.drop_chance = start_drop_rate
        game.put()
    else:
        game = game[0]
    return game
开发者ID:Ultixan,项目名称:ohnoes,代码行数:44,代码来源:util.py


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