Class: Klondike::NextsPlace

Inherits:
CardPlace show all
Defined in:
lib/rubysketch/solitaire/klondike.rb

Instance Attribute Summary

Attributes inherited from CardPlace

#cards, #name

Instance Method Summary collapse

Methods inherited from CardPlace

#accept?, #id, #initialize, #inspect, #sprite, #updateCards

Methods included from HasSprite

#hit?

Constructor Details

This class inherits a constructor from CardPlace

Instance Method Details

#add(*cards, **kwargs) ⇒ Object



909
910
911
912
# File 'lib/rubysketch/solitaire/klondike.rb', line 909

def add(*cards, **kwargs)
  super
  updateCards excludes: cards
end

#drawCountObject



899
900
901
# File 'lib/rubysketch/solitaire/klondike.rb', line 899

def drawCount()
  @game.difficulty == :hard ? 3 : 1
end

#overlapObject



927
928
929
# File 'lib/rubysketch/solitaire/klondike.rb', line 927

def overlap()
  skin.cardSpriteSize[0] * 0.4
end

#pop(*args) ⇒ Object



914
915
916
917
# File 'lib/rubysketch/solitaire/klondike.rb', line 914

def pop(*args)
  super
  updateCards
end

#posFor(card, index = nil) ⇒ Object



919
920
921
922
923
924
925
# File 'lib/rubysketch/solitaire/klondike.rb', line 919

def posFor(card, index = nil)
  index ||= indexFor card
  super.tap do |pos|
    rindex = cards.size - index
    pos.x += overlap * (drawCount - rindex).clamp(0, drawCount - 1)
  end
end

#startedObject



903
904
905
906
907
# File 'lib/rubysketch/solitaire/klondike.rb', line 903

def started()
  w       = skin.cardSpriteSize[0] + overlap * (drawCount - 1)
  self.x -= w - self.w
  self.w  = w
end