kittyverse 0.0.1 → 0.1.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: 4db7fd9714831d1c5a9bce00237adaef27f8f924
4
- data.tar.gz: 45a936916fb9baab102b40464d18e98688555418
3
+ metadata.gz: 70c6b5c648ee1718de835e129f15a847a66979b2
4
+ data.tar.gz: 65b590568925c9948c3ed8f929eff8b4589c6ebc
5
5
  SHA512:
6
- metadata.gz: 5428a2df86294fa7c9c608334baf44fd1895a9ed213387814cdd4b070c513dbcc5b1e1597a5291de6dde9ffde06f51aa7dbc290d162f49aa5555958ea42ac75e
7
- data.tar.gz: a60928d8fddd4099308947aa6c82f18d0ae079ab4cf30cab7d20308a00a012f7e13d1e1fadc56075e6e293ba7deaa4f81cf5056fff3a4fb738161451cdcdc71a
6
+ metadata.gz: 6216a9e6016f61e492300ed64e0791bbff10563800530b4898fda3a93d8028866d0c037ee56d9362264c6ecbc8901a6adcf8501f7d95a05489ded1ed88de6f22
7
+ data.tar.gz: b6f629dfbbc8352a2e2abbec68f31dc5846064d982af3dac6300e0faa2e03e13f7b42b6a78db9b483c113381f7d238ee77c3df821ee1a3a3bbe43ca4c6d2d9c7
@@ -4,4 +4,7 @@ Manifest.txt
4
4
  README.md
5
5
  Rakefile
6
6
  lib/kittyverse.rb
7
+ lib/kittyverse/traits.rb
7
8
  lib/kittyverse/version.rb
9
+ test/helper.rb
10
+ test/test_traits.rb
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Kittyverse
2
2
 
3
3
 
4
- kittyverse library / gem - helper classes for cattributes, trait types, traits, genes, genomes and more for cryptokitties and copycats
4
+ kittyverse library - helper classes for cattributes, trait types, traits, genes, genomes and more for cryptokitties and copycats
5
5
 
6
6
  * home :: [github.com/cryptocopycats/kittyverse](https://github.com/cryptocopycats/kittyverse)
7
7
  * bugs :: [github.com/cryptocopycats/kittyverse/issues](https://github.com/cryptocopycats/kittyverse/issues)
@@ -1,11 +1,270 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'pp'
3
+ require 'base32-alphabets'
4
4
 
5
5
 
6
6
  ## our own code
7
7
  require 'kittyverse/version' # note: let version always go first
8
+ require 'kittyverse/traits'
8
9
 
9
10
 
10
- pp Kittyverse.banner
11
- pp Kittyverse.root
11
+
12
+ class Trait
13
+
14
+ def self.traits_by_name() @@traits_by_name ||= {}; end
15
+ def self.traits_by_code() @@traits_by_code ||= {}; end
16
+
17
+ def self.find_by_code( code )
18
+ ## note: allow string AND symbols (thus, use .to_s)
19
+ ## e.g. allow 'FU01', 'fu01', :fu01, :FU01, etc.
20
+ @@traits_by_code[ code.upcase.to_s ]
21
+ end
22
+
23
+ def self.find_by_name( name )
24
+ ## note: allow string AND symbols (thus, use .to_s !!!)
25
+ ## note: downcase name e.g. allow Savannah too (not just savannah)
26
+ @@traits_by_name[ name.downcase.to_s ]
27
+ end
28
+
29
+ ## add "generic" convenience find helper
30
+ def self.find_by( **kwargs )
31
+ if kwargs[ :name ]
32
+ find_by_name( kwargs[ :name ] )
33
+ elsif kwargs[ :code ]
34
+ find_by_code( kwargs[ :code] )
35
+ else
36
+ ## todo/fix: throw argument except!!!
37
+ nil
38
+ end
39
+ end
40
+
41
+
42
+
43
+ attr_accessor :type,
44
+ :name,
45
+ :kai # kai char e.g. '1', '2', etc.
46
+
47
+ def initialize( **kwargs )
48
+ update( kwargs )
49
+ end
50
+
51
+ def update( **kwargs )
52
+ kwargs.each do |name,value|
53
+ send( "#{name}=", value ) ## use "regular" plain/classic attribute setter
54
+ end
55
+ self ## return self for chaining
56
+ end
57
+
58
+ def num() Kai::NUMBER[@kai]; end
59
+ def code() @type.code + Kai::CODE[@kai]; end
60
+ end # class Trait
61
+
62
+
63
+
64
+ class TraitType
65
+
66
+ def self.trait_types_by_key() @@trait_types_by_key ||= {}; end
67
+ def self.trait_types_by_code() @@trait_types_by_code ||= {}; end
68
+ def self.trait_types_by_name() @@trait_types_by_name ||= {}; end
69
+
70
+ # quick hack - map copycats keys to (internal) cryptokitties trait type keys
71
+ # note: all keys are the same except:
72
+ ALT_TRAIT_TYPE_KEYS =
73
+ {
74
+ :colorprimary => :color1,
75
+ :colorsecondary => :color2,
76
+ :colortertiary => :color3
77
+ }
78
+
79
+ def self.find_by_key( key )
80
+ ## note: allow string AND symbols (thus, use .to_sym !!!)
81
+ ## note: allow known alternative mappings/key (e.g. "internal" cryptokitties keys if different)
82
+ key = ALT_TRAIT_TYPE_KEYS[ key.to_sym ] if ALT_TRAIT_TYPE_KEYS[ key.to_sym ]
83
+
84
+ @@trait_types_by_key[ key.to_sym ]
85
+ end
86
+
87
+ def self.find_by_code( code )
88
+ ## note: allow string AND symbols (thus, use .to_s)
89
+ ## e.g. allow 'FU', 'fu', :fu, :FU, etc.
90
+ @@trait_types_by_code[ code.upcase.to_s ]
91
+ end
92
+
93
+ ALT_TRAIT_TYPE_NAMES =
94
+ {
95
+ 'body' => 'fur',
96
+ 'eyes' => 'eye shape',
97
+ 'eye type' => 'eye shape',
98
+ 'body color' => 'base color',
99
+ 'primary color' => 'base color',
100
+ 'base colour' => 'base color', # british (canadian) spelling
101
+ 'secondary color' => 'highlight color',
102
+ 'sec color' => 'highlight color',
103
+ 'pattern color' => 'highlight color',
104
+ 'highlight colour' => 'highlight color', # british (canadian) spelling
105
+ 'tertiary color' => 'accent color',
106
+ 'accent colour' => 'accent color', # british (canadian) spelling
107
+ 'wild' => 'wild element',
108
+ 'secrect' => 'secret y gene'
109
+ }
110
+
111
+ def self.find_by_name( name )
112
+ ## note: downcase name e.g. allow fur too (not just Fur)
113
+ ## note: allow known alternative mappings/key (e.g. "internal" cryptokitties keys if different)
114
+ name = ALT_TRAIT_TYPE_NAMES[ name.downcase ] if ALT_TRAIT_TYPE_NAMES[ name.downcase ]
115
+
116
+ @@trait_types_by_name[ name.downcase ]
117
+ end
118
+
119
+
120
+ ## add "generic" convenience find helper
121
+ def self.find_by( **kwargs )
122
+ if kwargs[ :key ]
123
+ find_by_key( kwargs[ :key ] )
124
+ elsif kwargs[ :code ]
125
+ find_by_code( kwargs[ :code ] )
126
+ elsif kwargs[ :name ]
127
+ find_by_name( kwargs[ :name ] )
128
+ else
129
+ ## todo/fix: throw argument except!!!
130
+ nil
131
+ end
132
+ end
133
+
134
+ def self.each
135
+ @@trait_types_by_key.each do |(key,type)|
136
+ yield( type )
137
+ end
138
+ end
139
+
140
+ def self.each_with_index
141
+ @@trait_types_by_key.each_with_index do |(key,type),i|
142
+ yield( type,i )
143
+ end
144
+ end
145
+
146
+
147
+ attr_accessor :key,
148
+ :name,
149
+ :code,
150
+ :genes,
151
+ :traits ## array of 32 traits
152
+
153
+ def initialize( **kwargs )
154
+ update( kwargs )
155
+ end
156
+
157
+ def update( **kwargs )
158
+ kwargs.each do |name,value|
159
+ send( "#{name}=", value ) ## use "regular" plain/classic attribute setter
160
+ end
161
+ self ## return self for chaining
162
+ end
163
+
164
+ def [](key)
165
+ if key.is_a? Integer ## assume 0,1,2,3,.. index
166
+ traits[ key ]
167
+ elsif key.size == 2 && key =~ /^[0-9]{2}$/ ## assume code e.g. '00', '01', .. etc.
168
+ traits[ key.to_i(10) ]
169
+ else ## assume kai char
170
+ traits[ Kai::NUMBER[key] ]
171
+ end
172
+ end
173
+
174
+
175
+ TRAITS.reduce( TraitType.trait_types_by_key ) do |types, (key, h)|
176
+
177
+ type = TraitType.new(
178
+ key: key,
179
+ name: h[:name], # e.g. 'Fur'
180
+ code: h[:code], # e.g. 'FU'
181
+ genes: h[:genes] # e.g. '0-3'
182
+ )
183
+
184
+ # auto-fill kai mapping
185
+ ## note: to keep "insertion" order - recreate new hash mapping
186
+ hash_kai = h[:kai]
187
+ hash_kai2 = {}
188
+ Kai::ALPHABET.each do |kai|
189
+ name = hash_kai[kai]
190
+ if name.nil?
191
+ ## puts "#{key} - #{kai} is missing"
192
+ hash_kai2[kai] = "#{key}_#{kai}"
193
+ elsif name.empty?
194
+ ## puts "#{key} - #{kai} is empty"
195
+ hash_kai2[kai] = "#{key}_#{kai}"
196
+ else
197
+ hash_kai2[kai] = name
198
+ end
199
+ end
200
+ h[:kai] = hash_kai2
201
+
202
+ type.traits = h[:kai].reduce([]) do |traits, (kai,name)| # array of 32 traits
203
+ trait = Trait.new(
204
+ type: type,
205
+ name: name,
206
+ kai: kai
207
+ )
208
+
209
+ ## (auto-)add traits for lookup by name, code, etc. via (hash) mapping
210
+ Trait.traits_by_name[ trait.name ] = trait
211
+ Trait.traits_by_code[ trait.code ] = trait
212
+
213
+ traits << trait
214
+ traits
215
+ end
216
+
217
+ types[key] = type
218
+ types
219
+ end
220
+
221
+ TraitType.trait_types_by_key.reduce( TraitType.trait_types_by_code ) do |types, (key, type)|
222
+ types[type.code] = type
223
+ types
224
+ end
225
+
226
+ TraitType.trait_types_by_key.reduce( TraitType.trait_types_by_name ) do |types, (key, type)|
227
+ ## note: downcase Fur to fur and so on (for case insensitive match)
228
+ types[type.name.downcase] = type
229
+ types
230
+ end
231
+
232
+ end # class TraitType
233
+
234
+
235
+
236
+
237
+ class Traits
238
+ def self.[]( key )
239
+
240
+ ## todo:
241
+ ## add lookup trait type by alt_names (string)
242
+ ## add lookup trait type by alt_keys (symbol)
243
+
244
+ ## check for codes e.g. FU, PA, ... (or fu, pa,...).
245
+ if key.size == 2 && key =~ /^[A-Za-z]{2}$/
246
+ TraitType.find_by_code( key )
247
+ ## check for codes e.g. FU00, FU01 ... (or fu00, fu01, ...)
248
+ elsif key.size == 4 && key =~ /^[A-Za-z]{2}[0-9]{2}$/
249
+ Trait.find_by_code( key )
250
+ else
251
+ if key.is_a? Symbol ## e.g. :body, :pattern, etc.
252
+ t = TraitType.find_by_key( key )
253
+ t = Trait.find_by_name( key ) if t.nil? ## try trait name next - why? why not?
254
+ t
255
+ else ## assume string
256
+ t = TraitType.find_by_name( key )
257
+ t = Trait.find_by_name( key ) if t.nil? ## try trait name next
258
+ t
259
+ end
260
+ end
261
+ end
262
+
263
+ def self.each() TraitType.each { |type| yield(type) }; end
264
+ def self.each_with_index() TraitType.each_with_index { |type,i| yield(type,i) }; end
265
+ end # class Traits
266
+
267
+
268
+
269
+ # say hello
270
+ puts Kittyverse.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
@@ -0,0 +1,377 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # trais / kaittributes
5
+ # see https://cryptokittydex.com/kaittributes
6
+ # https://docs.google.com/spreadsheets/d/1ShiBKSglFAB2vJe4Uow3iF09FBVq6ZAaOzTCIECf4iA
7
+ # http://www.rolldice.club/cryptokitties/wkt_tree.php
8
+ # https://www.cryptokitties.co/cattributes (official cattributes list)
9
+ #
10
+ #
11
+ # for latest updates on new cattributes see:
12
+ # https://updates.cryptokitties.co (official latest updates/timeline)
13
+
14
+ ## ordered by gene position (0,1,3.4,5,... etc.)
15
+ ## 12 traits (4 genes each)
16
+ TRAITS =
17
+ {
18
+ body: {
19
+ genes: '0-3',
20
+ name: 'Fur', code: 'FU',
21
+ kai: {
22
+ '1' => 'savannah',
23
+ '2' => 'selkirk',
24
+ '3' => 'chantilly',
25
+ '4' => 'birman',
26
+ '5' => 'koladiviya',
27
+ '6' => 'bobtail',
28
+ '7' => 'manul',
29
+ '8' => 'pixiebob',
30
+ '9' => 'siberian',
31
+ 'a' => 'cymric',
32
+ 'b' => 'chartreux',
33
+ 'c' => 'himalayan',
34
+ 'd' => 'munchkin',
35
+ 'e' => 'sphynx',
36
+ 'f' => 'ragamuffin',
37
+ 'g' => 'ragdoll',
38
+ 'h' => 'norwegianforest',
39
+ 'i' => 'mekong',
40
+ 'j' => 'highlander',
41
+ 'k' => 'balinese',
42
+ 'm' => 'lynx',
43
+ 'n' => 'mainecoon',
44
+ 'o' => 'laperm',
45
+ 'p' => 'persian',
46
+ 'q' => 'fox',
47
+ 'r' => 'kurilian',
48
+ 's' => 'toyger',
49
+ 't' => 'manx',
50
+ 'u' => 'lykoi',
51
+ 'v' => 'burmilla',
52
+ 'w' => 'liger',
53
+ 'x' => ''
54
+ }
55
+ },
56
+ pattern: {
57
+ genes: '4-7',
58
+ name: 'Pattern', code: 'PA',
59
+ kai: {
60
+ '1' => 'vigilante',
61
+ '2' => 'tiger',
62
+ '3' => 'rascal',
63
+ '4' => 'ganado',
64
+ '5' => 'leopard',
65
+ '6' => 'camo',
66
+ '7' => 'rorschach',
67
+ '8' => 'spangled',
68
+ '9' => 'calicool',
69
+ 'a' => 'luckystripe',
70
+ 'b' => 'amur',
71
+ 'c' => 'jaguar',
72
+ 'd' => 'spock',
73
+ 'e' => 'mittens',
74
+ 'f' => 'totesbasic_f', ## use totesbasic_f - why? why not?
75
+ 'g' => 'totesbasic_g', ## use totesbasic_g
76
+ 'h' => 'splat',
77
+ 'i' => 'thunderstruck',
78
+ 'j' => 'dippedcone',
79
+ 'k' => 'highsociety',
80
+ 'm' => 'tigerpunk',
81
+ 'n' => 'henna',
82
+ 'o' => 'arcreactor',
83
+ 'p' => 'totesbasic_p', ## use totesbasic_p
84
+ 'q' => 'scorpius',
85
+ 'r' => 'razzledazzle',
86
+ 's' => 'hotrod',
87
+ 't' => 'allyouneed',
88
+ 'u' => 'avatar',
89
+ 'v' => 'gyre',
90
+ 'w' => 'moonrise',
91
+ 'x' => ''
92
+ }
93
+ },
94
+ coloreyes: {
95
+ genes: '8-11',
96
+ name: 'Eye Color', code: 'EC',
97
+ kai: {
98
+ '1' => 'thundergrey',
99
+ '2' => 'gold',
100
+ '3' => 'topaz',
101
+ '4' => 'mintgreen',
102
+ '5' => 'isotope',
103
+ '6' => 'sizzurp',
104
+ '7' => 'chestnut',
105
+ '8' => 'strawberry',
106
+ '9' => 'sapphire',
107
+ 'a' => 'forgetmenot',
108
+ 'b' => 'dahlia',
109
+ 'c' => 'coralsunrise',
110
+ 'd' => 'olive',
111
+ 'e' => 'doridnudibranch',
112
+ 'f' => 'parakeet',
113
+ 'g' => 'cyan',
114
+ 'h' => 'pumpkin',
115
+ 'i' => 'limegreen',
116
+ 'j' => 'bridesmaid',
117
+ 'k' => 'bubblegum',
118
+ 'm' => 'twilightsparkle',
119
+ 'n' => 'palejade',
120
+ 'o' => 'pinefresh',
121
+ 'p' => 'eclipse',
122
+ 'q' => 'babypuke',
123
+ 'r' => 'downbythebay',
124
+ 's' => 'autumnmoon',
125
+ 't' => 'oasis',
126
+ 'u' => 'gemini',
127
+ 'v' => 'dioscuri',
128
+ 'w' => 'kaleidoscope',
129
+ 'x' => ''
130
+ }
131
+ },
132
+ eyes: {
133
+ genes: '12-15',
134
+ name: 'Eye Shape', code: 'ES', ## eye type
135
+ kai: {
136
+ '1' => 'swarley',
137
+ '2' => 'wonky',
138
+ '3' => 'serpent',
139
+ '4' => 'googly',
140
+ '5' => 'otaku',
141
+ '6' => 'simple',
142
+ '7' => 'crazy',
143
+ '8' => 'thicccbrowz',
144
+ '9' => 'caffeine',
145
+ 'a' => 'wowza',
146
+ 'b' => 'baddate',
147
+ 'c' => 'asif',
148
+ 'd' => 'chronic',
149
+ 'e' => 'slyboots',
150
+ 'f' => 'wiley',
151
+ 'g' => 'stunned',
152
+ 'h' => 'chameleon',
153
+ 'i' => 'alien',
154
+ 'j' => 'fabulous',
155
+ 'k' => 'raisedbrow',
156
+ 'm' => 'tendertears',
157
+ 'n' => 'hacker',
158
+ 'o' => 'sass',
159
+ 'p' => 'sweetmeloncakes',
160
+ 'q' => 'oceanid',
161
+ 'r' => 'wingtips',
162
+ 's' => 'firedup',
163
+ 't' => 'buzzed',
164
+ 'u' => 'bornwithit',
165
+ 'v' => 'candyshoppe',
166
+ 'w' => 'drama',
167
+ 'x' => ''
168
+ }
169
+ },
170
+ color1: {
171
+ genes: '16-19',
172
+ name: 'Base Color', code: 'BC', ## colorprimary / body color
173
+ kai: {
174
+ '1' => 'shadowgrey',
175
+ '2' => 'salmon',
176
+ '3' => 'meowgarine',
177
+ '4' => 'orangesoda',
178
+ '5' => 'cottoncandy',
179
+ '6' => 'mauveover',
180
+ '7' => 'aquamarine',
181
+ '8' => 'nachocheez',
182
+ '9' => 'harbourfog',
183
+ 'a' => 'cinderella',
184
+ 'b' => 'greymatter',
185
+ 'c' => 'tundra',
186
+ 'd' => 'brownies',
187
+ 'e' => 'dragonfruit',
188
+ 'f' => 'hintomint',
189
+ 'g' => 'bananacream',
190
+ 'h' => 'cloudwhite',
191
+ 'i' => 'cornflower',
192
+ 'j' => 'oldlace',
193
+ 'k' => 'koala',
194
+ 'm' => 'lavender',
195
+ 'n' => 'glacier',
196
+ 'o' => 'redvelvet',
197
+ 'p' => 'verdigris',
198
+ 'q' => 'icicle',
199
+ 'r' => 'onyx',
200
+ 's' => 'hyacinth',
201
+ 't' => 'martian',
202
+ 'u' => 'hotcocoa',
203
+ 'v' => 'shamrock',
204
+ 'w' => 'firstblush',
205
+ 'x' => ''
206
+ }
207
+ },
208
+ color2: {
209
+ genes: '20-23',
210
+ name: 'Highlight Color', code: 'HC', ## colorsecondary / sec color / pattern color
211
+ kai: {
212
+ '1' => 'cyborg',
213
+ '2' => 'springcrocus',
214
+ '3' => 'egyptiankohl',
215
+ '4' => 'poisonberry',
216
+ '5' => 'lilac',
217
+ '6' => 'apricot',
218
+ '7' => 'royalpurple',
219
+ '8' => 'padparadscha',
220
+ '9' => 'swampgreen',
221
+ 'a' => 'violet',
222
+ 'b' => 'scarlet',
223
+ 'c' => 'barkbrown',
224
+ 'd' => 'coffee',
225
+ 'e' => 'lemonade',
226
+ 'f' => 'chocolate',
227
+ 'g' => 'butterscotch',
228
+ 'h' => 'ooze',
229
+ 'i' => 'safetyvest',
230
+ 'j' => 'turtleback',
231
+ 'k' => 'rosequartz',
232
+ 'm' => 'wolfgrey',
233
+ 'n' => 'cerulian',
234
+ 'o' => 'skyblue',
235
+ 'p' => 'garnet',
236
+ 'q' => 'peppermint',
237
+ 'r' => 'universe',
238
+ 's' => 'royalblue',
239
+ 't' => 'mertail',
240
+ 'u' => 'inflatablepool',
241
+ 'v' => 'pearl',
242
+ 'w' => 'prairierose',
243
+ 'x' => ''
244
+ }
245
+ },
246
+ color3: {
247
+ genes: '24-27',
248
+ name: 'Accent Color', code: 'AC', ## colortertiary
249
+ kai: {
250
+ '1' => 'belleblue',
251
+ '2' => 'sandalwood',
252
+ '3' => 'peach',
253
+ '4' => 'icy',
254
+ '5' => 'granitegrey',
255
+ '6' => 'cashewmilk',
256
+ '7' => 'kittencream',
257
+ '8' => 'emeraldgreen',
258
+ '9' => 'kalahari',
259
+ 'a' => 'shale',
260
+ 'b' => 'purplehaze',
261
+ 'c' => 'hanauma',
262
+ 'd' => 'azaleablush',
263
+ 'e' => 'missmuffett',
264
+ 'f' => 'morningglory',
265
+ 'g' => 'frosting',
266
+ 'h' => 'daffodil',
267
+ 'i' => 'flamingo',
268
+ 'j' => 'buttercup',
269
+ 'k' => 'bloodred',
270
+ 'm' => 'atlantis',
271
+ 'n' => 'summerbonnet',
272
+ 'o' => 'periwinkle',
273
+ 'p' => 'patrickstarfish',
274
+ 'q' => 'seafoam',
275
+ 'r' => 'cobalt',
276
+ 's' => 'mallowflower',
277
+ 't' => 'mintmacaron',
278
+ 'u' => 'sully',
279
+ 'v' => 'fallspice',
280
+ 'w' => 'dreamboat',
281
+ 'x' => ''
282
+ }
283
+ },
284
+ wild: {
285
+ genes: '28-31',
286
+ name: 'Wild Element', code: 'WE',
287
+ kai: {
288
+ 'h' => 'littlefoot',
289
+ 'i' => 'elk',
290
+ 'j' => 'ducky',
291
+ 'k' => 'trioculus',
292
+ 'm' => 'daemonwings',
293
+ 'n' => 'featherbrain',
294
+ 'o' => 'flapflap',
295
+ 'p' => 'daemonhorns',
296
+ 'q' => 'dragontail',
297
+ 'r' => 'aflutter',
298
+ 's' => 'foghornpawhorn',
299
+ 't' => 'unicorn',
300
+ 'u' => 'dragonwings',
301
+ 'v' => 'alicorn',
302
+ 'w' => 'wyrm',
303
+ 'x' => ''
304
+ }
305
+ },
306
+ mouth: {
307
+ genes: '32-35',
308
+ name: 'Mouth', code: 'MO',
309
+ kai: {
310
+ '1' => 'whixtensions',
311
+ '2' => 'wasntme',
312
+ '3' => 'wuvme',
313
+ '4' => 'gerbil',
314
+ '5' => 'confuzzled',
315
+ '6' => 'impish',
316
+ '7' => 'belch',
317
+ '8' => 'rollercoaster',
318
+ '9' => 'beard',
319
+ 'a' => 'pouty',
320
+ 'b' => 'saycheese',
321
+ 'c' => 'grim',
322
+ 'd' => 'fangtastic',
323
+ 'e' => 'moue',
324
+ 'f' => 'happygokitty',
325
+ 'g' => 'soserious',
326
+ 'h' => 'cheeky',
327
+ 'i' => 'starstruck',
328
+ 'j' => 'samwise',
329
+ 'k' => 'ruhroh',
330
+ 'm' => 'dali',
331
+ 'n' => 'grimace',
332
+ 'o' => 'majestic',
333
+ 'p' => 'tongue',
334
+ 'q' => 'yokel',
335
+ 'r' => 'topoftheworld',
336
+ 's' => 'neckbeard',
337
+ 't' => 'satiated',
338
+ 'u' => 'walrus',
339
+ 'v' => 'struck',
340
+ 'w' => 'delite',
341
+ 'x' => ''
342
+ }
343
+ },
344
+ environment: {
345
+ genes: '36-39',
346
+ name: 'Environment', code: 'EN',
347
+ kai: {
348
+ 'h' => 'salty',
349
+ 'i' => 'dune',
350
+ 'j' => 'juju',
351
+ 'k' => 'tinybox',
352
+ 'm' => 'myparade',
353
+ 'n' => 'finalfrontier',
354
+ 'o' => 'metime',
355
+ 'p' => 'drift',
356
+ 'q' => 'secretgarden',
357
+ 'r' => 'frozen',
358
+ 's' => 'roadtogold',
359
+ 't' => 'jacked',
360
+ 'u' => 'floorislava',
361
+ 'v' => 'prism',
362
+ 'w' => 'junglebook',
363
+ 'x' => ''
364
+ }
365
+ },
366
+ secret: {
367
+ genes: '40-43',
368
+ name: 'Secret Y Gene', code: 'SE', ## todo: change to Y Gene or Y (see https://guide.cryptokitties.co/guide/cat-features/genes)
369
+ kai: { }
370
+ },
371
+ prestige: {
372
+ genes: '44-47',
373
+ name: 'Purrstige', code: 'PU',
374
+ kai: { }
375
+ ## prune, furball, duckduckcat, or thatsawrap - more like fancies (not really traits)
376
+ }
377
+ }
@@ -4,8 +4,8 @@
4
4
  class Kittyverse
5
5
 
6
6
  MAJOR = 0
7
- MINOR = 0
8
- PATCH = 1
7
+ MINOR = 1
8
+ PATCH = 0
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
@@ -0,0 +1,10 @@
1
+ ## $:.unshift(File.dirname(__FILE__))
2
+
3
+ ## minitest setup
4
+
5
+ require 'minitest/autorun'
6
+
7
+
8
+ ## our own code
9
+
10
+ require 'kittyverse'
@@ -0,0 +1,199 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_traits.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestTraits < MiniTest::Test
12
+
13
+
14
+ def test_find
15
+
16
+ t = Traits[ 'FU00' ]
17
+ assert_equal Trait, t.class
18
+ assert_equal "savannah", t.name
19
+ assert_equal "Fur", t.type.name
20
+ assert_equal "FU00", t.code
21
+ assert_equal "1", t.kai
22
+
23
+ t = Trait.find_by_code( 'FU00' )
24
+ assert_equal Trait, t.class
25
+ assert_equal "savannah", t.name
26
+ assert_equal "Fur", t.type.name
27
+ assert_equal "FU00", t.code
28
+ assert_equal "1", t.kai
29
+
30
+
31
+ t = Trait.find_by( code: 'FU00' )
32
+ assert_equal Trait, t.class
33
+ assert_equal "savannah", t.name
34
+ assert_equal "Fur", t.type.name
35
+ assert_equal "FU00", t.code
36
+ assert_equal "1", t.kai
37
+
38
+
39
+ t = Traits[ 'savannah' ]
40
+ assert_equal Trait, t.class
41
+ assert_equal "savannah", t.name
42
+ assert_equal "Fur", t.type.name
43
+ assert_equal "FU00", t.code
44
+ assert_equal "1", t.kai
45
+
46
+ t = Traits[ 'Savannah' ]
47
+ assert_equal Trait, t.class
48
+ assert_equal "savannah", t.name
49
+ assert_equal "Fur", t.type.name
50
+ assert_equal "FU00", t.code
51
+ assert_equal "1", t.kai
52
+
53
+ t = Trait.find_by_name( 'Savannah' )
54
+ assert_equal Trait, t.class
55
+ assert_equal "savannah", t.name
56
+ assert_equal "Fur", t.type.name
57
+ assert_equal "FU00", t.code
58
+ assert_equal "1", t.kai
59
+
60
+ t = Trait.find_by( name: 'Savannah' )
61
+ assert_equal Trait, t.class
62
+ assert_equal "savannah", t.name
63
+ assert_equal "Fur", t.type.name
64
+ assert_equal "FU00", t.code
65
+ assert_equal "1", t.kai
66
+
67
+ t = Traits[ :body ][ '1' ]
68
+ assert_equal Trait, t.class
69
+ assert_equal "savannah", t.name
70
+ assert_equal "Fur", t.type.name
71
+ assert_equal "FU00", t.code
72
+ assert_equal "1", t.kai
73
+
74
+ t = Traits[ :body ][ 'x' ]
75
+ assert_equal Trait, t.class
76
+ assert_equal "body_x", t.name
77
+ assert_equal "Fur", t.type.name
78
+ assert_equal "FU31", t.code
79
+ assert_equal "x", t.kai
80
+
81
+ t = Traits[ :body ][ '00' ]
82
+ assert_equal Trait, t.class
83
+ assert_equal "savannah", t.name
84
+ assert_equal "Fur", t.type.name
85
+ assert_equal "FU00", t.code
86
+ assert_equal "1", t.kai
87
+
88
+ t = Traits[ :body ][ '31' ]
89
+ assert_equal Trait, t.class
90
+ assert_equal "body_x", t.name
91
+ assert_equal "Fur", t.type.name
92
+ assert_equal "FU31", t.code
93
+ assert_equal "x", t.kai
94
+
95
+ t = Traits[ :body ][ 0 ]
96
+ assert_equal Trait, t.class
97
+ assert_equal "savannah", t.name
98
+ assert_equal "Fur", t.type.name
99
+ assert_equal "FU00", t.code
100
+ assert_equal "1", t.kai
101
+
102
+ t = Traits[ :body ][ 31 ]
103
+ assert_equal Trait, t.class
104
+ assert_equal "body_x", t.name
105
+ assert_equal "Fur", t.type.name
106
+ assert_equal "FU31", t.code
107
+ assert_equal "x", t.kai
108
+
109
+
110
+ t = Traits[ :body ]
111
+ assert_equal TraitType, t.class
112
+ assert_equal "Fur", t.name
113
+
114
+ t = TraitType.find_by_key( :body )
115
+ assert_equal TraitType, t.class
116
+ assert_equal "Fur", t.name
117
+
118
+ t = TraitType.find_by( :key => :body )
119
+ assert_equal TraitType, t.class
120
+ assert_equal "Fur", t.name
121
+
122
+
123
+ t = Traits['FU']['00']
124
+ assert_equal Trait, t.class
125
+ assert_equal "savannah", t.name
126
+ assert_equal "Fur", t.type.name
127
+ assert_equal "FU00", t.code
128
+ assert_equal "1", t.kai
129
+
130
+ t = Traits['FU'][0]
131
+ assert_equal Trait, t.class
132
+ assert_equal "savannah", t.name
133
+ assert_equal "Fur", t.type.name
134
+ assert_equal "FU00", t.code
135
+ assert_equal "1", t.kai
136
+
137
+ t = Traits[:FU][0]
138
+ assert_equal Trait, t.class
139
+ assert_equal "savannah", t.name
140
+ assert_equal "Fur", t.type.name
141
+ assert_equal "FU00", t.code
142
+ assert_equal "1", t.kai
143
+
144
+ t = Traits[:FU00]
145
+ assert_equal Trait, t.class
146
+ assert_equal "savannah", t.name
147
+ assert_equal "Fur", t.type.name
148
+ assert_equal "FU00", t.code
149
+ assert_equal "1", t.kai
150
+
151
+ t = Traits['Fur'][0]
152
+ assert_equal Trait, t.class
153
+ assert_equal "savannah", t.name
154
+ assert_equal "Fur", t.type.name
155
+ assert_equal "FU00", t.code
156
+ assert_equal "1", t.kai
157
+
158
+ t = Traits['Pattern'][0]
159
+ assert_equal Trait, t.class
160
+ assert_equal "vigilante", t.name
161
+ assert_equal "Pattern", t.type.name
162
+ assert_equal "PA00", t.code
163
+ assert_equal "1", t.kai
164
+
165
+ t = Traits['PA00']
166
+ assert_equal Trait, t.class
167
+ assert_equal "vigilante", t.name
168
+ assert_equal "Pattern", t.type.name
169
+ assert_equal "PA00", t.code
170
+ assert_equal "1", t.kai
171
+
172
+ t = Traits['Vigilante']
173
+ assert_equal Trait, t.class
174
+ assert_equal "vigilante", t.name
175
+ assert_equal "Pattern", t.type.name
176
+ assert_equal "PA00", t.code
177
+ assert_equal "1", t.kai
178
+ end
179
+
180
+
181
+ def test_each
182
+ TraitType.each do |type|
183
+ puts "#{type.key} => #{type.name} (#{type.code}), genes #{type.genes}"
184
+ end
185
+
186
+ Traits.each do |type|
187
+ puts "#{type.key} => #{type.name} (#{type.code}), genes #{type.genes}"
188
+ end
189
+
190
+ TraitType.each_with_index do |type,i|
191
+ puts "#{i}: #{type.key} => #{type.name} (#{type.code}), genes #{type.genes}"
192
+ end
193
+
194
+ Traits.each_with_index do |type,i|
195
+ puts "#{i}: #{type.key} => #{type.name} (#{type.code}), genes #{type.genes}"
196
+ end
197
+ end
198
+
199
+ end # class TestTraits
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kittyverse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-11 00:00:00.000000000 Z
11
+ date: 2019-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base32-alphabets
@@ -69,7 +69,10 @@ files:
69
69
  - README.md
70
70
  - Rakefile
71
71
  - lib/kittyverse.rb
72
+ - lib/kittyverse/traits.rb
72
73
  - lib/kittyverse/version.rb
74
+ - test/helper.rb
75
+ - test/test_traits.rb
73
76
  homepage: https://github.com/cryptocopycats/kittyverse
74
77
  licenses:
75
78
  - Public Domain