manasimu 0.0.9 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7daccf511ec20b2a789c10abd6907f9e6de2ad8ab205006c40d43d159a340730
4
- data.tar.gz: a378ba600c389a14c9f631660aa7000c669f2215966843979d9681be4ce38a46
3
+ metadata.gz: 8f369c20d49bd696fd184cd0874385b5072f3b66b4371a8a1698e6a6dd9cc2ff
4
+ data.tar.gz: 34b0f4b9bacb5cfa05b6e549a06576c0f07d1f904b79a8d36c8cd55e4a763c8c
5
5
  SHA512:
6
- metadata.gz: 2ccab49af9746d58f143401856905f42c79a55e449fbdf3d78a00f39ba022adb622b49b2f0d34a6720df33694653f01b912f2638b1b33db6913a627719afd904
7
- data.tar.gz: 5423c8b49381c1546c3395a46ef41096f1a00946cd4baa29063f504d0392580412812cd29ec7da700a4abb98b1d7c43cb2f2a5b311fbd92d7a2bd0e9f1814141
6
+ metadata.gz: f84f7ede021935431da0b01f3554e77473f56146ca67bdd6036c1e7401c704ade04414cc404ebdf5fb214e2238613ae6112cb38cc2eeeb27c1846b147f21598f
7
+ data.tar.gz: f9db31ef0e7aebbc74e7bcd389bf64a04c076d2b9e5fab389785e5abbf5665e91c546b9c34fce28f97f936e2b15785422d8c13c2513dee27d2c6773eae726452
@@ -0,0 +1,25 @@
1
+ class PathwayCard < Card
2
+
3
+ def first_produce_symbol=(symbol)
4
+ if symbol.to_i.to_s == symbol
5
+ @side = 'a'
6
+ @symbol = @card_type.color_identity[0]
7
+ else
8
+ @card_type.color_identity.each_with_index do |ci, i|
9
+ if ci == symbol
10
+ @side = @card_type.contents[i].side
11
+ @symbol = ci
12
+ break
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ def color_identity
19
+ if @side
20
+ [@symbol]
21
+ else
22
+ @card_type.color_identity
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ class TapLandCard < Card
2
+
3
+ def tapped?
4
+ @tapped
5
+ end
6
+
7
+ def drawed(turn)
8
+ super(turn)
9
+ @tapped = true
10
+ end
11
+
12
+ def step(turn)
13
+ @tapped = false
14
+ end
15
+ end
data/lib/manasimu/card.rb CHANGED
@@ -3,9 +3,12 @@ class Card
3
3
 
4
4
  def initialize(card_type)
5
5
  @card_type = card_type
6
+ @playable = false
6
7
  end
7
8
 
8
9
  def step(turn)
10
+ @card_type.step(turn - 1, self)
11
+ @can_play = false
9
12
  end
10
13
 
11
14
  def drawed(turn)
@@ -32,7 +35,13 @@ class Card
32
35
  end
33
36
 
34
37
  def playable?(lands, capas)
35
- @card_type.playable?(lands, capas)
38
+ ret = @card_type.playable?(lands, capas)
39
+ @can_play = true if ret and ret[0]
40
+ ret
41
+ end
42
+
43
+ def can_play?
44
+ @can_play
36
45
  end
37
46
 
38
47
  def types
@@ -88,19 +97,23 @@ class Card
88
97
  end
89
98
 
90
99
  class CardType
91
- attr_accessor :contents, :played, :drawed, :name
100
+ attr_accessor :contents, :played, :drawed, :name, :can_plays
92
101
 
93
102
  def self.create(card_type, name)
94
103
  ret = card_type.dup
95
104
  ret.contents = card_type.contents
96
- ret.played = nil
97
- ret.drawed = nil
105
+ ret.played = {}
106
+ ret.drawed = {}
107
+ ret.can_plays = {}
98
108
  ret.name = name
99
109
  ret
100
110
  end
101
111
 
102
112
  def initialize(contents)
103
113
  return if not contents
114
+ @played = {}
115
+ @drawed = {}
116
+ @can_plays = {}
104
117
  @contents = contents.map {|c| Content.new(c)}
105
118
  end
106
119
 
@@ -108,14 +121,19 @@ class CardType
108
121
  @name ||= @contents[0].name
109
122
  end
110
123
 
124
+ def step(turn, card)
125
+ if turn >= 0 and card.can_play?
126
+ @can_plays[turn] ||= 0
127
+ @can_plays[turn] += 1
128
+ end
129
+ end
130
+
111
131
  def played(turn)
112
- @played ||= {}
113
132
  @played[turn] ||= 0
114
133
  @played[turn] += 1
115
134
  end
116
135
 
117
136
  def drawed(turn)
118
- @drawed ||= {}
119
137
  @drawed[turn] ||= 0
120
138
  @drawed[turn] += 1
121
139
  end
@@ -266,15 +284,13 @@ class CardType
266
284
 
267
285
  def count(turn = nil)
268
286
  turn ||= converted_mana_cost
269
- played = @played ? @played [turn] : 0
287
+ played = @played [turn] || 0
270
288
  drawed = 0
271
- if (@drawed)
272
- (turn+1).times do |i|
273
- next if not @drawed[i]
274
- drawed += @drawed[i]
275
- end
289
+ (turn+1).times do |i|
290
+ drawed += @drawed[i] || 0
276
291
  end
277
- [played, drawed]
292
+ can_played = @can_plays[turn] || 0
293
+ [played, drawed, can_played]
278
294
  end
279
295
 
280
296
  def to_s
data/lib/manasimu/data.rb CHANGED
@@ -72,6 +72,9 @@ class Deck
72
72
  card_types << clone
73
73
  if clone.name =~ /.*Pathway$/ and clone.mana_source?
74
74
  card = PathwayCard.new(clone)
75
+ elsif clone.types[0] == "Land" and
76
+ clone.contents[0].text =~ /enters the battlefield tapped\./
77
+ card = TapLandCard.new(clone)
75
78
  else
76
79
  card = Card.new(clone)
77
80
  end
data/lib/manasimu/game.rb CHANGED
@@ -25,6 +25,7 @@ class Game
25
25
  end
26
26
 
27
27
  def upkeep(turn)
28
+ @hands.each { |card| card.step(turn) }
28
29
  @plays.each { |card| card.step(turn) }
29
30
  end
30
31
 
@@ -86,7 +86,11 @@ class Planner
86
86
  spell = spells[index]
87
87
  used_lands = bit_lands.to_s(2).chars
88
88
  capas = lands.length.times.to_a.map do |i|
89
- used_lands[i] == "1" ? "0" : "1"
89
+ if used_lands[i] == "1"
90
+ "0"
91
+ else
92
+ lands[i].tapped? ? "0" : "1"
93
+ end
90
94
  end
91
95
 
92
96
  # shrink
data/lib/manasimu.rb CHANGED
@@ -3,6 +3,7 @@ Bundler.require
3
3
 
4
4
  require_relative './manasimu/card.rb'
5
5
  require_relative './manasimu/card/pathway.rb'
6
+ require_relative './manasimu/card/tapland.rb'
6
7
  require_relative './manasimu/planner.rb'
7
8
  require_relative './manasimu/game.rb'
8
9
  require_relative './manasimu/simulator.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manasimu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - so1itaryrove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-11 00:00:00.000000000 Z
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: mtg arrena mana curve simulator
14
14
  email: so1itaryrove@gmail.com
@@ -20,6 +20,8 @@ files:
20
20
  - ext/ford_fulkerson.so
21
21
  - lib/manasimu.rb
22
22
  - lib/manasimu/card.rb
23
+ - lib/manasimu/card/pathway.rb
24
+ - lib/manasimu/card/tapland.rb
23
25
  - lib/manasimu/data.rb
24
26
  - lib/manasimu/game.rb
25
27
  - lib/manasimu/hello.rb