20 package net.sf.gridarta.model.validation.checks;
22 import java.util.Collection;
23 import java.util.HashSet;
24 import java.util.Iterator;
54 import org.apache.log4j.Category;
55 import org.apache.log4j.Logger;
56 import org.jetbrains.annotations.NotNull;
57 import org.jetbrains.annotations.Nullable;
83 public static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
void addChecks(@NotNull
final ArchetypeTypeSet archetypeTypeSet, @Nullable
final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull
final EnvironmentChecker<G, A, R> environmentChecker) {
84 if (attributeRangeChecker == null) {
88 final Set<Integer> allowsAllInvTypes =
new HashSet<>();
90 if (archetypeType.isAllowsAllInv()) {
91 allowsAllInvTypes.add(archetypeType.getTypeNo());
95 addChecks(archetypeTypeSet, attributeRangeChecker, archetypeType);
96 if (!archetypeType.isMap()) {
97 environmentChecker.addNoMap(archetypeType);
99 final int[] types = archetypeType.getInv();
101 final Collection<Integer> tmp =
new HashSet<>(allowsAllInvTypes);
102 for (
final int type : types) {
105 final int[] tmp2 =
new int[tmp.size()];
106 final Iterator<Integer> it = tmp.iterator();
107 for (
int i = 0; i < tmp2.length; i++) {
110 assert !it.hasNext();
111 environmentChecker.addInv(archetypeType, tmp2);
123 private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends
Archetype<G, A, R>>
void addChecks(@NotNull
final ArchetypeTypeSet archetypeTypeSet, @NotNull
final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull
final ArchetypeType archetypeType) {
124 if (archetypeType.hasTypeAttributes()) {
137 final AttributeBitmask bitmask = archetypeTypeSet.getBitmask(archetypeAttribute.getBitmaskName());
138 if (bitmask != null) {
140 attributeRangeChecker.add(archetypeType.getTypeNo(), archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName(), 0, bitmask.
getMaxValue());
142 LOG.warn(ex.getMessage() +
" in type " + archetypeType.getTypeNo() +
".");
150 attributeRangeChecker.add(archetypeType.getTypeNo(), archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName(), 0, 1);
152 LOG.warn(ex.getMessage() +
" in type " + archetypeType.getTypeNo() +
".");
179 attributeRangeChecker.add(archetypeType.getTypeNo(), archetypeAttribute.getArchetypeAttributeName(), archetypeAttribute.getAttributeName(), archetypeAttribute.getMinCheckValue(), archetypeAttribute.getMaxCheckValue());
181 LOG.warn(ex.getMessage() +
" in type " + archetypeType.getTypeNo() +
".");
244 archetypeAttribute.visit(archetypeAttributeVisitor);
A validator that checks for suspicious attribute values.
An ArchetypeAttribute for selecting long integer values.
An ArchetypeAttribute for selecting face names.
Manages ArchetypeType instances, list, and bitmask definitions.
This Class contains the data of one archetype attribute.
An ArchetypeAttribute for selecting an optional spell encoded as an integer attribute.
An ArchetypeAttribute for selecting animation names.
Contains the data of one Gridarta Object-Type.
An ArchetypeAttribute displaying a fixed string.
An ArchetypeAttribute for selecting boolean values having specific "true" and "false" values...
An ArchetypeAttribute for selecting script files.
An ArchetypeAttribute for selecting map path names.
An ArchetypeAttribute for selecting string values.
An Exception indicating that an attribute check is invalid.
int getMaxValue()
Returns the maximum allowed bitmask value.
A GameObjectValidator that checks for valid environment.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
A set of ArchetypeAttributes.
Interface for visitors of ArchetypeAttributes.
GameObjects are the objects based on Archetypes found on maps.
This class manages bitmask values which appear in Gridarta archetype attributes.
An ArchetypeAttribute for selecting bitmask values.
An ArchetypeAttribute for selecting spells encoded as in integer attribute.
An ArchetypeAttribute for selecting integer values.
Creates checks from ArchetypeTypes.
An ArchetypeAttribute for selecting a value from two lists.
ArchetypeTypeChecks()
Private constructor to prevent instantiation.
An ArchetypeAttribute for selecting boolean values.
static final Category LOG
The logger for printing log messages.
An ArchetypeAttribute for selecting a value from a list.
An ArchetypeAttribute for selecting floating point values.
An ArchetypeAttribute for selecting text fields.
An ArchetypeAttribute for selecting a spell encoded as an inventory game object.
An ArchetypeAttribute representing a treasurelist.
Defines types of GameObjects with corresponding attributes.
Interface for MapArchObjects.