Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Commit

Permalink
FINAL CHANGES!
Browse files Browse the repository at this point in the history
Hopefully…

• Minor interface adjustments
• Fixed bug where humans could control computer players (I'm sure I fixed that ages ago… something else must have changed)
• Added a few more comments
• Changed behaviour of New Game button in GameView. Now asks to close the current game, instead of just leaving it sitting around
• Fixed display of StartupWindow when using Windows Classic theme
• Saved beta and 1.0 releases
  • Loading branch information
DouglasHeriot committed Jun 26, 2010
1 parent ef6317f commit 3b39f4e
Show file tree
Hide file tree
Showing 45 changed files with 277 additions and 222 deletions.
Binary file modified Uno.suo
Binary file not shown.
58 changes: 49 additions & 9 deletions Uno/AboutBox.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Uno/AboutBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,20 @@ public string AssemblyCompany

private void douglasHeriotLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://douglasheriot.com/");
// Open douglasheriot.com in the default web browser
System.Diagnostics.Process.Start("http://douglasheriot.com/uno/");
}

private void doneButton_Click(object sender, EventArgs e)
{
// Close this window
this.Close();
}

private void helpButton_Click(object sender, EventArgs e)
{
// Show help, and close this window
Program.ShowHelp(Help.HelpPage.NewGame);
this.Close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Uno/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public enum CardColor
/// </summary>
Blue,

/// <summary>
/// <summary>
/// Wild cards
/// </summary>
Wild
Expand Down
2 changes: 1 addition & 1 deletion Uno/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public int Score
/// </summary>
public bool Finished
{
get { return cards.Count <= 0; }
get { return cards.Count <= 0 || finishRank >= 0; }
}


Expand Down
60 changes: 31 additions & 29 deletions Uno/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public enum CardPlayStatus
IncorrectPlayer,

/// <summary>
/// The card is actually in the deck
/// The card is actually in the discard pile
/// </summary>
Deck,
DiscardPile,

/// <summary>
/// The card was cancelled
Expand All @@ -48,6 +48,11 @@ public enum CardPlayStatus
/// </summary>
Draw4NotAllowed,

/// <summary>
/// The current player can only be controlled by the computer
/// </summary>
ComputerPlayer,

/// <summary>
/// The reason is unknown: an error may have occurred
/// </summary>
Expand All @@ -63,7 +68,6 @@ public enum CardPlayStatus
private Game game;
private GameView gameView;


private int cardsToDraw = 0;
private bool skip = false;

Expand Down Expand Up @@ -97,24 +101,20 @@ public Game Game
/// <param name="newGame"></param>
public GameController(Game newGame)
{
// Save the Game object
game = newGame;



// Setup the uno deck
game.Deck = GenerateUnoDeck();
shuffleDeck();



// Create a new game view
gameView = new GameView(game, this);
gameView.FormClosed += new FormClosedEventHandler(gameView_FormClosed);

// Deal the cards to players
dealCards();


// Sort the cards in each player's hand
foreach (System.Collections.DictionaryEntry p in game.PlayersCards)
sortCards((p.Value as Game.GamePlayer).Cards);
Expand All @@ -123,30 +123,18 @@ public GameController(Game newGame)
performAction(Game.CurrentCard);
handleActions();


// Get ready for the first player (make a move if it's a computer)
setupCurrentPlayer();

// Prepare the game view
gameView.ReDraw();


// Setup the computer player delay timer
computerPlayerTimer.Interval = game.Options.ComputerPlayerDelay;
computerPlayerTimer.Tick += new EventHandler(computerPlayerTimer_Tick);





// Show the game view
gameView.Show();



// Testing purposes only!
//makeComputerMove();


gameView.Show();
}


Expand All @@ -163,13 +151,16 @@ public GameController(Game newGame)
/// <param name="card"></param>
public CardPlayStatus SelectCard(Card card)
{
// Don't let humans play on behalf of the computer!
if (game.CurrentPlayer.Type != Player.PlayerType.Human)
return CardPlayStatus.ComputerPlayer;


// Check if the card can be played before asking for wild colour
CardPlayStatus wildCheckStatus = CanPlayCardStatus(card);
if (wildCheckStatus != CardPlayStatus.Success)
return wildCheckStatus;


// Ask for the color for a wild card
if (card.Color == Card.CardColor.Wild)
{
Expand Down Expand Up @@ -310,7 +301,7 @@ public bool CanPlayCard(Card card)
// Check if a card can be played
public CardPlayStatus CanPlayCardStatus(Card card)
{
// Assume success unless otherwise
// Assume success unless otherwise (because we're looking for the reason it isn't allowed)
CardPlayStatus success = CardPlayStatus.Success;

// Check the colour is correct, or the card is a wild
Expand All @@ -323,26 +314,37 @@ public CardPlayStatus CanPlayCardStatus(Card card)
{
bool checkForCurrentColor = false;

// Look at each card to check if the player holds any cards of the current color
foreach (Card c in game.CurrentGamePlayer.Cards)
{
if (c.Color == game.CurrentColor)
{
// We can stop checking now
checkForCurrentColor = true;
break;
}
}

// Set the success status
if (checkForCurrentColor)
success = CardPlayStatus.Draw4NotAllowed;

}


// Don't allow playing somebody else's cards!
// TODO: allow optional pickup put downs
if (game.CurrentGamePlayer.Cards.IndexOf(card) < 0)
success = CardPlayStatus.IncorrectPlayer;

{
if (game.DiscardPile.IndexOf(card) > -1)
// The card is in the discard pile
success = CardPlayStatus.DiscardPile;
else
// The card is in someone else's hand
success = CardPlayStatus.IncorrectPlayer;
}


return success;
}

Expand All @@ -351,13 +353,13 @@ public CardPlayStatus CanPlayCardStatus(Card card)
// Debugging methods
//////////////////////////////////////

public void SwapPlayersHands()
internal void SwapPlayersHands()
{
swapAllPlayerHands();
gameView.ReDraw();
}

public void MakeComputerMoveForPlayer()
internal void MakeComputerMoveForPlayer()
{
makeComputerMove(true);
}
Expand Down Expand Up @@ -697,7 +699,7 @@ private void makeComputerMove(bool computerOnlyOverride)
return;

// Set a flag to check if it should be smart (easier than referencing the type all the time)
bool smart = game.CurrentPlayer.Type == Player.PlayerType.SmartComputer ? true : false;
bool smart = game.CurrentPlayer.Type == Player.PlayerType.SmartComputer;

// Make cards easier to access
List<Card> cards = game.CurrentGamePlayer.Cards;
Expand Down
1 change: 1 addition & 0 deletions Uno/GameView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3b39f4e

Please sign in to comment.