Job + Spell merge #9
3
pom.xml
3
pom.xml
@@ -20,10 +20,9 @@
|
||||
<version>5.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest</artifactId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -4,16 +4,16 @@ import Job.HasJob;
|
||||
import Job.Wizard;
|
||||
|
||||
public class CastAction implements Action {
|
||||
@Override
|
||||
public void exectue(Actor actor) {
|
||||
Wizard wizard = requireWizard(actor);
|
||||
wizard.castSpell(actor);
|
||||
}
|
||||
|
||||
private Wizard requireWizard(Actor actor) {
|
||||
if (actor instanceof HasJob hasJob && hasJob.getJob() instanceof Wizard wizard) {
|
||||
return wizard;
|
||||
}
|
||||
throw new IllegalStateException(actor + " cannot perform this action without being a Wizard!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Actor player) {
|
||||
var wizard = requireWizard(player);
|
||||
wizard.castSpell(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import Job.Wizard;
|
||||
|
||||
public class LearnSpellAction implements Action {
|
||||
@Override
|
||||
public void exectue(Actor actor) {
|
||||
public void execute(Actor actor) {
|
||||
Wizard wizard = requireWizard(actor);
|
||||
wizard.learnSpell(actor);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ public class Player extends Entity implements Movable, Actor, HasInventory, HasS
|
||||
protected Job job;
|
||||
protected Position position = new Position(0,0);
|
||||
protected Inventory inventory= new Inventory();
|
||||
protected Position position;
|
||||
protected List<String> items = new LinkedList<>();
|
||||
protected List<Spell> spells = new LinkedList<>();
|
||||
public Player(String name, Job job) {
|
||||
super(name);
|
||||
@@ -42,7 +40,7 @@ public class Player extends Entity implements Movable, Actor, HasInventory, HasS
|
||||
|
||||
@Override
|
||||
public boolean canMoveTo(Position position) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public Job getJob() {
|
||||
return job;
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
import Action.Actor;
|
||||
import Combat.HasMana;
|
||||
import Combat.OffensiveDamageSpell;
|
||||
import Combat.Spell;
|
||||
import Entity.Entity;
|
||||
import Entity.Player;
|
||||
import Inventory.HasSpellBook;
|
||||
import Job.Wizard;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
||||
public class InterestingTests {
|
||||
|
||||
@@ -67,7 +59,7 @@ public class InterestingTests {
|
||||
|
||||
wizard.castSpell(player);
|
||||
|
||||
assertThat(player.getMana(),is(initialMana));
|
||||
assertThat(player.getMana(), is(initialMana));
|
||||
assertThat(player.getHealth(),is(initialHealth));
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class MagicSystemTest {
|
||||
CastAction action = new CastAction();
|
||||
IllegalStateException exception = assertThrows(
|
||||
IllegalStateException.class,
|
||||
() -> action.exectue(p)
|
||||
() -> action.execute(p)
|
||||
);
|
||||
|
||||
assertTrue(exception.getMessage().contains("cannot perform this action without being a Wizard"));
|
||||
@@ -28,7 +28,7 @@ public class MagicSystemTest {
|
||||
LearnSpellAction action = new LearnSpellAction();
|
||||
IllegalStateException exception = assertThrows(
|
||||
IllegalStateException.class,
|
||||
() -> action.exectue(p)
|
||||
() -> action.execute(p)
|
||||
);
|
||||
assertTrue(exception.getMessage().contains("cannot perform this action without being a Wizard"));
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ public class MinerTest {
|
||||
assertEquals(10, job.getExperience());
|
||||
}
|
||||
|
||||
@Test
|
||||
void dig_on_ice_require_ice_pick() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user