fix: make thanos also knock out characters he walks over, adapt for new UseInfinityStoneRequest

This commit is contained in:
punchready 2021-06-24 20:41:37 +02:00
parent 7334b234d4
commit 7b1ce8af8f

View File

@ -139,22 +139,7 @@ public class GameLogic {
}
}
case RealityStone -> {
if(data.originEntity.equals(data.targetEntity)) { // => place stone
if(state.entities.findByPosition(data.targetField).size() != 0) {
throw new InvalidRequestException("Invalid reality stone target (rock already there)");
}
}else { // => destroy stone
boolean hasRock = false;
for(Entity entity: state.entities.findByPosition(data.targetField)) {
if(entity.id.isSameType(EntityType.Rocks)) {
hasRock = true;
break;
}
}
if(!hasRock) {
throw new InvalidRequestException("Invalid reality stone target (no rock found)");
}
}
// no check done
}
case PowerStone -> {
Character target = getCharacter(state, data.targetField, data.targetEntity);
@ -420,15 +405,22 @@ public class GameLogic {
}
}
case RealityStone -> {
if(data.originEntity == data.targetEntity) { // => place stone
EntityID target = null;
for(Entity entity: state.entities.findByPosition(data.targetField)) {
if(entity.id.type == EntityType.Rocks) {
target = entity.id;
break;
}
}
if(target == null) {
result.add(new EventBuilder(EventType.SpawnEntityEvent)
.withTargetField(data.targetField)
.withEntity(new Rock(new EntityID(EntityType.Rocks, state.entities.findFreeRockSlot()), data.targetField, 100))
.buildEntityEvent());
}else { // => destroy stone
}else {
result.add(new EventBuilder(EventType.DestroyedEntityEvent)
.withTargetField(data.targetField)
.withTargetEntity(data.targetEntity)
.withTargetEntity(target)
.buildEntityEvent());
}
}
@ -1149,7 +1141,6 @@ public class GameLogic {
.withAmount(1)
.buildEntityEvent());
if(pos.equals(picked)) {
for(Entity entity: state.entities.findByPosition(pos)) {
if(entity instanceof Character) {
result.add(new EventBuilder(EventType.MoveEvent)
@ -1172,7 +1163,6 @@ public class GameLogic {
break;
}
}
}
current = pos;
if(--mp == 0) {