Compare commits
8 Commits
d69376c110
...
9f5303ba74
Author | SHA1 | Date | |
---|---|---|---|
9f5303ba74 | |||
48409b1e4a | |||
fbe38c978a | |||
6ab818b155 | |||
77be059d45 | |||
ddd0f2f953 | |||
dd8e9813fa | |||
e68298781b |
44
build.gradle
44
build.gradle
@ -18,6 +18,50 @@ test {
|
|||||||
maxParallelForks = 1
|
maxParallelForks = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Fancy live test output (from https://stackoverflow.com/questions/3963708/gradle-how-to-display-test-results-in-the-console-in-real-time)
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
|
||||||
|
tasks.withType(Test) {
|
||||||
|
testLogging {
|
||||||
|
// set options for log level LIFECYCLE
|
||||||
|
events TestLogEvent.FAILED,
|
||||||
|
TestLogEvent.PASSED,
|
||||||
|
TestLogEvent.SKIPPED
|
||||||
|
// TestLogEvent.STANDARD_OUT
|
||||||
|
exceptionFormat TestExceptionFormat.FULL
|
||||||
|
showExceptions true
|
||||||
|
showCauses true
|
||||||
|
showStackTraces true
|
||||||
|
|
||||||
|
// set options for log level DEBUG and INFO
|
||||||
|
debug {
|
||||||
|
events TestLogEvent.STARTED,
|
||||||
|
TestLogEvent.FAILED,
|
||||||
|
TestLogEvent.PASSED,
|
||||||
|
TestLogEvent.SKIPPED,
|
||||||
|
TestLogEvent.STANDARD_ERROR
|
||||||
|
TestLogEvent.STANDARD_OUT
|
||||||
|
exceptionFormat TestExceptionFormat.FULL
|
||||||
|
}
|
||||||
|
// info.events = debug.events
|
||||||
|
// info.exceptionFormat = debug.exceptionFormat
|
||||||
|
|
||||||
|
afterSuite { desc, result ->
|
||||||
|
if (!desc.parent) { // will match the outermost suite
|
||||||
|
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
|
||||||
|
def startItem = '| ', endItem = ' |'
|
||||||
|
def repeatLength = startItem.length() + output.length() + endItem.length()
|
||||||
|
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
jacocoTestReport {
|
jacocoTestReport {
|
||||||
reports {
|
reports {
|
||||||
html.enabled true
|
html.enabled true
|
||||||
|
@ -110,6 +110,7 @@ public class IntVector2 implements Serializable {
|
|||||||
return dot(v.x, v.y);
|
return dot(v.x, v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This returns a new Vector for now, but should scale the actually modified vector
|
||||||
public IntVector2 scale(float x, float y) {
|
public IntVector2 scale(float x, float y) {
|
||||||
return new IntVector2(Math.round(this.x * x), Math.round(this.y * y));
|
return new IntVector2(Math.round(this.x * x), Math.round(this.y * y));
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,15 @@ public class Stat {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new {@link Stat} with the same values as the
|
||||||
|
* given {@link Stat}
|
||||||
|
* @param toCopy is the {@link Stat} to copy
|
||||||
|
*/
|
||||||
|
public Stat(Stat toCopy) {
|
||||||
|
this(toCopy.type, toCopy.value, toCopy.max);
|
||||||
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -131,17 +131,12 @@ public class GameLogic {
|
|||||||
case SpaceStone -> {
|
case SpaceStone -> {
|
||||||
verifyCoordinates(state, data.targetField);
|
verifyCoordinates(state, data.targetField);
|
||||||
|
|
||||||
if(state.entities.blocksMovement(data.targetField)) {
|
if(state.entities.findByPosition(data.targetField).size() != 0) {
|
||||||
throw new InvalidRequestException("Using space stone onto blocked field");
|
throw new InvalidRequestException("Using space stone onto non-free field");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case MindStone -> {
|
case MindStone -> {
|
||||||
if(data.originField == data.targetField) {
|
requireLineOfSight(state, data.originField, data.targetField);
|
||||||
throw new InvalidRequestException("Invalid mind stone target field");
|
|
||||||
}
|
|
||||||
if(data.value != state.partyConfig.mindStoneDMG) {
|
|
||||||
throw new InvalidRequestException("Invalid mind stone damage");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case RealityStone -> {
|
case RealityStone -> {
|
||||||
// no check done
|
// no check done
|
||||||
@ -452,28 +447,45 @@ public class GameLogic {
|
|||||||
.withOriginField(data.originField)
|
.withOriginField(data.originField)
|
||||||
.withTargetField(data.targetField)
|
.withTargetField(data.targetField)
|
||||||
.buildCharacterEvent());
|
.buildCharacterEvent());
|
||||||
for(Entity entity: state.entities.findByPosition(data.targetField)) {
|
|
||||||
if(entity instanceof InfinityStone) {
|
|
||||||
result.add(new EventBuilder(EventType.DestroyedEntityEvent)
|
|
||||||
.withTargetField(data.targetField)
|
|
||||||
.withTargetEntity(entity.id)
|
|
||||||
.buildEntityEvent());
|
|
||||||
break; //we should only have one entity per field anyways
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case MindStone -> {
|
case MindStone -> {
|
||||||
EntityType target = data.originEntity.type == EntityType.P1 ? EntityType.P2 : EntityType.P1;
|
Entity targetEntity = state.entities.findEntity(data.targetEntity);
|
||||||
for(IntVector2 pos: rasterizeInfinity(data.originField, data.targetField, state.mapSize, false)) {
|
|
||||||
for(Entity entity: state.entities.findByPosition(pos)) {
|
|
||||||
if(entity.id.isSameType(target)) {
|
|
||||||
result.add(new EventBuilder(EventType.TakenDamageEvent)
|
result.add(new EventBuilder(EventType.TakenDamageEvent)
|
||||||
.withTargetEntity(entity.id)
|
.withTargetEntity(targetEntity.id)
|
||||||
.withTargetField(pos)
|
.withTargetField(data.targetField)
|
||||||
.withAmount(data.value)
|
.withAmount(state.partyConfig.mindStoneDMG)
|
||||||
|
.buildEntityEvent());
|
||||||
|
|
||||||
|
if(targetEntity instanceof Character) {
|
||||||
|
Character target = (Character)targetEntity;
|
||||||
|
if(target.hp.getValue() <= data.value) {
|
||||||
|
|
||||||
|
List<StoneType> stones = Arrays.asList(target.inventory.getStonesAsArray());
|
||||||
|
Collections.shuffle(stones); // required by documents
|
||||||
|
|
||||||
|
ArrayList<IntVector2> used = new ArrayList<>();
|
||||||
|
for(StoneType stone: stones) {
|
||||||
|
ArrayList<IntVector2> options = getFreeNeighbour(state, target.getPosition(), used);
|
||||||
|
IntVector2 picked = options.get(rand.nextInt(options.size()));
|
||||||
|
used.add(picked);
|
||||||
|
result.add(new EventBuilder(EventType.SpawnEntityEvent)
|
||||||
|
.withEntity(new InfinityStone(
|
||||||
|
new EntityID(EntityType.InfinityStones, stone.getID()),
|
||||||
|
picked,
|
||||||
|
stone
|
||||||
|
))
|
||||||
.buildEntityEvent());
|
.buildEntityEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else if(targetEntity instanceof Rock) {
|
||||||
|
Rock target = (Rock)targetEntity;
|
||||||
|
if(target.getHp() <= data.value) {
|
||||||
|
result.add(new EventBuilder(EventType.DestroyedEntityEvent)
|
||||||
|
.withTargetField(data.targetField)
|
||||||
|
.withTargetEntity(target.id)
|
||||||
|
.buildEntityEvent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case RealityStone -> {
|
case RealityStone -> {
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
package uulm.teamname.marvelous.gamelibrary;
|
||||||
|
|
||||||
|
import net.jqwik.api.*;
|
||||||
|
import net.jqwik.api.Tuple;
|
||||||
|
import net.jqwik.api.lifecycle.BeforeProperty;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class IntVector2Test {
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
@BeforeProperty
|
||||||
|
void beforeAll() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Property
|
||||||
|
@Disabled("This test fails! Therefore,a bug exists here")
|
||||||
|
void settingLengthToOneResultsInCardinalDirections(
|
||||||
|
@ForAll int x,
|
||||||
|
@ForAll int y
|
||||||
|
) {
|
||||||
|
var vec = new IntVector2(x, y).setLength(1);
|
||||||
|
// System.out.printf("Input was (%d, %d). Output is %s\n", x, y, vec);
|
||||||
|
if (!vec.equals(new IntVector2(0, 0))) {
|
||||||
|
assertThat(IntVector2.CardinalDirections)
|
||||||
|
.contains(vec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Property
|
||||||
|
void settingSmallVectorLengthResultsInCardinalDirections(
|
||||||
|
@ForAll("SmallIntegers") Integer x,
|
||||||
|
@ForAll("SmallIntegers") Integer y
|
||||||
|
) {
|
||||||
|
var vec = new IntVector2(x, y).setLength(1);
|
||||||
|
// System.out.printf("Input was (%d, %d). Output is %s\n", x, y, vec);
|
||||||
|
if (!vec.equals(new IntVector2(0, 0))) {
|
||||||
|
assertThat(IntVector2.CardinalDirections)
|
||||||
|
.contains(vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setLengthCardinalTest() {
|
||||||
|
assertThat(new IntVector2(1, 1).setLength(1))
|
||||||
|
.isEqualTo(new IntVector2(1, 1));
|
||||||
|
assertThat(new IntVector2(0, 1).setLength(1))
|
||||||
|
.isEqualTo(new IntVector2(0, 1));
|
||||||
|
assertThat(new IntVector2(1, -1).setLength(1))
|
||||||
|
.isEqualTo(new IntVector2(1, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provide("SmallIntegers")
|
||||||
|
Arbitrary<Integer> smallIntegers() {
|
||||||
|
return Arbitraries.integers()
|
||||||
|
.between(-1000, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -120,7 +120,7 @@ class MessageValidationUtilityTest {
|
|||||||
var characterConfig = new CharacterConfig();
|
var characterConfig = new CharacterConfig();
|
||||||
|
|
||||||
assertThat(ValidationUtility.validate(characterConfig).get())
|
assertThat(ValidationUtility.validate(characterConfig).get())
|
||||||
.isIn("characters mus not be empty", "characters darf nicht leer sein");
|
.isIn("characters must not be empty", "characters darf nicht leer sein");
|
||||||
// .isEqualTo("characters must not be empty");
|
// .isEqualTo("characters must not be empty");
|
||||||
|
|
||||||
characterConfig.characters = new CharacterProperties[] {racoon, quicksilver, hulk, loki, silversurfer};
|
characterConfig.characters = new CharacterProperties[] {racoon, quicksilver, hulk, loki, silversurfer};
|
||||||
|
Loading…
Reference in New Issue
Block a user