fix: mind stone is apparently just a glorified ranged attack

This commit is contained in:
punchready 2021-08-06 15:57:05 +02:00
parent fbe38c978a
commit 48409b1e4a

View File

@ -136,12 +136,7 @@ public class GameLogic {
} }
} }
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
@ -454,17 +449,43 @@ public class GameLogic {
.buildCharacterEvent()); .buildCharacterEvent());
} }
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)) { result.add(new EventBuilder(EventType.TakenDamageEvent)
if(entity.id.isSameType(target)) { .withTargetEntity(targetEntity.id)
result.add(new EventBuilder(EventType.TakenDamageEvent) .withTargetField(data.targetField)
.withTargetEntity(entity.id) .withAmount(state.partyConfig.mindStoneDMG)
.withTargetField(pos) .buildEntityEvent());
.withAmount(data.value)
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 -> {