Initial Commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/App1/bin/Debug/
|
||||
BIN
.vs/App1/v15/.suo
Normal file
BIN
.vs/App1/v15/.suo
Normal file
Binary file not shown.
0
.vs/App1/v15/Server/sqlite3/db.lock
Normal file
0
.vs/App1/v15/Server/sqlite3/db.lock
Normal file
BIN
.vs/App1/v15/Server/sqlite3/storage.ide
Normal file
BIN
.vs/App1/v15/Server/sqlite3/storage.ide
Normal file
Binary file not shown.
3
.vs/ProjectSettings.json
Normal file
3
.vs/ProjectSettings.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"CurrentProjectSetting": null
|
||||
}
|
||||
7
.vs/VSWorkspaceState.json
Normal file
7
.vs/VSWorkspaceState.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ExpandedNodes": [
|
||||
""
|
||||
],
|
||||
"SelectedNode": "\\App1.sln",
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
||||
BIN
.vs/slnx.sqlite
Normal file
BIN
.vs/slnx.sqlite
Normal file
Binary file not shown.
25
App1.sln
Normal file
25
App1.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2027
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App1", "App1\App1.csproj", "{F5C8294B-E041-4D88-A50C-98A0D6BB99CB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F5C8294B-E041-4D88-A50C-98A0D6BB99CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F5C8294B-E041-4D88-A50C-98A0D6BB99CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F5C8294B-E041-4D88-A50C-98A0D6BB99CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F5C8294B-E041-4D88-A50C-98A0D6BB99CB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3148AB21-97F4-462B-A875-B3BD490D1295}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
57
App1/.vscode/launch.json
vendored
Normal file
57
App1/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "internalConsole",
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"launchBrowser": {
|
||||
"enabled": true,
|
||||
"args": "${auto-detect-url}",
|
||||
"windows": {
|
||||
"command": "cmd.exe",
|
||||
"args": "/C start ${auto-detect-url}"
|
||||
},
|
||||
"osx": {
|
||||
"command": "open"
|
||||
},
|
||||
"linux": {
|
||||
"command": "xdg-open"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||
24
App1/.vscode/tasks.json
vendored
Normal file
24
App1/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"type": "shell",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
// Ask msbuild to generate full paths for file names.
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/t:build"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
// Reveal the output only if unrecognized errors occur.
|
||||
"reveal": "silent"
|
||||
},
|
||||
// Use the standard MS compiler pattern to detect errors, warnings and infos
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
6
App1/App.config
Normal file
6
App1/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
</configuration>
|
||||
58
App1/App1.csproj
Normal file
58
App1/App1.csproj
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{F5C8294B-E041-4D88-A50C-98A0D6BB99CB}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>App1</RootNamespace>
|
||||
<AssemblyName>App1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</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="Encryption.cs" />
|
||||
<Compile Include="GuessARandomNumber.cs" />
|
||||
<Compile Include="ReadAndWrite.cs" />
|
||||
<Compile Include="TextAdventure.cs" />
|
||||
<Compile Include="LoggedIn.cs" />
|
||||
<Compile Include="LogIn.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
52
App1/Encryption.cs
Normal file
52
App1/Encryption.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace App1 {
|
||||
class encryption {
|
||||
static readonly string PasswordHash = "P@@Sw0rd"; //password hash
|
||||
static readonly string SaltKey = "S@LT&KEY";
|
||||
static readonly string VIKey = "@1B2c3D4e5F6g7H8";
|
||||
|
||||
|
||||
public string Encrypt(string plainText) //encryot plaintext
|
||||
{
|
||||
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
|
||||
|
||||
byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(256 / 8);
|
||||
var symmetricKey = new RijndaelManaged() { Mode = CipherMode.CBC, Padding = PaddingMode.Zeros };
|
||||
var encryptor = symmetricKey.CreateEncryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));
|
||||
|
||||
byte[] cipherTextBytes;
|
||||
|
||||
using (var memoryStream = new MemoryStream()) {
|
||||
using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) {
|
||||
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
|
||||
cryptoStream.FlushFinalBlock();
|
||||
cipherTextBytes = memoryStream.ToArray();
|
||||
cryptoStream.Close();
|
||||
}
|
||||
memoryStream.Close();
|
||||
}
|
||||
return Convert.ToBase64String(cipherTextBytes);
|
||||
}
|
||||
|
||||
public string Decrypt(string encryptedText) //decrypts encrypted text
|
||||
{
|
||||
byte[] cipherTextBytes = Convert.FromBase64String(encryptedText);
|
||||
byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(256 / 8);
|
||||
var symmetricKey = new RijndaelManaged() { Mode = CipherMode.CBC, Padding = PaddingMode.None };
|
||||
|
||||
var decryptor = symmetricKey.CreateDecryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));
|
||||
var memoryStream = new MemoryStream(cipherTextBytes);
|
||||
var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
|
||||
byte[] plainTextBytes = new byte[cipherTextBytes.Length];
|
||||
|
||||
int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
|
||||
memoryStream.Close();
|
||||
cryptoStream.Close();
|
||||
return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount).TrimEnd("\0".ToCharArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
48
App1/GuessARandomNumber.cs
Normal file
48
App1/GuessARandomNumber.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace App1 {
|
||||
class GuessRandom {
|
||||
public void start() {
|
||||
Console.Clear();
|
||||
|
||||
Random rnd = new Random();
|
||||
int RandomNumber = rnd.Next(1, 100);
|
||||
|
||||
Console.WriteLine("A random number has been generated, you have to guess it. " +
|
||||
"Each guess you will be told wheather your guess was higher or lower");
|
||||
|
||||
int guess;
|
||||
bool correct = false;
|
||||
while (correct == false) {
|
||||
Console.Write("Your guess:");
|
||||
|
||||
string stringguess = Console.ReadLine();
|
||||
try {
|
||||
guess = int.Parse(stringguess);
|
||||
Console.WriteLine();
|
||||
|
||||
if (guess == RandomNumber) {
|
||||
break;
|
||||
} else if (guess < RandomNumber) {
|
||||
Console.WriteLine("The number is greater than your guess");
|
||||
Console.WriteLine();
|
||||
} else if (guess > RandomNumber) {
|
||||
Console.WriteLine("The number is less than your guess");
|
||||
Console.WriteLine();
|
||||
}
|
||||
} catch (FormatException) {
|
||||
Console.WriteLine("{0} is not a number", stringguess);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Correct, the number was {0}", RandomNumber);
|
||||
Console.WriteLine("Press enter to return to your account");
|
||||
Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
258
App1/LogIn.cs
Normal file
258
App1/LogIn.cs
Normal file
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace App1 {
|
||||
class LogIn {
|
||||
public void start() {
|
||||
Console.Clear();
|
||||
Console.WriteLine("Would you like to (L)ogin or (S)ign up?"); //login / signup chooser
|
||||
var response = Console.ReadKey();
|
||||
switch (response.KeyChar) {
|
||||
case 'L':
|
||||
case 'l':
|
||||
login();
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
signup();
|
||||
break;
|
||||
}
|
||||
start();
|
||||
}
|
||||
|
||||
public void signup() {
|
||||
var Encrypt = new encryption();
|
||||
var rw = new ReadAndWrite();
|
||||
|
||||
Console.Clear();
|
||||
|
||||
string username = enterUsername(); //calls enterusernmae - username is returned
|
||||
|
||||
string email = enterEmail(); //calls enteremail - email is returned
|
||||
|
||||
int age = enterAge(); //calls enterage - age is returned
|
||||
|
||||
Console.Write("Password: ");
|
||||
string password = getPassword();
|
||||
|
||||
Random rnd = new Random();
|
||||
int recoverycode = rnd.Next(100000000, 999999999); // picks recovery code
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Your recovery code is {0}, if you have " +
|
||||
"forgoten your password you can use this to retreive your " +
|
||||
"password.", recoverycode);
|
||||
|
||||
bool admin = false;
|
||||
if (username == "Plane000_BEN") // sets admin for specified username
|
||||
{
|
||||
admin = true;
|
||||
}
|
||||
|
||||
rw.write(username, email, age, password, recoverycode, admin);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("SignUp Succesfull, enter to continue");
|
||||
Console.ReadKey();
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
public void login() {
|
||||
var Encrypt = new encryption();
|
||||
var rw = new ReadAndWrite();
|
||||
|
||||
Console.Clear();
|
||||
|
||||
string username = null;
|
||||
bool findfile = false;
|
||||
while (findfile == false) {
|
||||
Console.Write("Username:");
|
||||
username = Console.ReadLine();
|
||||
|
||||
if (File.Exists(username + ".asd")) {
|
||||
break;
|
||||
} else {
|
||||
Console.WriteLine("The user you have entered does not exist");
|
||||
Console.WriteLine("Press enter to try again and S to signup");
|
||||
var response = Console.ReadKey();
|
||||
switch (response.KeyChar) {
|
||||
case 'S':
|
||||
case 's':
|
||||
signup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string encryptedpassword = rw.readEncryptedPassword(username);
|
||||
|
||||
bool passwordcorrect = false;
|
||||
while (!passwordcorrect) {
|
||||
Console.Write("Password:");
|
||||
string enteredpassword = Encrypt.Encrypt(getPassword());
|
||||
|
||||
if (enteredpassword == encryptedpassword) {
|
||||
LoginSuccess(username);
|
||||
return;
|
||||
} else {
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("The password you have entered is incorrect " +
|
||||
"press enter to try again and L to log in with a " +
|
||||
"different user");
|
||||
Console.WriteLine("If you have forgotten your password press " +
|
||||
"R to recover your account");
|
||||
var response = Console.ReadKey();
|
||||
switch (response.KeyChar) {
|
||||
case 'L':
|
||||
case 'l':
|
||||
login();
|
||||
break;
|
||||
case 'R':
|
||||
case 'r':
|
||||
AccountRecovery(username);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public void LoginSuccess(string username) {
|
||||
var i = new LoggedIn();
|
||||
i.loggedIn(username);
|
||||
}
|
||||
|
||||
private void AccountRecovery(string username) {
|
||||
var Encrypt = new encryption();
|
||||
var rw = new ReadAndWrite();
|
||||
|
||||
Console.Clear();
|
||||
|
||||
string encryptedpassword = rw.readEncryptedPassword(username);
|
||||
string encryptedrecovery = rw.readEncryptedRecovery(username);
|
||||
|
||||
bool recoverycorrect = false;
|
||||
while (recoverycorrect == false) {
|
||||
Console.Write("Please enter the recovery code given to you at account " +
|
||||
"creation: ");
|
||||
|
||||
string recovery = Encrypt.Encrypt(Console.ReadLine());
|
||||
|
||||
if (recovery == encryptedrecovery) {
|
||||
|
||||
Console.WriteLine("Your password is {0}", Encrypt.Decrypt(encryptedpassword));
|
||||
Console.WriteLine("Press enter to return");
|
||||
Console.ReadKey();
|
||||
return;
|
||||
} else {
|
||||
Console.WriteLine("Your recovery code was incorrect");
|
||||
Console.WriteLine("Press enter to try again or S to signup");
|
||||
var response = Console.ReadKey();
|
||||
switch (response.KeyChar) {
|
||||
case 'S':
|
||||
case 's':
|
||||
signup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private string enterUsername() {
|
||||
bool usernamecorrect = false;
|
||||
string username = null;
|
||||
while (!usernamecorrect) {
|
||||
Console.Write("Username: ");
|
||||
username = Console.ReadLine();
|
||||
|
||||
if (username.Contains(" ")) {
|
||||
Console.WriteLine("That username is not valid");
|
||||
} else if (username == "") {
|
||||
Console.WriteLine("That username is not valid");
|
||||
} else if (File.Exists(username + ".asd")) {
|
||||
Console.WriteLine("That account is taken");
|
||||
} else {
|
||||
usernamecorrect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
public int enterAge() {
|
||||
bool agepassed = false;
|
||||
int age = 0;
|
||||
while (!agepassed) {
|
||||
Console.Write("Age: ");
|
||||
string ReadLine = Console.ReadLine();
|
||||
try {
|
||||
age = int.Parse(ReadLine);
|
||||
break;
|
||||
} catch (FormatException) {
|
||||
Console.WriteLine("{0} is not an number", ReadLine);
|
||||
} catch (OverflowException) {
|
||||
Console.WriteLine("Thats not your age");
|
||||
}
|
||||
}
|
||||
return age;
|
||||
}
|
||||
|
||||
public string enterEmail() {
|
||||
bool checkemail = false;
|
||||
string email = null;
|
||||
while (checkemail == false) {
|
||||
Console.Write("Email: ");
|
||||
email = Console.ReadLine();
|
||||
checkemail = checkEmail(email);
|
||||
|
||||
if (checkemail) {
|
||||
break;
|
||||
} else {
|
||||
Console.WriteLine("The email you entered is not valid");
|
||||
}
|
||||
}
|
||||
return email;
|
||||
}
|
||||
|
||||
public bool checkEmail(string email) {
|
||||
bool passed = false;
|
||||
|
||||
if (email.Contains("@") && email.Contains(".")) {
|
||||
passed = true;
|
||||
} else {
|
||||
passed = false;
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
public string getPassword() {
|
||||
var pwd = new SecureString();
|
||||
while (true) {
|
||||
ConsoleKeyInfo i = Console.ReadKey(true);
|
||||
if (i.Key == ConsoleKey.Enter) {
|
||||
break;
|
||||
} else if (i.Key == ConsoleKey.Backspace) {
|
||||
if (pwd.Length > 0) {
|
||||
pwd.RemoveAt(pwd.Length - 1);
|
||||
Console.Write("\b \b");
|
||||
}
|
||||
} else {
|
||||
pwd.AppendChar(i.KeyChar);
|
||||
Console.Write("*");
|
||||
}
|
||||
}
|
||||
string password = new System.Net.NetworkCredential(string.Empty, pwd).Password;
|
||||
return Convert.ToString(password);
|
||||
}
|
||||
}
|
||||
}
|
||||
198
App1/LoggedIn.cs
Normal file
198
App1/LoggedIn.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace App1 {
|
||||
class LoggedIn {
|
||||
public void loggedIn(string username) {
|
||||
var Encrypt = new encryption();
|
||||
var Login = new LogIn();
|
||||
var TextAdventure = new Game();
|
||||
var GuessRandom = new GuessRandom();
|
||||
var rw = new ReadAndWrite();
|
||||
|
||||
string[] encrypteddata = rw.readEncrypted(username);
|
||||
string[] data = rw.read(username);
|
||||
string email = data[1];
|
||||
int age = int.Parse(data[2]);
|
||||
string password = data[3];
|
||||
bool admin = Convert.ToBoolean(data[5]);
|
||||
|
||||
Console.Clear();
|
||||
|
||||
string isadmin = null;
|
||||
if (admin) {
|
||||
isadmin = "you are signed in as an administrator";
|
||||
}
|
||||
|
||||
Console.WriteLine("Welcome {0}, {1}", username, isadmin);
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("You have access to:");
|
||||
Console.WriteLine();
|
||||
|
||||
if (admin) {
|
||||
Console.WriteLine("(0) Admin tools");
|
||||
}
|
||||
|
||||
Console.WriteLine("(1) Adventure Game");
|
||||
Console.WriteLine("(2) Guess a Random Number Game");
|
||||
Console.WriteLine("(3)");
|
||||
Console.WriteLine("(4)");
|
||||
Console.WriteLine("(5) Reveiw and change your details");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Press enter to logout");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
switch (response.KeyChar) {
|
||||
case '0':
|
||||
adminTools(admin, username, encrypteddata);
|
||||
break;
|
||||
case '1':
|
||||
TextAdventure.start();
|
||||
break;
|
||||
case '2':
|
||||
GuessRandom.start();
|
||||
break;
|
||||
case '3':
|
||||
string[] thing = rw.read(username);
|
||||
break;
|
||||
case '4':
|
||||
break;
|
||||
case '5':
|
||||
userDetails(username);
|
||||
break;
|
||||
}
|
||||
switch (response.Key) {
|
||||
case ConsoleKey.Enter:
|
||||
Login.start();
|
||||
return;
|
||||
}
|
||||
loggedIn(username);
|
||||
}
|
||||
|
||||
private void adminTools(bool admin, string username, string[] encrypteddata) {
|
||||
Console.Clear();
|
||||
|
||||
if (admin) {
|
||||
|
||||
Console.WriteLine("Welcome {0}, you are in the admin control panel", username);
|
||||
|
||||
|
||||
|
||||
Console.ReadKey();
|
||||
|
||||
} else {
|
||||
Console.WriteLine("You are not signed in as an administrator");
|
||||
Console.WriteLine("Press enter to return");
|
||||
Console.ReadKey();
|
||||
loggedIn(username);
|
||||
}
|
||||
}
|
||||
|
||||
private void userDetails(string username) {
|
||||
var get = new LogIn();
|
||||
var Encrypt = new encryption();
|
||||
var rw = new ReadAndWrite();
|
||||
|
||||
string[] encrypteddata = rw.readEncrypted(username);
|
||||
|
||||
string[] data = rw.read(username);
|
||||
string email = data[1];
|
||||
int age = int.Parse(data[2]);
|
||||
string password = data[3];
|
||||
int recoverycode = int.Parse(data[4]);
|
||||
bool admin = Convert.ToBoolean(data[5]);
|
||||
|
||||
Console.Clear();
|
||||
|
||||
Console.WriteLine(username + ", here are your details:");
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("Email: " + email);
|
||||
Console.WriteLine("Age: " + age);
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("(1) Update email");
|
||||
Console.WriteLine("(2) Update age");
|
||||
Console.WriteLine("(3) Change password");
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("Press enter to save and return");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
switch (response.KeyChar) {
|
||||
case '1':
|
||||
email = updateEmail(email);
|
||||
break;
|
||||
case '2':
|
||||
age = updateAge(age);
|
||||
break;
|
||||
case '3':
|
||||
password = changePassword(password);
|
||||
break;
|
||||
}
|
||||
|
||||
rw.write(username, email, age, password, recoverycode, admin);
|
||||
|
||||
loggedIn(username);
|
||||
|
||||
switch (response.Key) {
|
||||
case ConsoleKey.Enter:
|
||||
loggedIn(username);
|
||||
break;
|
||||
}
|
||||
|
||||
userDetails(username);
|
||||
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private string updateEmail(string email) {
|
||||
var get = new LogIn();
|
||||
|
||||
Console.Clear();
|
||||
|
||||
email = get.enterEmail();
|
||||
Console.WriteLine("Your new email is: " + email);
|
||||
Console.WriteLine("Press enter to return");
|
||||
Console.ReadKey();
|
||||
|
||||
return email;
|
||||
}
|
||||
|
||||
private int updateAge(int age) {
|
||||
var get = new LogIn();
|
||||
|
||||
Console.Clear();
|
||||
age = get.enterAge();
|
||||
Console.WriteLine("Your new age is: " + age);
|
||||
Console.WriteLine("Press enter to return");
|
||||
Console.ReadKey();
|
||||
|
||||
return age;
|
||||
}
|
||||
|
||||
private string changePassword(string password) {
|
||||
var get = new LogIn();
|
||||
|
||||
Console.Clear();
|
||||
Console.WriteLine("Your password is: {0}", password);
|
||||
Console.WriteLine("Press enter to return or space to continue");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
switch (response.Key) {
|
||||
case ConsoleKey.Enter:
|
||||
return password;
|
||||
case ConsoleKey.Spacebar:
|
||||
break;
|
||||
}
|
||||
|
||||
Console.Write("Password: ");
|
||||
password = get.getPassword();
|
||||
|
||||
return password;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
App1/Program.cs
Normal file
13
App1/Program.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace App1 {
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.BackgroundColor = ConsoleColor.Black;
|
||||
|
||||
var i = new LogIn(); //calls login file LogIn.cs
|
||||
i.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
App1/Properties/AssemblyInfo.cs
Normal file
36
App1/Properties/AssemblyInfo.cs
Normal 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("App1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("App1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[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("f5c8294b-e041-4d88-a50c-98a0d6bb99cb")]
|
||||
|
||||
// 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")]
|
||||
84
App1/ReadAndWrite.cs
Normal file
84
App1/ReadAndWrite.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace App1 {
|
||||
class ReadAndWrite {
|
||||
public string[] read(string username) {
|
||||
var Encrypt = new encryption();
|
||||
|
||||
string LoginData64 = File.ReadAllText(username + ".asd");
|
||||
var LoginDataBytes = Convert.FromBase64String(LoginData64);
|
||||
string LoginData = Encoding.UTF8.GetString(LoginDataBytes);
|
||||
|
||||
string[] encrypteddata = LoginData.Split(',');
|
||||
|
||||
string email = Encrypt.Decrypt(encrypteddata[1]);
|
||||
string age = Encrypt.Decrypt(encrypteddata[2]);
|
||||
string password = Encrypt.Decrypt(encrypteddata[3]);
|
||||
string recoverycode = Encrypt.Decrypt(encrypteddata[4]);
|
||||
string admin = Encrypt.Decrypt(encrypteddata[5]);
|
||||
|
||||
string[] data = new string[] { username, email, age, password, recoverycode, admin };
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public string[] readEncrypted(string username) {
|
||||
string LoginData64 = File.ReadAllText(username + ".asd");
|
||||
var LoginDataBytes = Convert.FromBase64String(LoginData64);
|
||||
string LoginData = Encoding.UTF8.GetString(LoginDataBytes);
|
||||
|
||||
string[] encrypteddata = LoginData.Split(',');
|
||||
|
||||
return encrypteddata;
|
||||
}
|
||||
|
||||
public string readEncryptedPassword(string username) {
|
||||
string LoginData64 = File.ReadAllText(username + ".asd");
|
||||
var LoginDataBytes = Convert.FromBase64String(LoginData64);
|
||||
string LoginData = Encoding.UTF8.GetString(LoginDataBytes);
|
||||
|
||||
string[] encrypteddata = LoginData.Split(',');
|
||||
|
||||
string encryptedpassword = encrypteddata[3];
|
||||
|
||||
return encryptedpassword;
|
||||
}
|
||||
|
||||
public string readEncryptedRecovery(string username) {
|
||||
string LoginData64 = File.ReadAllText(username + ".asd");
|
||||
var LoginDataBytes = Convert.FromBase64String(LoginData64);
|
||||
string LoginData = Encoding.UTF8.GetString(LoginDataBytes);
|
||||
|
||||
string[] encrypteddata = LoginData.Split(',');
|
||||
|
||||
string encryptedrecovery = encrypteddata[4];
|
||||
|
||||
return encryptedrecovery;
|
||||
}
|
||||
|
||||
public void write(string username, string email, int age,
|
||||
string password, int recoverycode, bool admin) {
|
||||
var Encrypt = new encryption();
|
||||
|
||||
string EncryptedEmail = Encrypt.Encrypt(email); // encrypts user data
|
||||
string EncryptedAge = Encrypt.Encrypt(Convert.ToString(age));
|
||||
string EncryptedPassword = Encrypt.Encrypt(password);
|
||||
string EncryptedRecovery = Encrypt.Encrypt(Convert.ToString(recoverycode));
|
||||
string EncryptedAdmin = Encrypt.Encrypt(Convert.ToString(admin));
|
||||
|
||||
string WriteFileString = username + "," + EncryptedEmail + "," + EncryptedAge
|
||||
+ "," + EncryptedPassword + "," + EncryptedRecovery + ","
|
||||
+ EncryptedAdmin; // makes user data one string
|
||||
|
||||
var WriteFileBytes = Encoding.UTF8.GetBytes(WriteFileString);
|
||||
string WriteFile64 = Convert.ToBase64String(WriteFileBytes); // converts to base 64
|
||||
|
||||
File.WriteAllText(username + ".asd", WriteFile64); // writes to file
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
665
App1/TextAdventure.cs
Normal file
665
App1/TextAdventure.cs
Normal file
@@ -0,0 +1,665 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace App1 {
|
||||
class Game {
|
||||
public void start() {
|
||||
Console.BackgroundColor = ConsoleColor.White;
|
||||
Console.ForegroundColor = ConsoleColor.Black;
|
||||
|
||||
Introduction();
|
||||
}
|
||||
|
||||
public string Level { get; private set; } = "Introduction";
|
||||
public int Food { get; private set; } = 10;
|
||||
public int Water { get; private set; } = 10;
|
||||
public int Comfort { get; private set; } = 5;
|
||||
public int PlayerHunger { get; private set; } = 10;
|
||||
public int PlayerHealth { get; private set; } = 10;
|
||||
public int Radiation { get; private set; } = 0;
|
||||
public int TimePassed { get; private set; } = 0;
|
||||
public bool EatSuccess { get; private set; } = false;
|
||||
public bool RadiationSuit { get; private set; } = false;
|
||||
|
||||
|
||||
private void Save() {
|
||||
Console.Clear();
|
||||
|
||||
string SaveGame = Level + "," + Food + "," + Water + "," + Comfort + ","
|
||||
+ PlayerHealth + "," + PlayerHunger + "," + Radiation + "," + RadiationSuit;
|
||||
|
||||
var SaveGameBytes = Encoding.UTF8.GetBytes(SaveGame);
|
||||
string SaveGame64 = Convert.ToBase64String(SaveGameBytes);
|
||||
|
||||
Console.WriteLine("Saving the game will overwrite any existing saves, are you sure you want to continue? Y/N");
|
||||
var response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case 'Y':
|
||||
case 'y':
|
||||
File.WriteAllText("Save.sav", SaveGame64);
|
||||
return;
|
||||
case 'N':
|
||||
case 'n':
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void Load() {
|
||||
Console.Clear();
|
||||
|
||||
if (File.Exists("Save.sav")) {
|
||||
int LoadSuccess = 1;
|
||||
|
||||
while (LoadSuccess == 1) {
|
||||
if (Food > 10) {
|
||||
LoadSuccess = 0;
|
||||
} else if (Water > 10) {
|
||||
LoadSuccess = 0;
|
||||
} else if (PlayerHealth > 10) {
|
||||
LoadSuccess = 0;
|
||||
} else if (Comfort > 10) {
|
||||
LoadSuccess = 0;
|
||||
} else {
|
||||
string content64 = File.ReadAllText("Save.sav");
|
||||
var contentbytes = Convert.FromBase64String(content64);
|
||||
string content = Encoding.UTF8.GetString(contentbytes);
|
||||
|
||||
string[] variables = content.Split(',');
|
||||
|
||||
string level = variables[0];
|
||||
Food = int.Parse(variables[1]);
|
||||
Water = int.Parse(variables[2]);
|
||||
Comfort = int.Parse(variables[3]);
|
||||
PlayerHealth = int.Parse(variables[4]);
|
||||
PlayerHunger = int.Parse(variables[5]);
|
||||
Radiation = int.Parse(variables[6]);
|
||||
RadiationSuit = Convert.ToBoolean(variables[7]);
|
||||
|
||||
Console.WriteLine("Succesfully loaded the games state");
|
||||
Console.WriteLine("Press enter to continue");
|
||||
Console.ReadKey();
|
||||
|
||||
switch (level) {
|
||||
case "Introduction":
|
||||
Introduction();
|
||||
break;
|
||||
case "GameStart":
|
||||
GameStart();
|
||||
break;
|
||||
case "Branch_1_1":
|
||||
Branch_1_1();
|
||||
break;
|
||||
case "Branch_2_1":
|
||||
Branch_2_1();
|
||||
break;
|
||||
case "Branch_3_1":
|
||||
Branch_3_1();
|
||||
break;
|
||||
case "Branch_1_1_1":
|
||||
Branch_1_1_1();
|
||||
break;
|
||||
case "Branch_1_1_2":
|
||||
Branch_1_1_2();
|
||||
break;
|
||||
case "Branch_1_1_3":
|
||||
Branch_1_1_3();
|
||||
break;
|
||||
case "Branch_2_1_1":
|
||||
Branch_2_1_1();
|
||||
break;
|
||||
case "Branch_2_1_2":
|
||||
Branch_2_1_2();
|
||||
break;
|
||||
case "Branch_2_1_3":
|
||||
Branch_2_1_3();
|
||||
break;
|
||||
case "Branch_3_1_1":
|
||||
Branch_3_1_1();
|
||||
break;
|
||||
case "Branch_3_1_2":
|
||||
Branch_3_1_2();
|
||||
break;
|
||||
case "Branch_3_1_3":
|
||||
Branch_3_1_3();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (LoadSuccess == 0) {
|
||||
Console.WriteLine("The load failed, maybe you eddited a value or there is an invalid entry");
|
||||
Console.WriteLine("Press enter to continue");
|
||||
Console.ReadKey();
|
||||
Introduction();
|
||||
}
|
||||
} else {
|
||||
Console.WriteLine("There is no savegame available");
|
||||
Console.WriteLine("Press enter to continue");
|
||||
Console.ReadKey();
|
||||
Introduction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Engine
|
||||
|
||||
private void NextLevelFunction() {
|
||||
Timepassed();
|
||||
|
||||
}
|
||||
|
||||
private void Timepassed() {
|
||||
//timepased based on moves, call at every function start
|
||||
}
|
||||
|
||||
private string GetRadiation() {
|
||||
string radiation = null;
|
||||
|
||||
radiation = Convert.ToString(Radiation);
|
||||
|
||||
if (Radiation == 10) {
|
||||
YouDied("Radiation Poisoning");
|
||||
}
|
||||
|
||||
return radiation;
|
||||
}
|
||||
|
||||
public void RadiationZone(int FalloutLevel) //DO DIS WHERE IF THERE IS LESS FALLOUT THEN LESS RADIATION POISONING
|
||||
{
|
||||
if (RadiationSuit == false) {
|
||||
if (FalloutLevel >= 8) {
|
||||
Radiation++;
|
||||
Radiation++;
|
||||
Radiation++;
|
||||
} else if (FalloutLevel == 7 || FalloutLevel == 6) {
|
||||
Radiation++;
|
||||
Radiation++;
|
||||
} else if (FalloutLevel == 5 || FalloutLevel == 4 || FalloutLevel == 3) {
|
||||
Radiation++;
|
||||
}
|
||||
}
|
||||
|
||||
if (Radiation == 8 || Radiation == 7) {
|
||||
PlayerHealth--;
|
||||
} else if (Radiation > 9) {
|
||||
PlayerHealth--;
|
||||
PlayerHealth--;
|
||||
}
|
||||
|
||||
if (Radiation == 10) {
|
||||
YouDied("Radiation Poisoning");
|
||||
}
|
||||
}
|
||||
|
||||
public string HaveRadiationSuit() {
|
||||
string have = null;
|
||||
|
||||
if (RadiationSuit) {
|
||||
have = "You have a radiation suit";
|
||||
} else {
|
||||
have = "You do not have a radiation suit";
|
||||
}
|
||||
|
||||
return have;
|
||||
}
|
||||
|
||||
private string GetComfort() {
|
||||
string localComfort = null;
|
||||
Comfort--;
|
||||
|
||||
if (Comfort == 4 || Comfort == 5 || Comfort == 6) {
|
||||
localComfort = "You are comfortable, but could certainly be more comfterble";
|
||||
}
|
||||
|
||||
|
||||
if (Comfort <= 0) {
|
||||
YouDied("Bored to death");
|
||||
}
|
||||
|
||||
return localComfort;
|
||||
}
|
||||
|
||||
private string Hungry() {
|
||||
string Localhunger = null;
|
||||
|
||||
if (PlayerHunger >= 10) {
|
||||
Localhunger = "You are not hungry";
|
||||
} else if (PlayerHunger == 9 || PlayerHunger == 8 || PlayerHunger == 7) {
|
||||
Localhunger = "Could do with a snack";
|
||||
} else if (PlayerHunger == 6 || PlayerHunger == 5) {
|
||||
Localhunger = "You are hungry now, but can go on for a while without food for a little while longer";
|
||||
} else if (PlayerHunger == 4) {
|
||||
Localhunger = "You are getting quite hungry now, you should probably think about eating";
|
||||
} else if (PlayerHunger == 3) {
|
||||
Localhunger = "You are getting really hungry now";
|
||||
} else if (PlayerHunger == 2) {
|
||||
Localhunger = "You are getting really hungry now, you cant go on much longer without food";
|
||||
} else if (PlayerHunger == 1) {
|
||||
Localhunger = "You are starving now, if you dont eat, you will surely die";
|
||||
} else {
|
||||
YouDied("Starvation");
|
||||
}
|
||||
|
||||
return Localhunger;
|
||||
}
|
||||
|
||||
private string Eat() {
|
||||
if (Food <= 0 || Water <= 0 || PlayerHunger >= 10) {
|
||||
EatSuccess = false;
|
||||
} else if (Food > 0 && Water > 0) {
|
||||
EatSuccess = true;
|
||||
}
|
||||
|
||||
string eatstring = EatString();
|
||||
|
||||
return eatstring;
|
||||
}
|
||||
private string EatString() {
|
||||
string EatString = null;
|
||||
|
||||
if (EatSuccess) {
|
||||
EatString = "You have eaten";
|
||||
PlayerHunger++;
|
||||
Food--;
|
||||
Water--;
|
||||
} else {
|
||||
EatString = "You do not have enough food to do that";
|
||||
}
|
||||
|
||||
return EatString;
|
||||
}
|
||||
|
||||
public string GetHealth() {
|
||||
string health = "Your health is at " + PlayerHealth + "/10";
|
||||
|
||||
if (PlayerHealth <= 0) {
|
||||
YouDied("Your health reached 0");
|
||||
}
|
||||
|
||||
return health;
|
||||
}
|
||||
|
||||
public void HungerDown() {
|
||||
Random rnd = new Random();
|
||||
int HungerDown = rnd.Next(1, 3);
|
||||
if (HungerDown == 1) {
|
||||
PlayerHunger--;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public void YouDied(string CauseOfDeath) {
|
||||
Console.BackgroundColor = ConsoleColor.DarkRed;
|
||||
Console.Clear();
|
||||
Console.WriteLine("You died");
|
||||
Console.WriteLine("Cause of death: {0}", CauseOfDeath);
|
||||
Console.WriteLine("You can try (A)gain, or (Q)uit");
|
||||
var response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case 'A':
|
||||
case 'a':
|
||||
Console.BackgroundColor = ConsoleColor.White;
|
||||
Introduction();
|
||||
break;
|
||||
case 'Q':
|
||||
case 'q':
|
||||
Console.WriteLine("Thanks for playing");
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void Introduction() {
|
||||
GetHealth();
|
||||
Level = "Introduction";
|
||||
Console.Clear();
|
||||
Console.WriteLine("Welcome to this game about the boring apocolipse");
|
||||
Console.WriteLine("In this game you have to make decisions in order to progress though the game");
|
||||
Console.WriteLine("To load from a previous save press L");
|
||||
Console.WriteLine("You can press S to save at any point throughout the game");
|
||||
Console.WriteLine("Do you wish to continue?");
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("(C)ontinue (Q)uit (L)oad");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case 'C':
|
||||
case 'c':
|
||||
GameStart();
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
case 'q':
|
||||
Console.WriteLine("Thanks for playing");
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
case 'l':
|
||||
Load();
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
Save();
|
||||
Introduction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void GameStart() {
|
||||
Level = "GameStart";
|
||||
Console.Clear();
|
||||
Console.WriteLine("Our story starts in a suburb of New York");
|
||||
Console.WriteLine("You hear a nuclear siren, and your phone warns you off a possible nuclear strike at your location");
|
||||
Console.WriteLine("You are faced with a decision to either get to the nuclear bunker, hide in your house or do nothing");
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Neuclear bunker (1) Hide (2) Do nothing (3)");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case '1':
|
||||
Console.WriteLine("You choose Get to the Bunker");
|
||||
break;
|
||||
|
||||
case '2':
|
||||
Console.Clear();
|
||||
Console.WriteLine("You choose Hide");
|
||||
Console.WriteLine("Enter to continue");
|
||||
Console.ReadKey();
|
||||
YouDied("Nuclear annihilation");
|
||||
break;
|
||||
|
||||
case '3':
|
||||
Console.Clear();
|
||||
Console.WriteLine("You choose Do Nothing");
|
||||
Console.WriteLine("Enter to continue");
|
||||
Console.ReadKey();
|
||||
YouDied("Nuclear annihilation");
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
Save();
|
||||
GameStart();
|
||||
break;
|
||||
}
|
||||
|
||||
HungerDown();
|
||||
GetHealth();
|
||||
|
||||
Eaten:
|
||||
Console.Clear();
|
||||
Console.WriteLine("You are now in the Nuclear Bunker");
|
||||
Console.WriteLine("You have survived the initial nuclear blast you now have to continue to survive");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("You managed to grab {0} food and {1} water before the blast", Food, Water);
|
||||
Console.WriteLine("F to eat 1 food (your hunger level is now at {0}/10)", PlayerHunger);
|
||||
Console.WriteLine(Hungry());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("From here, you can go outside and search for supplies, search the fallout bunker for a radiation suit or " +
|
||||
"rest and wait for the fallout to pass slightly, reducing the chance of radiation poisoning (this will consume 6 hunger)");
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Go outside (1) Search inside (2) Rest and wait (3)");
|
||||
|
||||
response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case '1':
|
||||
Branch_1_1();
|
||||
break;
|
||||
|
||||
case '2':
|
||||
Branch_2_1();
|
||||
break;
|
||||
|
||||
case '3':
|
||||
Branch_3_1();
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
case 'f':
|
||||
Eat();
|
||||
goto Eaten;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
Save();
|
||||
GameStart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Branch_1_1() {
|
||||
Level = "Branch_1_1";
|
||||
RadiationZone(1); //THIS NEEDS TO CHANGE ONCE U DONE THE THING WITH CALCULATING FALLOUT BASED ON TIME PASSED
|
||||
HungerDown();
|
||||
GetHealth();
|
||||
|
||||
Eaten:
|
||||
Console.Clear();
|
||||
Console.WriteLine("You choose to go outside and search for any possible supplies");
|
||||
Console.WriteLine("You currently have {0} water {1} food", Water, Food);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("You are outside of the bunker now, it is radioactive out here, your current radioactivity level is {0}/10." +
|
||||
"The higher it gets, the more dangerous it is. Bad stuff happens when your radioactivity level gains. The longer " +
|
||||
"you spend outside, the higher it will get. If you have a radiation suit, all radiation and damage will be " +
|
||||
"negated.", GetRadiation());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(HaveRadiationSuit());
|
||||
Console.WriteLine(GetHealth());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("F to eat 1 food (your hunger level is now at {0}/10)", PlayerHunger);
|
||||
Console.WriteLine(Hungry());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("From here, you can search for Food, Water or Comforts to make you more comfortable this will mean that you get less " +
|
||||
"bored and therefore are less likely to die, your current comfort level is {0}/10, the lower your health the lower your" +
|
||||
"comfort and a higher chance of death.", Comfort);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Food (1) Water (2) Comforts (3)");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case '1':
|
||||
Branch_1_1_1();
|
||||
break;
|
||||
|
||||
case '2':
|
||||
Branch_1_1_2();
|
||||
break;
|
||||
|
||||
case '3':
|
||||
Branch_1_1_3();
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
case 'f':
|
||||
Eat();
|
||||
goto Eaten;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
Save();
|
||||
Branch_1_1();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Branch_2_1() {
|
||||
Level = "Branch_2_1";
|
||||
HungerDown();
|
||||
GetHealth();
|
||||
|
||||
Eaten:
|
||||
Console.Clear();
|
||||
Console.WriteLine("You choose to stay inside and search the fallout shelter for a radiation suit");
|
||||
Console.WriteLine("You currently have {0} water {1} food", Water, Food);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("You wonder the inside of the bunker in search for a radiation suit, this is a very mundane task, you are getting " +
|
||||
"quite bored, {0}, you should probably try and find comforts when you get out of the bunker.", GetComfort());
|
||||
Console.WriteLine("You can see a radiation suit in the distance. However it is smotherd in flames and there is no easy way to get it.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(HaveRadiationSuit());
|
||||
Console.WriteLine(GetHealth());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("F to eat 1 food (your hunger level is now at {0}/10)", PlayerHunger);
|
||||
Console.WriteLine(Hungry());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("From here you can try and grab the radiation suit from the fire, try and use the water you have to extinguish" +
|
||||
"the flames, or disregard the radiation sut and go outside anyway.");
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Go for it (1) Extinguish flames (2) Disregard (3)");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case '1':
|
||||
Branch_2_1_1();
|
||||
break;
|
||||
|
||||
case '2':
|
||||
Branch_2_1_2();
|
||||
break;
|
||||
|
||||
case '3':
|
||||
Branch_1_1();
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
case 'f':
|
||||
Eat();
|
||||
goto Eaten;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
Save();
|
||||
Branch_2_1();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Branch_3_1() {
|
||||
Level = "Branch_3_1";
|
||||
HungerDown();
|
||||
GetHealth();
|
||||
|
||||
Eaten:
|
||||
Console.Clear();
|
||||
Console.WriteLine("You choose to");
|
||||
Console.WriteLine("You currently have {0} water {1} food", Water, Food);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(HaveRadiationSuit());
|
||||
Console.WriteLine(GetHealth());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("F to eat 1 food (your hunger level is now at {0}/10)", PlayerHunger);
|
||||
Console.WriteLine(Hungry());
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("From here you can ");
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Go for it (1) Extinguish flames (2) Disregard (3)");
|
||||
|
||||
var response = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
switch (response.KeyChar) {
|
||||
case '1':
|
||||
Branch_3_1_1();
|
||||
break;
|
||||
|
||||
case '2':
|
||||
Branch_3_1_2();
|
||||
break;
|
||||
|
||||
case '3':
|
||||
Branch_3_1_3();
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
case 'f':
|
||||
Eat();
|
||||
goto Eaten;
|
||||
|
||||
case 'S':
|
||||
case 's':
|
||||
Save();
|
||||
Branch_3_1();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Branch_1_1_1() {
|
||||
Level = "Branch_1_1_1";
|
||||
HungerDown();
|
||||
}
|
||||
|
||||
private void Branch_1_1_2() {
|
||||
Level = "Branch_1_1_2";
|
||||
HungerDown();
|
||||
}
|
||||
|
||||
private void Branch_1_1_3() {
|
||||
Level = "Branch_1_1_3";
|
||||
HungerDown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Branch_2_1_1() {
|
||||
Level = "Branch_2_1_1";
|
||||
HungerDown();
|
||||
}
|
||||
|
||||
private void Branch_2_1_2() {
|
||||
Level = "Branch_2_1_2";
|
||||
HungerDown();
|
||||
}
|
||||
private void Branch_2_1_3() {
|
||||
Level = "Branch_2_1_3";
|
||||
HungerDown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Branch_3_1_1() {
|
||||
Level = "Branch_3_1_1";
|
||||
HungerDown();
|
||||
}
|
||||
|
||||
public void Branch_3_1_2() {
|
||||
Level = "Branch_3_1_2";
|
||||
HungerDown();
|
||||
}
|
||||
|
||||
public void Branch_3_1_3() {
|
||||
Level = "Branch_3_1_3";
|
||||
HungerDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
1
App1/obj/Debug/App1.csproj.CoreCompileInputs.cache
Normal file
1
App1/obj/Debug/App1.csproj.CoreCompileInputs.cache
Normal file
@@ -0,0 +1 @@
|
||||
d3ea33e7a1f7c75e960cd0692ad6a3f2f9bcda19
|
||||
14
App1/obj/Debug/App1.csproj.FileListAbsolute.txt
Normal file
14
App1/obj/Debug/App1.csproj.FileListAbsolute.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
F:\Programming\C#\App1\App1\bin\Debug\App1.exe.config
|
||||
F:\Programming\C#\App1\App1\bin\Debug\App1.exe
|
||||
F:\Programming\C#\App1\App1\bin\Debug\App1.pdb
|
||||
F:\Programming\C#\App1\App1\obj\Debug\App1.csprojResolveAssemblyReference.cache
|
||||
F:\Programming\C#\App1\App1\obj\Debug\App1.csproj.CoreCompileInputs.cache
|
||||
F:\Programming\C#\App1\App1\obj\Debug\App1.exe
|
||||
F:\Programming\C#\App1\App1\obj\Debug\App1.pdb
|
||||
E:\Programming\C#\App1\App1\bin\Debug\App1.exe.config
|
||||
E:\Programming\C#\App1\App1\bin\Debug\App1.exe
|
||||
E:\Programming\C#\App1\App1\bin\Debug\App1.pdb
|
||||
E:\Programming\C#\App1\App1\obj\Debug\App1.csprojResolveAssemblyReference.cache
|
||||
E:\Programming\C#\App1\App1\obj\Debug\App1.csproj.CoreCompileInputs.cache
|
||||
E:\Programming\C#\App1\App1\obj\Debug\App1.exe
|
||||
E:\Programming\C#\App1\App1\obj\Debug\App1.pdb
|
||||
BIN
App1/obj/Debug/App1.csprojResolveAssemblyReference.cache
Normal file
BIN
App1/obj/Debug/App1.csprojResolveAssemblyReference.cache
Normal file
Binary file not shown.
BIN
App1/obj/Debug/App1.exe
Normal file
BIN
App1/obj/Debug/App1.exe
Normal file
Binary file not shown.
BIN
App1/obj/Debug/App1.pdb
Normal file
BIN
App1/obj/Debug/App1.pdb
Normal file
Binary file not shown.
BIN
App1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
BIN
App1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Normal file
Binary file not shown.
1
App1/obj/Release/App1.csproj.CoreCompileInputs.cache
Normal file
1
App1/obj/Release/App1.csproj.CoreCompileInputs.cache
Normal file
@@ -0,0 +1 @@
|
||||
3bc42b96ccf3b37781b0fb8f41a941fe12fd0ec1
|
||||
Reference in New Issue
Block a user