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 -> {
if(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");
}
requireLineOfSight(state, data.originField, data.targetField);
}
case RealityStone -> {
// no check done
@ -454,17 +449,43 @@ public class GameLogic {
.buildCharacterEvent());
}
case MindStone -> {
EntityType target = data.originEntity.type == EntityType.P1 ? EntityType.P2 : EntityType.P1;
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)
.withTargetEntity(entity.id)
.withTargetField(pos)
.withAmount(data.value)
Entity targetEntity = state.entities.findEntity(data.targetEntity);
result.add(new EventBuilder(EventType.TakenDamageEvent)
.withTargetEntity(targetEntity.id)
.withTargetField(data.targetField)
.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());
}
}
}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 -> {