本文整理汇总了Python中store.Store.get_store方法的典型用法代码示例。如果您正苦于以下问题:Python Store.get_store方法的具体用法?Python Store.get_store怎么用?Python Store.get_store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类store.Store
的用法示例。
在下文中一共展示了Store.get_store方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_player
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import get_store [as 别名]
def create_player(cls, name):
"""
:type name: str
"""
if cls.get_player(name):
raise RuntimeError('Player already exists: %s' % name)
Store.get_store().set_player(Player(name, trueskill.Rating()))
示例2: rate
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import get_store [as 别名]
def rate(cls, names):
"""
:type names: list[str]
"""
if not isinstance(names, list):
raise TypeError("Argument must be a list")
if len(names) != 4:
raise ValueError("Please specify 4 players")
players = []
missing = []
for name in names:
player = cls.get_player(name)
if not player:
missing.append(name)
else:
players.append(player)
if missing:
raise RuntimeError("Players not registered: %s" % missing)
winner1 = players[0]
winner2 = players[1]
loser1 = players[2]
loser2 = players[3]
winners = [winner1.rating, winner2.rating]
losers = [loser1.rating, loser2.rating]
winners, losers = trueskill.rate([winners, losers])
winner1.rating = winners[0]
winner2.rating = winners[1]
loser1.rating = losers[0]
loser2.rating = losers[1]
Store.get_store().set_player(winner1)
Store.get_store().set_player(winner2)
Store.get_store().set_player(loser1)
Store.get_store().set_player(loser2)
Store.get_store().log_results(names)
示例3: get_all_players
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import get_store [as 别名]
def get_all_players(cls):
return Store.get_store().get_all_players()
示例4: get_player
# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import get_store [as 别名]
def get_player(cls, name):
"""
:rtype : Player
"""
player = Store.get_store().get_player(name)
return player