Пример #1
0
    def doEffectTaunt(self, room, pos, effect, uniqids=[]):
        '''
		处理嘲讽的效果
		modified by tm at 2014-01-27
		1. add summary
		2. 重新整理代码逻辑
		'''
        if isinstance(room, dict) == False or isinstance(
                effect, dict) == False or (pos != 1 and pos != 2):
            return False

        target_range = effect['targetA'].get('range')
        pointer = effect['targetA'].get('pointer')

        uniqids = EffectHelperModel.getEffectTarget(room, pos, effect, uniqids)
        print 'doEffectTaunt--------------------------', uniqids
        if not uniqids:
            return False

        # 获取受到effect影响的上卡牌组的key组成的list(cardPlay1,cardPlay2,cardHand1,cardHand2)
        c_keys = EffectHelperModel.getEffectPointer(pos, pointer, target_range)
        if not c_keys:
            self.log.error(str(effect))
            return False

        for ck in c_keys:
            for card in room[ck]:
                uniqid = card.get('uniqid')
                if uniqid in uniqids:
                    #uniqids.remove(uniqid)
                    card['status'] = card['status'] | STATUS_TAUNT

        return True
Пример #2
0
    def doEffectHp(self,
                   room,
                   pos,
                   effect,
                   uniqids=[],
                   hp_type=EFFECT_TYPE_HEAL):
        '''
		处理回血的效果
		modified by tm at 2014-01-27
		1. add summary
		2. 重新整理代码逻辑
		'''
        if isinstance(room, dict) == False or isinstance(
                effect, dict) == False or (pos != 1 and pos != 2):
            return False

        target_range = effect['targetA'].get('range')
        pointer = effect['targetA'].get('pointer')

        # 获取受到影响的卡uniqid列表
        uniqids = EffectHelperModel.getEffectTarget(room, pos, effect, uniqids)
        print 'doEffectHealHp--------------------------', uniqids
        if not uniqids:
            return False

        # 获取值分配
        uniqid_values = EffectHelperModel.getEffectValue(
            room, pos, effect, uniqids)
        print uniqid_values
        if not uniqid_values:
            return False

        # 获取受到effect影响的上卡牌组的key组成的list(cardPlay1,cardPlay2,cardHand1,cardHand2)
        c_keys = EffectHelperModel.getEffectPointer(pos, pointer, target_range)
        if not c_keys:
            self.log.error(str(effect))
            return False

        uniqid_keys = uniqid_values.keys()
        for ck in c_keys:
            for card in room[ck]:
                uniqid = card.get('uniqid')
                if uniqid in uniqid_keys:
                    if hp_type == EFFECT_TYPE_HEAL:  # 回血(不能超过血上限)
                        card['hp'] = min(card['hp'] + uniqid_values[uniqid],
                                         card['maxHp'])
                    elif hp_type == EFFECT_TYPE_ADDHP:  # 加血(血上限不变)
                        card['hp'] = card['hp'] + uniqid_values[uniqid]
                    elif hp_type == EFFECT_TYPE_ADDMAXHP:  # 加血上限(也要加血)
                        card['maxHp'] = card['maxHp'] + uniqid_values[uniqid]
                        card['hp'] = card['hp'] + uniqid_values[uniqid]

        return True
Пример #3
0
    def doEffectAddDamage(self, room, pos, effect, uniqids=[]):
        '''
		处理伤害的效果(造成伤害,如火球术)
		modified by tm at 2014-01-27
		1. add summary
		2. 重新整理代码逻辑
		'''
        if isinstance(room, dict) == False or isinstance(
                effect, dict) == False or (pos != 1 and pos != 2):
            return False

        target_range = effect['targetA'].get('range')
        pointer = effect['targetA'].get('pointer')
        field = target_range.get('field', 'battleField')

        uniqids = EffectHelperModel.getEffectTarget(room, pos, effect, uniqids)
        print 'doEffectAddDamage--------------------------', uniqids
        if not uniqids:
            return False

        # 获取值分配
        uniqid_values = EffectHelperModel.getEffectValue(
            room, pos, effect, uniqids)
        print uniqid_values
        if not uniqid_values:
            return False

        # 获取受到effect影响的上卡牌组的key组成的list(cardPlay1,cardPlay2,cardHand1,cardHand2)
        c_keys = EffectHelperModel.getEffectPointer(pos, pointer, target_range)
        if not c_keys:
            self.log.error(str(effect))
            return False

        uniqid_keys = uniqid_values.keys()
        for ck in c_keys:
            for card in room[ck]:
                uniqid = card.get('uniqid')
                if uniqid in uniqid_keys:
                    #uniqids.remove(uniqid)
                    FightModel.doDamage(card, uniqid_values[uniqid])
                    if field == 'battleField':
                        RoomModel.checkCardDie(room, pos, card)

        return True
Пример #4
0
    def doEffectArmor(self, room, pos, effect, uniqids=[]):
        '''
		处理加护甲的效果
		modified by tm at 2014-01-27
		1. add summary
		2. 重新整理代码逻辑
		'''
        if isinstance(room, dict) == False or isinstance(
                effect, dict) == False or (pos != 1 and pos != 2):
            return False

        target_range = effect['targetA'].get('range')
        pointer = effect['targetA'].get('pointer')

        # 获取受到影响的卡uniqid列表
        uniqids = EffectHelperModel.getEffectTarget(room, pos, effect, uniqids)
        print 'doEffectArmor--------------------------', uniqids
        if not uniqids:
            return False

        # 获取值分配
        uniqid_values = EffectHelperModel.getEffectValue(
            room, pos, effect, uniqids)
        print uniqid_values
        if not uniqid_values:
            return False

        # 获取受到effect影响的上卡牌组的key组成的list(cardPlay1,cardPlay2,cardHand1,cardHand2)
        c_keys = EffectHelperModel.getEffectPointer(pos, pointer, target_range)
        print c_keys
        if not c_keys:
            self.log.error(str(effect))
            return False

        uniqid_keys = uniqid_values.keys()
        for ck in c_keys:
            for card in room[ck]:
                uniqid = card.get('uniqid')
                if uniqid in uniqid_keys:
                    print uniqid
                    #uniqids.remove(uniqid)
                    card['armor'] = card['armor'] + uniqid_values[uniqid]

        return True