crystel 4.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/crystel.rb +318 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ea21ec5c62e26e50e51d945903c45ce3447cc3d407d083e0a495ddb578613144
4
+ data.tar.gz: 59a1a2a54bb131886b89e380155b5615a80c894838d6a04cf2e28e5a099dd894
5
+ SHA512:
6
+ metadata.gz: 340ca4eb8e8862815fb7aad47908edf3de155af7b288cc2067693c8633f5d2fd51a523fb94049f7d27746dfde61a731ba76812d681d7a7ab38bee24e224eee7b
7
+ data.tar.gz: e8a619b82e5c9477e1c3b55d78cede064cc2bf4d3d22136029f7db02b7bfe05da01b8c6f7d36257814f47703d6b638b97cce2ee495c79ed5c88de93a860ce24c
data/lib/crystel.rb ADDED
@@ -0,0 +1,318 @@
1
+ require 'json'
2
+ class Crystel
3
+ def initialize(value="")
4
+ @value = value
5
+ end
6
+ attr_accessor :value
7
+ def print
8
+ @value
9
+ end
10
+ def blank_input
11
+ @value = gets.chomp
12
+ end
13
+ def from_prompt(user_input)
14
+ puts user_input
15
+ @value = gets.chomp
16
+ end
17
+ def isin?(bigger_thing)
18
+ bigger_thing.value.include? @value
19
+ end
20
+ def in(bigger_thing)
21
+ bigger_thing.include? @value
22
+ end
23
+ def contains?(smaller_thing)
24
+ @value.include? smaller_thing
25
+ end
26
+ def s(num1, num2=" ")
27
+ if num2 == " "
28
+ num2 = @value.length
29
+ end
30
+ @value[num1...num2]
31
+ end
32
+ def s!(num1, num2=" ")
33
+ if num2 == " "
34
+ num2 = @value.length
35
+ end
36
+ self.replace(@value[num1...num2])
37
+ end
38
+ end
39
+
40
+ class Integer
41
+ def additorial
42
+ x = 1
43
+ to_return = 0
44
+ while x <= self
45
+ to_return += x
46
+ x += 1
47
+ end
48
+ to_return
49
+ end
50
+ def factorial
51
+ x = self
52
+ to_return = 1
53
+ while x > 1
54
+ to_return *= x
55
+ x -= 1
56
+ end
57
+ to_return
58
+ end
59
+ def adt
60
+ self.additorial
61
+ end
62
+ def fct
63
+ self.factorial
64
+ end
65
+ def radt
66
+ x = 1
67
+ while x.adt <= self
68
+ x += 1
69
+ end
70
+ x -= 1
71
+ return "#{x} additorial is #{x.adt}. You are #{self-x.adt} off!"
72
+ end
73
+ def rfct
74
+ x = 1
75
+ while x.fct <= self
76
+ x += 1
77
+ end
78
+ x -= 1
79
+ return "#{x} factorial is #{x.fct}. You are #{self-x.fct} off!"
80
+ end
81
+ def d(number)
82
+ self.fdiv(number)
83
+ end
84
+ def xx
85
+ puts self**self
86
+ end
87
+ end
88
+
89
+ class Object
90
+ def putsjson
91
+ if self.case == Hash or self.case == Array
92
+ JSON.generate(self)
93
+ end
94
+ end
95
+ def from_prompt(user_input)
96
+ puts user_input
97
+ self.replace(gets.chomp)
98
+ end
99
+ end
100
+
101
+ class String
102
+ def getsjson
103
+ JSON.parse(self)
104
+ end
105
+ def all_upper?
106
+ self == self.upcase
107
+ end
108
+ def all_lower?
109
+ self == self.downcase
110
+ end
111
+ def upper?(digit)
112
+ self[digit] == self[digit].downcase
113
+ end
114
+ def lower?(digit)
115
+ self[digit] == self[digit].upcase
116
+ end
117
+ def in(bigger_thing)
118
+ bigger_thing.include? self
119
+ end
120
+ def beforespace
121
+ self[0...self.index(" ")]
122
+ end
123
+ def afterspace
124
+ self[self.index(" ")+1..self.length]
125
+ end
126
+ def allof(small, big)
127
+ at = []
128
+
129
+ end
130
+ def del(*to_delete)
131
+ alslf = self
132
+ to_delete.each do |item|
133
+ alslf.gsub!(item, '')
134
+ end
135
+ alslf
136
+ end
137
+ def join(str)
138
+ self.split('').join(str)
139
+ end
140
+ end
141
+
142
+ def expect(yesOrNo, test_name="Test", raise_error=false)
143
+ puts "#{test_name} Passed: #{yesOrNo}" if yesOrNo
144
+ raise RuntimeError, "Failed test: #{test_name}" if not yesOrNo and raise_error
145
+ end
146
+
147
+ def raw_input(prompt)
148
+ print prompt
149
+ gets.chomp
150
+ end
151
+
152
+ def range(num1, num2=0)
153
+ if num2 == 0
154
+ 0...num1
155
+ else
156
+ num1...num2
157
+ end
158
+ end
159
+
160
+ #deckcrystel
161
+
162
+ class Deck
163
+ attr_accessor :position
164
+ attr_accessor :groups
165
+ def swap(one=rand(@position.size), two=rand(@position.size))
166
+ swap = @position[one]
167
+ @position[one] = @position[two]
168
+ @position[two] = swap
169
+ self
170
+ end
171
+ def shuffle
172
+ for x in 0..200
173
+ swap
174
+ end
175
+ self
176
+ end
177
+ def initialize
178
+ @position = []
179
+ @groups = []
180
+ ["c", "h", "s", "d"].each do |suit|
181
+ for card in 2..10
182
+ @position.push("#{card}#{suit}")
183
+ end
184
+ ["a", "j", "q", "k"].each do |card|
185
+ @position.push("#{card}#{suit}")
186
+ end
187
+ end
188
+ shuffle
189
+ end
190
+ def card_at(card)
191
+ @position[card]
192
+ end
193
+ def index_of(card)
194
+ @position.index(card)
195
+ end
196
+ def top(number)
197
+ if number > @position.length + 1
198
+ @position
199
+ else
200
+ @position[0...number]
201
+ end
202
+ end
203
+ def deal(num_cards, num_hands)
204
+ for i in 0...num_hands
205
+ @groups.push(top(num_cards))
206
+ for x in 0...num_cards
207
+ @position.shift
208
+ end
209
+ end
210
+ self
211
+ end
212
+ def combine
213
+ @position.push(@groups.flatten).flatten!
214
+ @groups = []
215
+ self
216
+ end
217
+ def deal_in
218
+ combine
219
+ end
220
+ def group_no(group, top_no, place, placein=1)
221
+ if (1..@groups.length).include?(place)
222
+ @groups[place-1].insert(placein-1, @groups[group-1][0...top_no]).flatten!
223
+ @groups[group-1][0...top_no].each do |card|
224
+ @groups[group-1].delete(card)
225
+ end
226
+ else
227
+ @position.insert(placein-1, @groups[group-1][0...top_no]).flatten!
228
+ @groups[group-1][0...top_no].each do |card|
229
+ @groups[group-1].delete(card)
230
+ end
231
+ end
232
+ end
233
+ end
234
+ class EukerDeck < Deck
235
+ def initialize
236
+ @position = []
237
+ @groups = []
238
+ ["c", "h", "s", "d"].each do |suit|
239
+ [9, 10, "a", "j", "q", "k"].each do |card|
240
+ @position.push("#{card}#{suit}")
241
+ end
242
+ end
243
+ shuffle
244
+ end
245
+ end
246
+ class ExplodingDeck < Deck
247
+ def initialize
248
+ @position = []
249
+ @groups = []
250
+ ['exp', 'fvr', 'shf', 'atk', 'skp', 'tac', 'mlc', 'bdc', 'rrc', 'hpc'].each do |card|
251
+ for x in 0...4
252
+ @position.push(card)
253
+ end
254
+ end
255
+ ['nop', 'fut'].each do |card|
256
+ for x in 0...5
257
+ @position.push(card)
258
+ end
259
+ end
260
+ for x in 0...6
261
+ @position.push('def')
262
+ end
263
+ shuffle
264
+ end
265
+ def deal(hands)
266
+ deal_in
267
+ @groups = []
268
+ @position.delete('def')
269
+ @position.delete('exp')
270
+ for x in 0...hands
271
+ @groups.push([])
272
+ @groups[x].push('def')
273
+ for y in 0...7
274
+ @groups[x].push(@position.shift)
275
+ end
276
+ end
277
+ for x in 0...(6-hands)
278
+ @position.insert(rand(@position.size), 'def')
279
+ end
280
+ for x in 0...(hands-1)
281
+ @position.insert(rand(@position.size), 'exp')
282
+ end
283
+ self
284
+ end
285
+ end
286
+ class CribbageDeck < Deck
287
+ def deal(num_players)
288
+ case num_players
289
+ when 2
290
+ for x in 0...3
291
+ if (1...3).include?(x)
292
+ x = top(6)
293
+ (0...6).each do
294
+ @position.shift
295
+ end
296
+ else
297
+ x = []
298
+ end
299
+ @groups.push(x)
300
+ end
301
+ when 3
302
+ for x in 0...4
303
+ if (1...3).include?(x)
304
+ x = top(5)
305
+ (0...5).each do
306
+ @position.shift
307
+ end
308
+ else
309
+ x = [@position[0]]
310
+ end
311
+ @groups.push(x)
312
+ end
313
+ end
314
+ self
315
+ end
316
+ end
317
+ class CribDeck < CribbageDeck
318
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crystel
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin M
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-02-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: The purpose of crystel is to add new functions and shortcuts to Ruby.
14
+ Parent gem to deckcrystel.
15
+ email: benjaminnner@icloud.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/crystel.rb
21
+ homepage: https://github.com/benjaminner/Ruby/tree/master/crystel
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.1.6
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Test Gem - Syntax Changes
43
+ test_files: []