本文整理汇总了Python中wouso.core.god.God.can_cast方法的典型用法代码示例。如果您正苦于以下问题:Python God.can_cast方法的具体用法?Python God.can_cast怎么用?Python God.can_cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wouso.core.god.God
的用法示例。
在下文中一共展示了God.can_cast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cast_spell
# 需要导入模块: from wouso.core.god import God [as 别名]
# 或者: from wouso.core.god.God import can_cast [as 别名]
def cast_spell(self, spell, source, due):
""" Curse self with given spell from source, for due time. """
try:
psamount = PlayerSpellAmount.objects.get(player=source, spell=spell)
assert psamount.amount > 0
except (PlayerSpellAmount.DoesNotExist, AssertionError):
return False
# Pre-cat God actions: immunity and curse ar done by this
# check
if not God.can_cast(spell, source, self):
return False
try:
psdue = PlayerSpellDue.objects.create(player=self, source=source, spell=spell, due=due)
except Exception as e:
logging.exception(e)
return False
# Post-cast God action (there are specific modifiers, such as clean-spells
# that are implemented in God
God.post_cast(psdue)
psamount.amount -= 1
if psamount.amount == 0:
psamount.delete()
else:
psamount.save()
return True
示例2: basic_cast
# 需要导入模块: from wouso.core.god import God [as 别名]
# 或者: from wouso.core.god.God import can_cast [as 别名]
def basic_cast(self, player_dest, spell, due):
# Pre-cast God actions: immunity and curse ar done by this
# check
can_cast, error = God.can_cast(spell=spell, source=self.player, destination=player_dest)
if not can_cast:
return error
try:
psdue = PlayerSpellDue.objects.create(player=player_dest, source=self.player, spell=spell, due=due)
except IntegrityError:
if not spell.mass:
return 'Cannot cast the same spell more than once'
# extend the affected time by spell
psdue = PlayerSpellDue.objects.get(player=player_dest, spell=spell)
if psdue.due < due:
psdue.delete()
psdue = PlayerSpellDue.objects.create(player=player_dest, source=self.player, spell=spell, due=due)
else:
return None
if psdue.source == psdue.player:
signal_msg = _("cast a spell on himself/herself")
else:
signal_msg = _("cast a spell on {to} ")
signals.addActivity.send(sender=None, user_from=psdue.source,
user_to=psdue.player,
message=signal_msg,
arguments=dict(to=psdue.player),
action='cast',
game=None)
# Post-cast God action (there are specific modifiers, such as clean-spells
# that are implemented in God
signals.postCast.send(sender=None, psdue=psdue)
return None
示例3: cast_spell
# 需要导入模块: from wouso.core.god import God [as 别名]
# 或者: from wouso.core.god.God import can_cast [as 别名]
def cast_spell(self, spell, source, due):
""" Cast a spell on this player.
Returns: error message if the spell was not cast, or None
"""
try:
psamount = PlayerSpellAmount.objects.get(player=source, spell=spell)
assert psamount.amount > 0
except (PlayerSpellAmount.DoesNotExist, AssertionError):
return 'Spell unavailable'
# Pre-cast God actions: immunity and curse ar done by this
# check
can_cast, error = God.can_cast(spell, source, self.player)
if not can_cast:
return error
try:
psdue = PlayerSpellDue.objects.create(player=self.player, source=source, spell=spell, due=due)
except IntegrityError:
return 'Cannot cast the same spell more than once'
# Post-cast God action (there are specific modifiers, such as clean-spells
# that are implemented in God
God.post_cast(psdue)
psamount.amount -= 1
if not psamount.amount:
psamount.delete()
else:
psamount.save()
return None
示例4: basic_cast
# 需要导入模块: from wouso.core.god import God [as 别名]
# 或者: from wouso.core.god.God import can_cast [as 别名]
def basic_cast(self, player_dest, spell, due):
# Pre-cast God actions: immunity and curse ar done by this
# check
can_cast, error = God.can_cast(spell=spell, source=self.player, destination=player_dest)
if not can_cast:
return error
try:
psdue = PlayerSpellDue.objects.create(player=player_dest, source=self.player, spell=spell, due=due)
except IntegrityError:
if not spell.mass:
return 'Cannot cast the same spell more than once'
#extend the affected time by spell
psdue = PlayerSpellDue.objects.get(player=player_dest, spell=spell)
if psdue.due < due:
psdue.delete()
psdue = PlayerSpellDue.objects.create(player=player_dest, source=self.player, spell=spell, due=due)
else:
return None
# Post-cast God action (there are specific modifiers, such as clean-spells
# that are implemented in God
God.post_cast(psdue)
return None