summaryrefslogtreecommitdiff
path: root/src/main/java/tlIItools/Affix.java
blob: 424b2dad1c1689cb1d998337ca2bb6d59b6d96a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package tlIItools;

import java.util.ArrayList;
import java.util.List;

/**
 * Represents a Torchlight II affix.
 */
public class Affix {
	/**
	 * Internal name of the affix.
	 */
	public String intName;

	/**
	 * The prefix/suffix attached to the affix.
	 *
	 * In general, only one of these is set for a given affix.
	 *
	 * NOTE: Some affixes have a mis-set suffix/prefix ordering, and
	 * may need to be changed.
	 */
	public String affixSuffix;
	public String affixPrefix;

	/**
	 * The min/max levels the affix can spawn at.
	 */
	public int minLevel;
	public int maxLevel;

	/**
	 * The spawn weight for the affix.
	 */
	public int weight;

	/**
	 * The number of affix slots taken up.
	 */
	public int slots;

	/**
	 * Whether this is a socketable affix.
	 */
	public boolean isSocketable;
	/**
	 * Whether this is an enchantment, instead of a standard affix.
	 */
	public boolean isEnchantment;
	/**
	 * Whether this is a mob/player affix.
	 */
	public boolean isPerson;

	/**
	 * The types of equipment this can spawn on.
	 */
	public List<String> equipTypes;
	/**
	 * The types of equipment this can't spawn on.
	 */
	public List<String> nonequipTypes;

	/**
	 * Places to get this enchantment from;
	 */
	public List<String> enchantSources;

	/**
	 * The socketable types this spawns on.
	 */
	public List<String> socketableTypes;

	/**
	 * The effects attached to this affix.
	 */
	public List<Effect> effects;

	/*
	 * Are invalid equip types being added?
	 */
	private boolean inNonEquip;

	/**
	 * Create a new blank affix.
	 */
	public Affix() {
		equipTypes      = new ArrayList<>();
		nonequipTypes   = new ArrayList<>();
		enchantSources  = new ArrayList<>();
		socketableTypes = new ArrayList<>();
		effects         = new ArrayList<>();
	}

	/**
	 * Sets the set of equip types that is added to.
	 *
	 * @param nonequip 
	 * 	True if the equip types being added are prohibited, or
	 * 	false if they are allowed.
	 */
	public void setEquipType(boolean nonequip) {
		inNonEquip = nonequip;
	}

	/**
	 * Add an equip type to the right set of equip types.
	 *
	 * @param type
	 * 	The equip type to add.
	 */
	public void addEquipType(String type) {
		if (inNonEquip) {
			nonequipTypes.add(type);
		} else {
			if (type.equals("SOCKETABLE") || type.contains(" EMBER")) {
				isSocketable = true;
				socketableTypes.add(type);
			} else if (type.startsWith("ENCHANTER")) {
				isEnchantment = true;
				enchantSources.add(type.substring(10));
			} else if (type.equals("MONSTER") || type.equals("PLAYER"))  {
				isPerson = true;
			} else {
				equipTypes.add(type);
			}
		}
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		if (isSocketable)  sb.append("Socketable ");
		else if (isPerson || (intName != null && intName.startsWith("HERO_"))) sb.append("Personal ");
		else if (intName != null & intName.startsWith("MAP_")) sb.append("Area ");

		if (isEnchantment) sb.append("Enchantment: ");
		else               sb.append("Affix: ");

		sb.append(intName);
		sb.append("\n");

		if (affixSuffix != null) {
			sb.append("\tSuffix: ");
			sb.append(affixSuffix);
			sb.append("\n");
		}

		if (affixPrefix != null) {
			sb.append("\tPrefix: ");
			sb.append(affixPrefix);
			sb.append("\n");

		}

		sb.append("\t");
		if (minLevel <= 1 && maxLevel == 999) {
			sb.append("No Level Range");
		} else if (minLevel != 1 && maxLevel != 999) {
			sb.append("Level Range: ");
			sb.append(minLevel);
			sb.append("-");
			sb.append(maxLevel);
		} else if (minLevel <= 1) {
			sb.append("Max Level: ");
			sb.append(maxLevel);
		} else if (maxLevel == 999) {
			sb.append("Minimum Level: ");
			sb.append(minLevel);
		}

		sb.append("\n");

		sb.append("\tSpawn Weight: ");
		sb.append(weight);
		sb.append("\n");

		if (slots == 0) {
			sb.append("\tOccupies no slots\n");
		} else {
			sb.append("\tSlots: ");
			sb.append(slots);
			sb.append("\n");
		}

		if (equipTypes.size() != 0) {
			if (isSocketable) sb.append("\tSocketable Into: ");
			else if (isEnchantment) sb.append("\tEnchants Onto: ");
			else sb.append("\tSpawns On: ");
			sb.append(equipTypes);
			sb.append("\n");
		}

		// Socketables & enchantments use this as a duplicate.
		if (!isSocketable && !isEnchantment && nonequipTypes.size() != 0) {
			sb.append("\tCan't Spawn On: ");
			sb.append(nonequipTypes);
			sb.append("\n");
		}

		if (enchantSources.size() != 0) {
			sb.append("\tEnchantment Sources: ");
			sb.append(enchantSources);
			sb.append("\n");
		}

		if (socketableTypes.size() != 0) {
			sb.append("\tSocketable Types: ");
			sb.append(socketableTypes);
			sb.append("\n");
		}

		if (effects.size() != 0) {
			sb.append("\tEffects: ");
			for (Effect eft : effects) {
				sb.append("\n\t\t");
				sb.append(eft.toString());
			}
			sb.append("\n");
		}

		return sb.toString();
	}
}