fix: utilize config in GameLogic
This commit is contained in:
parent
c0b8108c76
commit
184c839c3a
@ -116,7 +116,6 @@ class GameLogic {
|
|||||||
}
|
}
|
||||||
case RealityStone -> {
|
case RealityStone -> {
|
||||||
if(data.originEntity == data.targetEntity) { // => place stone
|
if(data.originEntity == data.targetEntity) { // => place stone
|
||||||
//TODO: use config values
|
|
||||||
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))
|
||||||
@ -303,7 +302,9 @@ class GameLogic {
|
|||||||
if(data.originField == data.targetField) {
|
if(data.originField == data.targetField) {
|
||||||
throw new InvalidRequestException();
|
throw new InvalidRequestException();
|
||||||
}
|
}
|
||||||
//TODO: mind stone damage check (config) ???????
|
if(data.value != state.partyConfig.mindStoneDMG) {
|
||||||
|
throw new InvalidRequestException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case RealityStone -> {
|
case RealityStone -> {
|
||||||
if(data.originEntity == data.targetEntity) { // => place stone
|
if(data.originEntity == data.targetEntity) { // => place stone
|
||||||
@ -527,7 +528,7 @@ class GameLogic {
|
|||||||
target.setPosition(((CharacterEvent)event).targetField);
|
target.setPosition(((CharacterEvent)event).targetField);
|
||||||
}
|
}
|
||||||
case UseInfinityStoneEvent -> {
|
case UseInfinityStoneEvent -> {
|
||||||
state.stoneCooldown.setCooldown(((CharacterEvent)event).stoneType, 10); //TODO: use stone cooldown from config
|
state.stoneCooldown.setCooldown(((CharacterEvent)event).stoneType);
|
||||||
}
|
}
|
||||||
case ExchangeInfinityStoneEvent -> {
|
case ExchangeInfinityStoneEvent -> {
|
||||||
((Character)state.entities.findEntity(((CharacterEvent)event).originEntity)).inventory.removeStone(((CharacterEvent)event).stoneType);
|
((Character)state.entities.findEntity(((CharacterEvent)event).originEntity)).inventory.removeStone(((CharacterEvent)event).stoneType);
|
||||||
|
@ -41,7 +41,7 @@ class GameState {
|
|||||||
public boolean won = false;
|
public boolean won = false;
|
||||||
|
|
||||||
/** The global cooldown of every infinity stone */
|
/** The global cooldown of every infinity stone */
|
||||||
public final StoneCooldownManager stoneCooldown = new StoneCooldownManager();
|
public final StoneCooldownManager stoneCooldown;
|
||||||
|
|
||||||
/** The data for every win condition for each player */
|
/** The data for every win condition for each player */
|
||||||
public final WinConditionManager winConditions = new WinConditionManager();
|
public final WinConditionManager winConditions = new WinConditionManager();
|
||||||
@ -54,6 +54,7 @@ class GameState {
|
|||||||
this.partyConfig = partyConfig;
|
this.partyConfig = partyConfig;
|
||||||
this.characterConfig = characterConfig;
|
this.characterConfig = characterConfig;
|
||||||
this.scenarioConfig = scenarioConfig;
|
this.scenarioConfig = scenarioConfig;
|
||||||
|
stoneCooldown = new StoneCooldownManager(partyConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package uulm.teamname.marvelous.gamelibrary.gamelogic;
|
package uulm.teamname.marvelous.gamelibrary.gamelogic;
|
||||||
|
|
||||||
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
|
|
||||||
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
|
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
|
||||||
|
import uulm.teamname.marvelous.gamelibrary.json.config.PartyConfig;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -10,6 +10,22 @@ public class StoneCooldownManager {
|
|||||||
/** The cooldown round numbers for every stone */
|
/** The cooldown round numbers for every stone */
|
||||||
private final HashMap<StoneType, Integer> cooldowns = new HashMap<>();
|
private final HashMap<StoneType, Integer> cooldowns = new HashMap<>();
|
||||||
|
|
||||||
|
/** The max cooldown round numbers for every stone */
|
||||||
|
private final HashMap<StoneType, Integer> maxCooldowns = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new {@link StoneCooldownManager} with the given config.
|
||||||
|
*/
|
||||||
|
public StoneCooldownManager(PartyConfig partyConfig) {
|
||||||
|
//thanks
|
||||||
|
maxCooldowns.put(StoneType.SpaceStone, partyConfig.spaceStoneCD);
|
||||||
|
maxCooldowns.put(StoneType.MindStone, partyConfig.mindStoneCD);
|
||||||
|
maxCooldowns.put(StoneType.RealityStone, partyConfig.realityStoneCD);
|
||||||
|
maxCooldowns.put(StoneType.PowerStone, partyConfig.powerStoneCD);
|
||||||
|
maxCooldowns.put(StoneType.TimeStone, partyConfig.timeStoneCD);
|
||||||
|
maxCooldowns.put(StoneType.SoulStone, partyConfig.soulStoneCD);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes over all the cooldowns from a different {@link StoneCooldownManager}.
|
* Takes over all the cooldowns from a different {@link StoneCooldownManager}.
|
||||||
* @param other The cooldown manager to take the data from
|
* @param other The cooldown manager to take the data from
|
||||||
@ -17,6 +33,8 @@ public class StoneCooldownManager {
|
|||||||
public void cloneFrom(StoneCooldownManager other) {
|
public void cloneFrom(StoneCooldownManager other) {
|
||||||
cooldowns.clear();
|
cooldowns.clear();
|
||||||
cooldowns.putAll(other.cooldowns);
|
cooldowns.putAll(other.cooldowns);
|
||||||
|
maxCooldowns.clear();
|
||||||
|
maxCooldowns.putAll(other.maxCooldowns);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,11 +64,10 @@ public class StoneCooldownManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a stone as on cooldown.
|
* Marks a stone as on cooldown.
|
||||||
* @param stone The {@link StoneType} to check for
|
* @param stone The {@link StoneType} to mark
|
||||||
* @param duration The number of rounds the stone should be on cooldown
|
|
||||||
*/
|
*/
|
||||||
public void setCooldown(StoneType stone, int duration) {
|
public void setCooldown(StoneType stone) {
|
||||||
cooldowns.put(stone, Math.max(0, duration));
|
cooldowns.put(stone, Math.max(0, maxCooldowns.get(stone)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user