Hal E. Fulton wrote:
> This is a very minor piece of code, 
> really. But I'm not seeing the "right"
> way to do it.
> 

Surely, there is now "right" way, but the way you look at the decision 
rule affects what you see.

Here are my thoughts:

The web page at http://www.pagat.com/boston/spades.html gives the
decision rule for a trick in spades as:

"A trick containing a spade is won by the highest spade played; if no
spade is played, the trick is won by the highest card of the suit led."

With theses rules, the decision of higher card is a binary
relationship on cards and can be expressed as a boolean method of the 
class card.  For example card1.loosesto(card2), where loosesto() assumes 
card1 is the best card on the trick so far.  When the next player plays 
card2 on the trick, card1 is asked if it can beat card2.

The logic for loosesto() goes like:

if (card2.suit == spades) then
    if (self.suit == spades) then
       return card2.rank > card1.rank
    else
       return true
    end
else
    if (card2.suit == self.suit) then
       return card2.rank > card1.rank
    else
       return false
    end
end

Using loosesto() the loop that scans the array of cards that encodes the 
trick could read something like:

def decide_trick(trick_array)
     current_best = trick_array[0]
     index = 0
     (1..3).each { |x|
        if current_best.loosesto(trick_array[i]) then
           current_best = trick_array[i]
           index = i
        end
     }
     return "player #{index} wins with card #{current_best}"
end

Your thoughts?