From dd93609ddbd0f52aacb02e842b2be11dd233595a Mon Sep 17 00:00:00 2001 From: Bernardo Sulzbach Date: Mon, 30 Oct 2017 16:01:16 -0200 Subject: [PATCH] Should have a Banishment spell Closed #412 --- .../dungeon/spells/SpellData.java | 38 +++++++++++++++++++ src/main/resources/items.json | 24 ++++++++++++ src/main/resources/locations.json | 4 ++ 3 files changed, 66 insertions(+) diff --git a/src/main/java/org/mafagafogigante/dungeon/spells/SpellData.java b/src/main/java/org/mafagafogigante/dungeon/spells/SpellData.java index 10873168..b6902e86 100644 --- a/src/main/java/org/mafagafogigante/dungeon/spells/SpellData.java +++ b/src/main/java/org/mafagafogigante/dungeon/spells/SpellData.java @@ -1,6 +1,7 @@ package org.mafagafogigante.dungeon.spells; import org.mafagafogigante.dungeon.entity.creatures.Creature; +import org.mafagafogigante.dungeon.entity.creatures.HealthState; import org.mafagafogigante.dungeon.entity.creatures.Hero; import org.mafagafogigante.dungeon.entity.creatures.HeroUtils; import org.mafagafogigante.dungeon.entity.items.Item; @@ -186,6 +187,43 @@ public void operate(Hero hero, String[] targetMatcher) { } } }); + putSpell(new Spell("BANISH", "Banish") { + + static final int SECONDS_TO_CAST = 10; + + @Override + public void operate(Hero hero, String[] targetMatcher) { + if (targetMatcher.length == 0) { + Writer.getDefaultWriter().write("Provide a target."); + } else { + Creature target = hero.findCreature(targetMatcher); + if (target != null) { + if (target == hero) { + Writer.getDefaultWriter().write("You cannot cast banish on yourself."); + return; + } + Game.getGameState().getEngine().rollDateAndRefresh(SECONDS_TO_CAST); + Writer.getDefaultWriter().write("You casted " + getName() + " on " + target.getName().getSingular() + "."); + if (target.getHealth().getHealthState() == HealthState.DEAD) { + Writer.getDefaultWriter().write("Your target seems to be already dead."); + } else { + double missingRatio = 1.0 - target.getHealth().getCurrent() / (double) target.getHealth().getMaximum(); + double successProbability = 0.1 + Math.pow(Math.sqrt(0.9) * missingRatio, 2); + if (Random.roll(successProbability)) { + hero.getLocation().removeCreature(target); + Writer.getDefaultWriter().write("You banished " + target.getName().getSingular() + "!"); + } else { + RichStringSequence stringSequence = new RichStringSequence(); + stringSequence.append("You failed to banish " + target.getName().getSingular() + "."); + stringSequence.append("\n"); + stringSequence.append("Try damaging " + target.getName().getSingular() + " so it is less resistant."); + Writer.getDefaultWriter().write(stringSequence); + } + } + } + } + } + }); putSpell(new Spell("DISPLACE", "Displace") { static final int SECONDS_TO_CAST_DISPLACE = 15; diff --git a/src/main/resources/items.json b/src/main/resources/items.json index c5ea6506..6a07de4a 100644 --- a/src/main/resources/items.json +++ b/src/main/resources/items.json @@ -1157,6 +1157,30 @@ "nutrition": -5, "integrityDecrementOnEat": 10 }, + { + "id": "TOME_OF_BANISH", + "type": "Book", + "name": { + "singular": "Tome of Banish", + "plural": "Tomes of Banish" + }, + "rarity": "UNCOMMON", + "tags": [ + "WEAPON", + "BOOK" + ], + "integrity": { + "current": 20, + "maximum": 20 + }, + "weight": 0.6, + "visibility": "60.00%", + "damage": 6, + "hitRate": "70.00%", + "integrityDecrementOnHit": 4, + "text": "The Banish spell permanently banishes a weak creature from this plane.", + "spell": "BANISH" + }, { "id": "TOME_OF_HEAL", "type": "Book", diff --git a/src/main/resources/locations.json b/src/main/resources/locations.json index 819d945c..2791d124 100644 --- a/src/main/resources/locations.json +++ b/src/main/resources/locations.json @@ -68,6 +68,10 @@ "id": "TOME_OF_UNVEIL", "probability": 0.15 }, + { + "id": "TOME_OF_BANISH", + "probability": 0.15 + }, { "id": "DAGGER", "probability": 0.2