fix: make thanos also knock out characters he walks over, adapt for new UseInfinityStoneRequest
This commit is contained in:
parent
7334b234d4
commit
7b1ce8af8f
@ -139,22 +139,7 @@ public class GameLogic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case RealityStone -> {
|
case RealityStone -> {
|
||||||
if(data.originEntity.equals(data.targetEntity)) { // => place stone
|
// no check done
|
||||||
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)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case PowerStone -> {
|
case PowerStone -> {
|
||||||
Character target = getCharacter(state, data.targetField, data.targetEntity);
|
Character target = getCharacter(state, data.targetField, data.targetEntity);
|
||||||
@ -420,15 +405,22 @@ public class GameLogic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case RealityStone -> {
|
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)
|
result.add(new EventBuilder(EventType.SpawnEntityEvent)
|
||||||
.withTargetField(data.targetField)
|
.withTargetField(data.targetField)
|
||||||
.withEntity(new Rock(new EntityID(EntityType.Rocks, state.entities.findFreeRockSlot()), data.targetField, 100))
|
.withEntity(new Rock(new EntityID(EntityType.Rocks, state.entities.findFreeRockSlot()), data.targetField, 100))
|
||||||
.buildEntityEvent());
|
.buildEntityEvent());
|
||||||
}else { // => destroy stone
|
}else {
|
||||||
result.add(new EventBuilder(EventType.DestroyedEntityEvent)
|
result.add(new EventBuilder(EventType.DestroyedEntityEvent)
|
||||||
.withTargetField(data.targetField)
|
.withTargetField(data.targetField)
|
||||||
.withTargetEntity(data.targetEntity)
|
.withTargetEntity(target)
|
||||||
.buildEntityEvent());
|
.buildEntityEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1149,7 +1141,6 @@ public class GameLogic {
|
|||||||
.withAmount(1)
|
.withAmount(1)
|
||||||
.buildEntityEvent());
|
.buildEntityEvent());
|
||||||
|
|
||||||
if(pos.equals(picked)) {
|
|
||||||
for(Entity entity: state.entities.findByPosition(pos)) {
|
for(Entity entity: state.entities.findByPosition(pos)) {
|
||||||
if(entity instanceof Character) {
|
if(entity instanceof Character) {
|
||||||
result.add(new EventBuilder(EventType.MoveEvent)
|
result.add(new EventBuilder(EventType.MoveEvent)
|
||||||
@ -1172,7 +1163,6 @@ public class GameLogic {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
current = pos;
|
current = pos;
|
||||||
if(--mp == 0) {
|
if(--mp == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user