Example #1
0
 def react(self, args):
     cards = args['discard']
     if len(cards) > 0:
         targets_ids = args['targets']
         checking.only_one_target(targets_ids)
         checking.forbid_target_self(self.player.player_id, targets_ids[0])
     return DiscardCards.react(self, args)
Example #2
0
    def react(self, args):
        if args['action'] == 'abort':
            return self.done(args)

        args['discard'] = args['use']
        if len(args['discard']) == 0:
            raise ValueError('wrong cards')
        targets_ids = args['targets']
        checking.only_one_target(targets_ids)
        checking.forbid_target_self(self.player.player_id, targets_ids[0])
        return DiscardCards.react(self, args)
Example #3
0
File: duel.py Project: neuront/sgs
def duel_check(game_control, args):
    targets_ids = args['targets']
    user = game_control.player_by_token(args['token'])
    cards = game_control.cards_by_ids(args['use'])
    checking.only_one_target(targets_ids)
    target = game_control.player_by_id(targets_ids[0])
    checking.valid_target(user, target, 'duel')
    checking.forbid_target_self(user, target)

    game_control.use_cards_for_players(user, targets_ids, args['action'], cards)
    game_control.push_frame(_Duel(game_control, user, target, cards))
    return { 'code': ret_code.OK }
Example #4
0
def duel(game_control, args):
    targets_ids = args['targets']
    user = game_control.player_by_token(args['token'])
    cards = game_control.cards_by_ids(args['use'])
    checking.only_one_target(targets_ids)
    target = game_control.player_by_id(targets_ids[0])
    checking.forbid_target_self(user, target)
    checking.only_one_card_named_as(cards, 'duel')

    game_control.use_cards_for_players(user, targets_ids, args['action'], cards)
    game_control.push_frame(play_slash_frame(game_control, target, user, cards))
    return { 'code': ret_code.OK }
Example #5
0
def arson_attack_check(game_control, args):
    targets_ids = args['targets']
    cards = game_control.cards_by_ids(args['use'])
    user = game_control.player_by_token(args['token'])
    checking.only_one_target(targets_ids)
    target = game_control.player_by_id(targets_ids[0])
    checking.valid_target(user, target, 'arson attack')
    checking.forbid_target_no_card_on_hand(target, game_control)

    game_control.use_cards_for_players(user, targets_ids, args['action'], cards)
    game_control.push_frame(_ArsonAttack(game_control, user, target, cards))
    return { 'code': ret_code.OK }
Example #6
0
File: slash.py Project: neuront/sgs
def slash_check(game_control, args):
    targets_ids = args['targets']
    user = game_control.player_by_token(args['token'])
    cards = game_control.cards_by_ids(args['use'])
    checking.only_one_target(targets_ids)
    target = game_control.player_by_id(targets_ids[0])
    action = args['action']
    checking.valid_target(user, target, action)
    checking.forbid_target_self(user, target)
    checking.within_range(game_control, user, target, 'slash')

    game_control.use_cards_for_players(user, targets_ids, action, cards)
    _SlashFlow(game_control, user, target, cards, action).resume()
    return { 'code': ret_code.OK }
Example #7
0
def sabotage_check(gc, args):
    targets_ids = args['targets']
    user = gc.player_by_token(args['token'])
    cards = gc.cards_by_ids(args['use'])
    checking.only_one_target(targets_ids)
    target = gc.player_by_id(targets_ids[0])
    checking.valid_target(user, target, 'sabotage')
    checking.forbid_target_self(user, target)
    checking.forbid_target_no_card(target, gc)

    gc.use_cards_for_players(user, targets_ids, args['action'], cards)
    hint = { 'regions': target.all_regions(gc) }
    gc.push_frame(frames.AcceptMessage(gc, [user], 'region', hint,
                                       lambda a: on_region(gc, target, a)))
    return { 'code': ret_code.OK }
Example #8
0
def sabotage(game_control, args):
    targets_ids = args['targets']
    user = game_control.player_by_token(args['token'])
    cards = game_control.cards_by_ids(args['use'])
    checking.only_one_target(targets_ids)
    target = game_control.player_by_id(targets_ids[0])
    checking.only_one_card_named_as(cards, 'sabotage')
    checking.forbid_target_self(user, target)
    checking.forbid_target_no_card(target, game_control)

    game_control.use_cards_for_players(user, targets_ids, args['action'], cards)
    on_result = lambda gc, a: None
    game_control.push_frame(
            frames.AcceptMessage(game_control, [user],
                                 lambda a: on_message(game_control, target, a),
                                 on_result))
    return { 'code': ret_code.OK }
Example #9
0
def sabotage(game_control, args):
    targets_ids = args['targets']
    user = game_control.player_by_token(args['token'])
    cards = game_control.cards_by_ids(args['use'])
    checking.only_one_target(targets_ids)
    target = game_control.player_by_id(targets_ids[0])
    checking.only_one_card_named_as(cards, 'sabotage')
    checking.forbid_target_self(user, target)
    checking.forbid_target_no_card(target, game_control)

    game_control.use_cards_for_players(user, targets_ids, args['action'],
                                       cards)
    on_result = lambda gc, a: None
    game_control.push_frame(
        frames.AcceptMessage(game_control, [user],
                             lambda a: on_message(game_control, target, a),
                             on_result))
    return {'code': ret_code.OK}
Example #10
0
    def react(self, args):
        if args['action'] == 'abort':
            return self.done(None)
        cards = self.game_control.cards_by_ids(args['use'])
        if len(cards) == 0:
            raise ValueError('bad cards')
        targets_ids = args['targets']
        checking.only_one_target(targets_ids)
        target = self.game_control.player_by_id(targets_ids[0])
        checking.forbid_target_self(self.player, target)
        checking.cards_region(cards, 'bequeathed strategy')

        for c in cards: c.set_region('onhand')
        self.game_control.private_cards_transfer(self.player, target, cards)
        self.cards = [c for c in self.cards if c not in cards]
        if len(self.cards) == 0:
            return self.done(None)
        return { 'code': ret_code.OK }
Example #11
0
def fire_attack(game_control, args):
    targets_ids = args['targets']
    cards = game_control.cards_by_ids(args['use'])
    user = game_control.player_by_token(args['token'])
    checking.only_one_target(targets_ids)
    checking.only_one_card_named_as(cards, 'fire attack')
    target = game_control.player_by_id(targets_ids[0])
    checking.forbid_target_no_card_in_hand(target, game_control)

    game_control.use_cards_for_players(user, targets_ids, args['action'], cards)
    on_result = lambda gc, a: discard_same_suit(gc, a, user, target, cards)
    def show_check(cards_ids):
        if len(cards_ids) != 1:
            raise ValueError('need exactly one card')
        if game_control.cards_by_ids(cards_ids)[0].region != 'cards':
            raise ValueError('bad region')
    game_control.push_frame(frames.ShowCards(game_control, target, show_check,
                                             on_result))
    return { 'code': ret_code.OK }
Example #12
0
def fire_attack(game_control, args):
    targets_ids = args['targets']
    cards = game_control.cards_by_ids(args['use'])
    user = game_control.player_by_token(args['token'])
    checking.only_one_target(targets_ids)
    checking.only_one_card_named_as(cards, 'fire attack')
    target = game_control.player_by_id(targets_ids[0])
    checking.forbid_target_no_card_in_hand(target, game_control)

    game_control.use_cards_for_players(user, targets_ids, args['action'],
                                       cards)
    on_result = lambda gc, a: discard_same_suit(gc, a, user, target, cards)

    def show_check(cards_ids):
        if len(cards_ids) != 1:
            raise ValueError('need exactly one card')
        if game_control.cards_by_ids(cards_ids)[0].region != 'cards':
            raise ValueError('bad region')

    game_control.push_frame(
        frames.ShowCards(game_control, target, show_check, on_result))
    return {'code': ret_code.OK}