kittyverse 0.4.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
-
3
-
4
- ###############################
5
- # cryptokitties.co links
6
-
7
- def kitties_kitty_url( id )
8
- "https://www.cryptokitties.co/kitty/#{id}"
9
- end
10
-
11
-
12
- def kitties_search_url( q )
13
- "https://www.cryptokitties.co/search?include=sale,sire,other&search=#{q}"
14
- end
15
-
16
-
17
-
18
-
19
- def kitties_fancy_search_url( fancy ) ## todo: find a better name - why? why not?
20
-
21
- ## note: use (official) chinese name for search param if present
22
- param = fancy.name_cn ? fancy.name_cn : fancy.key
23
-
24
- if fancy.special_edition?
25
- q = "specialedition:#{param}" ## todo: urlescape param - why? why not?
26
- elsif fancy.exclusive? ## just use fancy too - why? why not?
27
- q = "exclusive:#{param}"
28
- else ## assume "normal/regular" fancy
29
- q = "fancy:#{param}"
30
- end
31
-
32
- "https://www.cryptokitties.co/search?include=sale,sire,other&search=#{q}"
33
- end
34
-
35
- ## alias :kitties_special_search_url :kitties_fancy_search_url
36
- def kitties_specialedition_search_url( fancy ) kitties_fancy_search_url( fancy ); end
37
-
38
-
39
-
40
- ################################
41
- # /media - image links
42
-
43
- def media_fancy_url( key, variant_key=nil ) ### todo: find a better name - why? why not?
44
- if variant_key
45
- "https://cryptocopycats.github.io/media/kitties/100x100/fancy-#{key}-#{variant_key}.png"
46
- else
47
- "https://cryptocopycats.github.io/media/kitties/100x100/fancy-#{key}.png"
48
- end
49
- end
50
-
51
- ## (old) alias for media_fany_url
52
- def media_fancy_pic_url( key, variant_key=nil ) media_fancy_url( key, variant_key ); end
53
-
54
-
55
- def media_icon_url( key ) ## note: use :unlocked, :locked, etc.
56
- "https://cryptocopycats.github.io/media/icons/18x18/#{key}.png"
57
- end
@@ -1,101 +0,0 @@
1
- # encoding: utf-8
2
-
3
-
4
- class GenesPage
5
-
6
- def build
7
- buf = ""
8
- buf << "# Genes (#{TraitType.size} x 4)\n\n"
9
-
10
- headings = []
11
- TraitType.each do |tt|
12
- anchor = "#{tt.name} #{tt.code}".downcase.gsub( ' ', '-' )
13
- headings << "[#{tt.name} (#{tt.code})](##{anchor})"
14
- end
15
-
16
- buf << headings.join( " • " )
17
- buf << "\n\n"
18
-
19
-
20
- TraitType.each do |tt|
21
- buf << "## #{tt.name} (#{tt.code})\n\n"
22
- buf << "_Genes #{tt.genes}_\n\n"
23
- buf << make_table( tt.traits )
24
- buf << "\n\n"
25
- end
26
-
27
- puts buf
28
-
29
- buf
30
- end ## method build
31
-
32
-
33
-
34
- def make_table( traits )
35
- rows = make_rows( traits, columns: 2 ) ## was 4
36
- ## pp rows
37
-
38
- buf = ""
39
- buf << "|Kai|Code|Name |Kai|Code|Name |\n"
40
- buf << "|--:|---:|-------------|--:|---:|------------|\n"
41
-
42
- rows.each do |row|
43
- buf << "| "
44
-
45
- parts = row.map do |trait|
46
- kai = trait.kai
47
- ## binary = "%05b" % Kai::NUM[kai]
48
- code = trait.code
49
- name = trait.name
50
- tier = trait.tier_roman ## e.g. I,II,III, etc. : String
51
-
52
- if name.nil?
53
- ## note: so far x/31 trait is unknown/undefined!!!
54
- if kai == "x"
55
- cattribute = "?"
56
- elsif trait.type.key == :secret
57
- cattribute = "? #{tier}" ## unknown unknown
58
- else ## "anonymous / unnamed" gene / trait
59
- cattribute = "∅ #{tier}" ## known unknown :-)
60
- end
61
- else
62
- if name.downcase.start_with?( "totesbasic" ) ## note: special case for three totesbasic traits
63
- q = "totesbasic"
64
- else
65
- q = name
66
- end
67
- cattribute = "**[#{name}](#{kitties_search_url(q)})** #{tier}"
68
- end
69
-
70
- "#{kai} | #{code} | #{cattribute}"
71
- end
72
-
73
- buf << parts.join( " | " )
74
- buf << " |\n"
75
- end
76
-
77
- buf
78
- end
79
-
80
-
81
- ## helpers
82
- def make_rows( items, columns: 2 )
83
- offset = items.size / columns
84
- pp offset
85
-
86
- rows = []
87
- offset.times.with_index do |row|
88
- ## note: construct [items[row],items[offset+row],items[offset*2+row], ...]
89
- rows << columns.times.with_index.map { |col| items[offset*col+row] }
90
- end
91
- rows
92
- end
93
-
94
-
95
- def save( path )
96
- File.open( path, "w:utf-8" ) do |f|
97
- f.write build
98
- end
99
- end
100
-
101
- end # class GenesPage