Class: Klondike::ColumnPlace
- Defined in:
- lib/rubysketch/solitaire/klondike.rb
Instance Attribute Summary
Attributes inherited from CardPlace
Instance Method Summary collapse
- #accept?(x, y, card) ⇒ Boolean
-
#initialize(*args, **kwargs, &block) ⇒ ColumnPlace
constructor
A new instance of ColumnPlace.
- #posFor(card, index = nil) ⇒ Object
Methods inherited from CardPlace
#add, #id, #inspect, #pop, #sprite, #updateCards
Methods included from HasSprite
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ ColumnPlace
Returns a new instance of ColumnPlace.
954 955 956 |
# File 'lib/rubysketch/solitaire/klondike.rb', line 954 def initialize(*args, **kwargs, &block) super(*args, linkCards: true, **kwargs, &block) end |
Instance Method Details
#accept?(x, y, card) ⇒ Boolean
958 959 960 961 962 963 964 965 966 967 968 |
# File 'lib/rubysketch/solitaire/klondike.rb', line 958 def accept?(x, y, card) return false if !card || card.closed? || !card.canDrop? if empty? hit?(x, y) && card.number == 13 else any? {|card| card.hit?(x, y)} && card.number == last.number - 1 && (@game.difficulty == :easy || card.color != last.color) end end |
#posFor(card, index = nil) ⇒ Object
970 971 972 973 974 975 |
# File 'lib/rubysketch/solitaire/klondike.rb', line 970 def posFor(card, index = nil) index ||= indexFor card super.tap do |pos| pos.y += self.h * 0.3 * index end end |