Merge remote-tracking branch 'origin/gamelib' into gamelib
This commit is contained in:
commit
5a667ea860
@ -4,9 +4,10 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<option name="delegatedBuild" value="true" />
|
||||||
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#JAVA_HOME" />
|
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
@ -13,12 +13,6 @@ public class CharacterEvent extends Event {
|
|||||||
public Integer amount = null;
|
public Integer amount = null;
|
||||||
public StoneType stoneType = null;
|
public StoneType stoneType = null;
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharacterEvent type(EventType type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CharacterEvent setOriginEntity(EntityID originEntity) {
|
public CharacterEvent setOriginEntity(EntityID originEntity) {
|
||||||
this.originEntity = originEntity;
|
this.originEntity = originEntity;
|
||||||
return this;
|
return this;
|
||||||
|
@ -9,12 +9,6 @@ public class EntityEvent extends Event {
|
|||||||
public IntVector2 targetField = null;
|
public IntVector2 targetField = null;
|
||||||
public Integer amount = null;
|
public Integer amount = null;
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityEvent type(EventType type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityEvent setTargetEntity(EntityID targetEntity) {
|
public EntityEvent setTargetEntity(EntityID targetEntity) {
|
||||||
this.targetEntity = targetEntity;
|
this.targetEntity = targetEntity;
|
||||||
return this;
|
return this;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package uulm.teamname.marvelous.gamelibrary.gamelogic;
|
package uulm.teamname.marvelous.gamelibrary.gamelogic;
|
||||||
|
|
||||||
import uulm.teamname.marvelous.gamelibrary.Tuple;
|
import uulm.teamname.marvelous.gamelibrary.Tuple;
|
||||||
import uulm.teamname.marvelous.gamelibrary.events.Event;
|
import uulm.teamname.marvelous.gamelibrary.events.*;
|
||||||
|
import uulm.teamname.marvelous.gamelibrary.requests.CharacterRequest;
|
||||||
import uulm.teamname.marvelous.gamelibrary.requests.Request;
|
import uulm.teamname.marvelous.gamelibrary.requests.Request;
|
||||||
|
import uulm.teamname.marvelous.gamelibrary.requests.RequestType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/** Contains game logic handling. */
|
/** Contains game logic handling. */
|
||||||
class GameLogic {
|
class GameLogic {
|
||||||
@ -14,18 +15,63 @@ class GameLogic {
|
|||||||
* @return The list of resulting events
|
* @return The list of resulting events
|
||||||
*/
|
*/
|
||||||
public static ArrayList<Event> executeRequest(Request request) {
|
public static ArrayList<Event> executeRequest(Request request) {
|
||||||
ArrayList<Event> result = new ArrayList<Event>();
|
ArrayList<Event> result = new ArrayList<>();
|
||||||
|
|
||||||
//TODO: implement GameLogic.executeRequest
|
switch(request.type) {
|
||||||
|
case MeleeAttackRequest, RangedAttackRequest -> {
|
||||||
/* Example Code:
|
CharacterRequest data = (CharacterRequest)request;
|
||||||
switch (event.type) {
|
result.add(new CharacterEvent()
|
||||||
case EventType.MeleeAttack:
|
.setOriginEntity(data.originEntity)
|
||||||
result.add(Event.Construct(EventType.APReduced, event.sourceEntity, event.ap));
|
.setTargetEntity(data.targetEntity)
|
||||||
result.add(Event.Construct(EventType.DamageTaken, event.targetEntity, event.value));
|
.setOriginField(data.originField)
|
||||||
break;
|
.setTargetField(data.targetField)
|
||||||
|
.setAmount(data.value)
|
||||||
|
.type(request.type == RequestType.MeleeAttackRequest ? EventType.MeleeAttackEvent : EventType.RangedAttackEvent));
|
||||||
|
result.add(new EntityEvent()
|
||||||
|
.setTargetEntity(data.originEntity)
|
||||||
|
.setTargetField(data.originField)
|
||||||
|
.setAmount(1)
|
||||||
|
.type(EventType.ConsumedAPEvent));
|
||||||
|
result.add(new EntityEvent()
|
||||||
|
.setTargetEntity(data.targetEntity)
|
||||||
|
.setTargetField(data.targetField)
|
||||||
|
.setAmount(data.value)
|
||||||
|
.type(EventType.TakenDamageEvent));
|
||||||
|
}
|
||||||
|
case MoveRequest -> {
|
||||||
|
CharacterRequest data = (CharacterRequest)request;
|
||||||
|
result.add(new CharacterEvent()
|
||||||
|
.setOriginEntity(data.originEntity)
|
||||||
|
.setOriginField(data.originField)
|
||||||
|
.setTargetField(data.targetField)
|
||||||
|
.type(EventType.MoveEvent));
|
||||||
|
result.add(new EntityEvent()
|
||||||
|
.setTargetEntity(data.originEntity)
|
||||||
|
.setTargetField(data.targetField) //when this event gets handled, the character already moved to the target field
|
||||||
|
.setAmount(1)
|
||||||
|
.type(EventType.ConsumedMPEvent));
|
||||||
|
}
|
||||||
|
case ExchangeInfinityStoneRequest, UseInfinityStoneRequest -> {
|
||||||
|
CharacterRequest data = (CharacterRequest)request;
|
||||||
|
result.add(new CharacterEvent()
|
||||||
|
.setOriginEntity(data.originEntity)
|
||||||
|
.setTargetEntity(data.targetEntity)
|
||||||
|
.setOriginField(data.originField)
|
||||||
|
.setTargetField(data.targetField)
|
||||||
|
.setStone(data.stoneType)
|
||||||
|
.type(request.type == RequestType.ExchangeInfinityStoneRequest ? EventType.ExchangeInfinityStoneEvent : EventType.UseInfinityStoneEvent));
|
||||||
|
result.add(new EntityEvent()
|
||||||
|
.setTargetEntity(data.originEntity)
|
||||||
|
.setTargetField(data.originField)
|
||||||
|
.setAmount(1)
|
||||||
|
.type(EventType.ConsumedAPEvent));
|
||||||
|
|
||||||
|
}
|
||||||
|
case DisconnectRequest -> {
|
||||||
|
result.add(new GameEvent()
|
||||||
|
.type(EventType.DisconnectEvent));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user