lita-mtg 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/mtg.rb +28 -2
- data/lita-mtg.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23377266362e1d96f453bcfe878e37ec7bfdbf38
|
4
|
+
data.tar.gz: 4aa9f57d46918109ad86030949e6960f8b82b181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c793ed11267e8c6a78bcaf0b9acab5e73f417f8b526758cae56873eb25b29b7ab3903884ae27f78131890c6f07b0ac4f4e2c3640a6911864673612bc8aa3ddbf
|
7
|
+
data.tar.gz: e2fd48ab25d5899f6de64e89c1606d1181d8edda47af830a9099d37b2d4f10a7f7f1e1883b2297ffb08283e4ecabe49df3c025834e5cd4d7cf3656ea9837f460
|
data/lib/lita/handlers/mtg.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mtg_sdk'
|
2
|
+
require 'pry'
|
2
3
|
|
3
4
|
module Lita
|
4
5
|
module Handlers
|
@@ -16,7 +17,7 @@ module Lita
|
|
16
17
|
puts "Searching for #{req.match_data[1]}"
|
17
18
|
cards = MTG::Card.where(name: "#{req.match_data[1]}").all
|
18
19
|
if cards.empty?
|
19
|
-
return req.reply "
|
20
|
+
return req.reply "Couldn't find \"#{req.match_data[1]}\", please try again"
|
20
21
|
end
|
21
22
|
|
22
23
|
for card in cards
|
@@ -27,7 +28,19 @@ module Lita
|
|
27
28
|
end
|
28
29
|
|
29
30
|
image = @card.image_url
|
30
|
-
|
31
|
+
|
32
|
+
if @card.layout == "double-faced"
|
33
|
+
back = card_back(@card)
|
34
|
+
image_two = back.image_url
|
35
|
+
end
|
36
|
+
|
37
|
+
if image_two
|
38
|
+
resp = "#{image}\n#{image_two}"
|
39
|
+
else
|
40
|
+
resp = image
|
41
|
+
end
|
42
|
+
|
43
|
+
req.reply resp
|
31
44
|
end
|
32
45
|
|
33
46
|
|
@@ -36,6 +49,19 @@ module Lita
|
|
36
49
|
false
|
37
50
|
end
|
38
51
|
|
52
|
+
def card_back(card)
|
53
|
+
multiverse_id = card.multiverse_id
|
54
|
+
|
55
|
+
if card.number[-1, 1] == "a"
|
56
|
+
multiverse_id += 1
|
57
|
+
else
|
58
|
+
multiverse_id -= 1
|
59
|
+
end
|
60
|
+
|
61
|
+
return MTG::Card.find(multiverse_id)
|
62
|
+
|
63
|
+
end
|
64
|
+
|
39
65
|
Lita.register_handler(self)
|
40
66
|
end
|
41
67
|
end
|
data/lita-mtg.gemspec
CHANGED