def testEffectWithHandler(self): desLife = self.desLc.lifeState.current damageEffector = DamageEffector(value=1, damageType=DamageType.Normal) self.srcECC.outboundChains.addHandler(AlterDamageByValueHandler(1)) self.desECC.inboundChains.addHandler(AlterDamageByValueHandler(-2)) damageEffector.effect(self.srcEntity, self.desLattice) self.assertEqual(self.desLc.lifeState.current, desLife)
def testEffect(self): self.desLc.lifeState.max = 100 self.desLc.lifeState.current = 50 desLife = self.desLc.lifeState.current info1 = CETSkillInfo(castor=OmnipotentCastor(), effectors=[HealEffector(value=1)]) info2 = CETSkillInfo(castor=OmnipotentCastor(), effectors=[DamageEffector(value=1)]) info3 = CETSkillInfo(castor=OmnipotentCastor(), effectors=[ModifyShieldEffector(value=2)]) skill = ChangeEveryTurnSkill.skill(infos=[info1, info2, info3]) skill.attach(self.srcEntity) self.srcCc.character.skill = skill effector = DamageEffector(value=3) damageCard = Card.card(CardType.Support, [effector]) self.srcCardController.addCard(damageCard) self.turnSystem.beginTurn() self.srcCc.castSkill(self.desLattice) self.turnSystem.endTurn() desLife += 1 self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() self.srcCc.castSkill(self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() self.srcCardController.castCard(damageCard.serial, self.desLattice) self.srcCc.castSkill(self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife)
def testEffect(self): percent, damage = 0.5, 2 desLife = self.desLc.lifeState.current self.turnSystem.beginTurn() # 使对方受到的伤害设置为percent effector = AlterDamageByPercentEffector( percent=percent, turn=1, alterType=ModifierAlterType.Suffer) # 打出该效果 castInfo = CastInfo(self.srcEntity, self.desLattice, 0, Card.card(CardType.Support, [effector])) self.world.eventCenter.fire(ClientCastEvent(castInfo)) # 对对方造成伤害 damageEffector = DamageEffector(value=damage, damageType=DamageType.Normal) # 打出该效果 castInfo = CastInfo(self.srcEntity, self.desLattice, 0, Card.card(CardType.Damage, [damageEffector])) self.world.eventCenter.fire(ClientCastEvent(castInfo)) # 进入结算 self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() self.world.eventCenter.fire(ClientCastEvent(castInfo)) self.turnSystem.endTurn() desLife -= 2 self.assertEqual(self.desLc.lifeState.current, desLife)
def testEffect(self): setValue = 1 self.srcLc.lifeState.current = setValue desLife = self.desLc.lifeState.current self.turnSystem.beginTurn() effector = HealByCauseDamageEffector(turn=1) effector.effect(self.srcEntity, self.srcLattice) effector = DamageEffector(value=2, damageType=DamageType.Normal) effector.effect(self.srcEntity, self.desLattice) effector = DamageEffector(value=2, damageType=DamageType.Normal) effector.effect(self.srcEntity, self.desLattice) self.turnSystem.endTurn() desLife -= 4 setValue += 4 self.assertEqual(self.desLc.lifeState.current, desLife) self.assertEqual(self.srcLc.lifeState.current, setValue)
def testCancelHandleCastCard(self): desLife = self.desLc.lifeState.current nde = DamageEffector(value=1, damageType=DamageType.Normal) castTarget = self.desLattice castInfo = CastInfo(self.srcEntity, castTarget, 0, GeneralCast([nde])) self.world.eventCenter.fire(ClientCastEvent(castInfo)) self.world.eventCenter.fire(ClientCancelCastEvent(castInfo)) self.turnSystem.endTurn() self.assertEqual(self.desLc.lifeState.current, desLife)
def testSettle(self): desLife = self.desLc.lifeState.current nde = DamageEffector(value=1, damageType=DamageType.Normal) castTarget = self.desLattice castInfo = CastInfo(self.srcEntity, castTarget, 0, GeneralCast([nde])) self.turnSystem.addCastInfo(castInfo) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife)
def testEffect(self): self.desLc.lifeState.max = 100 self.desLc.lifeState.current = 100 desLife = self.desLc.lifeState.current effector = DamageEffector(value=1) damageCard1 = Card.card(CardType.Damage, [effector]) self.srcCardController.addCard(damageCard1) damageCard2 = Card.card(CardType.Damage, [effector]) self.srcCardController.addCard(damageCard2) skill = ConsSkill.skill(castor=OmnipotentCastor(), damage=1, cd=4, cardTypeToUse=CardType.Damage, cardCountToUse=2) skill.attach(self.srcEntity) self.srcCc.character.skill = skill self.turnSystem.beginTurn() self.srcCc.castSkill(self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife) # turn 1 self.turnSystem.beginTurn() self.srcCc.castSkill(self.desLattice) self.turnSystem.endTurn() self.assertEqual(self.desLc.lifeState.current, desLife) # turn 2 self.turnSystem.beginTurn() self.srcCc.castSkill(self.desLattice) self.srcCardController.castCard(damageCard1.serial, self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife) # turn 3 self.turnSystem.beginTurn() self.srcCc.castSkill(self.desLattice) self.srcCardController.castCard(damageCard2.serial, self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife) # turn 4 self.turnSystem.beginTurn() self.srcCc.castSkill(self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife)
def testEffect(self): desMaxLife = self.desLc.lifeState.max desLife = self.desLc.lifeState.current self.turnSystem.beginTurn() damageOverTimeEffector = DamageEffector(value=2, damageType=DamageType.Normal) damageOverTimeEffector.effect(self.srcEntity, self.desLattice) self.turnSystem.endTurn() desLife -= 2 self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() effector = FullHealIfNoDamageLastTurnEffector() effector.effect(self.desEntity, self.desLattice) self.turnSystem.endTurn() self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() effector = FullHealIfNoDamageLastTurnEffector() effector.effect(self.desEntity, self.desLattice) self.turnSystem.endTurn() desLife = desMaxLife self.assertEqual(self.desLc.lifeState.current, desLife)
def testEffect(self): desLife = self.desLc.lifeState.current effector = DamageEffector(value=1) damageCard1 = Card.card( CardType.Damage, [effector], castTargetType=CastorTargetType.CharacterEntity) self.srcCardController.addCard(damageCard1) damageCard2 = Card.card( CardType.Damage, [effector], castTargetType=CastorTargetType.CharacterEntity) self.srcCardController.addCard(damageCard2) damageCard3 = Card.card( CardType.Damage, [effector], castTargetType=CastorTargetType.CharacterEntity) self.srcCardController.addCard(damageCard3) effector = DodgeCardEffectEffector(probability=1, turn=1) dodgeCard = Card.card(CardType.Support, [effector], castTargetType=CastorTargetType.CharacterEntity) self.srcCardController.addCard(dodgeCard) self.turnSystem.beginTurn() self.srcCardController.castCard(dodgeCard.serial, self.desLattice) self.srcCardController.castCard(damageCard1.serial, self.desLattice) self.srcCardController.castCard(damageCard2.serial, self.desLattice) self.turnSystem.endTurn() self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() self.srcCardController.castCard(damageCard3.serial, self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife) self.srcCardController.addCard(damageCard1) effector = DodgeCardEffectEffector(probability=0, turn=1) dodgeCard = Card.card(CardType.Support, [effector]) self.srcCardController.addCard(dodgeCard) self.turnSystem.beginTurn() self.srcCardController.castCard(dodgeCard.serial, self.srcLattice) self.srcCardController.castCard(damageCard1.serial, self.desLattice) self.turnSystem.endTurn() desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife)
def testAliveEffect(self): shield, damage = 8, 5 desLife = self.desLc.lifeState.current effector = TurnedShieldEffector(value=shield, turn=2) castInfo = CastInfo(self.srcEntity, self.desLattice, 0, Card.card(CardType.Support, [effector])) self.world.eventCenter.fire(ClientCastEvent(castInfo)) damageEffector = DamageEffector(value=damage, damageType=DamageType.Normal) castInfo = CastInfo(self.srcEntity, self.desLattice, 0, Card.card(CardType.Damage, [damageEffector])) self.world.eventCenter.fire(ClientCastEvent(castInfo)) self.turnSystem.endTurn() self.assertEqual(self.desLc.lifeState.current, desLife) self.world.eventCenter.fire(ClientCastEvent(castInfo)) self.turnSystem.endTurn() desLife -= 2 self.assertEqual(self.desLc.lifeState.current, desLife) self.world.eventCenter.fire(ClientCastEvent(castInfo)) self.turnSystem.endTurn() desLife -= 5 self.assertEqual(self.desLc.lifeState.current, desLife)
def testAliveEffect(self): # 满血值 original = desLife = self.desLc.lifeState.current # 直接给目标角色施加免疫伤害 effector = ImmuneDeadDamageOnceEffector(turn=-1) effector.effect(self.desEntity, self.desLattice) self.turnSystem.beginTurn() # 尝试施加不致死伤害 damageEffector = DamageEffector(value=1, damageType=DamageType.Normal) damageEffector.effect(self.srcEntity, self.desLattice) self.turnSystem.endTurn() # 正常计算伤害 desLife -= 1 self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() # 施加不致死伤害 damageEffector = DamageEffector(value=3, damageType=DamageType.Normal) damageEffector.effect(self.srcEntity, self.desLattice) # 尝试施加致死伤害 damageEffector = DamageEffector(value=original, damageType=DamageType.Normal) damageEffector.effect(self.srcEntity, self.desLattice) # 并施加后续伤害 damageEffector = DamageEffector(value=1, damageType=DamageType.Normal) damageEffector.effect(self.srcEntity, self.desLattice) self.turnSystem.endTurn() # 只收到了之前的不致死伤害 desLife -= 3 self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() # 施加不至死伤害 damageEffector = DamageEffector(value=2, damageType=DamageType.Normal) damageEffector.effect(self.srcEntity, self.desLattice) self.turnSystem.endTurn() # 正常计算伤害,说明buff没有后向影响 desLife -= 2 self.assertEqual(self.desLc.lifeState.current, desLife) self.turnSystem.beginTurn() # 施加致死伤害 damageEffector = DamageEffector(value=original, damageType=DamageType.Normal) damageEffector.effect(self.srcEntity, self.desLattice) self.turnSystem.endTurn() # 检测死亡 self.desLc.checkDead() # 确认死亡,说明buff不再存在 self.assertTrue(self.desLc.dead())
def testEffect(self): desLife = self.desLc.lifeState.current damageEffector = DamageEffector(value=1, damageType=DamageType.Normal) damageEffector.effect(self.srcEntity, self.desLattice) self.assertEqual(self.desLc.lifeState.current, desLife - 1)