From 224a4c1c043813ad6d5e080709db9a93f5033633 Mon Sep 17 00:00:00 2001 From: Vincent Quatrevieux Date: Sun, 10 Mar 2024 12:24:25 +0100 Subject: [PATCH] feat(spell): Allow to define critical effect target --- .../transformer/SpellTargetsTransformer.java | 70 ++++++++++++++++ .../araknemu/data/value/SpellTarget.java | 47 +++++++++++ .../data/world/entity/SpellTemplate.java | 7 +- .../sql/SqlSpellTemplateRepository.java | 8 +- .../sql/SqlWorldRepositoriesModule.java | 5 +- .../game/player/race/PlayerRaceService.java | 5 +- .../araknemu/game/spell/SpellService.java | 5 +- .../game/spell/effect/SpellEffectService.java | 25 +++++- .../SpellTargetsTransformerTest.java | 79 +++++++++++++++++++ .../sql/SqlSpellTemplateRepositoryTest.java | 37 ++++++++- .../araknemu/game/GameDataSet.java | 2 +- .../araknemu/game/spell/SpellServiceTest.java | 25 ++++++ 12 files changed, 299 insertions(+), 16 deletions(-) create mode 100644 src/main/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformer.java create mode 100644 src/main/java/fr/quatrevieux/araknemu/data/value/SpellTarget.java create mode 100644 src/test/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformerTest.java diff --git a/src/main/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformer.java b/src/main/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformer.java new file mode 100644 index 000000000..ae737cb87 --- /dev/null +++ b/src/main/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformer.java @@ -0,0 +1,70 @@ +/* + * This file is part of Araknemu. + * + * Araknemu is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Araknemu is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Araknemu. If not, see . + * + * Copyright (c) 2017-2024 Vincent Quatrevieux + */ + +package fr.quatrevieux.araknemu.data.transformer; + +import fr.quatrevieux.araknemu.data.value.SpellTarget; +import org.checkerframework.checker.nullness.qual.PolyNull; + +/** + * Transformer for spell effect target flags + * + * Parse format: "normal,critical;normal;..." + * Example: "1,2;3;4,5" + * + * When critical is not specified, it's the same as normal + */ +public final class SpellTargetsTransformer implements Transformer { + @Override + public @PolyNull String serialize(SpellTarget @PolyNull [] value) { + throw new UnsupportedOperationException("Not implemented"); + } + + @Override + public SpellTarget @PolyNull [] unserialize(@PolyNull String serialize) throws TransformerException { + if (serialize == null) { + return null; + } + + final String[] parts = serialize.split(";"); + + if (parts.length == 1 && parts[0].isEmpty()) { + return new SpellTarget[0]; + } + + final SpellTarget[] targets = new SpellTarget[parts.length]; + + for (int i = 0; i < parts.length; i++) { + final String[] subParts = parts[i].split(",", 2); + + final int normal = Integer.parseInt(subParts[0]); + final int critical; + + if (subParts.length > 1) { + critical = Integer.parseInt(subParts[1]); + } else { + critical = normal; + } + + targets[i] = new SpellTarget(normal, critical); + } + + return targets; + } +} diff --git a/src/main/java/fr/quatrevieux/araknemu/data/value/SpellTarget.java b/src/main/java/fr/quatrevieux/araknemu/data/value/SpellTarget.java new file mode 100644 index 000000000..991cf97d9 --- /dev/null +++ b/src/main/java/fr/quatrevieux/araknemu/data/value/SpellTarget.java @@ -0,0 +1,47 @@ +/* + * This file is part of Araknemu. + * + * Araknemu is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Araknemu is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Araknemu. If not, see . + * + * Copyright (c) 2017-2024 Vincent Quatrevieux + */ + +package fr.quatrevieux.araknemu.data.value; + +/** + * Target flags for a spell effect + */ +public final class SpellTarget { + private final int normal; + private final int critical; + + public SpellTarget(int normal, int critical) { + this.normal = normal; + this.critical = critical; + } + + /** + * Target flags for normal spell effect + */ + public int normal() { + return normal; + } + + /** + * Target flags for critical spell effect + */ + public int critical() { + return critical; + } +} diff --git a/src/main/java/fr/quatrevieux/araknemu/data/world/entity/SpellTemplate.java b/src/main/java/fr/quatrevieux/araknemu/data/world/entity/SpellTemplate.java index 22b09be21..b31a6ab57 100644 --- a/src/main/java/fr/quatrevieux/araknemu/data/world/entity/SpellTemplate.java +++ b/src/main/java/fr/quatrevieux/araknemu/data/world/entity/SpellTemplate.java @@ -21,6 +21,7 @@ import fr.arakne.utils.value.Interval; import fr.quatrevieux.araknemu.data.value.EffectArea; +import fr.quatrevieux.araknemu.data.value.SpellTarget; import fr.quatrevieux.araknemu.data.value.SpellTemplateEffect; import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.nullness.qual.Nullable; @@ -36,9 +37,9 @@ public final class SpellTemplate { private final int sprite; private final String spriteArgs; private final @Nullable Level[] levels; - private final int[] targets; + private final SpellTarget[] targets; - public SpellTemplate(int id, String name, int sprite, String spriteArgs, @Nullable Level[] levels, int[] targets) { + public SpellTemplate(int id, String name, int sprite, String spriteArgs, @Nullable Level[] levels, SpellTarget[] targets) { this.id = id; this.name = name; this.sprite = sprite; @@ -67,7 +68,7 @@ public String spriteArgs() { return levels; } - public int[] targets() { + public SpellTarget[] targets() { return targets; } diff --git a/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepository.java b/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepository.java index 578931cda..acb390fa0 100644 --- a/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepository.java +++ b/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepository.java @@ -25,6 +25,7 @@ import fr.quatrevieux.araknemu.core.dbal.repository.RepositoryException; import fr.quatrevieux.araknemu.core.dbal.repository.RepositoryUtils; import fr.quatrevieux.araknemu.data.transformer.Transformer; +import fr.quatrevieux.araknemu.data.value.SpellTarget; import fr.quatrevieux.araknemu.data.world.entity.SpellTemplate; import fr.quatrevieux.araknemu.data.world.repository.SpellTemplateRepository; import org.checkerframework.checker.nullness.qual.Nullable; @@ -41,10 +42,13 @@ final class SqlSpellTemplateRepository implements SpellTemplateRepository { private final RepositoryUtils utils; private final Transformer levelTransformer; + private final Transformer spellTargetsTransformer; - public SqlSpellTemplateRepository(QueryExecutor executor, Transformer levelTransformer) { + public SqlSpellTemplateRepository(QueryExecutor executor, Transformer levelTransformer, Transformer spellTargetsTransformer) { this.executor = executor; this.levelTransformer = levelTransformer; + this.spellTargetsTransformer = spellTargetsTransformer; + utils = new RepositoryUtils<>(this.executor, new SqlSpellTemplateRepository.Loader()); } @@ -126,7 +130,7 @@ public SpellTemplate create(Record record) throws SQLException { record.nullableUnserialize("SPELL_LVL_5", levelTransformer), record.nullableUnserialize("SPELL_LVL_6", levelTransformer), }, - record.getIntArray("SPELL_TARGET", ';') + record.unserialize("SPELL_TARGET", spellTargetsTransformer) ); } diff --git a/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlWorldRepositoriesModule.java b/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlWorldRepositoriesModule.java index 09f3c13b5..deec9b490 100644 --- a/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlWorldRepositoriesModule.java +++ b/src/main/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlWorldRepositoriesModule.java @@ -26,6 +26,7 @@ import fr.quatrevieux.araknemu.core.di.ContainerConfigurator; import fr.quatrevieux.araknemu.core.di.ContainerModule; import fr.quatrevieux.araknemu.data.transformer.ImmutableCharacteristicsTransformer; +import fr.quatrevieux.araknemu.data.transformer.SpellTargetsTransformer; import fr.quatrevieux.araknemu.data.world.repository.SpellTemplateRepository; import fr.quatrevieux.araknemu.data.world.repository.character.PlayerExperienceRepository; import fr.quatrevieux.araknemu.data.world.repository.character.PlayerRaceRepository; @@ -144,7 +145,8 @@ public void configure(ContainerConfigurator configurator) { SpellTemplateRepository.class, container -> new SqlSpellTemplateRepository( executor, - container.get(SpellTemplateLevelTransformer.class) + container.get(SpellTemplateLevelTransformer.class), + container.get(SpellTargetsTransformer.class) ) ); @@ -287,5 +289,6 @@ public void configure(ContainerConfigurator configurator) { ); configurator.persist(WeaponsAbilitiesTransformer.class, container -> new WeaponsAbilitiesTransformer()); + configurator.persist(SpellTargetsTransformer.class, container -> new SpellTargetsTransformer()); } } diff --git a/src/main/java/fr/quatrevieux/araknemu/game/player/race/PlayerRaceService.java b/src/main/java/fr/quatrevieux/araknemu/game/player/race/PlayerRaceService.java index 8eed33a62..eca02cbf9 100644 --- a/src/main/java/fr/quatrevieux/araknemu/game/player/race/PlayerRaceService.java +++ b/src/main/java/fr/quatrevieux/araknemu/game/player/race/PlayerRaceService.java @@ -20,6 +20,7 @@ package fr.quatrevieux.araknemu.game.player.race; import fr.arakne.utils.value.constant.Race; +import fr.quatrevieux.araknemu.data.value.SpellTarget; import fr.quatrevieux.araknemu.data.world.entity.SpellTemplate; import fr.quatrevieux.araknemu.data.world.entity.character.PlayerRace; import fr.quatrevieux.araknemu.data.world.repository.character.PlayerRaceRepository; @@ -89,8 +90,8 @@ private GamePlayerRace create(PlayerRace entity) { private DefaultCloseCombat createDefaultCloseCombat(SpellTemplate.Level characteristics) { return new DefaultCloseCombat( characteristics, - effectService.makeAll(characteristics.effects(), characteristics.effectAreas(), new int[0]), - effectService.makeAll(characteristics.criticalEffects(), characteristics.effectAreas(), new int[0]) + effectService.makeAll(characteristics.effects(), characteristics.effectAreas(), new SpellTarget[0]), + effectService.makeAll(characteristics.criticalEffects(), characteristics.effectAreas(), new SpellTarget[0]) ); } } diff --git a/src/main/java/fr/quatrevieux/araknemu/game/spell/SpellService.java b/src/main/java/fr/quatrevieux/araknemu/game/spell/SpellService.java index b828901cf..1ffab58e9 100644 --- a/src/main/java/fr/quatrevieux/araknemu/game/spell/SpellService.java +++ b/src/main/java/fr/quatrevieux/araknemu/game/spell/SpellService.java @@ -100,11 +100,12 @@ private Spell makeLevel(@Positive int level, SpellTemplate template, SpellTempla level, template, data, - effectService.makeAll(data.effects(), data.effectAreas(), template.targets()), + effectService.makeAll(data.effects(), data.effectAreas(), template.targets(), false), effectService.makeAll( data.criticalEffects(), data.effectAreas().subList(data.effects().size(), data.effectAreas().size()), - template.targets() + template.targets(), + true ) ); } diff --git a/src/main/java/fr/quatrevieux/araknemu/game/spell/effect/SpellEffectService.java b/src/main/java/fr/quatrevieux/araknemu/game/spell/effect/SpellEffectService.java index 811930716..0a0f6a292 100644 --- a/src/main/java/fr/quatrevieux/araknemu/game/spell/effect/SpellEffectService.java +++ b/src/main/java/fr/quatrevieux/araknemu/game/spell/effect/SpellEffectService.java @@ -20,6 +20,7 @@ package fr.quatrevieux.araknemu.game.spell.effect; import fr.quatrevieux.araknemu.data.value.EffectArea; +import fr.quatrevieux.araknemu.data.value.SpellTarget; import fr.quatrevieux.araknemu.data.value.SpellTemplateEffect; import fr.quatrevieux.araknemu.game.spell.effect.area.CellArea; import fr.quatrevieux.araknemu.game.spell.effect.area.CheckboardArea; @@ -78,11 +79,31 @@ public SpellEffect make(SpellTemplateEffect template, EffectArea area, SpellEffe * @param areas The effects areas * @param targets The effects targets */ - public List makeAll(List templates, List areas, int[] targets) { + public List makeAll(List templates, List areas, SpellTarget[] targets) { + return makeAll(templates, areas, targets, false); + } + + /** + * Make an effect list + * + * @param templates List of effects + * @param areas The effects areas + * @param targets The effects targets + * @param critical Is the effect critical + */ + public List makeAll(List templates, List areas, SpellTarget[] targets, boolean critical) { final List effects = new ArrayList<>(templates.size()); for (int i = 0; i < templates.size(); ++i) { - effects.add(make(templates.get(i), areas.get(i), targets.length > i ? new SpellEffectTarget(targets[i]) : SpellEffectTarget.DEFAULT)); + final SpellEffectTarget target; + + if (targets.length > i) { + target = new SpellEffectTarget(critical ? targets[i].critical() : targets[i].normal()); + } else { + target = SpellEffectTarget.DEFAULT; + } + + effects.add(make(templates.get(i), areas.get(i), target)); } return effects; diff --git a/src/test/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformerTest.java b/src/test/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformerTest.java new file mode 100644 index 000000000..224056f99 --- /dev/null +++ b/src/test/java/fr/quatrevieux/araknemu/data/transformer/SpellTargetsTransformerTest.java @@ -0,0 +1,79 @@ +/* + * This file is part of Araknemu. + * + * Araknemu is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Araknemu is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Araknemu. If not, see . + * + * Copyright (c) 2017-2024 Vincent Quatrevieux + */ + +package fr.quatrevieux.araknemu.data.transformer; + +import fr.quatrevieux.araknemu.data.value.SpellTarget; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class SpellTargetsTransformerTest { + @Test + void serialize() { + assertThrows(UnsupportedOperationException.class, () -> new SpellTargetsTransformer().serialize(null)); + } + + @Test + void unserializeNull() { + assertNull(new SpellTargetsTransformer().unserialize(null)); + } + + @Test + void unserializeEmpty() { + assertArrayEquals(new SpellTarget[0], new SpellTargetsTransformer().unserialize("")); + } + + @Test + void unserializeSimple() { + SpellTarget[] parsed = new SpellTargetsTransformer().unserialize("1"); + + assertEquals(1, parsed.length); + assertEquals(1, parsed[0].normal()); + assertEquals(1, parsed[0].critical()); + } + + @Test + void unserializeMultiple() { + + SpellTarget[] parsed = new SpellTargetsTransformer().unserialize("1;4;0"); + + assertEquals(3, parsed.length); + assertEquals(1, parsed[0].normal()); + assertEquals(1, parsed[0].critical()); + assertEquals(4, parsed[1].normal()); + assertEquals(4, parsed[1].critical()); + assertEquals(0, parsed[2].normal()); + assertEquals(0, parsed[2].critical()); + } + + @Test + void unserializeMultipleWithExplicitCritical() { + + SpellTarget[] parsed = new SpellTargetsTransformer().unserialize("1,5;4;0,1"); + + assertEquals(3, parsed.length); + assertEquals(1, parsed[0].normal()); + assertEquals(5, parsed[0].critical()); + assertEquals(4, parsed[1].normal()); + assertEquals(4, parsed[1].critical()); + assertEquals(0, parsed[2].normal()); + assertEquals(1, parsed[2].critical()); + } +} diff --git a/src/test/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepositoryTest.java b/src/test/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepositoryTest.java index 881e9b730..3f4d85914 100644 --- a/src/test/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepositoryTest.java +++ b/src/test/java/fr/quatrevieux/araknemu/data/world/repository/implementation/sql/SqlSpellTemplateRepositoryTest.java @@ -21,12 +21,16 @@ import fr.quatrevieux.araknemu.core.dbal.executor.ConnectionPoolExecutor; import fr.quatrevieux.araknemu.core.dbal.repository.EntityNotFoundException; +import fr.quatrevieux.araknemu.data.transformer.SpellTargetsTransformer; +import fr.quatrevieux.araknemu.data.value.SpellTarget; import fr.quatrevieux.araknemu.data.world.entity.SpellTemplate; import fr.quatrevieux.araknemu.data.world.transformer.SpellTemplateLevelTransformer; import fr.quatrevieux.araknemu.game.GameBaseCase; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.sql.SQLException; + import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -45,7 +49,8 @@ public void setUp() throws Exception { repository = new SqlSpellTemplateRepository( new ConnectionPoolExecutor(app.database().get("game")), - container.get(SpellTemplateLevelTransformer.class) + container.get(SpellTemplateLevelTransformer.class), + container.get(SpellTargetsTransformer.class) ); } @@ -63,7 +68,7 @@ void getById() { assertEquals(102, spell.sprite()); assertEquals("11,1,1", spell.spriteArgs()); assertCount(6, spell.levels()); - assertArrayEquals(new int[0], spell.targets()); + assertArrayEquals(new SpellTarget[0], spell.targets()); } @Test @@ -75,7 +80,33 @@ void getByTemplate() { assertEquals(102, spell.sprite()); assertEquals("11,1,1", spell.spriteArgs()); assertCount(6, spell.levels()); - assertArrayEquals(new int[0], spell.targets()); + assertArrayEquals(new SpellTarget[0], spell.targets()); + } + + @Test + void getWithTarget() { + SpellTemplate spell = repository.get(6); + + assertEquals(6, spell.id()); + assertEquals("Armure Terrestre", spell.name()); + assertCount(6, spell.levels()); + assertCount(1, spell.targets()); + assertEquals(4, spell.targets()[0].normal()); + assertEquals(4, spell.targets()[0].critical()); + } + + @Test + void getWithTargetExplicitCritical() throws SQLException { + dataSet.pushFunctionalSpells(); + + SpellTemplate spell = repository.get(320); + + assertEquals(320, spell.id()); + assertEquals("Incurable", spell.name()); + assertCount(6, spell.levels()); + assertCount(1, spell.targets()); + assertEquals(0, spell.targets()[0].normal()); + assertEquals(64, spell.targets()[0].critical()); } @Test diff --git a/src/test/java/fr/quatrevieux/araknemu/game/GameDataSet.java b/src/test/java/fr/quatrevieux/araknemu/game/GameDataSet.java index 6ba3f7240..f4acb3620 100644 --- a/src/test/java/fr/quatrevieux/araknemu/game/GameDataSet.java +++ b/src/test/java/fr/quatrevieux/araknemu/game/GameDataSet.java @@ -570,7 +570,7 @@ public GameDataSet pushFunctionalSpells() throws SQLException, ContainerExceptio "(495, 'Prospection', 0, '0,0,1', '176,1,5,,3,0,1d5+0||5|0|0|0|0|false|true|false|false|0|1|0|0|Pa||18;19;3;1;41|0|true', '176,6,10,,3,0,1d5+5||5|0|0|0|0|false|true|false|false|0|1|0|0|Pa||18;19;3;1;41|0|true', '176,6,15,,3,0,1d10+5||5|0|0|0|0|false|true|false|false|0|1|0|0|Pa||18;19;3;1;41|0|true', '176,11,20,,3,0,1d10+10||5|0|0|0|0|false|true|false|false|0|1|0|0|Pa||18;19;3;1;41|0|true', '176,11,20,,5,0,1d10+10||5|0|0|0|0|false|true|false|false|0|1|0|0|Pa||18;19;3;1;41|0|true', '176,31,50,,5,0,1d20+30||5|0|0|0|0|false|true|false|false|0|1|0|0|Pa||18;19;3;1;41|0|true', '')", "(1009, 'Peste Noire', 0, '0,1,0', '87,50,,,6,0,0d0+50|87,75,,,6,0,0d0+75|3|1|6|50|50|false|true|false|true|0|1|0|3|PaPa||18;19;3;1;41|0|true', '87,50,,,6,0,0d0+50|87,75,,,6,0,0d0+75|3|1|6|50|50|false|true|false|true|0|1|0|3|PaPa||18;19;3;1;41|0|true', '87,50,,,6,0,0d0+50|87,75,,,6,0,0d0+75|3|1|6|50|50|false|true|false|true|0|1|0|3|PaPa||18;19;3;1;41|0|true', '87,50,,,6,0,0d0+50|87,75,,,6,0,0d0+75|3|1|6|50|50|false|true|false|true|0|1|0|3|PaPa||18;19;3;1;41|0|true', '87,50,,,6,0,0d0+50|87,75,,,6,0,0d0+75|3|1|6|50|50|false|true|false|true|0|1|0|3|PaPa||18;19;3;1;41|0|true', '', '64')", "(20, 'Immunité ', 105, '11,1,1', '105,1500,,,1,0,0d0+1500||4|0|1|0|100|false|false|false|true|0|0|0|11|Pa||18;19;3;1;41|21|false', '105,1500,,,1,0,0d0+1500||4|0|2|0|100|false|false|false|true|0|0|0|10|Pa||18;19;3;1;41|21|false', '105,1500,,,1,0,0d0+1500||4|0|3|0|100|false|false|false|true|0|0|0|9|Pa||18;19;3;1;41|21|false', '105,1500,,,1,0,0d0+1500||4|0|4|0|100|false|false|false|true|0|0|0|8|Pa||18;19;3;1;41|21|false', '105,1500,,,1,0,0d0+1500||4|0|5|0|100|false|false|false|true|0|0|0|7|Pa||18;19;3;1;41|21|false', '105,1500,,,1,0,0d0+1500||3|0|6|0|100|false|false|false|true|0|0|0|6|Pa||18;19;3;1;41|121|false', '')", - "(320, 'Incurable', 0, '10,0,1', '132,,,,0,0|100,51,100,,-1,0,1d50+50|6|1|8|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,61,110,,-1,0,1d50+60|6|1|9|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,71,120,,-1,0,1d50+70|6|1|10|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,81,130,,-1,0,1d50+80|6|1|11|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,91,140,,-1,0,1d50+90|6|1|12|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '', '64')", + "(320, 'Incurable', 0, '10,0,1', '132,,,,0,0|100,51,100,,-1,0,1d50+50|6|1|8|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,61,110,,-1,0,1d50+60|6|1|9|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,71,120,,-1,0,1d50+70|6|1|10|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,81,130,,-1,0,1d50+80|6|1|11|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '132,,,,0,0|100,91,140,,-1,0,1d50+90|6|1|12|2|0|false|false|false|false|0|0|0|3|PaPa||18;19;3;1;41|0|false', '', '0,64')", "(1010, 'Rascasse', 0, '0,1,0', '212,50,,,2,0,0d0+50;211,50,,,2,0,0d0+50;213,50,,,2,0,0d0+50;214,50,,,2,0,0d0+50;210,50,,,2,0,0d0+50||3|0|0|0|50|false|true|false|false|0|0|0|3|PaPaPaPaPa||18;19;3;1;41|0|true', '212,50,,,2,0,0d0+50;211,50,,,2,0,0d0+50;213,50,,,2,0,0d0+50;214,50,,,2,0,0d0+50;210,50,,,2,0,0d0+50||3|0|0|0|50|false|true|false|false|0|0|0|3|PaPaPaPaPa||18;19;3;1;41|0|true', '212,50,,,2,0,0d0+50;211,50,,,2,0,0d0+50;213,50,,,2,0,0d0+50;214,50,,,2,0,0d0+50;210,50,,,2,0,0d0+50||3|0|0|0|50|false|true|false|false|0|0|0|3|PaPaPaPaPa||18;19;3;1;41|0|true', '212,50,,,2,0,0d0+50;211,50,,,2,0,0d0+50;213,50,,,2,0,0d0+50;214,50,,,2,0,0d0+50;210,50,,,2,0,0d0+50||3|0|0|0|50|false|true|false|false|0|0|0|3|PaPaPaPaPa||18;19;3;1;41|0|true', '212,50,,,2,0,0d0+50;211,50,,,2,0,0d0+50;213,50,,,2,0,0d0+50;214,50,,,2,0,0d0+50;210,50,,,2,0,0d0+50||3|0|0|0|50|false|true|false|false|0|0|0|3|PaPaPaPaPa||18;19;3;1;41|0|true', '', '320;256;384;128;192')", "(1038, 'Rasage', 0, '0,2,0', '125,100,,,10,0,0d0+100;111,2,,,4,0,0d0+2|125,200,,,10,0,0d0+200;111,4,,,4,0,0d0+4|1|0|0|50|50|false|true|false|false|0|1|0|4|PaPaPaPa||18;19;3;1;41|0|true', '125,100,,,10,0,0d0+100;111,2,,,4,0,0d0+2|125,200,,,10,0,0d0+200;111,4,,,4,0,0d0+4|1|0|0|50|50|false|true|false|false|0|1|0|4|PaPaPaPa||18;19;3;1;41|0|true', '125,100,,,10,0,0d0+100;111,2,,,4,0,0d0+2|125,200,,,10,0,0d0+200;111,4,,,4,0,0d0+4|1|0|0|50|50|false|true|false|false|0|1|0|4|PaPaPaPa||18;19;3;1;41|0|true', '125,100,,,10,0,0d0+100;111,2,,,4,0,0d0+2|125,200,,,10,0,0d0+200;111,4,,,4,0,0d0+4|1|0|0|50|50|false|true|false|false|0|1|0|4|PaPaPaPa||18;19;3;1;41|0|true', '125,100,,,10,0,0d0+100;111,2,,,4,0,0d0+2|125,200,,,10,0,0d0+200;111,4,,,4,0,0d0+4|1|0|0|50|50|false|true|false|false|0|1|0|4|PaPaPaPa||18;19;3;1;41|0|true', '', '0;448')", }, ",") + ";" diff --git a/src/test/java/fr/quatrevieux/araknemu/game/spell/SpellServiceTest.java b/src/test/java/fr/quatrevieux/araknemu/game/spell/SpellServiceTest.java index 63a6a3454..2ec71d6de 100644 --- a/src/test/java/fr/quatrevieux/araknemu/game/spell/SpellServiceTest.java +++ b/src/test/java/fr/quatrevieux/araknemu/game/spell/SpellServiceTest.java @@ -27,7 +27,11 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import java.sql.SQLException; + import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; class SpellServiceTest extends GameBaseCase { private SpellService service; @@ -59,6 +63,27 @@ void get() { assertEquals(5, levels.level(2).apCost()); } + @Test + void getDifferentTargetBetweenNormalAndCritical() throws SQLException { + dataSet.pushFunctionalSpells(); + SpellLevels levels = service.get(320); + + assertEquals(320, levels.id()); + assertEquals("Incurable", levels.name()); + assertEquals(5, levels.max()); + + assertEquals(132, levels.level(2).effects().get(0).effect()); + assertEquals(0, levels.level(2).effects().get(0).min()); + assertEquals(0, levels.level(2).effects().get(0).max()); + assertFalse(levels.level(2).effects().get(0).target().isHook()); + assertEquals(100, levels.level(2).criticalEffects().get(0).effect()); + assertEquals(61, levels.level(2).criticalEffects().get(0).min()); + assertEquals(110, levels.level(2).criticalEffects().get(0).max()); + assertTrue(levels.level(2).criticalEffects().get(0).target().isHook()); + assertEquals(1, levels.level(2).criticalEffects().get(0).target().hookId()); + assertEquals(6, levels.level(2).apCost()); + } + @Test void preload() { Logger logger = Mockito.mock(Logger.class);