From 3a5393c512fc66ede71913567528e5d220bd525c Mon Sep 17 00:00:00 2001 From: Alexander-D-Karpov Date: Tue, 17 Oct 2023 01:15:53 +0300 Subject: [PATCH] added code for pokemons and moves --- .gitignore | 1 + lab-2.iml | 12 ++++++++++++ src/Main.java | 21 +++++++++++++++++++++ src/Moves/Confide.java | 21 +++++++++++++++++++++ src/Moves/DarkPulse.java | 30 ++++++++++++++++++++++++++++++ src/Moves/DoubleHit.java | 21 +++++++++++++++++++++ src/Moves/Extrasensory.java | 27 +++++++++++++++++++++++++++ src/Moves/HyperVoice.java | 15 +++++++++++++++ src/Moves/Leer.java | 22 ++++++++++++++++++++++ src/Moves/NightSlash.java | 15 +++++++++++++++ src/Moves/Rest.java | 24 ++++++++++++++++++++++++ src/Moves/Roost.java | 30 ++++++++++++++++++++++++++++++ src/Moves/Snarl.java | 24 ++++++++++++++++++++++++ src/Moves/ThunderWave.java | 27 +++++++++++++++++++++++++++ src/Moves/Thunderbolt.java | 27 +++++++++++++++++++++++++++ src/Pokemons/Deino.java | 15 +++++++++++++++ src/Pokemons/Hydreigon.java | 11 +++++++++++ src/Pokemons/Uxie.java | 19 +++++++++++++++++++ src/Pokemons/Zoroark.java | 14 ++++++++++++++ src/Pokemons/Zorua.java | 16 ++++++++++++++++ src/Pokemons/Zweilous.java | 11 +++++++++++ 21 files changed, 403 insertions(+) create mode 100644 lab-2.iml create mode 100644 src/Main.java create mode 100644 src/Moves/Confide.java create mode 100644 src/Moves/DarkPulse.java create mode 100644 src/Moves/DoubleHit.java create mode 100644 src/Moves/Extrasensory.java create mode 100644 src/Moves/HyperVoice.java create mode 100644 src/Moves/Leer.java create mode 100644 src/Moves/NightSlash.java create mode 100644 src/Moves/Rest.java create mode 100644 src/Moves/Roost.java create mode 100644 src/Moves/Snarl.java create mode 100644 src/Moves/ThunderWave.java create mode 100644 src/Moves/Thunderbolt.java create mode 100644 src/Pokemons/Deino.java create mode 100644 src/Pokemons/Hydreigon.java create mode 100644 src/Pokemons/Uxie.java create mode 100644 src/Pokemons/Zoroark.java create mode 100644 src/Pokemons/Zorua.java create mode 100644 src/Pokemons/Zweilous.java diff --git a/.gitignore b/.gitignore index 9154f4c..7941b1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea # ---> Java # Compiled class file *.class diff --git a/lab-2.iml b/lab-2.iml new file mode 100644 index 0000000..de96565 --- /dev/null +++ b/lab-2.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..c4ee437 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,21 @@ +import Pokemons.*; +import ru.ifmo.se.pokemon.*; + +public class Main { + public static void main(String[] args) { + Battle battle = new Battle(); + + Pokemon deino = new Deino("[368403] Куликов Алексей", 69); + Pokemon hydreigon = new Hydreigon("[409163] Молодиченко Семен", 69); + Pokemon uxie = new Uxie("[408837] Комилов Масрур", 69); + Pokemon zoroark = new Zoroark("[409938] Юсупова Алиса", 69); + Pokemon zweilous = new Zweilous("[342582] Карпов Александр", 69); + + battle.addAlly(deino); + battle.addAlly(hydreigon); + battle.addAlly(uxie); + battle.addFoe(zoroark); + battle.addFoe(zweilous); + battle.go(); + } +} \ No newline at end of file diff --git a/src/Moves/Confide.java b/src/Moves/Confide.java new file mode 100644 index 0000000..40d37f1 --- /dev/null +++ b/src/Moves/Confide.java @@ -0,0 +1,21 @@ +package Moves; + +import ru.ifmo.se.pokemon.*; + +public class Confide extends StatusMove { + public Confide(){ + super(Type.NORMAL, 0, 0); + } + + @Override + protected void applyOppEffects(Pokemon pokemon) { + int specAtt = (int) pokemon.getStat(Stat.SPECIAL_ATTACK); + if (specAtt != 0) { + pokemon.setMod(Stat.SPECIAL_ATTACK, specAtt-1); + } + } + @Override + protected String describe() { + return "признался"; + } +} diff --git a/src/Moves/DarkPulse.java b/src/Moves/DarkPulse.java new file mode 100644 index 0000000..f669949 --- /dev/null +++ b/src/Moves/DarkPulse.java @@ -0,0 +1,30 @@ +package Moves; + +import ru.ifmo.se.pokemon.Effect; +import ru.ifmo.se.pokemon.Pokemon; +import ru.ifmo.se.pokemon.SpecialMove; +import ru.ifmo.se.pokemon.Type; + +public class DarkPulse extends SpecialMove { + private boolean success = false; + public DarkPulse(){ + super(Type.PSYCHIC, 80, 100); + } + + @Override + protected void applyOppEffects(Pokemon pokemon) { + int chance = (int)(Math.random() * 101); + if (chance <= 20) { + this.success = true; + Effect.flinch(pokemon); + } + } + + @Override + protected String describe() { + if (this.success) { + return "успешно запулсировал"; + } + return "запулсировал"; + } +} diff --git a/src/Moves/DoubleHit.java b/src/Moves/DoubleHit.java new file mode 100644 index 0000000..c4bbb50 --- /dev/null +++ b/src/Moves/DoubleHit.java @@ -0,0 +1,21 @@ +package Moves; + +import ru.ifmo.se.pokemon.PhysicalMove; +import ru.ifmo.se.pokemon.Pokemon; +import ru.ifmo.se.pokemon.Stat; +import ru.ifmo.se.pokemon.Type; + +public class DoubleHit extends PhysicalMove { + public DoubleHit(){ + super(Type.NORMAL, 35, 90); + } + + @Override + protected void applyOppDamage(Pokemon pokemon, double value) { + pokemon.setMod(Stat.HP, (int)Math.round(value * 2)); + } + @Override + protected String describe() { + return "ударил 2 раза"; + } +} diff --git a/src/Moves/Extrasensory.java b/src/Moves/Extrasensory.java new file mode 100644 index 0000000..89ad094 --- /dev/null +++ b/src/Moves/Extrasensory.java @@ -0,0 +1,27 @@ +package Moves; + +import ru.ifmo.se.pokemon.*; + +public class Extrasensory extends SpecialMove { + private boolean success = false; + public Extrasensory(){ + super(Type.PSYCHIC, 80, 100); + } + + @Override + protected void applyOppEffects(Pokemon pokemon) { + int chance = (int)(Math.random() * 101); + if (chance <= 10) { + this.success = true; + Effect.flinch(pokemon); + } + } + + @Override + protected String describe() { + if (this.success) { + return "прочитал мысли"; + } + return "прочитал мысли, но ничего не понял, у"; + } +} diff --git a/src/Moves/HyperVoice.java b/src/Moves/HyperVoice.java new file mode 100644 index 0000000..8f57727 --- /dev/null +++ b/src/Moves/HyperVoice.java @@ -0,0 +1,15 @@ +package Moves; + +import ru.ifmo.se.pokemon.SpecialMove; +import ru.ifmo.se.pokemon.Type; + +public class HyperVoice extends SpecialMove { + public HyperVoice(){ + super(Type.NORMAL, 90, 100); + } + @Override + protected String describe() { + return "накричал на"; + } + +} diff --git a/src/Moves/Leer.java b/src/Moves/Leer.java new file mode 100644 index 0000000..8562799 --- /dev/null +++ b/src/Moves/Leer.java @@ -0,0 +1,22 @@ +package Moves; + +import ru.ifmo.se.pokemon.*; + +public class Leer extends StatusMove { + public Leer(){ + super(Type.NORMAL, 0, 100); + } + + @Override + protected void applyOppEffects(Pokemon pokemon) { + int def = (int) pokemon.getStat(Stat.DEFENSE); + if (def != 0) { + pokemon.setMod(Stat.DEFENSE, def-1); + } + } + + @Override + protected String describe() { + return "обозвал"; + } +} diff --git a/src/Moves/NightSlash.java b/src/Moves/NightSlash.java new file mode 100644 index 0000000..88e63a0 --- /dev/null +++ b/src/Moves/NightSlash.java @@ -0,0 +1,15 @@ +package Moves; + +import ru.ifmo.se.pokemon.PhysicalMove; +import ru.ifmo.se.pokemon.Type; + +public class NightSlash extends PhysicalMove { + + public NightSlash(){ + super(Type.DARK, 70, 100); + } + @Override + protected String describe() { + return "ударил со спины"; + } +} diff --git a/src/Moves/Rest.java b/src/Moves/Rest.java new file mode 100644 index 0000000..e353552 --- /dev/null +++ b/src/Moves/Rest.java @@ -0,0 +1,24 @@ +package Moves; + +import ru.ifmo.se.pokemon.*; + +public class Rest extends StatusMove{ + public Rest(){ + super(Type.PSYCHIC, 0, 0); + } + @Override + protected void applySelfEffects(Pokemon pokemon){ + pokemon.setMod(Stat.HP, (int)(pokemon.getHP() - pokemon.getStat(Stat.HP))); + pokemon.setCondition((new Effect()).condition(Status.SLEEP).turns(2).attack(0)); + } + + @Override + protected boolean checkAccuracy(Pokemon var1, Pokemon var2) { + // Rest accuracy - n/a + return true; + } + @Override + protected String describe() { + return "уснул на 2 пары"; + } +} \ No newline at end of file diff --git a/src/Moves/Roost.java b/src/Moves/Roost.java new file mode 100644 index 0000000..1b6ea64 --- /dev/null +++ b/src/Moves/Roost.java @@ -0,0 +1,30 @@ +package Moves; + +import ru.ifmo.se.pokemon.*; + +public class Roost extends StatusMove { + public Roost(){ + super(Type.FIGHTING, 0, 0); + } + @Override + protected void applySelfEffects(Pokemon pokemon){ + int curHp = (int)(pokemon.getHP()); + int maxHp = (int) pokemon.getStat(Stat.HP); + if ((maxHp - curHp) < maxHp / 2) { + pokemon.setMod(Stat.HP, (int)(pokemon.getHP() + maxHp / 2)); + } + else { + pokemon.setMod(Stat.HP, (int)(pokemon.getHP() - pokemon.getStat(Stat.HP))); + } + } + + @Override + protected boolean checkAccuracy(Pokemon var1, Pokemon var2) { + // Rest accuracy - n/a + return true; + } + @Override + protected String describe() { + return "уснул на 2 пары"; + } +} diff --git a/src/Moves/Snarl.java b/src/Moves/Snarl.java new file mode 100644 index 0000000..5492adc --- /dev/null +++ b/src/Moves/Snarl.java @@ -0,0 +1,24 @@ +package Moves; + +import ru.ifmo.se.pokemon.Pokemon; +import ru.ifmo.se.pokemon.SpecialMove; +import ru.ifmo.se.pokemon.Stat; +import ru.ifmo.se.pokemon.Type; + +public class Snarl extends SpecialMove { + public Snarl(){ + super(Type.DARK, 55, 95); + } + + @Override + protected void applyOppEffects(Pokemon pokemon) { + int specAtt = (int) pokemon.getStat(Stat.SPECIAL_ATTACK); + if (specAtt != 0) { + pokemon.setMod(Stat.SPECIAL_ATTACK, specAtt-1); + } + } + @Override + protected String describe() { + return "рыкнул на"; + } +} diff --git a/src/Moves/ThunderWave.java b/src/Moves/ThunderWave.java new file mode 100644 index 0000000..9df3a34 --- /dev/null +++ b/src/Moves/ThunderWave.java @@ -0,0 +1,27 @@ +package Moves; + +import ru.ifmo.se.pokemon.*; + +public class ThunderWave extends StatusMove { + private boolean success = false; + public ThunderWave(){ + super(Type.ELECTRIC, 0, 90); + } + + @Override + protected void applyOppEffects(Pokemon pokemon) { + int chance = (int)(Math.random() * 101); + if (chance >= 10) { + this.success = true; + pokemon.setCondition((new Effect()).condition(Status.PARALYZE)); + } + } + + @Override + protected String describe() { + if (this.success) { + return "успешно кинул оголенный провод в"; + } + return "кинул оголенный провод в"; + } +} diff --git a/src/Moves/Thunderbolt.java b/src/Moves/Thunderbolt.java new file mode 100644 index 0000000..c6f42b0 --- /dev/null +++ b/src/Moves/Thunderbolt.java @@ -0,0 +1,27 @@ +package Moves; + +import ru.ifmo.se.pokemon.*; + +public class Thunderbolt extends SpecialMove { + private boolean success = false; + public Thunderbolt(){ + super(Type.ELECTRIC, 90, 100); + } + + @Override + protected void applyOppEffects(Pokemon pokemon) { + int chance = (int)(Math.random() * 101); + if (chance <= 10) { + this.success = true; + pokemon.setCondition((new Effect()).condition(Status.PARALYZE)); + } + } + + @Override + protected String describe() { + if (this.success) { + return "успешно отравил просроченным энергетиком"; + } + return "подкинул просроченный энергетик"; + } +} diff --git a/src/Pokemons/Deino.java b/src/Pokemons/Deino.java new file mode 100644 index 0000000..527c6b0 --- /dev/null +++ b/src/Pokemons/Deino.java @@ -0,0 +1,15 @@ +package Pokemons; + +import Moves.DarkPulse; +import Moves.HyperVoice; +import ru.ifmo.se.pokemon.Pokemon; +import ru.ifmo.se.pokemon.Type; + +public class Deino extends Pokemon { + public Deino(String name, int level) { + super(name, level); + setStats(52, 65, 50, 45, 50, 38); + setType(Type.DARK, Type.DRAGON); + setMove(new HyperVoice(), new DarkPulse()); + } +} \ No newline at end of file diff --git a/src/Pokemons/Hydreigon.java b/src/Pokemons/Hydreigon.java new file mode 100644 index 0000000..3c7c3e8 --- /dev/null +++ b/src/Pokemons/Hydreigon.java @@ -0,0 +1,11 @@ +package Pokemons; + +import Moves.Roost; + +public class Hydreigon extends Zweilous{ + public Hydreigon(String name, int level) { + super(name, level); + setStats(92, 105, 90, 125, 90, 98); + addMove(new Roost()); + } +} diff --git a/src/Pokemons/Uxie.java b/src/Pokemons/Uxie.java new file mode 100644 index 0000000..9efd758 --- /dev/null +++ b/src/Pokemons/Uxie.java @@ -0,0 +1,19 @@ +package Pokemons; + +import Moves.Extrasensory; +import Moves.Rest; +import Moves.ThunderWave; +import Moves.Thunderbolt; +import ru.ifmo.se.pokemon.Pokemon; +import ru.ifmo.se.pokemon.Type; + + + +public class Uxie extends Pokemon { + public Uxie(String name, int level) { + super(name, level); + setStats(75, 75, 130, 75, 130, 95); + setType(Type.PSYCHIC); + setMove(new Rest(), new ThunderWave(), new Thunderbolt(), new Extrasensory()); + } +} diff --git a/src/Pokemons/Zoroark.java b/src/Pokemons/Zoroark.java new file mode 100644 index 0000000..780d9e2 --- /dev/null +++ b/src/Pokemons/Zoroark.java @@ -0,0 +1,14 @@ +package Pokemons; + + +import Moves.NightSlash; +import ru.ifmo.se.pokemon.Type; + +public class Zoroark extends Zorua{ + public Zoroark(String name, int level){ + super(name, level); + setType(Type.DARK); + setStats(60, 105, 60, 120, 60, 105); + addMove(new NightSlash()); + } +} \ No newline at end of file diff --git a/src/Pokemons/Zorua.java b/src/Pokemons/Zorua.java new file mode 100644 index 0000000..f05e8ad --- /dev/null +++ b/src/Pokemons/Zorua.java @@ -0,0 +1,16 @@ +package Pokemons; + +import Moves.Confide; +import Moves.Leer; +import Moves.Snarl; +import ru.ifmo.se.pokemon.Pokemon; +import ru.ifmo.se.pokemon.Type; + +public class Zorua extends Pokemon { + public Zorua(String name, int level) { + super(name, level); + setStats(40, 65, 40, 80, 40, 65); + setType(Type.DARK); + setMove(new Leer(), new Snarl(), new Confide()); + } +} diff --git a/src/Pokemons/Zweilous.java b/src/Pokemons/Zweilous.java new file mode 100644 index 0000000..cab3c8b --- /dev/null +++ b/src/Pokemons/Zweilous.java @@ -0,0 +1,11 @@ +package Pokemons; + +import Moves.DoubleHit; + +public class Zweilous extends Deino { + public Zweilous(String name, int level) { + super(name, level); + setStats(72, 85, 70, 65, 70, 58); + addMove(new DoubleHit()); + } +} \ No newline at end of file