Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBetteridge committed Oct 6, 2016
1 parent 94954e8 commit 4d545e3
Show file tree
Hide file tree
Showing 22 changed files with 641 additions and 705 deletions.
10 changes: 5 additions & 5 deletions Connect4.ExampleBot/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ internal static Game GetGame(Guid playerID, string serverURL)
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.GetAsync($"api/Game/GetGameState?playerID={playerID}").Result;
var httpResponseMessage = httpClient.GetAsync($"api/GameState?playerID={playerID}").Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
var errors = httpResponseMessage.Content.ReadAsStringAsync().Result;
throw new Exception(string.Format("Failed to call {0}. Status {1}. Reason {2}. {3}", "GetGame", (int)httpResponseMessage.StatusCode, httpResponseMessage.ReasonPhrase, errors));
throw new Exception(string.Format("Failed to call {0}. Status {1}. Reason {2}. {3}", "GameState", (int)httpResponseMessage.StatusCode, httpResponseMessage.ReasonPhrase, errors));
}
else
{
Expand All @@ -43,7 +43,7 @@ internal static Guid RegisterTeam(string TeamName, string teamPassword, string s
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.PostAsync($"api/Game/Register?teamName={TeamName}&password={teamPassword}", null).Result;
var httpResponseMessage = httpClient.PostAsync($"api/Register?teamName={TeamName}&password={teamPassword}", null).Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
Expand All @@ -70,7 +70,7 @@ internal static void MakeMove(Guid playerID, string serverURL, int columnNumber)
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.PostAsync($"api/Game/MakeMove?playerID={playerID}&columnNumber={columnNumber}", null).Result;
var httpResponseMessage = httpClient.PostAsync($"api/MakeMove?playerID={playerID}&columnNumber={columnNumber}", null).Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
Expand All @@ -91,7 +91,7 @@ internal static void NewGame(Guid playerID, string serverURL)
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.PostAsync($"api/Game/NewGame?playerID={playerID}", null).Result;
var httpResponseMessage = httpClient.PostAsync($"api/NewGame?playerID={playerID}", null).Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
Expand Down
1 change: 1 addition & 0 deletions Connect4.ExampleBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static void Main(string[] args)
var playerID = API.RegisterTeam(teamName, teamPassword, serverURL);
Console.WriteLine($"PlayerID is {playerID}");


// This is the main game loop
var gameIsComplete = false;
while (!gameIsComplete)
Expand Down
10 changes: 5 additions & 5 deletions Connect4.Manual/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ internal static Game GetGame(Guid playerID, string serverURL)
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.GetAsync($"api/Game/GetGameState?playerID={playerID}").Result;
var httpResponseMessage = httpClient.GetAsync($"api/GameState?playerID={playerID}").Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
var errors = httpResponseMessage.Content.ReadAsStringAsync().Result;
throw new Exception(string.Format("Failed to call {0}. Status {1}. Reason {2}. {3}", "GetGame", (int)httpResponseMessage.StatusCode, httpResponseMessage.ReasonPhrase, errors));
throw new Exception(string.Format("Failed to call {0}. Status {1}. Reason {2}. {3}", "GameState", (int)httpResponseMessage.StatusCode, httpResponseMessage.ReasonPhrase, errors));
}
else
{
Expand All @@ -43,7 +43,7 @@ internal static Guid RegisterTeam(string TeamName, string teamPassword, string s
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.PostAsync($"api/Game/Register?teamName={TeamName}&password={teamPassword}", null).Result;
var httpResponseMessage = httpClient.PostAsync($"api/Register?teamName={TeamName}&password={teamPassword}", null).Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
Expand All @@ -70,7 +70,7 @@ internal static void MakeMove(Guid playerID, string serverURL, int columnNumber)
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.PostAsync($"api/Game/MakeMove?playerID={playerID}&columnNumber={columnNumber}", null).Result;
var httpResponseMessage = httpClient.PostAsync($"api/MakeMove?playerID={playerID}&columnNumber={columnNumber}", null).Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
Expand All @@ -91,7 +91,7 @@ internal static void NewGame(Guid playerID, string serverURL)
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(serverURL);

var httpResponseMessage = httpClient.PostAsync($"api/Game/NewGame?playerID={playerID}", null).Result;
var httpResponseMessage = httpClient.PostAsync($"api/NewGame?playerID={playerID}", null).Result;
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Something has gone wrong
Expand Down
17 changes: 14 additions & 3 deletions Connect4.Manual/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ class Program
private const string teamPassword = "MyPassword";

// The location of the game server
private const string serverURL = "http://yorkdojoconnect4.azurewebsites.net/";
//private const string serverURL = "http://yorkdojoconnect4.azurewebsites.net/";
private const string serverURL = "http://localhost:55011/";

private static void MakeMove(Game game, Guid playerID, string serverURL)
{

// Display the board
var currentColor = Console.ForegroundColor;
Console.WriteLine("");
for (int row = Game.NUMBER_OF_ROWS - 1; row >= 0; row--)
{
Expand All @@ -28,10 +30,14 @@ private static void MakeMove(Game game, Guid playerID, string serverURL)
Console.Write("0");
break;
case CellContent.Red:
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("R");
Console.ForegroundColor = currentColor;
break;
case CellContent.Yellow:
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("Y");
Console.ForegroundColor = currentColor;
break;
default:
break;
Expand All @@ -41,8 +47,13 @@ private static void MakeMove(Game game, Guid playerID, string serverURL)
}
Console.WriteLine("");

Console.WriteLine("Enter the column number");
if (game.RedPlayerID == playerID)
Console.ForegroundColor = ConsoleColor.Red;
else
Console.ForegroundColor = ConsoleColor.Yellow;

Console.WriteLine("Enter the column number");
Console.ForegroundColor = currentColor;
var c = -1;
while (c == -1)
{
Expand Down Expand Up @@ -92,7 +103,7 @@ static void Main(string[] args)
{
Console.WriteLine(e.Message);
}

}
break;

Expand Down
3 changes: 3 additions & 0 deletions Connect4.Tests/Connect4.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<Name>Connect4</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
43 changes: 43 additions & 0 deletions Connect4.Tests/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Loading

0 comments on commit 4d545e3

Please sign in to comment.