manasimu 0.0.17 → 0.0.18

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
  SHA256:
3
- metadata.gz: cd8f2deebb97ccdfec7d84f59caf31ca2548c5d2152d03f171acef1718619035
4
- data.tar.gz: 1422e049b960adb6f9365921c20426a61a5c384ecb87435b1ca4ed284b156025
3
+ metadata.gz: 8d6ea60d2d69b6ec0c517c241c03f51dedb5fcb6f9830d01c5e43a71ca952fb3
4
+ data.tar.gz: d918b9183adf48e7fd623234f05fce40d9b880ffe80719d9c6532e191b65fafe
5
5
  SHA512:
6
- metadata.gz: 60cb513f51880b6150fac14f1caef1e86775bcd04da5c55406e3d439d4d0e770606ab4254f599b1dccbad0a27cdc7fdd728db3deeae346b9fbf7d15fb9c5ff26
7
- data.tar.gz: c95fcc75ff9f576d42791ac69997500de7cff984360f81d146def3555f80df084549a9ca97d64564e5d6b34b69c21e9a76adee29904330943ca75dce0c917b59
6
+ metadata.gz: 0747c61c051fc5477ddb4c695d0b6a53d2038ad52861cd989d3a6cdb7ff8a5e21661c6bf3da6a9eca3a0ff87c260f7ac4c7ee5ba512fcad9e012e65b668ef77a
7
+ data.tar.gz: b60ead57d04031778ce0d618c9ebf00726e78523deff225aeefc34b4235444546224f7611d1aea215b4a8fdb34bb70a7bf8a935cd575f177a742ef3a6030d840
@@ -0,0 +1,64 @@
1
+ class FetchLandCard < TapLandCard
2
+ attr_accessor :deck
3
+
4
+ # enter the battlefield
5
+ def resolve(side, hands, plays, deck)
6
+ super(side, hands, plays, deck)
7
+ return @fetch_source if @fetch_source
8
+ if deck
9
+ @fetches = deck
10
+ .select { |card| card.instance_of? BasicLandCard }
11
+ .select { |card| @mana_source.include? card.mana_source[0] }
12
+ .uniq { |card| card.card_type }
13
+ @deck = deck
14
+ @fetch_source = @fetches.map { |card| card.mana_source }.flatten.uniq
15
+ else
16
+ @fetches = []
17
+ @fetch_source = []
18
+ end
19
+ end
20
+
21
+ def first_produce_symbol=(color)
22
+ super(color)
23
+ basic_land = @deck
24
+ .select { |card| card.instance_of? BasicLandCard }
25
+ .select { |card| color.to_i.to_s == color || card.mana_source.include?(color) }
26
+ .first
27
+ if basic_land
28
+ @fetched = color
29
+ @deck.delete basic_land
30
+ @deck.shuffle!
31
+ @fetch_source = basic_land.mana_source
32
+ @fetches = [basic_land]
33
+ else
34
+ raise Exception.new('basic land is empty')
35
+ end
36
+ @deck
37
+ end
38
+
39
+ def mana_source
40
+ raise Exception.new('you should resolve first') if not @fetch_source
41
+ @fetch_source
42
+ end
43
+
44
+ def mana_source=(m)
45
+ @mana_source = m
46
+ end
47
+
48
+ def configure
49
+ mana_types = ManaType.all
50
+ @mana_source = mana_types.map {|mana_type| mana_type.color}.flatten.uniq
51
+ @fetched = nil
52
+ self
53
+ end
54
+
55
+ def reset
56
+ super
57
+ @fetched = nil
58
+ @fetch_source = nil
59
+ end
60
+
61
+ def mana_produced?
62
+ not @fetched.nil?
63
+ end
64
+ end
@@ -1,64 +1,8 @@
1
- class SncFetchLandCard < TapLandCard
2
-
3
- attr_accessor :deck
4
-
5
- def resolve(side, hands, plays, deck)
6
- super(side, hands, plays, deck)
7
- return @fetch_source if @fetch_source
8
- @tapped = true
9
- if deck
10
- @fetches = deck
11
- .select { |card| card.instance_of? BasicLandCard }
12
- .select { |card| @mana_source.include? card.mana_source[0] }
13
- .uniq { |card| card.card_type }
14
- @deck = deck
15
- @fetch_source = @fetches.map { |card| card.mana_source }.flatten.uniq
16
- else
17
- @fetches = []
18
- @fetch_source = []
19
- end
20
- end
21
-
22
- def first_produce_symbol=(color)
23
- super(color)
24
- if @deck
25
- basic_land = @deck
26
- .select { |card| card.instance_of? BasicLandCard }
27
- .select { |card| color.to_i.to_s == color || card.mana_source.include?(color) }
28
- .first
29
- if basic_land
30
- @deck.delete basic_land
31
- @deck.shuffle!
32
- @fetch_source = [color]
33
- @fetches = [basic_land]
34
- else
35
- raise Exception.new('basic land is empty')
36
- end
37
- else
38
- []
39
- end
40
- @fetched = true
41
- end
42
-
43
- def mana_source
44
- raise Exception.new('you should resolve first') if not @fetch_source
45
- @fetch_source
46
- end
1
+ class SncFetchLandCard < FetchLandCard
47
2
 
48
3
  def configure
49
4
  mana_types = ManaType.search_text_by_land_type(card_type.text)
50
- @mana_source = mana_types.map {|mana_type| mana_type.color}.flatten.uniq
51
- @fetched = false
5
+ super.mana_source = mana_types.map {|mana_type| mana_type.color}.flatten.uniq
52
6
  self
53
7
  end
54
-
55
- def reset
56
- super
57
- @fetched = false
58
- @fetch_source = nil
59
- end
60
-
61
- def mana_produced?
62
- @fetched
63
- end
64
8
  end
@@ -4,6 +4,7 @@ class TapLandCard < Card
4
4
  @tapped
5
5
  end
6
6
 
7
+ # when enter the battlefield
7
8
  def resolve(side, hands, plays, deck)
8
9
  super(side, hands, plays, deck)
9
10
  @tapped = true
@@ -14,6 +15,10 @@ class TapLandCard < Card
14
15
  @tapped = false
15
16
  end
16
17
 
18
+ def tappend=(tapped)
19
+ @tapped = tapped
20
+ end
21
+
17
22
  def reset
18
23
  super
19
24
  @tapped = false
data/lib/manasimu/data.rb CHANGED
@@ -77,6 +77,9 @@ class Deck
77
77
  card = TapLandCard.new(clone)
78
78
  elsif clone.contents[0].text =~ /enters the battlefield tapped unless you control two or more other lands./
79
79
  card = SlowLandCard.new(clone)
80
+ elsif clone.text =~ /earch your library for a basic land card, put it onto the battlefield tapped, then shuffle/
81
+ card = FetchLandCard.new(clone)
82
+ card.configure
80
83
  elsif clone.set_code == 'SNC' and
81
84
  clone.contents[0].text =~ /enters the battlefield, sacrifice it/
82
85
  card = SncFetchLandCard.new(clone)
data/lib/manasimu/game.rb CHANGED
@@ -18,7 +18,7 @@ class Game
18
18
  def step(turn)
19
19
  if @debugg
20
20
  puts "---------------------------------"
21
- puts "turn #{turn} deck #{@deck.length}"
21
+ puts "turn #{turn} basic_lands #{@deck.select {|c| c.instance_of? BasicLandCard}.length}"
22
22
  puts "played"
23
23
  @plays.each do |card| puts " #{card}" end
24
24
  puts "hands"
@@ -26,11 +26,12 @@ class Game
26
26
  end
27
27
 
28
28
  draw(turn)
29
- play_cards = plan;
29
+ play_cards, deck = plan;
30
30
  @hands.each { |card| card.step_in_hands(turn) }
31
- plan.each do |card|
31
+ play_cards.each do |card|
32
32
  play(card, turn)
33
33
  end
34
+ deck = deck if deck
34
35
  @plays.each { |card| card.step_in_plays(turn) }
35
36
  end
36
37
 
@@ -53,8 +54,6 @@ class Game
53
54
  end
54
55
 
55
56
  card.resolve(nil, @hands, @plays, @deck)
56
- @deck = card.deck if card.respond_to? :deck
57
-
58
57
  card.played(turn, nil)
59
58
  @plays << card
60
59
  @hands.delete card
@@ -43,16 +43,17 @@ class Planner
43
43
  max_land = lands_in_hand[0]
44
44
  end
45
45
 
46
+ deck = nil
46
47
  if max_lands
47
48
  max_lands.each_with_index do |land, i|
48
49
  if not land.mana_produced? and max_symbols[i]
49
- debugger if max_symbols[i].nil?
50
50
  land.first_produce_symbol = max_symbols[i]
51
+ deck = land.deck if land.respond_to? :deck
51
52
  end
52
53
  end
53
54
  end
54
55
 
55
- [max_land, max_spells].select {|a| a}.flatten
56
+ [[max_land, max_spells].select {|a| a}.flatten, deck]
56
57
  end
57
58
 
58
59
  #
data/lib/manasimu.rb CHANGED
@@ -7,6 +7,7 @@ require_relative './manasimu/card/basicland.rb'
7
7
  require_relative './manasimu/card/pathway.rb'
8
8
  require_relative './manasimu/card/tapland.rb'
9
9
  require_relative './manasimu/card/slowland.rb'
10
+ require_relative './manasimu/card/fetchland.rb'
10
11
  require_relative './manasimu/card/snc_fetchland.rb'
11
12
  require_relative './manasimu/planner.rb'
12
13
  require_relative './manasimu/game.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manasimu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - so1itaryrove
@@ -21,6 +21,7 @@ files:
21
21
  - lib/manasimu.rb
22
22
  - lib/manasimu/card.rb
23
23
  - lib/manasimu/card/basicland.rb
24
+ - lib/manasimu/card/fetchland.rb
24
25
  - lib/manasimu/card/pathway.rb
25
26
  - lib/manasimu/card/slowland.rb
26
27
  - lib/manasimu/card/snc_fetchland.rb