refactor: unify comment styles

feat: add entity list class
This commit is contained in:
punchready 2021-04-30 20:54:34 +02:00
parent 67a7ab35f9
commit 3f7d393d5d
25 changed files with 269 additions and 263 deletions

2
.gitignore vendored
View File

@ -44,6 +44,8 @@ gradle-app.setting
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml

View File

@ -6,8 +6,7 @@ public class Tuple<X, Y> {
public final X item1;
public final Y item2;
/** Constructs a new {@link Tuple} based on the given objects.
*/
/** Constructs a new {@link Tuple} based on the given objects. */
public Tuple(X item1, Y item2) {
this.item1 = item1;
this.item2 = item2;

View File

@ -2,51 +2,43 @@ package uulm.teamname.marvelous.gamelibrary.entities;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
/** Represents a playable character inside a match.
*/
/** Represents a playable character inside a match. */
public class Character extends Entity {
/** The name of the character.
*/
/** The name of the character */
public final String name;
/** The hp stat of the character.
*/
/** The hp stat of the character */
public final Stat hp;
/** The mp stat of the character.
*/
/** The mp stat of the character */
public final Stat mp;
/** The ap stat of the character.
*/
/** The ap stat of the character */
public final Stat ap;
/** The ranged attack range of the character.
*/
/** The ranged attack range of the character */
public final int attackRange;
/** The ranged attack damage of the character.
*/
/** The ranged attack damage of the character */
public final int rangedDamage;
/** The melee attack damage of the character.
*/
/** The melee attack damage of the character */
public final int meleeDamage;
/** The {@link Inventory} of the character.
*/
/** The {@link Inventory} of the character */
public final Inventory inventory = new Inventory();
/** Constructs a new {@link Character} with an empty inventory.
* @param id The {@link EntityID} of the character.
* @param position The position of the character.
* @param name The name of the character.
* @param hp The maximum hp of the character.
* @param mp The maximum mp of the character.
* @param ap The maximum ap of the character.
* @param attackRange The ranged attack range of the character.
* @param rangedDamage The ranged damage of the character.
* @param meleeDamage The melee damage of the character.
/**
* Constructs a new {@link Character} with an empty inventory.
* @param id The {@link EntityID} of the character
* @param position The position of the character
* @param name The name of the character
* @param hp The maximum hp of the character
* @param mp The maximum mp of the character
* @param ap The maximum ap of the character
* @param attackRange The ranged attack range of the character
* @param rangedDamage The ranged damage of the character
* @param meleeDamage The melee damage of the character
*/
public Character(EntityID id, IntVector2 position, String name, int hp, int mp, int ap, int attackRange, int rangedDamage, int meleeDamage) {
super(id, position);
@ -59,8 +51,9 @@ public class Character extends Entity {
this.meleeDamage = meleeDamage;
}
/** Checks if the character is still alive.
* @return Whether or not the characters hp is greater than 0.
/**
* Checks if the character is still alive.
* @return Whether or not the characters hp is greater than 0
*/
public boolean isAlive() {
return hp.getValue() > 0;

View File

@ -2,24 +2,21 @@ package uulm.teamname.marvelous.gamelibrary.entities;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
/** Represents an abstract entity.
*/
/** Represents an abstract entity. */
public abstract class Entity {
/** Whether or not the entity is currently active in the game.
*/
/** Whether or not the entity is currently active in the game */
private boolean active = true;
/** The position of the entity.
*/
/** The position of the entity */
private IntVector2 position;
/** The {@link EntityID} of the entity.
*/
/** The {@link EntityID} of the entity */
public final EntityID id;
/** Constructs a new {@link Entity}.
* @param id The {@link EntityID} of the entity.
* @param position The position of the entity.
/**
* Constructs a new {@link Entity}.
* @param id The {@link EntityID} of the entity
* @param position The position of the entity
*/
protected Entity(EntityID id, IntVector2 position) {
this.position = position;

View File

@ -1,35 +1,35 @@
package uulm.teamname.marvelous.gamelibrary.entities;
/** Represents a distinct identification for every {@link Entity} in a game.
*/
/** Represents a distinct identification for every {@link Entity} in a game. */
public class EntityID {
/** The index of the entity.
*/
/** The index of the entity */
public final int id;
/** The type of the entity.
*/
/** The type of the entity */
public final EntityType type;
/** Constructs a new {@link Entity}-{@link EntityID} based on the given index and {@link EntityType}.
* @param id The index of the entity.
* @param type The type of the entity.
/**
* Constructs a new {@link Entity}-{@link EntityID} based on the given index and {@link EntityType}.
* @param id The index of the entity
* @param type The type of the entity
*/
public EntityID(int id, EntityType type) {
this.id = id;
this.type = type;
}
/** Checks if the id has the same {@link EntityType} as the given one.
* @param other The type to compare to.
* @return Whether or not the id has the same type.
/**
* Checks if the id has the same {@link EntityType} as the given one.
* @param other The type to compare to
* @return Whether or not the id has the same type
*/
public boolean isSameType(EntityType other) {
return type == other;
}
/** Serializes the id for debugging.
* @return A debug string containing all the necessary information about the id.
/**
* Serializes the id for debugging.
* @return A debug string containing all the necessary information about the id
*/
public String toString() {
return "["+type.toString()+":"+id+"]";

View File

@ -0,0 +1,50 @@
package uulm.teamname.marvelous.gamelibrary.entities;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
/** Represents a list of {@link Entity}s. */
public class EntityList {
/** The internal collection of {@link Entity}s */
private final HashSet<Entity> entities = new HashSet<>();
/**
* Clears the list of entities.
*/
public void clear() {
entities.clear();
}
/**
* Adds an entity to the list.
* @param entity The {@link Entity} to add
*/
public void addEntity(Entity entity) {
entities.add(entity);
}
/**
* Adds multiple entities to the list.
* @param entities The entities to add
*/
public void addEntities(Entity... entities) {
this.entities.addAll(Arrays.asList(entities));
}
/**
* Removes an entity from the list.
* @param entity The {@link Entity} to remove
*/
public boolean removeEntity(Entity entity) {
return entities.remove(entity);
}
/**
* Iterates over all entities inside the list.
* @return An iterator over every {@link Entity}
*/
public Iterator<Entity> getEntities() {
return entities.iterator();
}
}

View File

@ -1,21 +1,15 @@
package uulm.teamname.marvelous.gamelibrary.entities;
/** Specifies the type of an {@link Entity}.
*/
/** Specifies the type of an {@link Entity}. */
public enum EntityType {
/** Represents an NPC entity.
*/
/** Represents an NPC entity */
NPC,
/** Represents the first Player.
*/
/** Represents the first Player */
P1,
/** Represents the second Player.
*/
/** Represents the second Player */
P2,
/** Represents a Rock entity.
*/
/** Represents a Rock entity */
Rocks,
/** Represents an InfinityStone entity.
*/
/** Represents an InfinityStone entity */
InfinityStones
}

View File

@ -2,17 +2,16 @@ package uulm.teamname.marvelous.gamelibrary.entities;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
/** Represents an infinity stone {@link Entity}. Can only exist on the map.
*/
/** Represents an infinity stone {@link Entity}. Can only exist on the map. */
public class InfinityStone extends Entity {
/** The {@link StoneType} of the infinity stone.
*/
/** The {@link StoneType} of the infinity stone */
public final StoneType type;
/** Constructs a new {@link InfinityStone}.
* @param id The {@link EntityID} of the stone.
* @param position The position of the stone.
* @param type The {@link StoneType} of the stone.
/**
* Constructs a new {@link InfinityStone}.
* @param id The {@link EntityID} of the stone
* @param position The position of the stone
* @param type The {@link StoneType} of the stone
*/
public InfinityStone(EntityID id, IntVector2 position, StoneType type) {
super(id, position);

View File

@ -4,19 +4,17 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
/** Represents an inventory of 6 slots of {@link StoneType}s that can be manipulated.
*/
/** Represents an inventory of 6 slots of {@link StoneType}s that can be manipulated. */
public class Inventory implements Iterable<StoneType> {
/** The size of the inventory.
*/
/** The size of the inventory */
private final int size = 6;
/** The content of the inventory.
*/
/** The content of the inventory */
private final HashSet<StoneType> content = new HashSet<>(size);
/** Constructs a new {@link Inventory}.
* @param content The starting content of the inventory.
/**
* Constructs a new {@link Inventory}.
* @param content The starting content of the inventory
*/
public Inventory(ArrayList<StoneType> content) {
if(content.size() > size) {
@ -31,27 +29,27 @@ public class Inventory implements Iterable<StoneType> {
}
}
/** Constructs a new empty {@link Inventory}.
*/
/** Constructs a new empty {@link Inventory}. */
public Inventory() {
}
/** Returns the number of free slots the inventory has.
*/
/** Returns the number of free slots the inventory has. */
public int getFreeSlots() {
return size - content.size();
}
/** Checks if the inventory contains the given stone.
* @param stone The {@link StoneType} to check for.
/**
* Checks if the inventory contains the given stone.
* @param stone The {@link StoneType} to check for
*/
public boolean hasStone(StoneType stone) {
return content.contains(stone);
}
/** Adds a stone to the inventory.
* @param stone The {@link StoneType} to add.
/**
* Adds a stone to the inventory.
* @param stone The {@link StoneType} to add
*/
public void addStone(StoneType stone) {
if(content.contains(stone)) {
@ -64,8 +62,9 @@ public class Inventory implements Iterable<StoneType> {
content.add(stone);
}
/** Removes a stone from the inventory.
* @param stone The {@link StoneType} to remove.
/**
* Removes a stone from the inventory.
* @param stone The {@link StoneType} to remove
*/
public void removeStone(StoneType stone) {
if(!content.contains(stone)) {
@ -75,8 +74,7 @@ public class Inventory implements Iterable<StoneType> {
content.remove(stone);
}
/** Iterates over the inventory.
*/
/** Iterates over the inventory. */
@Override
public Iterator<StoneType> iterator() {
return content.iterator();

View File

@ -4,26 +4,26 @@ import uulm.teamname.marvelous.gamelibrary.IntVector2;
import java.util.ArrayList;
/** Represents an NPC inside the game.
*/
/** Represents an NPC inside the game. */
public class NPC extends Entity {
/** The {@link Inventory} of the NPC.
*/
/** The {@link Inventory} of the NPC */
public final Inventory inventory;
/** Constructs a new {@link NPC}.
* @param id The {@link EntityID} of the NPC.
* @param position The position of the NPC.
* @param inventory The starting inventory the NPC should have.
/**
* Constructs a new {@link NPC}.
* @param id The {@link EntityID} of the NPC
* @param position The position of the NPC
* @param inventory The starting inventory the NPC should have
*/
public NPC(EntityID id, IntVector2 position, ArrayList<StoneType> inventory) {
super(id, position);
this.inventory = new Inventory(inventory);
}
/** Constructs a new {@link NPC} with an empty inventory.
* @param id The {@link EntityID} of the NPC.
* @param position The position of the NPC.
/**
* Constructs a new {@link NPC} with an empty inventory.
* @param id The {@link EntityID} of the NPC
* @param position The position of the NPC
*/
public NPC(EntityID id, IntVector2 position) {
super(id, position);

View File

@ -1,15 +1,8 @@
package uulm.teamname.marvelous.gamelibrary.entities;
/** Specifies the type of an {@link NPC}.
*/
/** Specifies the type of an {@link NPC}. */
public enum NPCType {
/** Represents the Goose.
*/
Goose,
/** Represents Stan Lee.
*/
Stan,
/** Represents Thanos.
*/
Thanos
}

View File

@ -2,21 +2,19 @@ package uulm.teamname.marvelous.gamelibrary.entities;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
/** Represents a rock entity on the map.
*/
/** Represents a rock entity on the map. */
public class Rock extends Entity {
/** The maximum hp of the rock.
*/
/** The maximum hp of the rock */
public final int maxHP;
/** The current hp of the rock.
*/
/** The current hp of the rock */
private int hp;
/** Constructs a new {@link Rock}.
* @param id The {@link EntityID} of the rock.
* @param position The position of the rock.
* @param hp The hp of the rock.
/**
* Constructs a new {@link Rock}.
* @param id The {@link EntityID} of the rock
* @param position The position of the rock
* @param hp The hp of the rock
*/
public Rock(EntityID id, IntVector2 position, int hp) {
super(id, position);

View File

@ -1,23 +1,20 @@
package uulm.teamname.marvelous.gamelibrary.entities;
/** Represents a stat property of a {@link Character}.
*/
/** Represents a stat property of a {@link Character}. */
public class Stat {
/** The {@link StatType} of the stat.
*/
/** The {@link StatType} of the stat */
public final StatType type;
/** The maximum value of the stat.
*/
/** The maximum value of the stat */
public final int max;
/** The current value of the stat.
*/
/** The current value of the stat */
private int value;
/** Constructs a new {@link Stat} with the initial value set to the maximum value.
* @param type The {@link StatType} of the stat.
* @param max The maximum value of the stat.
/**
* Constructs a new {@link Stat} with the initial value set to the maximum value.
* @param type The {@link StatType} of the stat
* @param max The maximum value of the stat
*/
public Stat(StatType type, int max) {
this.type = type;

View File

@ -1,15 +1,11 @@
package uulm.teamname.marvelous.gamelibrary.entities;
/** Specifies the type of a {@link Stat}.
*/
/** Specifies the type of a {@link Stat}. */
public enum StatType {
/** Represents the life points of a character.
*/
/** Represents the life points of a character */
HP,
/** Represents the mana points of a character.
*/
/** Represents the mana points of a character */
MP,
/** Represents thr action points of a character.
*/
/** Represents thr action points of a character */
AP
}

View File

@ -1,7 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.entities;
/** Specifies the type of an {@link InfinityStone}.
*/
/** Specifies the type of an {@link InfinityStone}. */
public enum StoneType {
SpaceStone,
MindStone,

View File

@ -1,20 +1,21 @@
package uulm.teamname.marvelous.gamelibrary.gamelogic;
/** Contains checksum calculations.
*/
/** Contains checksum calculations. */
class ChecksumCalculator {
/** Compares a checksum to the checksum of a {@link GameState}.
* @param state The state to check.
* @param input the checksum to compare to.
* @return Whether or not the checksum matches the state's checksum.
/**
* Compares a checksum to the checksum of a {@link GameState}.
* @param state The state to check
* @param input the checksum to compare to
* @return Whether or not the checksum matches the state's checksum
*/
public static boolean checkChecksum(GameState state, long input) {
return calculateChecksum(state) == input;
}
/** Calculates the corresponding checksum to a {@link GameState}.
* @param state The state to check.
* @return The checksum.
/**
* Calculates the corresponding checksum to a {@link GameState}.
* @param state The state to check
* @return The checksum
*/
public static long calculateChecksum(GameState state) {
//TODO: implement ChecksumCalculator.calculateChecksum

View File

@ -2,8 +2,7 @@ package uulm.teamname.marvelous.gamelibrary.gamelogic;
import java.util.Observable;
/** Represents an event emitter for game events fired by a game instance.
*/
/** Represents an event emitter for game events fired by a game instance. */
class EventEmitter extends Observable {
}

View File

@ -6,51 +6,48 @@ import uulm.teamname.marvelous.gamelibrary.requests.Request;
import java.util.Observer;
/** Represents a game instance.
*/
/** Represents a game instance. */
public class GameInstance {
/** The private {@link GameState} of the instance.
*/
/** The private {@link GameState} of the instance */
private final GameState _state;
/** The public view for the underlying {@link GameState} of the instance.
*/
/** The public view for the underlying {@link GameState} of the instance */
public final GameStateView state;
/** The {@link GameStateManager} managing the {@link GameState} of the instance.
*/
/** The {@link GameStateManager} managing the {@link GameState} of the instance */
private final GameStateManager manager;
/** The {@link EventEmitter} for {@link Event}s resulting from {@link Request}s.
*/
/** The {@link EventEmitter} for {@link Event}s resulting from {@link Request}s */
private final EventEmitter emitter = new EventEmitter();
/** Constructs a new {@link GameInstance}.
*/
/** Constructs a new {@link GameInstance}. */
public GameInstance(IntVector2 mapSize) {
_state = new GameState(mapSize);
this.state = new GameStateView(_state);
manager = new GameStateManager(_state);
}
/** Checks a checksum with the current one.
* @param input The checksum to compare to.
* @return Whether or not the checksum matches.
/**
* Checks a checksum with the current one.
* @param input The checksum to compare to
* @return Whether or not the checksum matches
*/
public boolean checkChecksum(long input) {
return ChecksumCalculator.checkChecksum(_state, input);
}
/** Calculates the current checksum of the game state.
* @return The calculated checksum.
/**
* Calculates the current checksum of the game state.
* @return The calculated checksum
*/
public long calculateChecksum() {
return ChecksumCalculator.calculateChecksum(_state);
}
/** Checks an array of {@link Request}s for validity and automatically applies them if valid.
* @param requests The requests to check.
* @return Whether or not the given set of requests was valid.
/**
* Checks an array of {@link Request}s for validity and automatically applies them if valid.
* @param requests The requests to check
* @return Whether or not the given set of requests was valid
*/
public boolean checkRequestsAndApply(Request... requests) {
if(manager.processRequests(requests, true)) {
@ -60,30 +57,34 @@ public class GameInstance {
return false;
}
/** Checks an array of {@link Request}s for validity without applying it.
* @param requests The requests to check.
* @return Whether or not the given set of requests is valid.
/**
* Checks an array of {@link Request}s for validity without applying it.
* @param requests The requests to check
* @return Whether or not the given set of requests is valid
*/
public boolean checkRequestsSilent(Request... requests) {
return manager.processRequests(requests, false);
}
/** Applies an array of {@link Event}s to the game state.
/**
* Applies an array of {@link Event}s to the game state.
* @param events The events to apply.
*/
public void applyEvents(Event... events) {
manager.applyEvents(events);
}
/** Adds an {@link Observer} for events.
* @param observer The observer to add.
/**
* Adds an {@link Observer} for events.
* @param observer The observer to add
*/
public void addObserver(Observer observer) {
emitter.addObserver(observer);
}
/** Emits an array of {@link Event}s.
* @param events The events to emit.
/**
* Emits an array of {@link Event}s.
* @param events The events to emit
*/
private void emit(Event... events) {
emitter.notifyObservers(events);

View File

@ -7,11 +7,11 @@ import uulm.teamname.marvelous.gamelibrary.requests.Request;
import java.util.ArrayList;
import java.util.HashMap;
/** Contains game logic handling.
*/
/** Contains game logic handling. */
class GameLogic {
/** Produces resulting {@link Event}s from a given {@link Request} independently of any {@link GameState}.
* @return The list of resulting events.
/**
* Produces resulting {@link Event}s from a given {@link Request} independently of any {@link GameState}.
* @return The list of resulting events
*/
public static ArrayList<Event> executeRequest(Request request) {
ArrayList<Event> result = new ArrayList<Event>();
@ -30,9 +30,10 @@ class GameLogic {
return result;
}
/** Checks a {@link Request} for validity for a {@link GameState}.
* @param state The game state to check on.
* @param request The request to validate.
/**
* Checks a {@link Request} for validity for a {@link GameState}.
* @param state The game state to check on
* @param request The request to validate
* @return Whether or not the request is valid
*/
public static boolean checkRequest(GameState state, Request request) {
@ -40,17 +41,19 @@ class GameLogic {
return false;
}
/** Applies an {@link Event} to a {@link GameState}.
* @param state The game state to apply to.
* @param event The event to apply.
/**
* Applies an {@link Event} to a {@link GameState}.
* @param state The game state to apply to
* @param event The event to apply
*/
public static void applyEvent(GameState state, Event event) {
//TODO: implement GameLogic.applyEvent
}
/** Checks a {@link GameState} for the current overtime win condition.
* @param state The game state to check.
* @return The {@link ParticipantType} that is currently winning the game according to overtime ruling.
/**
* Checks a {@link GameState} for the current overtime win condition.
* @param state The game state to check
* @return The {@link ParticipantType} that is currently winning the game according to overtime ruling
*/
public static ParticipantType checkWinConditions(GameState state) {
//TODO: GameLogic.checkWinConditions is kind of ugly

View File

@ -3,60 +3,53 @@ package uulm.teamname.marvelous.gamelibrary.gamelogic;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
import uulm.teamname.marvelous.gamelibrary.entities.EntityID;
import uulm.teamname.marvelous.gamelibrary.entities.EntityList;
import uulm.teamname.marvelous.gamelibrary.entities.StoneType;
import uulm.teamname.marvelous.gamelibrary.Tuple;
import java.util.ArrayList;
import java.util.HashMap;
/** Represents the state of a game instance.
*/
/** Represents the state of a game instance. */
class GameState {
/** The size of the map.
*/
/** The size of the map */
public final IntVector2 mapSize;
/** The list of {@link Entity}'s inside the game.
*/
public ArrayList<Entity> entities;
/** The list of {@link Entity}s inside the game */
public final EntityList entities = new EntityList();
/** The total amount of full turn cycles that occurred.
*/
/** The total amount of full turn cycles that occurred */
public int roundNumber = 0;
/** The turn order of every character.
*/
/** The turn order of every character */
public ArrayList<EntityID> turnOrder;
/** The total amount of turns that occurred.
*/
/** The total amount of turns that occurred */
public int turnNumber = 0;
/** The {@link EntityID} of the active character.
*/
/** The {@link EntityID} of the active character */
public EntityID activeCharacter;
/** Whether or not the game was won.
*/
/** Whether or not the game was won */
public boolean won = false;
/** The global cooldown of every infinity stone.
*/
public HashMap<StoneType, Float> stoneCooldown;
/** The global cooldown of every infinity stone */
public final HashMap<StoneType, Float> stoneCooldown = new HashMap<>();
/** The store of the {@link WinCondition} data for every win condition for each player.
*/
public HashMap<Tuple<ParticipantType, WinCondition>, Integer> winConditions;
/** The store of the {@link WinCondition} data for every win condition for each player */
public final HashMap<Tuple<ParticipantType, WinCondition>, Integer> winConditions = new HashMap<>();
/** Constructs a new {@link GameState}.
* @param mapSize The size of the map.
/**
* Constructs a new {@link GameState}.
* @param mapSize The size of the map
*/
public GameState(IntVector2 mapSize) {
this.mapSize = mapSize;
}
/** Clones the state into a new {@link GameState} object.
* @return The cloned game state.
/**
* Clones the state into a new {@link GameState} object.
* @return The cloned game state
*/
public GameState snapshot() {
//TODO: implement GameState.snapshot

View File

@ -6,27 +6,26 @@ import uulm.teamname.marvelous.gamelibrary.requests.Request;
import java.util.ArrayDeque;
import java.util.ArrayList;
/** Represents manager for a game state.
*/
/** Represents manager for a game state. */
class GameStateManager {
/** The managed {@link GameState}.
*/
/** The managed {@link GameState} */
private final GameState state;
/** The queue of {@link Event}s to be applied during {@link Request} processing.
*/
/** The queue of {@link Event}s to be applied during {@link Request} processing */
private final ArrayDeque<Event> queue = new ArrayDeque<Event>();
/** Constructs a new {@link GameStateManager}.
* @param state A reference to the state to be managed.
/**
* Constructs a new {@link GameStateManager}.
* @param state A reference to the state to be managed
*/
public GameStateManager(GameState state) {
this.state = state;
}
/** Checks a list of {@link Request}s for validity and optionally produces resulting {@link Event}s.
* @param requests The requests to check.
* @param apply True if resulting events should be stored for later application.
/**
* Checks a list of {@link Request}s for validity and optionally produces resulting {@link Event}s.
* @param requests The requests to check
* @param apply True if resulting events should be stored for later application
*/
public boolean processRequests(Request[] requests, boolean apply) {
GameState snapshot = state.snapshot();
@ -46,8 +45,9 @@ class GameStateManager {
return true;
}
/** Applies an array of {@link Event}s to the game state.
* @param events The events to apply.
/**
* Applies an array of {@link Event}s to the game state.
* @param events The events to apply
*/
public void applyEvents(Event[] events) {
for(Event event: events) {
@ -55,8 +55,9 @@ class GameStateManager {
}
}
/** Applies the result of the last processRequests call.
* @return A list of applied events.
/**
* Applies the result of the last processRequests call.
* @return A list of applied events
*/
public Event[] apply() {
Event[] toReturn = new Event[queue.size()];

View File

@ -3,16 +3,16 @@ package uulm.teamname.marvelous.gamelibrary.gamelogic;
import uulm.teamname.marvelous.gamelibrary.entities.Entity;
import java.util.ArrayList;
import java.util.Iterator;
/** Represents a game state view containing getters for all the properties of a {@link GameState}.
*/
/** Represents a game state view containing getters for all the properties of a {@link GameState}. */
public class GameStateView {
/** The managed {@link GameState}.
*/
/** The managed {@link GameState} */
private final GameState state;
/** Constructs a new {@link GameStateView}.
* @param state A reference to the state to be viewable.
/**
* Constructs a new {@link GameStateView}.
* @param state A reference to the state to be viewable
*/
public GameStateView(GameState state) {
this.state = state;
@ -20,7 +20,7 @@ public class GameStateView {
//TODO: add immutable getters for all state properties
public ArrayList<Entity> getEntities() {
return new ArrayList<>(state.entities);
public Iterator<Entity> getEntities() {
return state.entities.getEntities();
}
}

View File

@ -1,7 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.gamelogic;
/** Specifies a participant type.
*/
/** Specifies a participant type. */
public enum ParticipantType {
None,
Player1,

View File

@ -1,15 +1,11 @@
package uulm.teamname.marvelous.gamelibrary.gamelogic;
/** Specifies a win condition. The order is important here.
*/
/** Specifies a win condition. The order is important here. */
enum WinCondition {
/** The maximum amount of total infinity stones the player had at a time.
*/
/** The maximum amount of total infinity stones the player had at a time */
MaxStones,
/** The total amount of enemy characters the player knocked out.
*/
/** The total amount of enemy characters the player knocked out */
TotalKnockouts,
/** The total amount of damage the player did to enemy characters.
*/
/** The total amount of damage the player did to enemy characters */
TotalDamage
}

View File

@ -8,8 +8,7 @@ import uulm.teamname.marvelous.gamelibrary.json.ingame.MessageStructure;
public class JSON {
/** Deserializes an incoming network message into a {@link MessageStructure}.
* @param input The JSON to deserialize.
* @return The parsed message.
*/
* @return The parsed message. */
public static MessageStructure[] parse(String input) throws ExecutionControl.NotImplementedException {
//TODO: implement JSON.parse
throw new ExecutionControl.NotImplementedException("JSON.parse is not implemented");
@ -17,8 +16,7 @@ public class JSON {
/** Serializes a {@link MessageStructure} into a JSON string.
* @param input The message to serialize.
* @return The message as JSON.
*/
* @return The message as JSON. */
public static String stringify(MessageStructure input) throws ExecutionControl.NotImplementedException {
//TODO: implement JSON.stringify
throw new ExecutionControl.NotImplementedException("JSON.stringify is not implemented");