Added solution files

This commit is contained in:
Brychan Dempsey 2021-10-06 14:25:26 +13:00
parent 6f8c23cfc8
commit f3fc5632af
4 changed files with 658 additions and 0 deletions

6
App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

556
Program.cs Normal file
View File

@ -0,0 +1,556 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace RollerWheel
{
class Program
{
static string[] gapChars = new string[] { " |##############|", " |--------------|" };
static string[] rollers = new string[] {
" |##############|", " |### ##|", " |########## ##|", " |### ##|", " |### #########|", " |### ##|", // Two
" |##############|", " |### ##|", " |########## ##|", " |### ##|", " |########## ##|", " |### ##|", // Three
" |##############|", " |### ##### ##|", " |### ##### ##|", " |### ##|", " |########## ##|", " |########## ##|", // Four
" |##############|", " |### ##|", " |### #########|", " |### ##|", " |########## ##|", " |### ##|", // Five
" |##############|", " |### ##|", " |### #########|", " |### ##|", " |### ##### ##|", " |### ##|", // Six
" |##############|", " |#### ###|", " |######## ####|", " |####### #####|", " |###### ######|", " |##### #######|" }; // Seven
static int[] titleBools = new int[] {
1,0,0,0,0,0,0,1,1, // First Line
1,0,0,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,1,2,
1,0,0,1,1,1,1,1,1, // Second Line
1,0,0,1,1,1,1,1,1,
1,0,0,1,1,1,0,0,1,
1,1,1,1,0,0,1,1,1,
1,0,0,1,1,1,1,1,1,2,
1,0,0,0,0,0,0,0,1, // Third Line
1,0,0,1,1,1,1,1,1,
1,0,0,1,1,1,0,0,1,
1,1,1,1,0,0,1,1,1,
1,0,0,0,0,0,0,0,1,2,
1,1,1,1,1,1,0,0,1, // Fourth Line
1,0,0,1,1,1,1,1,1,
1,0,0,1,1,1,0,0,1,
1,1,1,1,0,0,1,1,1,
1,1,1,1,1,1,0,0,1,2,
1,0,0,0,0,0,0,0,1, // Fith Line
1,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,1,
1,1,1,1,0,0,1,1,1,
1,0,0,0,0,0,0,0,1,2,
};
#if DEBUG
static bool verbose = false;
#endif
static bool drawTitle()
{
#if DEBUG
if (!verbose)
{
#endif
Console.Clear();
#if DEBUG
}
#endif
#if DEBUG
Console.BackgroundColor = ConsoleColor.Red;
#else
Console.BackgroundColor = ConsoleColor.Green;
#endif
string writeString = "";
for (int r = 0; r < 45; r++)
{
writeString += " ";
}
Console.WriteLine(writeString);
for (int i = 0; i < titleBools.Length; i++)
{
if (titleBools[i] == 2)
{
Console.Write(Environment.NewLine);
}
if (titleBools[i] == 1)
{
switch (Console.BackgroundColor)
{
case ConsoleColor.Green:
Console.Write(" ");
break;
case ConsoleColor.Black:
Console.BackgroundColor = ConsoleColor.Green;
#if DEBUG
Console.BackgroundColor = ConsoleColor.Red;
#endif
Console.Write(" ");
break;
#if DEBUG
case ConsoleColor.Red:
Console.Write(" ");
break;
#endif
}
}
else if (titleBools[i] != 2)
{
switch (Console.BackgroundColor)
{
case ConsoleColor.Black:
Console.Write(" ");
break;
case ConsoleColor.Green:
Console.BackgroundColor = ConsoleColor.Black;
Console.Write(" ");
break;
#if DEBUG
case ConsoleColor.Red:
Console.BackgroundColor = ConsoleColor.Black;
Console.Write(" ");
break;
#endif
}
}
}
Console.WriteLine(writeString);
Console.ResetColor();
#if DEBUG
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("DEBUG VERSION ! DEBUG VERSION ! DEBUG VERSION");
#else
Console.ForegroundColor = ConsoleColor.DarkGreen;
#endif
Console.WriteLine("Slots! A command prompt-based game!");
Console.WriteLine("Written in C# by Brychan Dempsey");
Console.WriteLine("");
drawCommands();
return true;
}
static bool drawCommands()
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Press ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("\'b\'");
Console.ForegroundColor = ConsoleColor.White;
Console.Write(" to begin, ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("\'Esc\'");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(" to cancel.");
Console.Write("Pressing ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Spacebar");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(" at any point will stop the rollers");
return true;
}
// Character ranges are 0-5, 6-11, 12-17, 18-23, 24-29, 30-35
static void Main(string[] args)
{
ConsoleKeyInfo readKey;
#if DEBUG
if(args.Length > 0)
{
if (args[0] == "-v")
{
verbose = true;
}
}
Console.Title = "Slots! - a C# game by Brychan Dempsey - DEBUG VERSION";
#else
Console.Title = "Slots! - a C# game by Brychan Dempsey";
#endif
drawTitle();
redrawnCommands:
#if DEBUG
if (!verbose)
{
#endif
readKey = Console.ReadKey();
if (readKey.Key == ConsoleKey.B)
{
}
else if (readKey.Key == ConsoleKey.Escape)
{
Environment.Exit(0);
}
else
{
Console.WriteLine("Invalid command. Try again:");
drawCommands();
goto redrawnCommands;
}
#if DEBUG
}
#endif
Thread thread1 = new Thread(new ThreadStart(readingKey));
thread1.Start();
if (doRoller())
{
Console.ResetColor();
Console.WriteLine("Success!");
}
else
{
Console.WriteLine("Something Went Wrong!");
}
int finalone = 0;
int finaltwo = 0;
int finalthree = 0;
if (finalindexone + 9 < rollers.Length)
{
finalone = (finalindexone + 9) / 6 + 2;
}
else
{
finalone = ((finalindexone + 9) - rollers.Length) / 6 + 2;
}
if (finalindextwo + 9 < rollers.Length)
{
finaltwo = (finalindextwo + 9) / 6 + 2;
}
else
{
finaltwo = ((finalindextwo + 9) - rollers.Length) / 6 + 2;
}
if (finalindexthree + 9 < rollers.Length)
{
finalthree = (finalindexthree + 9) / 6 + 2;
}
else
{
finalthree = ((finalindexthree + 9) - rollers.Length) / 6 + 2;
}
Console.WriteLine("Final numbers are: {0} {1} {2}", finalone, finaltwo, finalthree);
#if DEBUG
Console.WriteLine("Final numbers are: {0} {1} {2}", finalindexone, finalindextwo, finalindexthree);
Console.WriteLine("Final numbers are: {0} {1} {2}", (finalindexone + 9)/6, (finalindextwo + 9)/6, (finalindexthree+9)/6);
#endif
finalExitPrompt:
readKey = Console.ReadKey();
if (readKey.Key == ConsoleKey.Escape)
{
Environment.Exit(0);
}
else
{
goto finalExitPrompt;
}
}
public static void readingKey()
{
while (!threelocked)
{
ConsoleKeyInfo readKey = Console.ReadKey();
if (readKey.Key == ConsoleKey.Spacebar)
{
Console.Beep();
Random rand = new Random();
//int wait = rand.Next() / 5000000;
// Thread.Sleep(wait);
if (onelocked)
{
if (twolocked)
{
finalindexthree = rollerthreeIndex;
#if DEBUG
Console.Write(finalindexthree);
#endif
threelocked = true;
}
else
{
finalindextwo = rollertwoIndex;
twolocked = true;
}
}
else
{
finalindexone = rolleroneIndex;
onelocked = true;
}
}
//Thread.Sleep(300);
}
}
static void clearScreen()
{
#if DEBUG
if (!verbose)
{
#endif
Console.SetCursorPosition(0, 0);
#if DEBUG
}
#endif
}
/// <summary>
/// Begins rolling the rollers
/// </summary>
/// <returns>true if rolling was successful</returns>
static bool doRoller()
{
int firstStarting = 7;
int secondStarting = 7;
int thirdStarting = 7;
drawDisplay(firstStarting, secondStarting, thirdStarting);
return true;
}
static int rolleroneIndex = 0;
static int rollertwoIndex = 0;
static int rollerthreeIndex = 0;
static int finalindexone = 0;
static int finalindextwo = 0;
static int finalindexthree = 0;
static bool onelocked = false;
static bool twolocked = false;
static bool threelocked = false;
/// <summary>
/// Draws the display using the numbers provided
/// </summary>
/// <param name="startone">number for the first roller</param>
/// <param name="starttwo">number for the second roller</param>
/// <param name="startthree">number for the third roller</param>
/// <returns>Returns true if successfull</returns>
static bool drawDisplay(int startone, int starttwo, int startthree)
{
createString(startone, starttwo, startthree);
//for (int r = 0; r < 10000; r++)
while(!threelocked)
{
if (onelocked)
{
rolleroneIndex = finalindexone;
}
if (twolocked)
{
rollertwoIndex = finalindextwo;
}
if (threelocked)
{
rollerthreeIndex = finalindexthree;
}
clearScreen();
for (int i = 0; i < 20; i++)
{
if (i < 3 || i > 15)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
}
else if (i < 6 || i > 11)
{
Console.ForegroundColor = ConsoleColor.Gray;
}
else if (i > 5 && i < 12)
{
Console.ForegroundColor = ConsoleColor.White;
}
if (i == 0 || i == 19)
{
Console.WriteLine("\t" + gapChars[1] + gapChars[1] + gapChars[1]);
}
if ((rolleroneIndex + i) == rollers.Length)
{
rolleroneIndex = 0 - i;
}
if ((rollertwoIndex + i) == rollers.Length)
{
rollertwoIndex = 0 - i;
}
if ((rollerthreeIndex + i) == rollers.Length)
{
rollerthreeIndex = 0 - i;
}
if (i > 0 && i < 19)
{
if (i == 10)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
#if DEBUG
int currentPos = Console.CursorTop;
Console.WriteLine("--------" + spinFirst(i) + spinSecond(i) + spinThird(i) + "--------\t\t\t");
if (!verbose)
{
Console.SetCursorPosition(0, currentPos);
Console.WriteLine("--------" + spinFirst(i) + spinSecond(i) + spinThird(i) + "-------- {0} {1} {2}", rolleroneIndex, rollertwoIndex, rollerthreeIndex);
}
#else
Console.WriteLine("--------" + spinFirst(i) + spinSecond(i) + spinThird(i) + "--------");
#endif
}
else
{
Console.WriteLine("\t" + spinFirst(i) + spinSecond(i) + spinThird(i));
}
}
}
if (rolleroneIndex < 0)
{
rolleroneIndex = rollers.Length + rolleroneIndex;
}
if (rollertwoIndex < 0)
{
rollertwoIndex = rollers.Length + rollertwoIndex;
}
if (rollerthreeIndex < 0)
{
rollerthreeIndex = rollers.Length + rollerthreeIndex;
}
int currentPos2 = Console.CursorTop;
#if DEBUG
if (!verbose)
{
Console.WriteLine("--------\t\t\t");
Console.SetCursorPosition(0, currentPos2);
Console.WriteLine("-------- {0} {1} {2}", rolleroneIndex, rollertwoIndex, rollerthreeIndex);
}
#endif
rolleroneIndex += 1;
rollertwoIndex += 1;
rollerthreeIndex += 1;
#if DEBUG
Thread.Sleep(500);
#else
Thread.Sleep(5);
#endif
}
return true;
}
static string spinFirst(int i)
{
if (onelocked)
{
return rollers[rolleroneIndex + i];
}
else
{
return rollers[rolleroneIndex + i];
}
}
static string spinSecond(int i)
{
if (twolocked)
{
return rollers[rollertwoIndex + i];
}
else
{
return rollers[rollertwoIndex + i];
}
}
static string spinThird(int i)
{
if (threelocked)
{
return rollers[rollerthreeIndex + i];
}
else
{
return rollers[rollerthreeIndex + i];
}
}
static void createString(int firstnumber, int secondnumber, int thirdnumber)
{
switch (firstnumber)
{
case 2:
rolleroneIndex = 0;
break;
case 3:
rolleroneIndex = 6;
break;
case 4:
rolleroneIndex = 12;
break;
case 5:
rolleroneIndex = 18;
break;
case 6:
rolleroneIndex = 24;
break;
case 7:
rolleroneIndex = 30;
break;
}
switch (secondnumber)
{
case 2:
rollertwoIndex = 0;
break;
case 3:
rollertwoIndex = 6;
break;
case 4:
rollertwoIndex = 12;
break;
case 5:
rollertwoIndex = 18;
break;
case 6:
rollertwoIndex = 24;
break;
case 7:
rollertwoIndex = 30;
break;
}
switch (thirdnumber)
{
case 2:
rollerthreeIndex = 0;
break;
case 3:
rollerthreeIndex = 6;
break;
case 4:
rollerthreeIndex = 12;
break;
case 5:
rollerthreeIndex = 18;
break;
case 6:
rollerthreeIndex = 24;
break;
case 7:
rollerthreeIndex = 30;
break;
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RollerWheel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RollerWheel")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("49d923ca-4a31-4c41-8389-ba6fbaa74c43")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

60
RollerWheel.csproj Normal file
View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{49D923CA-4A31-4C41-8389-BA6FBAA74C43}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RollerWheel</RootNamespace>
<AssemblyName>RollerWheel</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>