kittyverse 0.4.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,30 +1,30 @@
1
- require 'hoe'
2
- require './lib/kittyverse/version.rb'
3
-
4
- Hoe.spec 'kittyverse' do
5
-
6
- self.version = Kittyverse::VERSION
7
-
8
- self.summary = "kittyverse - helper classes for cattributes, trait types, traits, genes, genomes and more for cryptokitties and copycats"
9
- self.description = summary
10
-
11
- self.urls = ['https://github.com/cryptocopycats/kittyverse']
12
-
13
- self.author = 'Gerald Bauer'
14
- self.email = 'wwwmake@googlegroups.com'
15
-
16
- # switch extension to .markdown for gihub formatting
17
- self.readme_file = 'README.md'
18
- self.history_file = 'CHANGELOG.md'
19
-
20
- self.extra_deps = [
21
- ['base32-alphabets', '>= 1.0.0']
22
- ]
23
-
24
- self.licenses = ['Public Domain']
25
-
26
- self.spec_extras = {
27
- required_ruby_version: '>= 2.2.2'
28
- }
29
-
30
- end
1
+ require 'hoe'
2
+ require './lib/kittyverse/version.rb'
3
+
4
+ Hoe.spec 'kittyverse' do
5
+
6
+ self.version = Kittyverse::VERSION
7
+
8
+ self.summary = "kittyverse - helper classes for cattributes, trait types, traits, genes, genomes and more for cryptokitties and copycats"
9
+ self.description = summary
10
+
11
+ self.urls = { home: 'https://github.com/cryptocopycats/kittyverse' }
12
+
13
+ self.author = 'Gerald Bauer'
14
+ self.email = 'wwwmake@googlegroups.com'
15
+
16
+ # switch extension to .markdown for gihub formatting
17
+ self.readme_file = 'README.md'
18
+ self.history_file = 'CHANGELOG.md'
19
+
20
+ self.extra_deps = [
21
+ ['base32-alphabets', '>= 1.0.0']
22
+ ]
23
+
24
+ self.licenses = ['Public Domain']
25
+
26
+ self.spec_extras = {
27
+ required_ruby_version: '>= 2.2.2'
28
+ }
29
+
30
+ end
data/lib/kittyverse.rb CHANGED
@@ -1,44 +1,39 @@
1
- # encoding: utf-8
2
-
3
- ## std libs
4
- require 'date'
5
- require 'json'
6
- require "pp"
7
- require "uri"
8
- require "net/http"
9
- require "net/https"
10
-
11
-
12
-
13
- ## 3rd party libs
14
- require 'base32-alphabets'
15
-
16
-
17
- ## our own code
18
- require 'kittyverse/version' # note: let version always go first
19
-
20
- require 'kittyverse/config/traits'
21
- require 'kittyverse/config/traits_timeline'
22
- require 'kittyverse/config/fancies'
23
- require 'kittyverse/config/purrstiges'
24
- require 'kittyverse/config/colors'
25
-
26
-
27
- require 'kittyverse/mewtations'
28
- require 'kittyverse/links'
29
-
30
- require 'kittyverse/pages/genes'
31
-
32
- require 'kittyverse/recipes'
33
- require 'kittyverse/traits'
34
- require 'kittyverse/cattributes'
35
- require 'kittyverse/fancies'
36
-
37
- ## api support
38
- require 'kittyverse/api/client'
39
- require 'kittyverse/api/versions'
40
-
41
-
42
-
43
- # say hello
44
- puts Kittyverse.banner if defined?($RUBYCOCO_DEBUG) && $RUBYCOCO_DEBUG
1
+ ## std libs
2
+ require 'pp'
3
+ require 'date'
4
+ require 'time'
5
+ require 'json'
6
+ require 'uri'
7
+ require 'fileutils'
8
+
9
+
10
+ ## 3rd party libs
11
+ require 'base32-alphabets'
12
+
13
+
14
+ ## our own code
15
+ require 'kittyverse/version' # note: let version always go first
16
+
17
+ require 'kittyverse/config/traits'
18
+ require 'kittyverse/config/traits_timeline'
19
+ require 'kittyverse/config/exclusives'
20
+ require 'kittyverse/config/special_editions'
21
+ require 'kittyverse/config/fancies'
22
+ require 'kittyverse/config/purrstiges'
23
+ require 'kittyverse/config/colors'
24
+
25
+ require 'kittyverse/mewtations'
26
+
27
+ require 'kittyverse/recipes'
28
+ require 'kittyverse/traits'
29
+ require 'kittyverse/cattributes'
30
+ require 'kittyverse/fancies'
31
+
32
+
33
+ ## genes / genome
34
+ require 'kittyverse/gene'
35
+ require 'kittyverse/genome'
36
+
37
+
38
+ # say hello
39
+ puts Kittyverse.banner
@@ -1,131 +1,123 @@
1
- # encoding: utf-8
2
-
3
-
4
-
5
- class Cattributes
6
- ## add cattributes (traits) type lookup to Cattribute itself - why? why not?
7
- def self.[]( key ) TraitType.find_by_key( key ).cattributes; end
8
- end
9
-
10
-
11
- class Cattribute
12
-
13
- def self.cattributes_by_name() @@cattributes_by_name ||= {}; end
14
-
15
- def self.find_by_name( name )
16
- ## note: allow string AND symbols (thus, use .to_s !!!)
17
- ## note: downcase name e.g. allow Savannah too (not just savannah)
18
- @@cattributes_by_name[ name.downcase.to_s ]
19
- end
20
-
21
- ## add "generic" convenience find helper
22
- def self.find_by( **kwargs )
23
- if kwargs[ :name ]
24
- find_by_name( kwargs[ :name ] )
25
- else
26
- ## todo/fix: throw argument except!!!
27
- nil
28
- end
29
- end
30
-
31
- def self.[]( name ) find_by_name( name ); end
32
-
33
-
34
-
35
- attr_accessor :type,
36
- :key,
37
- :name,
38
- :traits,
39
- :recipe,
40
- :count
41
-
42
- def initialize( **kwargs )
43
- update( kwargs )
44
- end
45
-
46
- def update( **kwargs )
47
- kwargs.each do |name,value|
48
- send( "#{name}=", value ) ## use "regular" plain/classic attribute setter
49
- end
50
- self ## return self for chaining
51
- end
52
-
53
-
54
-
55
- ## autofill cattributes
56
- TraitType.each do |tt|
57
- key = tt.key
58
- puts "key: #{key}"
59
-
60
- tt.cattributes ||= [] ## if nil make sure it's an empty array when starting
61
- ## pp tt
62
-
63
- next if [:secret, :prestige].include?( key)
64
-
65
- tt.traits.each do |t|
66
- ## 1) skip "unnamed" traits
67
- next if t.name.nil?
68
-
69
- pp t.name
70
-
71
- ## 2) special case for totesbasic - one cattribute, three traits
72
- ## (that is, Totesbasic 1, Totesbasic 2, Totesbasic 3)
73
- if TOTESBASIC.include?( t.name )
74
- if t.name == TOTESBASIC.first
75
- t1 = Traits[ TOTESBASIC[0] ]
76
- t2 = Traits[ TOTESBASIC[1] ]
77
- t3 = Traits[ TOTESBASIC[2] ]
78
-
79
- cattribute = Cattribute.new(
80
- key: 'totesbasic'.to_sym,
81
- name: 'Totesbasic',
82
- type: tt,
83
- traits: [t1,t2,t3]
84
- )
85
- else
86
- next ## skip all other totesbasic traits
87
- end
88
- else
89
- cattribute = Cattribute.new(
90
- key: t.name.to_sym,
91
- name: t.name,
92
- type: tt,
93
- traits: [t]
94
- )
95
- ## pp cattribute
96
- end
97
-
98
- tt.cattributes << cattribute
99
-
100
- cattributes_by_name[ cattribute.name.downcase ] = cattribute
101
- end
102
- end
103
-
104
- ## add purrstiges traits
105
- tt = Traits[:prestige]
106
- tt.cattributes ||= [] ## if nil make sure it's an empty array when starting
107
- PURRSTIGES.each do |key, h|
108
- puts "key: #{key}"
109
- pp h
110
-
111
- recipe = Recipe.new(
112
- traits: h[:recipe][:traits], ## todo/fix: turn strings into trait objs!!!!
113
- limit: h[:recipe][:limit],
114
- time_start: h[:recipe][:time] && h[:recipe][:time][:start] ? Date.strptime( h[:recipe][:time][:start], '%Y-%m-%d' ) : nil,
115
- time_end: h[:recipe][:time] && h[:recipe][:time][:end] ? Date.strptime( h[:recipe][:time][:end], '%Y-%m-%d' ) : nil )
116
-
117
- cattribute = Cattribute.new(
118
- key: key,
119
- name: h[:name],
120
- type: tt,
121
- traits: [], ## empty traits
122
- count: h[:recipe][:count], # note: add count from recipe hash (NOT incl. in recipe struct)
123
- recipe: recipe
124
- )
125
- tt.cattributes << cattribute
126
-
127
- cattributes_by_name[ cattribute.name.downcase ] = cattribute
128
- end
129
-
130
-
131
- end # class Cattribute
1
+
2
+
3
+ class Cattribute
4
+
5
+ def self.cattributes_by_name() @@cattributes_by_name ||= {}; end
6
+
7
+ def self.find_by_name( name )
8
+ ## note: allow string AND symbols (thus, use .to_s !!!)
9
+ ## note: downcase name e.g. allow Savannah too (not just savannah)
10
+ @@cattributes_by_name[ name.downcase.to_s ]
11
+ end
12
+
13
+ ## add "generic" convenience find helper
14
+ def self.find_by( **kwargs )
15
+ if kwargs[ :name ]
16
+ find_by_name( kwargs[ :name ] )
17
+ else
18
+ ## todo/fix: throw argument except!!!
19
+ nil
20
+ end
21
+ end
22
+
23
+ def self.[]( name ) find_by_name( name ); end
24
+
25
+
26
+
27
+ attr_accessor :type,
28
+ :key,
29
+ :name,
30
+ :traits,
31
+ :recipe,
32
+ :count
33
+
34
+ def initialize( **kwargs )
35
+ update( kwargs )
36
+ end
37
+
38
+ def update( **kwargs )
39
+ kwargs.each do |name,value|
40
+ send( "#{name}=", value ) ## use "regular" plain/classic attribute setter
41
+ end
42
+ self ## return self for chaining
43
+ end
44
+
45
+
46
+
47
+ ## autofill cattributes
48
+ TraitType.each do |tt|
49
+ key = tt.key
50
+ puts "key: #{key}"
51
+
52
+ tt.cattributes ||= [] ## if nil make sure it's an empty array when starting
53
+ ## pp tt
54
+
55
+ next if [:secret, :prestige].include?( key)
56
+
57
+ tt.traits.each do |t|
58
+ ## 1) skip "unnamed" traits
59
+ next if t.name.nil?
60
+
61
+ pp t.name
62
+
63
+ ## 2) special case for totesbasic - one cattribute, three traits
64
+ ## (that is, Totesbasic 1, Totesbasic 2, Totesbasic 3)
65
+ if TOTESBASIC.include?( t.name )
66
+ if t.name == TOTESBASIC.first
67
+ t1 = Traits[ TOTESBASIC[0] ]
68
+ t2 = Traits[ TOTESBASIC[1] ]
69
+ t3 = Traits[ TOTESBASIC[2] ]
70
+
71
+ cattribute = Cattribute.new(
72
+ key: 'totesbasic'.to_sym,
73
+ name: 'Totesbasic',
74
+ type: tt,
75
+ traits: [t1,t2,t3]
76
+ )
77
+ else
78
+ next ## skip all other totesbasic traits
79
+ end
80
+ else
81
+ cattribute = Cattribute.new(
82
+ key: t.name.to_sym,
83
+ name: t.name,
84
+ type: tt,
85
+ traits: [t]
86
+ )
87
+ ## pp cattribute
88
+ end
89
+
90
+ tt.cattributes << cattribute
91
+
92
+ cattributes_by_name[ cattribute.name.downcase ] = cattribute
93
+ end
94
+ end
95
+
96
+ ## add purrstiges traits
97
+ tt = Traits[:prestige]
98
+ tt.cattributes ||= [] ## if nil make sure it's an empty array when starting
99
+ PURRSTIGES.each do |key, h|
100
+ puts "key: #{key}"
101
+ pp h
102
+
103
+ recipe = Recipe.new(
104
+ traits: h[:recipe][:traits], ## todo/fix: turn strings into trait objs!!!!
105
+ limit: h[:recipe][:limit],
106
+ time_start: h[:recipe][:time] && h[:recipe][:time][:start] ? Date.strptime( h[:recipe][:time][:start], '%Y-%m-%d' ) : nil,
107
+ time_end: h[:recipe][:time] && h[:recipe][:time][:end] && h[:recipe][:time][:end] != '?' ? Date.strptime( h[:recipe][:time][:end], '%Y-%m-%d' ) : nil )
108
+
109
+ cattribute = Cattribute.new(
110
+ key: key,
111
+ name: h[:name],
112
+ type: tt,
113
+ traits: [], ## empty traits
114
+ count: h[:recipe][:count], # note: add count from recipe hash (NOT incl. in recipe struct)
115
+ recipe: recipe
116
+ )
117
+ tt.cattributes << cattribute
118
+
119
+ cattributes_by_name[ cattribute.name.downcase ] = cattribute
120
+ end
121
+
122
+
123
+ end # class Cattribute
@@ -1,132 +1,146 @@
1
- # encoding: utf-8
2
-
3
- COLORS = {
4
- ## 31 colors body
5
- meowgarine: "#fcfc95",
6
- cornflower: "#7592fc",
7
- icicle: "#c5e2ff",
8
- hotcocoa: "#5e4a47",
9
- firstblush: "#fcd0f8",
10
- tundra: "#dbccbf",
11
- glacier: "#ccffff",
12
- hyacinth: "#a45de2",
13
- shamrock: "#50c878",
14
- shadowgrey: "#b1b1be",
15
- salmon: "#f4a792",
16
- orangesoda: "#f7bc56",
17
- cottoncandy: "#ecd1eb",
18
- mauveover: "#ded0ee",
19
- aquamarine: "#add5d2",
20
- nachocheez: "#fcda86",
21
- harbourfog: "#afb4d5",
22
- cinderella: "#5ab0f1",
23
- greymatter: "#d1dadf",
24
- brownies: "#b78662",
25
- dragonfruit: "#ec79f2",
26
- hintomint: "#d0ead2",
27
- bananacream: "#f8f8e0",
28
- cloudwhite: "#ffffff",
29
- oldlace: "#ffebe9",
30
- koala: "#85828a",
31
- lavender: "#bc99ff",
32
- redvelvet: "#f77272",
33
- verdigris: "#73ffc3",
34
- onyx: "#42414c",
35
- martian: "#a4ff6f",
36
- ## 31 colors eyes
37
- olive: "#729100",
38
- pinefresh: "#177a25",
39
- oasis: "#ccffef",
40
- dioscuri: "#0ba09c",
41
- isotope: "#e4ff73",
42
- bridesmaid: "#ffc2df",
43
- downbythebay: "#83b293",
44
- gemini: "#ffd150",
45
- kaleidoscope: "#bcba5e",
46
- thundergrey: "#828282",
47
- gold: "#fcdf35",
48
- topaz: "#0ba09c",
49
- mintgreen: "#43edac",
50
- sizzurp: "#7c40ff",
51
- chestnut: "#a56429",
52
- strawberry: "#ef4b62",
53
- sapphire: "#4c7aef",
54
- forgetmenot: "#4eb4f9",
55
- dahlia: "#b8bdff",
56
- coralsunrise: "#ff9088",
57
- doridnudibranch: "#fa9fff",
58
- parakeet: "#49b749",
59
- cyan: "#45f0f4",
60
- pumpkin: "#ffa039",
61
- limegreen: "#aef72f",
62
- bubblegum: "#ef52d1",
63
- twilightsparkle: "#ba8aff",
64
- palejade: "#c3d8cf",
65
- eclipse: "#484c5b",
66
- babypuke: "#bcba5e",
67
- autumnmoon: "#ffe8bb",
68
- ## 31 colors secondary
69
- cyborg: "#959cae",
70
- ooze: "#daea31",
71
- peppermint: "#00a86b",
72
- inflatablepool: "#4fb9c5",
73
- prairierose: "#e0115f",
74
- springcrocus: "#ab7fef",
75
- egyptiankohl: "#4a4855",
76
- poisonberry: "#773c5f",
77
- lilac: "#e5e5f9",
78
- apricot: "#f4a45b",
79
- royalpurple: "#cf5be8",
80
- padparadscha: "#ffd5c7",
81
- swampgreen: "#44e192",
82
- violet: "#765be8",
83
- scarlet: "#ea5f5a",
84
- barkbrown: "#886662",
85
- coffee: "#756650",
86
- lemonade: "#ffef85",
87
- chocolate: "#c47e33",
88
- butterscotch: "#ffce6c",
89
- safetyvest: "#b0f852",
90
- turtleback: "#387573",
91
- rosequartz: "#ffaefb",
92
- wolfgrey: "#737184",
93
- cerulian: "#385877",
94
- skyblue: "#83d5ff",
95
- garnet: "#f4679a",
96
- universe: "#494981",
97
- royalblue: "#5b6ee8",
98
- mertail: "#36f2bc",
99
- pearl: "#fff8fa",
100
- ## 31 colors tertiary
101
- hanauma: "#7accb5",
102
- belleblue: "#afd0f7",
103
- peach: "#f9cfad",
104
- granitegrey: "#b1aeb9",
105
- kittencream: "#f7ebda",
106
- emeraldgreen: "#8be179",
107
- bloodred: "#ff7a7a",
108
- daffodil: "#fff09f",
109
- sandalwood: "#b8916c",
110
- icy: "#eef8f8",
111
- flamingo: "#ec87ba",
112
- seafoam: "#9eeec5",
113
- azaleablush: "#ffccd8",
114
- morningglory: "#887cff",
115
- purplehaze: "#dad6e1",
116
- missmuffett: "#f4b3f0",
117
- summerbonnet: "#cbb0ff",
118
- mallowflower: "#c170b1",
119
- fallspice: "#ff9331",
120
- dreamboat: "#fd6cd5",
121
- periwinkle: "#cacaff",
122
- frosting: "#ffdce6",
123
- patrickstarfish: "#ffad97",
124
- mintmacaron: "#b0f1f4",
125
- shale: "#585666",
126
- cashewmilk: "#f9efef",
127
- buttercup: "#f4e65d",
128
- cobalt: "#5262db",
129
- sully: "#70f9f9",
130
- kalahari: "#ffcf8a",
131
- atlantis: "#2a7f96"
132
- }
1
+ # encoding: utf-8
2
+
3
+ ## 31 colors body
4
+ COLORS_BODY = {
5
+ meowgarine: "#fcfc95",
6
+ cornflower: "#7592fc",
7
+ icicle: "#c5e2ff",
8
+ hotcocoa: "#5e4a47",
9
+ firstblush: "#fcd0f8",
10
+ tundra: "#dbccbf",
11
+ glacier: "#ccffff",
12
+ hyacinth: "#a45de2",
13
+ shamrock: "#50c878",
14
+ shadowgrey: "#b1b1be",
15
+ salmon: "#f4a792",
16
+ orangesoda: "#f7bc56",
17
+ cottoncandy: "#ecd1eb",
18
+ mauveover: "#ded0ee",
19
+ aquamarine: "#add5d2",
20
+ nachocheez: "#fcda86",
21
+ harbourfog: "#afb4d5",
22
+ cinderella: "#5ab0f1",
23
+ greymatter: "#d1dadf",
24
+ brownies: "#b78662",
25
+ dragonfruit: "#ec79f2",
26
+ hintomint: "#d0ead2",
27
+ bananacream: "#f8f8e0",
28
+ cloudwhite: "#ffffff",
29
+ oldlace: "#ffebe9",
30
+ koala: "#85828a",
31
+ lavender: "#bc99ff",
32
+ redvelvet: "#f77272",
33
+ verdigris: "#73ffc3",
34
+ onyx: "#42414c",
35
+ martian: "#a4ff6f"
36
+ }
37
+
38
+ ## 31 colors eyes
39
+ COLORS_EYES = {
40
+ olive: "#729100",
41
+ pinefresh: "#177a25",
42
+ oasis: "#ccffef",
43
+ dioscuri: "#0ba09c",
44
+ isotope: "#e4ff73",
45
+ bridesmaid: "#ffc2df",
46
+ downbythebay: "#83b293",
47
+ gemini: "#ffd150",
48
+ kaleidoscope: "#bcba5e",
49
+ thundergrey: "#828282",
50
+ gold: "#fcdf35",
51
+ topaz: "#0ba09c",
52
+ mintgreen: "#43edac",
53
+ sizzurp: "#7c40ff",
54
+ chestnut: "#a56429",
55
+ strawberry: "#ef4b62",
56
+ sapphire: "#4c7aef",
57
+ forgetmenot: "#4eb4f9",
58
+ dahlia: "#b8bdff",
59
+ coralsunrise: "#ff9088",
60
+ doridnudibranch: "#fa9fff",
61
+ parakeet: "#49b749",
62
+ cyan: "#45f0f4",
63
+ pumpkin: "#ffa039",
64
+ limegreen: "#aef72f",
65
+ bubblegum: "#ef52d1",
66
+ twilightsparkle: "#ba8aff",
67
+ palejade: "#c3d8cf",
68
+ eclipse: "#484c5b",
69
+ babypuke: "#bcba5e",
70
+ autumnmoon: "#ffe8bb"
71
+ }
72
+
73
+ ## 31 colors secondary
74
+ COLORS_SECONDARY = {
75
+ cyborg: "#959cae",
76
+ ooze: "#daea31",
77
+ peppermint: "#00a86b",
78
+ inflatablepool: "#4fb9c5",
79
+ prairierose: "#e0115f",
80
+ springcrocus: "#ab7fef",
81
+ egyptiankohl: "#4a4855",
82
+ poisonberry: "#773c5f",
83
+ lilac: "#e5e5f9",
84
+ apricot: "#f4a45b",
85
+ royalpurple: "#cf5be8",
86
+ padparadscha: "#ffd5c7",
87
+ swampgreen: "#44e192",
88
+ violet: "#765be8",
89
+ scarlet: "#ea5f5a",
90
+ barkbrown: "#886662",
91
+ coffee: "#756650",
92
+ lemonade: "#ffef85",
93
+ chocolate: "#c47e33",
94
+ butterscotch: "#ffce6c",
95
+ safetyvest: "#b0f852",
96
+ turtleback: "#387573",
97
+ rosequartz: "#ffaefb",
98
+ wolfgrey: "#737184",
99
+ cerulian: "#385877",
100
+ skyblue: "#83d5ff",
101
+ garnet: "#f4679a",
102
+ universe: "#494981",
103
+ royalblue: "#5b6ee8",
104
+ mertail: "#36f2bc",
105
+ pearl: "#fff8fa"
106
+ }
107
+
108
+ ## 31 colors tertiary
109
+ COLORS_TERTIARY = {
110
+ hanauma: "#7accb5",
111
+ belleblue: "#afd0f7",
112
+ peach: "#f9cfad",
113
+ granitegrey: "#b1aeb9",
114
+ kittencream: "#f7ebda",
115
+ emeraldgreen: "#8be179",
116
+ bloodred: "#ff7a7a",
117
+ daffodil: "#fff09f",
118
+ sandalwood: "#b8916c",
119
+ icy: "#eef8f8",
120
+ flamingo: "#ec87ba",
121
+ seafoam: "#9eeec5",
122
+ azaleablush: "#ffccd8",
123
+ morningglory: "#887cff",
124
+ purplehaze: "#dad6e1",
125
+ missmuffett: "#f4b3f0",
126
+ summerbonnet: "#cbb0ff",
127
+ mallowflower: "#c170b1",
128
+ fallspice: "#ff9331",
129
+ dreamboat: "#fd6cd5",
130
+ periwinkle: "#cacaff",
131
+ frosting: "#ffdce6",
132
+ patrickstarfish: "#ffad97",
133
+ mintmacaron: "#b0f1f4",
134
+ shale: "#585666",
135
+ cashewmilk: "#f9efef",
136
+ buttercup: "#f4e65d",
137
+ cobalt: "#5262db",
138
+ sully: "#70f9f9",
139
+ kalahari: "#ffcf8a",
140
+ atlantis: "#2a7f96"
141
+ }
142
+
143
+ COLORS = {}.merge( COLORS_BODY )
144
+ .merge( COLORS_EYES )
145
+ .merge( COLORS_SECONDARY )
146
+ .merge( COLORS_TERTIARY )