kittyverse 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b83f8ccd15b5d6499f12627e7a8bb1261b33176b
4
- data.tar.gz: 9086b03449228f510ac73ee7198fe9264744a93c
3
+ metadata.gz: e56df36f3f3c53df42e7ecd83ebda939624943f1
4
+ data.tar.gz: 4bfcfff584c9e0329c2dfe5de70bf262dd605cd2
5
5
  SHA512:
6
- metadata.gz: 2bcfa16de3bb45b077bbfff8d503e87a7f28de68d55a2b1257b4540eb91ac5f28a88fceb94b814b7167b5b4a7aeb1812628fd33200ce81ae785fa90507c8f8c1
7
- data.tar.gz: 22938b98bdd3bfb741033537516d28dff5f5b0e527571600c5016514e1969f7422fafa81885a9bcc0a5ae3823a918c681377ae5fc2daec0970784e08d8149fac
6
+ metadata.gz: 6ad27041804377e2ed42ab9161f74a03a601f154b80af45972a96bdf4c233866ec5f10aafbb165b6f173a39eaaaa8d130dab2ec66300ffaff79992fd57359983
7
+ data.tar.gz: 585438e11230eaf60ad40115045a6a3198934f14fb0d7d35f8eb2cac6ceb4df01289244f280ae3c817fdb4d482d87239c23466ce3713fa02d5a9da4f9a9f0ab9
@@ -4,16 +4,18 @@ Manifest.txt
4
4
  README.md
5
5
  Rakefile
6
6
  lib/kittyverse.rb
7
- lib/kittyverse/catalog.rb
8
7
  lib/kittyverse/cattributes.rb
8
+ lib/kittyverse/config/fancies.rb
9
+ lib/kittyverse/config/purrstiges.rb
10
+ lib/kittyverse/config/traits.rb
11
+ lib/kittyverse/config/traits_timeline.rb
9
12
  lib/kittyverse/fancies.rb
10
13
  lib/kittyverse/links.rb
11
14
  lib/kittyverse/mewtations.rb
12
15
  lib/kittyverse/pages/genes.rb
13
- lib/kittyverse/purrstige.rb
14
16
  lib/kittyverse/traits.rb
15
- lib/kittyverse/traits_timeline.rb
16
17
  lib/kittyverse/version.rb
17
18
  test/helper.rb
18
19
  test/test_cattributes.rb
20
+ test/test_fancies.rb
19
21
  test/test_traits.rb
data/README.md CHANGED
@@ -18,7 +18,7 @@ Use the `Traits` helper class to lookup trait types (e.g. fur, pattern, eye colo
18
18
  ``` ruby
19
19
  t = Traits[ 'FU00' ]
20
20
  p t.class #=> Trait
21
- p t.name #=> "savannah"
21
+ p t.name #=> "Savannah"
22
22
  p t.type.name #=> "Fur"
23
23
  p t.code #=> "FU00"
24
24
  p t.kai #=> "1"
@@ -51,7 +51,7 @@ Use:
51
51
  ``` ruby
52
52
  t = Traits[ 'PA14' ]
53
53
  p t.class #=> Trait
54
- p t.name #=> "totesbasic 1"
54
+ p t.name #=> "Totesbasic 1"
55
55
  p t.type.name #=> "Pattern"
56
56
  p t.code #=> "PA14"
57
57
  p t.kai #=> "f"
@@ -68,7 +68,7 @@ t = Traits[ :body ][ 'f' ]
68
68
  t = Traits[ :body ][ '14' ]
69
69
  t = Traits[ :body ][ 14 ]
70
70
  # ...
71
- ```
71
+ ```
72
72
 
73
73
 
74
74
 
@@ -104,19 +104,19 @@ Use the `Cattribute` helper class to lookup cattributes incl. purrstige cattribu
104
104
  ``` ruby
105
105
  c = Cattribute[ 'savannah' ]
106
106
  p c.class #=> Cattribute
107
- p c.name #=> "savannah"
107
+ p c.name #=> "Savannah"
108
108
  p c.type.name #=> "Fur"
109
109
  p c.traits.size #=> 1
110
- p c.traits #=> ["savannah"]
110
+ p c.traits #=> ["Savannah"]
111
111
  p c.traits[0].code #=> "FU00"
112
112
  # ...
113
113
 
114
114
  c = Cattribute[ 'totesbasic' ]
115
115
  p c.class #=> Cattribute
116
- p c.name #=> "totesbasic"
116
+ p c.name #=> "Totesbasic"
117
117
  p c.type.name #=> "Pattern"
118
118
  p c.traits.size #=> 3
119
- p c.traits #=> ["totesbasic 1", "totesbasic 2", "totesbasic 3"]
119
+ p c.traits #=> ["Totesbasic 1", "Totesbasic 2", "Totesbasic 3"]
120
120
  p c.traits[0].code #=> "PA14"
121
121
  p c.traits[1].code #=> "PA15"
122
122
  p c.traits[2].code #=> "PA23"
@@ -124,20 +124,79 @@ p c.traits[2].code #=> "PA23"
124
124
 
125
125
  c = Cattribute[ 'bionic' ]
126
126
  p c.class #=> Cattribute
127
- p c.name #=> "bionic"
127
+ p c.name #=> "Bionic"
128
128
  p c.type.name #=> "Purrstige"
129
129
  p c.traits.size #=> 0
130
130
  p c.traits #=> []
131
131
  p c.recipe #=> {time: {start: "2019-05-01", end: "2019-08-31"},
132
- # traits: ["ragdoll",
132
+ # traits: ["Ragdoll",
133
133
  # "WE05",
134
- # ["totesbasic 1", "totesbasic 2", "totesbasic 3"],
134
+ # ["Totesbasic 1", "Totesbasic 2", "Totesbasic 3"],
135
135
  # "PU30"]}
136
136
 
137
137
  # ...
138
138
  ```
139
139
 
140
+ ### Fancies
141
+
142
+ Use the `Fancy` helper class to lookup fancy or exclusive or special edition cats incl. timed trait recipes / forumlas, counts, limits, ids and more:
143
+
144
+ ``` ruby
145
+ f = Fancy[ :genesis ]
146
+ p f.class #=> Fancy
147
+ p f.name #=> "Genesis"
148
+ p f.key #=> :genesis
149
+ p f.exlusive? #=> true
150
+ p f.ids.size #=> 1
151
+ p f.ids #=> [1]
152
+ #...
153
+
154
+ # -or-
155
+
156
+ f = Fancy.find_by_key( :genesis )
157
+ f = Fancy.find_by( key: 'genesis' )
158
+ f = Fancy[ 'Genesis' ]
159
+ f = Fancy.find_by_name( 'Genesis' )
160
+ f = Fancy.find_by( name: 'Genesis' )
161
+ # ...
162
+
163
+ f = Fancy[ :bugcat ]
164
+ p f.class #=> Fancy
165
+ p f.name #=> "Bug Cat"
166
+ p f.key #=> :bugcat
167
+ p f.exlusive? #=> true
168
+ p f.ids.size #=> 3
169
+ p f.ids #=> [101,102,103]
170
+ #...
140
171
 
172
+ # -or-
173
+
174
+ f = Fancy[ 'Bug Cat' ]
175
+ f = Fancy[ 'BugCat' ]
176
+ f = Fancy[ 'bugcat' ]
177
+ f = Fancy.find_by_name( 'Bug Cat' )
178
+ f = Fancy.find_by( name: 'Bug Cat' )
179
+ # ...
180
+ ```
181
+
182
+ **Fancy Cat Types**
183
+
184
+ ``` ruby
185
+ p Fancy.size #=> 83
186
+ p Fancy.exclusives.size #=> 22
187
+ p Fancy.special_editions.size #=> 5
188
+ p Fancy.fancies.size #=> 56
189
+ ```
190
+
191
+ Loop over all fancies:
192
+
193
+ ``` ruby
194
+ Fancy.each do |fancy|
195
+ p fancy.name
196
+ end
197
+
198
+ # ...
199
+ ```
141
200
 
142
201
 
143
202
  ## Real World Usage
@@ -11,281 +11,22 @@ require 'base32-alphabets'
11
11
 
12
12
  ## our own code
13
13
  require 'kittyverse/version' # note: let version always go first
14
- require 'kittyverse/traits'
15
- require 'kittyverse/traits_timeline'
16
- require 'kittyverse/mewtations'
17
- require 'kittyverse/fancies'
18
- require 'kittyverse/purrstige'
19
- require 'kittyverse/catalog'
20
-
21
-
22
- require 'kittyverse/links'
23
- require 'kittyverse/pages/genes'
24
-
25
-
26
- class Trait
27
-
28
- def self.traits_by_name() @@traits_by_name ||= {}; end
29
- def self.traits_by_code() @@traits_by_code ||= {}; end
30
-
31
- def self.find_by_code( code )
32
- ## note: allow string AND symbols (thus, use .to_s)
33
- ## e.g. allow 'FU01', 'fu01', :fu01, :FU01, etc.
34
- @@traits_by_code[ code.upcase.to_s ]
35
- end
36
-
37
- def self.find_by_name( name )
38
- ## note: allow string AND symbols (thus, use .to_s !!!)
39
- ## note: downcase name e.g. allow Savannah too (not just savannah)
40
- @@traits_by_name[ name.downcase.to_s ]
41
- end
42
-
43
- ## add "generic" convenience find helper
44
- def self.find_by( **kwargs )
45
- if kwargs[ :name ]
46
- find_by_name( kwargs[ :name ] )
47
- elsif kwargs[ :code ]
48
- find_by_code( kwargs[ :code] )
49
- else
50
- ## todo/fix: throw argument except!!!
51
- nil
52
- end
53
- end
54
-
55
-
56
-
57
- attr_accessor :type,
58
- :name,
59
- :kai # kai char e.g. '1', '2', etc.
60
-
61
- def initialize( **kwargs )
62
- update( kwargs )
63
- end
64
-
65
- def update( **kwargs )
66
- kwargs.each do |name,value|
67
- send( "#{name}=", value ) ## use "regular" plain/classic attribute setter
68
- end
69
- self ## return self for chaining
70
- end
71
-
72
- def num() Kai::NUMBER[@kai]; end
73
- def code() @type.code + Kai::CODE[@kai]; end
74
- end # class Trait
75
-
76
-
77
-
78
- class TraitType
79
-
80
- def self.trait_types_by_key() @@trait_types_by_key ||= {}; end
81
- def self.trait_types_by_code() @@trait_types_by_code ||= {}; end
82
- def self.trait_types_by_name() @@trait_types_by_name ||= {}; end
83
-
84
- # quick hack - map copycats keys to (internal) cryptokitties trait type keys
85
- # note: all keys are the same except:
86
- ALT_TRAIT_TYPE_KEYS =
87
- {
88
- # :colorprimary => :color1,
89
- # :colorsecondary => :color2,
90
- # :colortertiary => :color3
91
-
92
- :color1 => :colorprimary,
93
- :color2 => :colorsecondary,
94
- :color3 => :colortertiary
95
- }
96
-
97
-
98
- def self.find_by_key( key )
99
- ## note: allow string AND symbols (thus, use .to_sym !!!)
100
- ## note: allow known alternative mappings/key (e.g. "internal" cryptokitties keys if different)
101
- key = ALT_TRAIT_TYPE_KEYS[ key.to_sym ] if ALT_TRAIT_TYPE_KEYS[ key.to_sym ]
102
-
103
- @@trait_types_by_key[ key.to_sym ]
104
- end
105
-
106
- def self.find_by_code( code )
107
- ## note: allow string AND symbols (thus, use .to_s)
108
- ## e.g. allow 'FU', 'fu', :fu, :FU, etc.
109
- @@trait_types_by_code[ code.upcase.to_s ]
110
- end
111
-
112
- ALT_TRAIT_TYPE_NAMES =
113
- {
114
- 'body' => 'fur',
115
- 'eyes' => 'eye shape',
116
- 'eye type' => 'eye shape',
117
- 'body color' => 'base color',
118
- 'primary color' => 'base color',
119
- 'base colour' => 'base color', # british (canadian) spelling
120
- 'secondary color' => 'highlight color',
121
- 'sec color' => 'highlight color',
122
- 'pattern color' => 'highlight color',
123
- 'highlight colour' => 'highlight color', # british (canadian) spelling
124
- 'tertiary color' => 'accent color',
125
- 'accent colour' => 'accent color', # british (canadian) spelling
126
- 'wild' => 'wild element',
127
- 'secret' => 'secret y gene'
128
- }
129
14
 
130
- def self.find_by_name( name )
131
- ## note: downcase name e.g. allow fur too (not just Fur)
132
- ## note: allow known alternative mappings/key (e.g. "internal" cryptokitties keys if different)
133
- name = ALT_TRAIT_TYPE_NAMES[ name.downcase ] if ALT_TRAIT_TYPE_NAMES[ name.downcase ]
15
+ require 'kittyverse/config/traits'
16
+ require 'kittyverse/config/traits_timeline'
17
+ require 'kittyverse/config/fancies'
18
+ require 'kittyverse/config/purrstiges'
134
19
 
135
- @@trait_types_by_name[ name.downcase ]
136
- end
137
20
 
21
+ require 'kittyverse/mewtations'
22
+ require 'kittyverse/links'
138
23
 
139
- ## add "generic" convenience find helper
140
- def self.find_by( **kwargs )
141
- if kwargs[ :key ]
142
- find_by_key( kwargs[ :key ] )
143
- elsif kwargs[ :code ]
144
- find_by_code( kwargs[ :code ] )
145
- elsif kwargs[ :name ]
146
- find_by_name( kwargs[ :name ] )
147
- else
148
- ## todo/fix: throw argument except!!!
149
- nil
150
- end
151
- end
152
-
153
- def self.each
154
- @@trait_types_by_key.each do |(key,type)|
155
- yield( type )
156
- end
157
- end
158
-
159
- def self.each_with_index
160
- @@trait_types_by_key.each_with_index do |(key,type),i|
161
- yield( type,i )
162
- end
163
- end
164
-
165
-
166
- attr_accessor :key,
167
- :name,
168
- :code,
169
- :genes,
170
- :traits, ## array of 32 traits
171
- :cattributes ## array of 29/31/x cattributes
172
-
173
- def initialize( **kwargs )
174
- update( kwargs )
175
- end
176
-
177
- def update( **kwargs )
178
- kwargs.each do |name,value|
179
- send( "#{name}=", value ) ## use "regular" plain/classic attribute setter
180
- end
181
- self ## return self for chaining
182
- end
183
-
184
- def [](key)
185
- if key.is_a? Integer ## assume 0,1,2,3,.. index
186
- traits[ key ]
187
- elsif key.size == 2 && key =~ /^[0-9]{2}$/ ## assume code e.g. '00', '01', .. etc.
188
- traits[ key.to_i(10) ]
189
- else ## assume kai char
190
- traits[ Kai::NUMBER[key] ]
191
- end
192
- end
193
-
194
-
195
- TRAITS.reduce( TraitType.trait_types_by_key ) do |types, (key, h)|
196
-
197
- type = TraitType.new(
198
- key: key,
199
- name: h[:name], # e.g. 'Fur'
200
- code: h[:code], # e.g. 'FU'
201
- genes: h[:genes] # e.g. '0-3'
202
- )
203
-
204
- # auto-fill kai mapping
205
- ## note: to keep "insertion" order - recreate new hash mapping
206
- hash_kai = h[:kai]
207
- hash_kai2 = {}
208
- Kai::ALPHABET.each do |kai|
209
- name = hash_kai[kai]
210
- if name.nil?
211
- ## puts "#{key} - #{kai} is missing"
212
- hash_kai2[kai] = "#{key}_#{kai}"
213
- elsif name.empty?
214
- ## puts "#{key} - #{kai} is empty"
215
- hash_kai2[kai] = "#{key}_#{kai}"
216
- else
217
- hash_kai2[kai] = name
218
- end
219
- end
220
- h[:kai] = hash_kai2
221
-
222
- type.traits = h[:kai].reduce([]) do |traits, (kai,name)| # array of 32 traits
223
- trait = Trait.new(
224
- type: type,
225
- name: name,
226
- kai: kai
227
- )
228
-
229
- ## (auto-)add traits for lookup by name, code, etc. via (hash) mapping
230
- Trait.traits_by_name[ trait.name ] = trait
231
- Trait.traits_by_code[ trait.code ] = trait
232
-
233
- traits << trait
234
- traits
235
- end
236
-
237
- types[key] = type
238
- types
239
- end
240
-
241
- TraitType.trait_types_by_key.reduce( TraitType.trait_types_by_code ) do |types, (key, type)|
242
- types[type.code] = type
243
- types
244
- end
245
-
246
- TraitType.trait_types_by_key.reduce( TraitType.trait_types_by_name ) do |types, (key, type)|
247
- ## note: downcase Fur to fur and so on (for case insensitive match)
248
- types[type.name.downcase] = type
249
- types
250
- end
251
-
252
- end # class TraitType
253
-
254
-
255
-
256
-
257
- class Traits
258
- def self.[]( key )
259
-
260
- ## todo:
261
- ## add lookup trait type by alt_names (string)
262
- ## add lookup trait type by alt_keys (symbol)
263
-
264
- ## check for codes e.g. FU, PA, ... (or fu, pa,...).
265
- if key.size == 2 && key =~ /^[A-Za-z]{2}$/
266
- TraitType.find_by_code( key )
267
- ## check for codes e.g. FU00, FU01 ... (or fu00, fu01, ...)
268
- elsif key.size == 4 && key =~ /^[A-Za-z]{2}[0-9]{2}$/
269
- Trait.find_by_code( key )
270
- else
271
- if key.is_a? Symbol ## e.g. :body, :pattern, etc.
272
- t = TraitType.find_by_key( key )
273
- t = Trait.find_by_name( key ) if t.nil? ## try trait name next - why? why not?
274
- t
275
- else ## assume string
276
- t = TraitType.find_by_name( key )
277
- t = Trait.find_by_name( key ) if t.nil? ## try trait name next
278
- t
279
- end
280
- end
281
- end
282
-
283
- def self.each() TraitType.each { |type| yield(type) }; end
284
- def self.each_with_index() TraitType.each_with_index { |type,i| yield(type,i) }; end
285
- end # class Traits
24
+ require 'kittyverse/pages/genes'
286
25
 
287
26
 
27
+ require 'kittyverse/traits'
288
28
  require 'kittyverse/cattributes'
29
+ require 'kittyverse/fancies'
289
30
 
290
31
 
291
32