Code covered by the BSD License  

Highlights from
Cribbage Suite

image thumbnail
from Cribbage Suite by Bryan
Cribbage Suite is a GUI interface designed to help teach and play the game of cribbage.

winnerGui.m
%winnerGui.m
%winnerGui is the GUI that shows when you have won the game!
%It is called by either AddPoints1 or AddPoints2

if get(currentPlayer,'score') > 120 %If the current player has just won the game    
    diff = get(currentPlayer,'score') - get(otherPlayer,'score'); %This is the difference of their scores, used to determine the skunkRating.
    if diff > 90 %Triple Skunk...nearly impossible; I bet it's a moot point.
        winString = [get(currentPlayer,'name') ' wins the game with a score of ' num2str(get(currentPlayer,'score')) ' points! That''s a TRIPLE SKUNK compared to ' get(otherPlayer,'name') '''s  score of ' num2str(get(otherPlayer,'score'))];
    elseif diff > 60 %Double Skunk...extremely embarrassing, but still possible.
        winString = [get(currentPlayer,'name') ' wins the game with a score of ' num2str(get(currentPlayer,'score')) ' points! That''s a DOUBLE SKUNK compared to ' get(otherPlayer,'name') '''s  score of ' num2str(get(otherPlayer,'score'))];
    elseif diff > 30 %Skunk...you've gotten beaten pretty badly!
        winString = [get(currentPlayer,'name') ' wins the game with a score of ' num2str(get(currentPlayer,'score')) ' points! ' get(otherPlayer,'name') '''s  been skunked with a measly score of ' num2str(get(otherPlayer,'score')) ' points.'];
    elseif diff > 5 %If it's not a totally close finish.
        winString = [get(currentPlayer,'name') ' wins the game with a score of ' num2str(get(currentPlayer,'score')) ' points! ' get(otherPlayer,'name') '''s  been beaten with a score of ' num2str(get(otherPlayer,'score')) ' points.'] ;
    else
        winString = ['What a close finish! ' get(currentPlayer,'name') ' wins by ' num2str(diff) ' points for a final score of ' num2str(get(player1,'score')) '-' num2str(get(player2,'score'))]; 
    end 
    
    %Update and display the head-to-head record of the two players.
    winnerRecord(1,player1,player2,currentPlayer);
    
    %Ask to start a new game.
    button = questdlg([winString ' Would you like to start a new game?'], 'WINNER!');
    switch button
        case 'Yes'
            newGame;
    end
    
end

Contact us at files@mathworks.com