예제 #1
0
 def __call__(self, *args, **kw):
     from Match import isPlayer, isCard
     obj = args[0]
     global_overrides = [f for f in self.global_overrides[::-1] if f.obj == "all" or f.obj() == obj]
     if global_overrides: return global_overrides[0](*args, **kw)
     else:
         funcs = self.build_replacements(*args, **kw)
         if funcs:
             if len(funcs) > 1:
                 if isPlayer(obj): player = affected = obj
                 elif hasattr(obj, "keeper"): player = affected = obj.active_player
                 # In this case it is a role
                 elif isCard(obj): player, affected = obj.controller, obj
                 func = player.make_selection([(f.msg, f) for f in funcs], number=1, prompt="Choose replacement effect to affect %s"%(affected))
                 funcs.remove(func)
             else: func = funcs.pop()
             # *** This where we could potentially recurse
             func.seen = True
             result = func(*args, **kw)
             # No more replacements - unmark this stacked_function
             func.seen = False
             return result
         else:
             overrides = [f for f in self.overrides[::-1] if f.obj == "all" or f.obj() == obj]+[self.original]
             return self.combiner(overrides, *args, **kw)
예제 #2
0
파일: Player.py 프로젝트: Incantus/incantus
 def convert_gui_action(action):
     if isinstance(action, PassPriority) or isinstance(action, OKAction): return action
     elif isinstance(action, CancelAction): return False
     sel = action.selection
     if isinstance(sel, StackAbility): return False
     elif isinstance(sel, CastSpell): sel = sel.source
     if sel == self or (not isPlayer(sel) and sel.controller == self): return action
     else: return False
예제 #3
0
파일: Player.py 프로젝트: Incantus/incantus
        def filter(action):
            # This function is really convoluted
            # If I return False here then the input function will keep cycling until valid input
            if isinstance(action, CancelAction):
                if not required: return action
                else: return False
            elif isinstance(action, PassPriority): return False

            target = action.selection
            if isPlayer(target) or ((not zone or str(target.zone) == zone) and (not from_player or (from_player == "you" and target.controller == self) or (from_player == "opponent" and target.controller in self.opponents))):
                for target_type in target_types:
                    if target_type(target): return target
            # Invalid target
            self.send(InvalidTargetEvent(), target=target)
            return False
예제 #4
0
        def filter(action):
            # This function is really convoluted
            # If I return False here then the input function will keep cycling until valid input
            if isinstance(action, CancelAction):
                if not required: return action
                else: return False
            elif isinstance(action, PassPriority): return False

            target = action.selection
            if isPlayer(target) or ((not zone or str(target.zone) == zone) and (not from_player or (from_player == "you" and target.controller == self) or (from_player == "opponent" and target.controller in self.opponents))):
                for target_type in target_types:
                    if target_type(target): return target
            # Invalid target
            self.send(InvalidTargetEvent(), target=target)
            return False
예제 #5
0
 def __call__(self, *args, **kw):
     from Match import isPlayer, isCard
     obj = args[0]
     global_overrides = [
         f for f in self.global_overrides[::-1]
         if f.obj == "all" or f.obj() == obj
     ]
     if global_overrides: return global_overrides[0](*args, **kw)
     else:
         funcs = self.build_replacements(*args, **kw)
         if funcs:
             if len(funcs) > 1:
                 if isPlayer(obj): player = affected = obj
                 elif hasattr(obj, "keeper"):
                     player = affected = obj.active_player
                     # In this case it is a role
                 elif isCard(obj):
                     player, affected = obj.controller, obj
                 func = player.make_selection(
                     [(f.msg, f) for f in funcs],
                     number=1,
                     prompt="Choose replacement effect to affect %s" %
                     (affected))
                 funcs.remove(func)
             else:
                 func = funcs.pop()
             # *** This where we could potentially recurse
             func.seen = True
             result = func(*args, **kw)
             # No more replacements - unmark this stacked_function
             func.seen = False
             return result
         else:
             overrides = [
                 f for f in self.overrides[::-1]
                 if f.obj == "all" or f.obj() == obj
             ] + [self.original]
             return self.combiner(overrides, *args, **kw)
예제 #6
0
파일: Player.py 프로젝트: Incantus/incantus
 def convert_gui_action(action):
     if isinstance(action, PassPriority): return False
     elif isinstance(action, CancelAction): return action
     sel = action.selection
     if not isPlayer(sel) and sel.controller == self: return action
     else: return False
예제 #7
0
 def convert_gui_action(action):
     if isinstance(action, PassPriority) or isinstance(action, OKAction) : return action
     elif isinstance(action, CancelAction): return False
     sel = action.selection
     if not isPlayer(sel) and sel.controller == self: return action
     else: return False