added code for pokemons and moves
This commit is contained in:
parent
80b10f1a31
commit
3a5393c512
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
.idea
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
|
12
lab-2.iml
Normal file
12
lab-2.iml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Pokemon" level="project" />
|
||||
</component>
|
||||
</module>
|
21
src/Main.java
Normal file
21
src/Main.java
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
21
src/Moves/Confide.java
Normal file
21
src/Moves/Confide.java
Normal file
|
@ -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 "признался";
|
||||
}
|
||||
}
|
30
src/Moves/DarkPulse.java
Normal file
30
src/Moves/DarkPulse.java
Normal file
|
@ -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 "запулсировал";
|
||||
}
|
||||
}
|
21
src/Moves/DoubleHit.java
Normal file
21
src/Moves/DoubleHit.java
Normal file
|
@ -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 раза";
|
||||
}
|
||||
}
|
27
src/Moves/Extrasensory.java
Normal file
27
src/Moves/Extrasensory.java
Normal file
|
@ -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 "прочитал мысли, но ничего не понял, у";
|
||||
}
|
||||
}
|
15
src/Moves/HyperVoice.java
Normal file
15
src/Moves/HyperVoice.java
Normal file
|
@ -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 "накричал на";
|
||||
}
|
||||
|
||||
}
|
22
src/Moves/Leer.java
Normal file
22
src/Moves/Leer.java
Normal file
|
@ -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 "обозвал";
|
||||
}
|
||||
}
|
15
src/Moves/NightSlash.java
Normal file
15
src/Moves/NightSlash.java
Normal file
|
@ -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 "ударил со спины";
|
||||
}
|
||||
}
|
24
src/Moves/Rest.java
Normal file
24
src/Moves/Rest.java
Normal file
|
@ -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 пары";
|
||||
}
|
||||
}
|
30
src/Moves/Roost.java
Normal file
30
src/Moves/Roost.java
Normal file
|
@ -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 пары";
|
||||
}
|
||||
}
|
24
src/Moves/Snarl.java
Normal file
24
src/Moves/Snarl.java
Normal file
|
@ -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 "рыкнул на";
|
||||
}
|
||||
}
|
27
src/Moves/ThunderWave.java
Normal file
27
src/Moves/ThunderWave.java
Normal file
|
@ -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 "кинул оголенный провод в";
|
||||
}
|
||||
}
|
27
src/Moves/Thunderbolt.java
Normal file
27
src/Moves/Thunderbolt.java
Normal file
|
@ -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 "подкинул просроченный энергетик";
|
||||
}
|
||||
}
|
15
src/Pokemons/Deino.java
Normal file
15
src/Pokemons/Deino.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
11
src/Pokemons/Hydreigon.java
Normal file
11
src/Pokemons/Hydreigon.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
19
src/Pokemons/Uxie.java
Normal file
19
src/Pokemons/Uxie.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
14
src/Pokemons/Zoroark.java
Normal file
14
src/Pokemons/Zoroark.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
16
src/Pokemons/Zorua.java
Normal file
16
src/Pokemons/Zorua.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
11
src/Pokemons/Zweilous.java
Normal file
11
src/Pokemons/Zweilous.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user