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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 662abf80d143d4ea2f6567989aaf7fed0ffa9ab7
4
- data.tar.gz: bff5d0875647ebdebdc34f674d584bee57307ba9
3
+ metadata.gz: 23377266362e1d96f453bcfe878e37ec7bfdbf38
4
+ data.tar.gz: 4aa9f57d46918109ad86030949e6960f8b82b181
5
5
  SHA512:
6
- metadata.gz: f75e171793fa0174806e4f0d69789dfff7e4bb6d9b2641b67799ad104af19ef63f318d4f8a19e9e970db351db595685ace20630adf47a3bcba780787054e0d4d
7
- data.tar.gz: d68f573e764b3c0fce6180848036b86df1e3dec4300c7f710078a6763ff6ce48bac22fb00c5664eed2f562a7380f8cb2529b521d7ee842409a98436af91a6fb2
6
+ metadata.gz: c793ed11267e8c6a78bcaf0b9acab5e73f417f8b526758cae56873eb25b29b7ab3903884ae27f78131890c6f07b0ac4f4e2c3640a6911864673612bc8aa3ddbf
7
+ data.tar.gz: e2fd48ab25d5899f6de64e89c1606d1181d8edda47af830a9099d37b2d4f10a7f7f1e1883b2297ffb08283e4ecabe49df3c025834e5cd4d7cf3656ea9837f460
@@ -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 "Nothing found, please try again"
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
- req.reply image
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-mtg"
3
- spec.version = "0.1.3"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Luke Lancaster"]
5
5
  spec.email = ["luketlancaster@gmail.com"]
6
6
  spec.description = "Lita plugin that returns a magic card!"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-mtg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Lancaster