Compare commits

...

4 Commits

3 changed files with 56 additions and 8 deletions

View File

@ -2,6 +2,7 @@ plugins {
id 'java' id 'java'
id 'idea' id 'idea'
id "org.sonarqube" version "3.2.0" id "org.sonarqube" version "3.2.0"
id 'jacoco'
} }
repositories { repositories {
@ -17,6 +18,28 @@ test {
maxParallelForks = 1 maxParallelForks = 1
} }
jacocoTestReport {
reports {
html.enabled true
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco.xml")
}
}
plugins.withType(JacocoPlugin) {
tasks["test"].finalizedBy 'jacocoTestReport'
}
sonarqube {
properties {
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.host.url", "https://sonarqube.yandrik.dev"
property "sonar.coverage.jacoco.xmlReportPath", "${buildDir}/reports/jacoco.xml"
}
}
dependencies { dependencies {
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4' implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.4' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.4'

View File

@ -452,6 +452,15 @@ 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; EntityType target = data.originEntity.type == EntityType.P1 ? EntityType.P2 : EntityType.P1;
@ -490,11 +499,15 @@ public class GameLogic {
case PowerStone -> { case PowerStone -> {
Character origin = (Character)state.entities.findEntity(data.originEntity); Character origin = (Character)state.entities.findEntity(data.originEntity);
int dmg = (int)Math.round(origin.hp.getMax() * 0.1); int dmg = (int)Math.round(origin.hp.getMax() * 0.1);
if(origin.hp.getValue() != 1 && dmg > 0) { //this is ugly ... but also easy to understand
int hp1 = origin.hp.getValue();
int hp2 = Math.max(1, origin.hp.getValue() - dmg);
int actualDmg = hp1 - hp2;
if(actualDmg > 0) {
result.add(new EventBuilder(EventType.TakenDamageEvent) result.add(new EventBuilder(EventType.TakenDamageEvent)
.withTargetEntity(data.originEntity) .withTargetEntity(data.originEntity)
.withTargetField(data.originField) .withTargetField(data.originField)
.withAmount(dmg) .withAmount(actualDmg)
.buildEntityEvent()); .buildEntityEvent());
} }
result.add(new EventBuilder(EventType.TakenDamageEvent) result.add(new EventBuilder(EventType.TakenDamageEvent)

View File

@ -120,15 +120,27 @@ class MessageValidationUtilityTest {
var characterConfig = new CharacterConfig(); var characterConfig = new CharacterConfig();
assertThat(ValidationUtility.validate(characterConfig).get()) assertThat(ValidationUtility.validate(characterConfig).get())
.isEqualTo("characters must not be empty"); .isIn("characters mus not be empty", "characters darf nicht leer sein");
// .isEqualTo("characters must not be empty");
characterConfig.characters = new CharacterProperties[] {racoon, quicksilver, hulk, loki, silversurfer}; characterConfig.characters = new CharacterProperties[] {racoon, quicksilver, hulk, loki, silversurfer};
assertThat(ValidationUtility.validate(characterConfig).get()) var results = ValidationUtility.validate(characterConfig).get();
.contains("characters has less than 24 characters", assertThat(results.contains("characters has less than 24 characters") ||
"characters[4].rangedDamage must be greater than 0", results.contains("characters hat weniger als 24 characters"))
"characters[4].name must not be empty", .isTrue();
"characters[4].meleeDamage must be greater than 0");
assertThat(results.contains("characters[4].rangedDamage must be greater than 0") ||
results.contains("characters[4].rangedDamage muss größer als 0 sein"))
.isTrue();
assertThat(results.contains("characters[4].name must not be empty") ||
results.contains("characters[4].name darf nicht leer sein"))
.isTrue();
assertThat(results.contains("characters[4].meleeDamage must be greater than 0") ||
results.contains("characters[4].meleeDamage muss größer als 0 sein"))
.isTrue();
} }
} }