示例 StartMatchmaking 请求 - Amazon GameLift Servers
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

示例 StartMatchmaking 请求

这些代码段为多个不同的对战构建器生成对战请求。如文中所述,请求必须提供所使用的对战构建器需要的玩家属性(在对战构建器的规则集中定义)。提供的属性必须使用在规则集中定义的相同的数据类型:数字 (N) 或字符串 (S)。

# Uses matchmaker for two-team game mode based on player skill level def start_matchmaking_for_cowboys_vs_aliens(config_name, ticket_id, player_id, skill, team): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "skill": {"N": skill} }, "PlayerId": player_id, "Team": team }], TicketId=ticket_id) # Uses matchmaker for monster hunter game mode based on player skill level def start_matchmaking_for_players_vs_monster(config_name, ticket_id, player_id, skill, is_monster): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "skill": {"N": skill}, "desiredSkillOfMonster": {"N": skill}, "wantsToBeMonster": {"N": int(is_monster)} }, "PlayerId": player_id }], TicketId=ticket_id) # Uses matchmaker for brawler game mode with latency def start_matchmaking_for_three_team_brawler(config_name, ticket_id, player_id, skill, role): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "skill": {"N": skill}, "character": {"S": [role]}, }, "PlayerId": player_id, "LatencyInMs": { "us-west-2": 20} }], TicketId=ticket_id) # Uses matchmaker for multiple game modes and maps based on player experience def start_matchmaking_for_multi_map(config_name, ticket_id, player_id, skill, maps, modes): response = gamelift.start_matchmaking( ConfigurationName=config_name, Players=[{ "PlayerAttributes": { "experience": {"N": skill}, "gameMode": {"SL": modes}, "mapPreference": {"SL": maps} }, "PlayerId": player_id }], TicketId=ticket_id)