 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.validation.checks;
22 import java.util.Arrays;
23 import java.util.IdentityHashMap;
35 import org.jetbrains.annotations.NotNull;
43 public class EnvironmentChecker<G
extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>> extends
AbstractValidator<G, A, R> implements
GameObjectValidator<G, A, R> {
49 private final Map<ArchetypeType, Void>
noMap =
new IdentityHashMap<>();
56 private final Map<ArchetypeType, int @NotNull []>
inv =
new IdentityHashMap<>();
71 noMap.put(archetypeType,
null);
81 if (
inv.containsKey(archetypeType)) {
82 throw new IllegalArgumentException(
"archetype type has already been set: " + archetypeType);
85 final int[] tmp = types.clone();
87 inv.put(archetypeType, tmp);
92 final G envGameObject = gameObject.getContainerGameObject();
93 if (envGameObject ==
null) {
95 if (archetypeType.matches(gameObject)) {
103 if (archetypeType.
matches(gameObject)) {
104 final int[] types = entry.getValue();
105 if (types !=
null && Arrays.binarySearch(types, envGameObject.getTypeNo()) < 0) {
106 final String typeDescription = archetypeType.
getTypeName();
107 final String envTypeDescription = Integer.toString(envGameObject.getTypeNo());
Defines types of GameObjects with corresponding attributes.
void addNoMap(@NotNull final ArchetypeType archetypeType)
Marks an ArchetypeType to not be allowed directly on maps.
boolean matches(@NotNull final BaseObject<?, ?, ?, ?> baseObject)
Checks whether a BaseObject matches all type attributes.
final Map< ArchetypeType, int @NotNull[]> inv
Maps ArchetypeTypes to allowed environment types.
Validation error that's used when the EnvironmentChecker detected a possible error on the map.
Base package of all Gridarta classes.
void addInv(@NotNull final ArchetypeType archetypeType, final int @NotNull[] types)
Sets the allowed environment game object types for an {}.
String getTypeName()
Returns the type name (artificial).
Reflects a game object (object on a map).
final ValidatorPreferences validatorPreferences
The ValidatorPreferences to use.
Configuration parameters for Validators.
GameObjects are the objects based on Archetypes found on maps.
Interface for MapArchObjects.
void validateGameObject(@NotNull final G gameObject, @NotNull final ErrorCollector< G, A, R > errorCollector)
Validates a game object.
An interface for classes that collect errors.
This is the base class for validators.
This package contains the framework for validating maps.
final Map< ArchetypeType, Void > noMap
The ArchetypeTypes that are not allowed on maps.
A GameObjectValidator that checks for valid environment.
Validation error that's used when the EnvironmentChecker detected a possible error on the map.
Interface for GameObject Validators.
Contains the data of one Gridarta Object-Type.
EnvironmentChecker(@NotNull final ValidatorPreferences validatorPreferences)
Creates a new instance.