--returns "ok" if the group is ok, but is not
--a trump card
--if it's exactly 1 trump, it returns "cut"
--otherwise an error code is returned:
--3=non valid mix of cards
--4= not enough or too many cards
--5=must play higher
--6=trump cards must be played alone
--7=no cards selected
function theGroupIsValid(tableOfCards)
	local size=tableLength(tableOfCards)
	if size==0 then --no cards!
		return 7
	end
	--there are cards	
	local power=tableOfCards[1].power
	if power==TRUMP then
		if size~=1 then --he's playing a trump and other cards (trumps)
			return 6
		else
			return "cut"
		end
	else --no trump
	
		--look if he plays the right number of cards
		if numberOfCardsPlayed~=0 then --otherwise he can play as many cards as wanted
			if size~=numberOfCardsPlayed then
				return 4
			end
		end
		
		--look if there arent different cards in the group ("2" are allowed)
		local i=0
		for i=1,size do
			if tableOfCards[i].power~=power and tableOfCards[i].power~=TWO then
				return 3
			end
		end
		
		--if he's not the one starting, look if he plays higher
		if powerOfCardsPlayed~=NOVALUE then
			if power<=powerOfCardsPlayed then
				return 5		
			end
		end
	end
	return "ok"
end

function nbCardsWithPower(playerNum, pow)
	local hand=players[playerNum].hand
	local handsz=handSize(playerNum)
	local nb=0
	local i=0
	for i=1,handsz do
		if hand[i].power==pow then
			nb=nb+1
		end
	end
	return nb
end

function randomDecision(yesPercent)
	local r=random(0, 100)
	fdebug("          random was "..r)
	if r<=yesPercent then
		return true
	end
	return false
end





