refactor: generated Equals and HashCode for requests where necessary
This commit is contained in:
parent
596ace355a
commit
035bf2eb7c
@ -4,6 +4,8 @@ import uulm.teamname.marvelous.gamelibrary.IntVector2;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/** Represents a character event for: {@link RequestType#MeleeAttackRequest}, {@link RequestType#RangedAttackRequest}, {@link RequestType#MoveRequest}, {@link RequestType#ExchangeInfinityStoneRequest}, {@link RequestType#UseInfinityStoneRequest}. */
|
||||
public class CharacterRequest extends Request {
|
||||
public EntityID originEntity = null;
|
||||
@ -12,4 +14,18 @@ public class CharacterRequest extends Request {
|
||||
public IntVector2 targetField = null;
|
||||
public Integer value = null; //why is it called amount in events and value in requests?
|
||||
public StoneType stoneType = null;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
CharacterRequest that = (CharacterRequest) o;
|
||||
return Objects.equals(originEntity, that.originEntity) && Objects.equals(targetEntity, that.targetEntity) && Objects.equals(originField, that.originField) && Objects.equals(targetField, that.targetField) && Objects.equals(value, that.value) && stoneType == that.stoneType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), originEntity, targetEntity, originField, targetField, value, stoneType);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.requests;
|
||||
|
||||
/** Represents a game request for: {@link RequestType#DisconnectRequest}. */
|
||||
public class GameRequest extends Request {
|
||||
|
||||
}
|
||||
public class GameRequest extends Request {}
|
||||
|
@ -2,7 +2,23 @@ package uulm.teamname.marvelous.gamelibrary.requests;
|
||||
|
||||
import uulm.teamname.marvelous.gamelibrary.json.ingame.MessageStructure;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/** Represents an abstract request sent inside a {@link MessageStructure} between client and server. */
|
||||
public abstract class Request {
|
||||
public RequestType type;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Request request = (Request) o;
|
||||
return type == request.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user