story-gen 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+
2
+ class String
3
+
4
+ # @param [String] prefix
5
+ # @return [String] this {String} without +prefix+ or just this {String}
6
+ # if it does not have +prefix+.
7
+ def lchomp(prefix)
8
+ if self.start_with? prefix
9
+ then self[prefix.size..-1]
10
+ else self
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+
3
+ class String
4
+
5
+ # The same as {String#downcase!} but considers Russian alphabet as well.
6
+ #
7
+ # @return [String]
8
+ #
9
+ def ru_downcase!
10
+ self.tr! "A-ZА-ЯЁ", "a-zа-яё"
11
+ end
12
+
13
+ # The same as {String#downcase} but considers Russian alphabet as well.
14
+ #
15
+ # @return [String]
16
+ #
17
+ def ru_downcase
18
+ self.tr "A-ZА-ЯЁ", "a-zа-яё"
19
+ end
20
+
21
+ end
@@ -0,0 +1,16 @@
1
+
2
+ class StringScanner
3
+
4
+ # @param [Integer] start some value of {StringScanner#pos}.
5
+ # @param [Integer] end_ some value of {StringScanner#pos}.
6
+ # @return [String]
7
+ def substr(start, end_)
8
+ old_pos = self.pos
9
+ self.pos = start
10
+ result = peek(end_ - start)
11
+ self.pos = old_pos
12
+ return result
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,269 @@
1
+ # encoding: UTF-8
2
+
3
+ # Infinite array of unique names.
4
+ class UniqueNames
5
+
6
+ # @param [Array<String>] base_names base names which will be used to
7
+ # generate the {UniqueNames}.
8
+ def initialize(base_names)
9
+ @base_names = base_names
10
+ @postfix_id = 0
11
+ reinit_current_names
12
+ end
13
+
14
+ # @return [UniqueNames]
15
+ def self.russian_male
16
+ UniqueNames.new %W{
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
+ end
117
+
118
+ # @return [UniqueNames]
119
+ def self.russian_female
120
+ UniqueNames.new %W{
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
+ Элеонора
225
+ Эльвира
226
+ Эмма
227
+
228
+ Юлиана
229
+ Юлия
230
+
231
+ Яна
232
+ Ярослава
233
+ }
234
+ end
235
+
236
+ # @return [UniqueNames]
237
+ def self.english_male
238
+ UniqueNames.new ["Jack", "Thomas", "Joshua", "Oliver", "Harry", "James", "Charlie", "William", "Daniel", "Samuel", "Alfie", "Benjamin", "Joseph", "George", "Callum", "Jake", "Ethan", "Lewis", "Luke", "Mohammed", "Matthew", "Dylan", "Jacob", "Alexander", "Ryan", "Adam", "Tyler", "Harvey", "Liam", "Max", "Cameron", "Harrison", "Jamie", "Jayden", "Leo", "Owen", "Henry", "Connor", "Archie", "Nathan", "Ben", "Muhammad", "Oscar", "Edward", "Lucas", "Michael", "Isaac", "Aaron", "Kyle", "Noah", "Finley", "Rhys", "Bradley", "Charles", "Toby", "Louis", "Brandon", "Logan", "Mason", "Reece", "Kieran", "Alex", "Riley", "Finlay", "Kai", "Freddie", "David", "Harley", "Kian", "Mohammad", "Bailey", "Sam", "Luca", "Joel", "Theo", "Leon", "John", "Robert", "Ashton", "Ellis", "Joe", "Aidan", "Billy", "Corey", "Hayden", "Evan", "Zachary", "Taylor", "Christopher", "Sebastian", "Elliot", "Morgan", "Jay", "Dominic", "Reuben", "Gabriel", "Sean", "Louie", "Andrew", "Frederick", "Ewan", "Zak"]
239
+ end
240
+
241
+ # @return [UniqueNames]
242
+ def self.english_female
243
+ UniqueNames.new ["Olivia", "Grace", "Ruby", "Jessica", "Emily", "Sophie", "Chloe", "Lucy", "Lily", "Ella", "Ellie", "Amelia", "Charlotte", "Katie", "Mia", "Hannah", "Evie", "Megan", "Amy", "Isabella", "Millie", "Isabelle", "Abigail", "Freya", "Molly", "Daisy", "Holly", "Emma", "Erin", "Poppy", "Jasmine", "Phoebe", "Leah", "Keira", "Caitlin", "Imogen", "Madison", "Rebecca", "Elizabeth", "Georgia", "Sophia", "Lauren", "Scarlett", "Amber", "Ava", "Eleanor", "Bethany", "Alice", "Isabel", "Summer", "Paige", "Anna", "Lola", "Libby", "Eva", "Maisie", "Isobel", "Brooke", "Lilly", "Alisha", "Tia", "Sarah", "Amelie", "Gracie", "Faith", "Rosie", "Courtney", "Matilda", "Niamh", "Maddison", "Sienna", "Eve", "Aimee", "Skye", "Zara", "Isla", "Shannon", "Madeleine", "Harriet", "Zoe", "Nicole", "Sofia", "Abbie", "Maya", "Lacey", "Rachel", "Francesca", "Layla", "Lydia", "Alicia", "Hollie", "Martha", "Alexandra", "Julia", "Natasha", "Lexie", "Mollie", "Morgan", "Maria", "Demi", "Rose", "Laura", "Lara", "Victoria", "Tilly", "Sara", "Evelyn", "Eloise"]
244
+ end
245
+
246
+ # @return [String]
247
+ def pop
248
+ n = @current_names.pop + postfix
249
+ if @current_names.empty?
250
+ @postfix_id += 1
251
+ reinit_current_names
252
+ end
253
+ return n
254
+ end
255
+
256
+ private
257
+
258
+ def reinit_current_names
259
+ @current_names = @base_names.shuffle
260
+ end
261
+
262
+ def postfix
263
+ if @postfix_id == 0
264
+ then ""
265
+ else "-#{@postfix_id}"
266
+ end
267
+ end
268
+
269
+ end
@@ -0,0 +1,58 @@
1
+ "
2
+ Fight club
3
+ ==========
4
+
5
+ "
6
+
7
+ ```
8
+ require 'unique_names'
9
+
10
+ names = UniqueNames.english_male
11
+ ```
12
+
13
+ "Today in the fight club the tournament is being held! Meet the participants:"
14
+
15
+ 10 раз:
16
+ ```n = names.pop```;
17
+ N is the current participant;
18
+ N is in;
19
+ "
20
+ - "N", the ";
21
+ either "tiger", or "fox", or "bear", or ("horse"; N has hooves);
22
+ " ";
23
+ either ("with powerful hands"; N uses "hands"),
24
+ or ("with powerful feet"; N uses "feet"),
25
+ or:
26
+ if X is the current participant and X has hooves then (
27
+ "with powerful hooves"; X uses "hooves"
28
+ )
29
+ or (
30
+ "with sharp claws"; N uses "claws"
31
+ )
32
+ .
33
+ N is not the current participant;
34
+ .
35
+ "
36
+
37
+ Let the tournament begin!
38
+
39
+ "
40
+ While the tournament not complete:
41
+ If X is in and Y is in and X != Y, then:
42
+ (note: fight!)
43
+ either (X won; Y lost), or (Y won; X lost);
44
+ (note: yup, it should be made that existing variables can be used in
45
+ conditions rather than capturing new ones only)
46
+ if A won and B lost and A uses "hands" then ""A" has beaten "B". "
47
+ or if A won and B lost and A uses "feet" then ""A" has kicked "B". "
48
+ or if A won and B lost and A uses "hooves" then ""A" has kicked "B" and knocked him out. "
49
+ or if A won and B lost and A uses "claws" then ""A" has scratched the whole "B". ";
50
+ if A lost then (A not lost; A is not in);
51
+ if A won then A not won;
52
+ .
53
+ Or the tournament complete;
54
+ .
55
+ If X is in then ""X" is the winner!".
56
+
57
+ "
58
+ "
@@ -0,0 +1,53 @@
1
+ "Oliver" is a boy.
2
+ "Sam" is a boy.
3
+ "Nathan" is a boy.
4
+ "John" is a boy.
5
+ "Jack" is a boy.
6
+ "Katie" is a girl.
7
+ "Abigail" is a girl.
8
+ "Rose" is a girl.
9
+ "Madeleine" is a girl.
10
+ "Liza" is a girl.
11
+
12
+ "
13
+ University
14
+ ==========
15
+
16
+ "
17
+
18
+ "Once upon a time in the University went "; for all X is a boy or X is a girl,
19
+ X", "; "that's it. They quickly became friends and went out often. "
20
+
21
+ While X is a boy and X not loves *:
22
+ if X is a boy and X not loves * and Y is a girl and * not loves Y then:
23
+ either:
24
+ "Once they all went out to a bar. Everyone danced. ";
25
+ either
26
+ "" (note: this means "do nothing")
27
+ or:
28
+ ""X" and "Y" danced together the most. They liked each other and soon they fell in love! ";
29
+ X loves Y.
30
+ .
31
+ or:
32
+ "Once "X" and "Y" met in the dorm's kitchen. ";
33
+ either
34
+ "They talked nicely and prepared a nice supper. "
35
+ or:
36
+ "They talked very much and prepared a great supper together. Soon they understood that they love each other! ";
37
+ X loves Y.
38
+ .
39
+ or:
40
+ "Once "X" and "Y" were at the lecture and constantly looked at each other. ";
41
+ either
42
+ "After the lectures they went home and did their home tasks. "
43
+ or:
44
+ "After the lectures "X" caught "Y" and told her that he loves her! "
45
+ X loves Y.
46
+ .
47
+ .
48
+ .
49
+
50
+ "
51
+
52
+ Then they all lived long and happy!
53
+ "
@@ -0,0 +1,58 @@
1
+ "
2
+ Бойцовский клуб
3
+ ===============
4
+
5
+ "
6
+
7
+ ```
8
+ require 'unique_names'
9
+
10
+ names = UniqueNames.russian_male
11
+ ```
12
+
13
+ "Сегодня в бойцовском клубе проводится турнир! Поприветствуйте участников:"
14
+
15
+ 10 раз:
16
+ ```n = names.pop```;
17
+ N - текущий участник;
18
+ N участвует в турнире;
19
+ "
20
+ - "N", ";
21
+ либо "тигр", либо "лис", либо "медведь", либо ("конь"; N имеет копыта);
22
+ " ";
23
+ либо ("с сильными руками"; N использует "руки"),
24
+ либо ("с сильными ногами"; N использует "ноги"),
25
+ либо:
26
+ если X - текущий участник и X имеет копыта, то (
27
+ "с мощными копытами"; X использует "копыта"
28
+ )
29
+ или (
30
+ "с острыми когтями"; N использует "когти"
31
+ )
32
+ .
33
+ N - не текущий участник;
34
+ .
35
+ "
36
+
37
+ Да начнется турнир!
38
+
39
+ "
40
+ Пока не конец турнира:
41
+ Если X участвует в турнире и Y участвует в турнире и X != Y, то:
42
+ (note: бой!)
43
+ либо (X победил; Y проиграл), либо (Y победил; X проиграл);
44
+ (note: дя, надо сделать, чтобы в условиях можно было существующие
45
+ переменные использовать, а не только захватывать новые)
46
+ если A победил и B проиграл и A использует "руки", то ""A" избил "B". "
47
+ или если A победил и B проиграл и A использует "ноги", то ""A" запинал "B". "
48
+ или если A победил и B проиграл и A использует "копыта", то ""A" лягнул "B" и вырубил его. "
49
+ или если A победил и B проиграл и A использует "когти", то ""A" исцарапал всего "B". ";
50
+ если A проиграл, то (A не проиграл; A не участвует в турнире);
51
+ если A победил, то A не победил;
52
+ .
53
+ Или конец турнира;
54
+ .
55
+ Если X участвует в турнире, то ""X" - победитель!".
56
+
57
+ "
58
+ "