summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/rgens/ZadronsPouch.java
blob: 827d02285cfb28667fe24ddfb9f3f995b77ffb3a (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
package bjc.rgens;

import bjc.utils.funcdata.FunctionalStringTokenizer;
import bjc.utils.funcdata.IList;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.gen.RandomGrammar;

/**
 * Example showing code manipulate of random grammars
 *
 * @author ben
 */
public class ZadronsPouch {
	/**
	 * Main method for running application
	 *
	 * @param args
	 * 	Unused CLI args
	 */
	public static void main(String[] args) {
		ZadronsPouch zp = new ZadronsPouch();

		for (int i = 0; i < 100; i++) {
			IList<String> ls = zp.grammar.generateListValues("[item]", " ");

			StringBuilder sb = new StringBuilder();

			ls.forEach(sp -> sb.append(sp));

			System.out.println(sb.toString().replaceAll("\\s+", " "));
		}
	}

	private RandomGrammar<String> grammar;

	/** Create a new instance with a grammar */
	public ZadronsPouch() {
		grammar = new RandomGrammar<>();

		/*
		 * @NOTE
		 * 	Should there be some sort of builder sort of interface?
		 */
		addRule("[item]",
		        "[egg]",      "[glove]", "[crys-sphere]", "[rock]",
		        "[figurine]", "[vial]",  "[mini-weapon]", "[bag]",
		        "[card]",     "[rope]",  "[box]",         "[wand]");

		addEggRules();
		addGloveRules();
		addCrysSphereRules();
		addRockRules();

		addFigurineRules();
		addVialRules();
		addMiniWeaponRules();
		addBagRules();

		addCardRules();
		addRopeRules();
		addBoxRules();
		addWandRules();
	}

	private void addBagRules() {
		addRule("[bag]",
		        "bag of [bag-type]", "[sack-type] sack", "[purse-type] purse");
		addRule("[bag-type]",
		        "holding",   "tricks",     "useful items",
		        "devouring", "dwarf-kind", "invisible cloth",
		        "monster summoning");
		addRule("[sack-type]",
		        "lunch", "recursive");
		addRule("[purse-type]",
		        "everfull");
	}

	private void addBoxRules() {
		addRule("[box]",
		        "[box-type] box", "cube of [box-type]");
		addRule("[box-type]",
		        "limited-force",    "frost-resisting", "morphing",
		        "self-destructing", "pandora",         "panicking");
	}

	private void addCardRules() {
		addRule("[card]",
		        "card of [card-type]", "[card-type] card");
		addRule("[card-type]",
		        "fate",        "teleporting", "elusive treasure", "spell-storing",
		        "many-things", "imprisoning", "messaging",        "bounty");
	}

	private void addCrysSphereRules() {
		addRule("[crys-sphere]",
		        "[sphere-type] spheres",     "[sphere-type] sphere",
		        "lens of [lens-type]",       "[crystal-type] crystal",
		        "crystal of [crystal-type]", "crystal ball",
		        "crystal ball of [crys-suffix]");
		addRule("[sphere-type]",
		        "microphonic", "seeing-eye");
		addRule("[lens-type]",
		        "detection");
		addRule("[crystal-type]",
		        "prison", "radar");
		addRule("[crys-suffix]",
		        "jumping");
	}

	private void addEggRules() {
		addRule("[egg]",
		        "[egg-type] egg");
		addRule("[egg-type]",
		        "copper", "stone",      "golden",
		        "white",  "white/pink", "glass");
	}

	private void addFigurineRules() {
		addRule("[figurine]",
		        "[fig-material] [fig-animal]");
		addRule("[fig-material]",
		        "golden", "onyx",   "serpentine", "ivory",
		        "marble", "bronze", "jade",       "limestone");
		addRule("[fig-animal]",
		        "lion",     "dog",     "owl",    "goat",
		        "elephant", "warrior", "palace", "leprechaun");
	}

	private void addGloveRules() {
		addRule("[glove]",
		        "gauntlets of [gauntlet-type]",
		        "gloves of [glove-type]",
		        "[glove-type] gloves");
		addRule("[gauntlet-type]",
		        "dexterity", "power");
		addRule("[glove-type]",
		        "pushing", "choking", "bigby", "stunning");
	}

	private void addMiniWeaponRules() {
		addRule("[mini-weapon]",
		        "minature [weapon-type]", "small [weapon-type]",
		        "tiny [weapon-type]",     "[sling-type] sling",
		        "[weapon-type]");
		addRule("[weapon-type]",
		        "boomerang", "arrow",  "net",
		        "catapult",  "hammer", "sword", "club");
		addRule("[sling-type]",
		        "seeking");
	}

	private void addRockRules() {
		addRule("[rock]",
		        "[pebble-type] pebble", "stone of [stone-type]",
		        "[stone-type] stone",   "brick of [brick-type]",
		        "[geode-type] geode");
		addRule("[pebble-type]",
		        "inscribed", "elemental control");
		addRule("[stone-type]",
		        "good-luck",     "weight",
		        "blind-defense", "metal-clinging");
		addRule("[brick-type]",
		        "flying");
		addRule("[geode-type]",
		        "ioun");
	}

	private void addRopeRules() {
		addRule("[rope]",
		        "[rope-type] rope", "rope of [rope-type]",
		        "ball of [string-type] [string-kind]");
		addRule("[rope-type]",
		        "trick",    "entangling", "climbing",   "dancing",
		        "tripping", "snaring",    "levitating", "self-entangling");
		addRule("[string-type]",
		        "endless");
		addRule("[string-kind]",
		        "string", "yarn");
	}

	private void addRule(String rule, String... cases) {
		IList<IList<String>> cses = new FunctionalList<>();

		for (String strang : cases) {
			cses.add(FunctionalStringTokenizer.fromString(strang).toList(s -> s));
		}

		grammar.makeRule(rule, cses);
	}

	private void addVialRules() {
		addRule("[vial]",
		        "vial of [vial-type]",  "[vial-type] vial",
		        "[bottle-type] bottle", "[flask-type] flask");
		addRule("[vial-type]",
		        "holding",    "trapping",
		        "experience", "unnatural regeneration");
		addRule("[bottle-type]",
		        "ever-smoking", "wheezing",
		        "blank potion");
		addRule("[flask-type]",
		        "iron");
	}

	private void addWandRules() {
		addRule("[wand]",
		        "[wand-type] wand", "wand of [wand-type]",
		        "canceling [wand-type] wand");
		addRule("[wand-type]",
		        "magic missile", "[spell-1]",      "[spell-2]",
		        "gusting",       "life-detecting", "zadron");
		addRule("[spell-1]",
		        "frost",        "fire",         "lightning",   "fear",
		        "illumination", "polymorphing", "conjuration", "paralyzing");
		addRule("[spell-2]",
		        "[spell2-type] detecting");
		addRule("[spell2-type]",
		        "magic", "enemy", "secret door/trap");
	}
}