summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/affixes/AffixMods.java
blob: d1242515ab1df454f3ae2929ef9fde317f724b61 (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
package darkknight.jewelrycraft.affixes;

import java.util.*;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import darkknight.jewelrycraft.api.ModifierEffect;
import darkknight.jewelrycraft.random.WeightedRandomAffix;
import net.minecraft.util.WeightedRandom;

public class AffixMods {
	private static Map<String, ModifierEffect> prefixes;
	private static Map<String, ModifierEffect> suffixes;

	private static List<WeightedRandomAffix> prefixGen;
	private static List<WeightedRandomAffix> suffixGen;

	public static void initializeAffixes(FMLPreInitializationEvent fpie) {
		prefixes = new HashMap<String, ModifierEffect>();
		suffixes = new HashMap<String, ModifierEffect>();
		
		prefixGen = new LinkedList<WeightedRandomAffix>();
		suffixGen = new LinkedList<WeightedRandomAffix>();
		
		ModifierEffect health1 = new HealthAffix(1);
		ModifierEffect health2 = new HealthAffix(2);
		ModifierEffect health3 = new HealthAffix(3);
		
		prefixes.put("health1", health1);
		prefixes.put("health2", health2);
		prefixes.put("health3", health3);
		
		prefixGen.add(new WeightedRandomAffix("health1", 10));
		prefixGen.add(new WeightedRandomAffix("health2", 7));
		prefixGen.add(new WeightedRandomAffix("health3", 5));
		
		suffixes.put("health1", health1);
		suffixes.put("health2", health2);
		suffixes.put("health3", health3);
		
		suffixGen.add(new WeightedRandomAffix("health1", 10));
		suffixGen.add(new WeightedRandomAffix("health2", 7));
		suffixGen.add(new WeightedRandomAffix("health3", 5));
	}

	public static ModifierEffect getPrefix(String prefix) {
		return prefixes.get(prefix);
	}

	public static ModifierEffect getSuffix(String suffix) {
		return suffixes.get(suffix);
	}

	public static String pickPrefix(Random random) {
		WeightedRandomAffix wra = ((WeightedRandomAffix) WeightedRandom.getRandomItem(random, prefixGen));

		return wra.getAffix(random);
	}

	public static String pickSuffix(Random random) {
		WeightedRandomAffix wra = ((WeightedRandomAffix) WeightedRandom.getRandomItem(random, suffixGen));

		return wra.getAffix(random);
	}
}