Intial commit with working base game and game status.
This commit is contained in:
295
Actions.cs
Normal file
295
Actions.cs
Normal file
@@ -0,0 +1,295 @@
|
|||||||
|
/*
|
||||||
|
public interface IAction
|
||||||
|
{
|
||||||
|
void GetAction(Character character);
|
||||||
|
void DoNothing(Character character);
|
||||||
|
void Attack();
|
||||||
|
void HealthPotion();
|
||||||
|
Item Items();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public sealed class Actions //: IAction
|
||||||
|
{
|
||||||
|
private static readonly Lazy<Actions> _instance = new Lazy<Actions>(() => new Actions());
|
||||||
|
private Actions() { }
|
||||||
|
public static Actions Instance
|
||||||
|
{
|
||||||
|
get { return _instance.Value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetAction(Character character)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
switch (MenuItem.Description)
|
||||||
|
{
|
||||||
|
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var type = character.GetType().ToString();
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case "Player": PlayerActions(character); break;
|
||||||
|
case "Skeleton": MonsterActions(character); break;
|
||||||
|
case "UncodedOne": MonsterActions(character); break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayerActions(Character character)
|
||||||
|
{
|
||||||
|
string? action;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
GameState.Instance.DisplayStatus();
|
||||||
|
Console.WriteLine($"Current Round: {GameState.Instance.currentRound}");
|
||||||
|
Console.WriteLine("\n1. Do Nothing");
|
||||||
|
Console.WriteLine("2. Punch");
|
||||||
|
if (GameState.Instance.herosAIControl == true)
|
||||||
|
{
|
||||||
|
action = AIPickAction();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write($"\n{character.name}, select an action: ");
|
||||||
|
action = Console.ReadLine();
|
||||||
|
}
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case "1": DoNothing(character); break;
|
||||||
|
case "2": Punch(character); break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Sorry, you can't do that...");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MonsterActions(Character character)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
string? action;
|
||||||
|
Console.Clear();
|
||||||
|
GameState.Instance.DisplayStatus();
|
||||||
|
Console.WriteLine($"Current Round: {GameState.Instance.currentRound}");
|
||||||
|
if (character.name == "Skeleton")
|
||||||
|
{
|
||||||
|
Console.WriteLine("\n1. Do Nothing");
|
||||||
|
Console.WriteLine("2. Bone Crunch");
|
||||||
|
if (GameState.Instance.monstersAIControl == true)
|
||||||
|
{
|
||||||
|
action = AIPickAction();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write($"\n{character.name}, select an action: ");
|
||||||
|
action = Console.ReadLine();
|
||||||
|
}
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case "1": DoNothing(character); break;
|
||||||
|
case "2": BoneCrunch(character); break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Sorry, you can't do that...");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (character.name == "The Uncoded One")
|
||||||
|
{
|
||||||
|
Console.WriteLine("\n1. Do Nothing");
|
||||||
|
Console.WriteLine("2. Unraveling");
|
||||||
|
if (GameState.Instance.monstersAIControl == true)
|
||||||
|
{
|
||||||
|
action = AIPickAction();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write($"\n{character.name}, select and action: ");
|
||||||
|
action = Console.ReadLine();
|
||||||
|
}
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case "1": DoNothing(character); break;
|
||||||
|
case "2": Unraveling(character); break;
|
||||||
|
default: Console.WriteLine("Sorry, you can't do that...");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Character SelectTarget(Character character)
|
||||||
|
{
|
||||||
|
int target;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (GameState.Instance.heros.Contains(character))
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
int number = 1;
|
||||||
|
foreach (var monster in GameState.Instance.monsters)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{number}. {monster.name}");
|
||||||
|
number++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (GameState.Instance.monsters.Contains(character))
|
||||||
|
{
|
||||||
|
int number = 1;
|
||||||
|
Console.WriteLine();
|
||||||
|
foreach (var hero in GameState.Instance.heros)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{number}. {hero.name}");
|
||||||
|
number++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.Write("\nSelect a target: ");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
target = Int32.Parse(Console.ReadLine());
|
||||||
|
}
|
||||||
|
catch (System.FormatException)
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nSorry, that's not a valid target...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (GameState.Instance.heros.Contains(character))
|
||||||
|
{
|
||||||
|
return GameState.Instance.monsters[target - 1];
|
||||||
|
}
|
||||||
|
else if (GameState.Instance.monsters.Contains(character))
|
||||||
|
{
|
||||||
|
return GameState.Instance.heros[target - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.ArgumentOutOfRangeException)
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nSorry, that's not a valid target...");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DoNothing(Character character)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine($"\n{character.name} does nothing...");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Punch(Character character)
|
||||||
|
{
|
||||||
|
Character target = null;
|
||||||
|
if (GameState.Instance.herosAIControl == true)
|
||||||
|
{
|
||||||
|
target = AIPickTarget(character);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
target = SelectTarget(character);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"\n{character.name} uses PUNCH on {target.name}!");
|
||||||
|
Console.WriteLine($"{target.name} took 1 damage!");
|
||||||
|
target.currentHP -= 1;
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BoneCrunch(Character character)
|
||||||
|
{
|
||||||
|
Character target = null;
|
||||||
|
if (GameState.Instance.monstersAIControl == true)
|
||||||
|
{
|
||||||
|
target = AIPickTarget(character);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
target = SelectTarget(character);
|
||||||
|
}
|
||||||
|
|
||||||
|
Random random = new Random();
|
||||||
|
int coin = random.Next(1, 101);
|
||||||
|
Console.WriteLine($"\n{character.name} used Bone Crunch on {target.name}!");
|
||||||
|
if (coin > 50)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{target.name} took 1 damage!");
|
||||||
|
target.currentHP -= 1;
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Nothing happened!");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unraveling(Character character)
|
||||||
|
{
|
||||||
|
Character target = null;
|
||||||
|
if (GameState.Instance.monstersAIControl == true)
|
||||||
|
{
|
||||||
|
target = AIPickTarget(character);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
target = SelectTarget(character);
|
||||||
|
}
|
||||||
|
Random random = new Random();
|
||||||
|
Console.WriteLine($"\n{character.name} used Unraveling on {target.name}!");
|
||||||
|
int damage = random.Next(3);
|
||||||
|
if (damage > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{target.name} took {damage} damage!");
|
||||||
|
target.currentHP -= damage;
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Character AIPickTarget(Character character)
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
if (GameState.Instance.heros.Contains(character))
|
||||||
|
{
|
||||||
|
var lastItem = GameState.Instance.monsters.Count();
|
||||||
|
var target = random.Next(1, lastItem + 1);
|
||||||
|
return GameState.Instance.monsters[target - 1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var lastItem = GameState.Instance.heros.Count();
|
||||||
|
var target = random.Next(1, lastItem + 1);
|
||||||
|
return GameState.Instance.heros[target - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AIPickAction()
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return random.Next(1, 3).ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
10
Character.cs
Normal file
10
Character.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
public abstract class Character
|
||||||
|
{
|
||||||
|
public string? name {get; set;}
|
||||||
|
public int maxHP {get; set;}
|
||||||
|
public int currentHP {get; set;}
|
||||||
|
public bool dead {get; set;} = false;
|
||||||
|
public string turnMarker = "*";
|
||||||
|
public bool isTurn {get; set;} = false;
|
||||||
|
//public List<Actions>CharacterEnabledActions = new List<Actions>();
|
||||||
|
}
|
||||||
10
FinalBattle.csproj
Normal file
10
FinalBattle.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
225
GameState.cs
Normal file
225
GameState.cs
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
public sealed class GameState
|
||||||
|
{
|
||||||
|
public static readonly Lazy<GameState> _instance = new Lazy<GameState>(() => new GameState());
|
||||||
|
private GameState() {}
|
||||||
|
public static GameState Instance
|
||||||
|
{
|
||||||
|
get {return _instance.Value;}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Character> heros = new List<Character>();
|
||||||
|
public List<Character> monsters = new List<Character>();
|
||||||
|
public List<Character> heroRemove = new List<Character>();
|
||||||
|
public List<Character> monsterRemove = new List<Character>();
|
||||||
|
public int currentRound = 1;
|
||||||
|
public bool gameOver = false;
|
||||||
|
public bool herosAIControl = false;
|
||||||
|
public bool monstersAIControl = true;
|
||||||
|
public bool lastRound = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
public record MenuItem
|
||||||
|
{
|
||||||
|
string? Description;
|
||||||
|
bool IsEnabled;
|
||||||
|
IAction? ActionToPerform;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildMenu()
|
||||||
|
{
|
||||||
|
foreach (action in Character.EnabledActions)
|
||||||
|
int number = 1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
Rounds(currentRound);
|
||||||
|
while (gameOver == false)
|
||||||
|
{
|
||||||
|
GameOver();
|
||||||
|
if (gameOver == true)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (heros.Any())
|
||||||
|
{
|
||||||
|
foreach (Character hero in heros)
|
||||||
|
{
|
||||||
|
hero.isTurn = true;
|
||||||
|
Actions.Instance.GetAction(hero);
|
||||||
|
CheckDead();
|
||||||
|
hero.isTurn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (Character monster in monsterRemove)
|
||||||
|
{
|
||||||
|
monsters.Remove(monster);
|
||||||
|
}
|
||||||
|
if (monsters.Any() && heros.Any())
|
||||||
|
{
|
||||||
|
foreach (Character monster in monsters)
|
||||||
|
{
|
||||||
|
monster.isTurn = true;
|
||||||
|
Actions.Instance.GetAction(monster);
|
||||||
|
CheckDead();
|
||||||
|
foreach (Character hero in heroRemove)
|
||||||
|
{
|
||||||
|
heros.Remove(hero);
|
||||||
|
}
|
||||||
|
if (!heros.Any())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
monster.isTurn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayStatus()
|
||||||
|
{
|
||||||
|
Console.WriteLine("================================= BATTLE =================================");
|
||||||
|
foreach (Character hero in GameState.Instance.heros)
|
||||||
|
{
|
||||||
|
if (hero.isTurn == true)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
|
}
|
||||||
|
Console.WriteLine($"{hero.name, -20} HP: {hero.currentHP}/{hero.maxHP}");
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
Console.WriteLine("----------------------------------- VS -----------------------------------");
|
||||||
|
}
|
||||||
|
foreach (Character monster in GameState.Instance.monsters)
|
||||||
|
{
|
||||||
|
if (monster.isTurn == true)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
}
|
||||||
|
if (monster.name == "The Uncoded One")
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{monster.name, 59} HP: {monster.currentHP, 2}/{monster.maxHP, -2}");
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{monster.name, 59} HP: {monster.currentHP}/{monster.maxHP, -2}");
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckDead()
|
||||||
|
{
|
||||||
|
foreach (Character hero in heros)
|
||||||
|
{
|
||||||
|
if (hero.currentHP <= 0)
|
||||||
|
{
|
||||||
|
hero.dead = true;
|
||||||
|
heroRemove.Add(hero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Character monster in monsters)
|
||||||
|
{
|
||||||
|
if (monster.currentHP <= 0)
|
||||||
|
{
|
||||||
|
monster.dead = true;
|
||||||
|
monsterRemove.Add(monster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GameOver()
|
||||||
|
{
|
||||||
|
if (currentRound == 3)
|
||||||
|
{
|
||||||
|
lastRound = true;
|
||||||
|
}
|
||||||
|
if (!heros.Any())
|
||||||
|
{
|
||||||
|
gameOver = true;
|
||||||
|
MonstersWin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!monsters.Any() && lastRound == false)
|
||||||
|
{
|
||||||
|
currentRound++;
|
||||||
|
Console.WriteLine($"Round {currentRound}");
|
||||||
|
Rounds(currentRound);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!monsters.Any() && lastRound == true)
|
||||||
|
{
|
||||||
|
gameOver = true;
|
||||||
|
HerosWin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Rounds(int currentRound)
|
||||||
|
{
|
||||||
|
if (currentRound == 1)
|
||||||
|
{
|
||||||
|
Skeleton skeleton1 = new Skeleton();
|
||||||
|
monsters.Add(skeleton1);
|
||||||
|
}
|
||||||
|
if (currentRound == 2)
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine("You are victorious in your first battle!");
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
Console.WriteLine("\nAs you make your way deeper into the Uncoded One's fortress"
|
||||||
|
+ "\nmore enemies appear to block your way to defeat their master...");
|
||||||
|
Console.WriteLine("\n\nPress Enter to continue...");
|
||||||
|
Console.ReadLine();
|
||||||
|
Skeleton skeleton1 = new Skeleton();
|
||||||
|
Skeleton skeleton2 = new Skeleton();
|
||||||
|
monsters.AddRange(skeleton1, skeleton2);
|
||||||
|
}
|
||||||
|
if (currentRound == 3)
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine("You have completed the second battle in your assualt on the"
|
||||||
|
+ " Uncoded One's fortress!");
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
Console.WriteLine("\nAs you move deeper into the fortress, you come upon two great"
|
||||||
|
+ "\nsteel doors set into a wall of stone. You push open the doors, and"
|
||||||
|
+ "\nfind yourself in the Uncoded One's throne room. The Uncoded One stands"
|
||||||
|
+ "\nfrom his throne of blackened steel and hisses, \"You have finally"
|
||||||
|
+ "\nappeared before me True Programmer. Now you will die, and the world"
|
||||||
|
+ "\nwill be mine!\"");
|
||||||
|
Console.WriteLine("\n\nPress Enter to continue...");
|
||||||
|
Console.ReadLine();
|
||||||
|
Skeleton skeleton1 = new Skeleton();
|
||||||
|
Skeleton skeleton2 = new Skeleton();
|
||||||
|
Skeleton skeleton3 = new Skeleton();
|
||||||
|
UncodedOne uncodedOne = new UncodedOne();
|
||||||
|
monsters.AddRange(skeleton1, skeleton2, skeleton3, uncodedOne);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HerosWin()
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
Console.WriteLine("As you strike the Uncoded One down, the sky brightens and the"
|
||||||
|
+ " miasma\nsurrounding his dark fortress begins to lift...\n\n"
|
||||||
|
+ "You are victorious!\n\nTrue Programming has been restored to the lands, and"
|
||||||
|
+ " the people\ncan now improve their lives through the various arts of code you\n"
|
||||||
|
+ "have helped restore...");
|
||||||
|
Console.WriteLine("\nPress Enter to exit your final challenge, True Programmer!");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MonstersWin()
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
Console.WriteLine("You have been brutally struck down by the Uncoded One and his evil\n"
|
||||||
|
+ "minions. This is a devastating loss for the all the people whom you have helped...\n"
|
||||||
|
+ "The Uncoded One will now reign supreme in unchecked war against the entire land, and\n"
|
||||||
|
+ "\nTrue Programming may forever be lost...");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Player.cs
Normal file
21
Player.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
public class Player : Character
|
||||||
|
{
|
||||||
|
public Player()
|
||||||
|
{
|
||||||
|
maxHP = 10;
|
||||||
|
currentHP = maxHP;
|
||||||
|
name = GetName();
|
||||||
|
//List<IherosAction>CharacterEnabledActions = new List<IAction>();
|
||||||
|
//CharacterEnabledActions.Add(Actions.Instance.DoNothing()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
string? input;
|
||||||
|
Console.Write("Enter your player's name: ");
|
||||||
|
input = Console.ReadLine();
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
69
Program.cs
Normal file
69
Program.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
string? input;
|
||||||
|
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine("Welcome True Programmer, to the final battle for the realms of C#.");
|
||||||
|
Console.WriteLine("------------------------------------------------------------------");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
Console.WriteLine("\nThis will be the final battle against the Uncoded One..."
|
||||||
|
+ "\nAre you ready?");
|
||||||
|
Console.WriteLine("--------------------------------------------------------"
|
||||||
|
+ "--------------");
|
||||||
|
Console.ReadLine();
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Console.Write("\nWould you like the heroes party to be controlled by AI? (yes/no): ");
|
||||||
|
input = Console.ReadLine().ToLower();
|
||||||
|
if (input == "yes" || input == "no")
|
||||||
|
{
|
||||||
|
if (input == "yes")
|
||||||
|
{
|
||||||
|
GameState.Instance.herosAIControl = true;
|
||||||
|
}
|
||||||
|
if (input == "no")
|
||||||
|
{
|
||||||
|
GameState.Instance.herosAIControl = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please answer yes or no.");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Console.Write("\nWould you like the monsters party to be controlled by AI? (yes/no): ");
|
||||||
|
input = Console.ReadLine().ToLower();
|
||||||
|
if (input == "yes" || input == "no")
|
||||||
|
{
|
||||||
|
if (input == "yes")
|
||||||
|
{
|
||||||
|
GameState.Instance.monstersAIControl = true;
|
||||||
|
}
|
||||||
|
if (input == "no")
|
||||||
|
{
|
||||||
|
GameState.Instance.monstersAIControl = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please answer yes or no.");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = new Player();
|
||||||
|
GameState.Instance.heros.Add(player);
|
||||||
|
|
||||||
|
Console.Clear();
|
||||||
|
Console.Write("Press Enter to to begin your battle to save True Programming...");
|
||||||
|
Console.ReadLine();
|
||||||
|
|
||||||
|
GameState.Instance.Run();
|
||||||
9
Skeleton.cs
Normal file
9
Skeleton.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
public class Skeleton : Character
|
||||||
|
{
|
||||||
|
public Skeleton()
|
||||||
|
{
|
||||||
|
maxHP = 5;
|
||||||
|
currentHP = maxHP;
|
||||||
|
name = "Skeleton";
|
||||||
|
}
|
||||||
|
}
|
||||||
9
UncodedOne.cs
Normal file
9
UncodedOne.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
public class UncodedOne : Character
|
||||||
|
{
|
||||||
|
public UncodedOne()
|
||||||
|
{
|
||||||
|
maxHP = 15;
|
||||||
|
currentHP = maxHP;
|
||||||
|
name = "The Uncoded One";
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
bin/Debug/net9.0/FinalBattle
Executable file
BIN
bin/Debug/net9.0/FinalBattle
Executable file
Binary file not shown.
23
bin/Debug/net9.0/FinalBattle.deps.json
Normal file
23
bin/Debug/net9.0/FinalBattle.deps.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"runtimeTarget": {
|
||||||
|
"name": ".NETCoreApp,Version=v9.0",
|
||||||
|
"signature": ""
|
||||||
|
},
|
||||||
|
"compilationOptions": {},
|
||||||
|
"targets": {
|
||||||
|
".NETCoreApp,Version=v9.0": {
|
||||||
|
"FinalBattle/1.0.0": {
|
||||||
|
"runtime": {
|
||||||
|
"FinalBattle.dll": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libraries": {
|
||||||
|
"FinalBattle/1.0.0": {
|
||||||
|
"type": "project",
|
||||||
|
"serviceable": false,
|
||||||
|
"sha512": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
bin/Debug/net9.0/FinalBattle.dll
Normal file
BIN
bin/Debug/net9.0/FinalBattle.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/FinalBattle.pdb
Normal file
BIN
bin/Debug/net9.0/FinalBattle.pdb
Normal file
Binary file not shown.
12
bin/Debug/net9.0/FinalBattle.runtimeconfig.json
Normal file
12
bin/Debug/net9.0/FinalBattle.runtimeconfig.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"runtimeOptions": {
|
||||||
|
"tfm": "net9.0",
|
||||||
|
"framework": {
|
||||||
|
"name": "Microsoft.NETCore.App",
|
||||||
|
"version": "9.0.0"
|
||||||
|
},
|
||||||
|
"configProperties": {
|
||||||
|
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||||
22
obj/Debug/net9.0/FinalBattle.AssemblyInfo.cs
Normal file
22
obj/Debug/net9.0/FinalBattle.AssemblyInfo.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
[assembly: System.Reflection.AssemblyCompanyAttribute("FinalBattle")]
|
||||||
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||||
|
[assembly: System.Reflection.AssemblyProductAttribute("FinalBattle")]
|
||||||
|
[assembly: System.Reflection.AssemblyTitleAttribute("FinalBattle")]
|
||||||
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
||||||
|
// Generated by the MSBuild WriteCodeFragment class.
|
||||||
|
|
||||||
1
obj/Debug/net9.0/FinalBattle.AssemblyInfoInputs.cache
Normal file
1
obj/Debug/net9.0/FinalBattle.AssemblyInfoInputs.cache
Normal file
@@ -0,0 +1 @@
|
|||||||
|
15175f65f6f63f0c4c3ae8d13187889e73fe451b685fbc2643b44dd8e1084a87
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
is_global = true
|
||||||
|
build_property.TargetFramework = net9.0
|
||||||
|
build_property.TargetPlatformMinVersion =
|
||||||
|
build_property.UsingMicrosoftNETSdkWeb =
|
||||||
|
build_property.ProjectTypeGuids =
|
||||||
|
build_property.InvariantGlobalization =
|
||||||
|
build_property.PlatformNeutralAssembly =
|
||||||
|
build_property.EnforceExtendedAnalyzerRules =
|
||||||
|
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||||
|
build_property.RootNamespace = FinalBattle
|
||||||
|
build_property.ProjectDir = /home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/
|
||||||
|
build_property.EnableComHosting =
|
||||||
|
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||||
|
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||||
|
build_property.EnableCodeStyleSeverity =
|
||||||
8
obj/Debug/net9.0/FinalBattle.GlobalUsings.g.cs
Normal file
8
obj/Debug/net9.0/FinalBattle.GlobalUsings.g.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// <auto-generated/>
|
||||||
|
global using global::System;
|
||||||
|
global using global::System.Collections.Generic;
|
||||||
|
global using global::System.IO;
|
||||||
|
global using global::System.Linq;
|
||||||
|
global using global::System.Net.Http;
|
||||||
|
global using global::System.Threading;
|
||||||
|
global using global::System.Threading.Tasks;
|
||||||
BIN
obj/Debug/net9.0/FinalBattle.assets.cache
Normal file
BIN
obj/Debug/net9.0/FinalBattle.assets.cache
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
3235bef0a15147595cd9d8b95c54ad6a8e17ed84b619b5a0ff9feb9b9eb6f2e3
|
||||||
14
obj/Debug/net9.0/FinalBattle.csproj.FileListAbsolute.txt
Normal file
14
obj/Debug/net9.0/FinalBattle.csproj.FileListAbsolute.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/bin/Debug/net9.0/FinalBattle
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/bin/Debug/net9.0/FinalBattle.deps.json
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/bin/Debug/net9.0/FinalBattle.runtimeconfig.json
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/bin/Debug/net9.0/FinalBattle.dll
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/bin/Debug/net9.0/FinalBattle.pdb
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/FinalBattle.GeneratedMSBuildEditorConfig.editorconfig
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/FinalBattle.AssemblyInfoInputs.cache
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/FinalBattle.AssemblyInfo.cs
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/FinalBattle.csproj.CoreCompileInputs.cache
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/FinalBattle.dll
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/refint/FinalBattle.dll
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/FinalBattle.pdb
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/FinalBattle.genruntimeconfig.cache
|
||||||
|
/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/Debug/net9.0/ref/FinalBattle.dll
|
||||||
BIN
obj/Debug/net9.0/FinalBattle.dll
Normal file
BIN
obj/Debug/net9.0/FinalBattle.dll
Normal file
Binary file not shown.
1
obj/Debug/net9.0/FinalBattle.genruntimeconfig.cache
Normal file
1
obj/Debug/net9.0/FinalBattle.genruntimeconfig.cache
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ae07ca1578eda8c8ded8dc8f92061eaf6da972b9dc05209dfcf30d5f5d79278a
|
||||||
BIN
obj/Debug/net9.0/FinalBattle.pdb
Normal file
BIN
obj/Debug/net9.0/FinalBattle.pdb
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/apphost
Executable file
BIN
obj/Debug/net9.0/apphost
Executable file
Binary file not shown.
BIN
obj/Debug/net9.0/ref/FinalBattle.dll
Normal file
BIN
obj/Debug/net9.0/ref/FinalBattle.dll
Normal file
Binary file not shown.
BIN
obj/Debug/net9.0/refint/FinalBattle.dll
Normal file
BIN
obj/Debug/net9.0/refint/FinalBattle.dll
Normal file
Binary file not shown.
73
obj/FinalBattle.csproj.nuget.dgspec.json
Normal file
73
obj/FinalBattle.csproj.nuget.dgspec.json
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"format": 1,
|
||||||
|
"restore": {
|
||||||
|
"/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/FinalBattle.csproj": {}
|
||||||
|
},
|
||||||
|
"projects": {
|
||||||
|
"/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/FinalBattle.csproj": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/FinalBattle.csproj",
|
||||||
|
"projectName": "FinalBattle",
|
||||||
|
"projectPath": "/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/FinalBattle.csproj",
|
||||||
|
"packagesPath": "/home/xp986/.nuget/packages/",
|
||||||
|
"outputPath": "/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/",
|
||||||
|
"projectStyle": "PackageReference",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/home/xp986/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"originalTargetFrameworks": [
|
||||||
|
"net9.0"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net9.0": {
|
||||||
|
"targetAlias": "net9.0",
|
||||||
|
"projectReferences": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"warningProperties": {
|
||||||
|
"warnAsError": [
|
||||||
|
"NU1605"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"restoreAuditProperties": {
|
||||||
|
"enableAudit": "true",
|
||||||
|
"auditLevel": "low",
|
||||||
|
"auditMode": "direct"
|
||||||
|
},
|
||||||
|
"SdkAnalysisLevel": "9.0.100"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net9.0": {
|
||||||
|
"targetAlias": "net9.0",
|
||||||
|
"imports": [
|
||||||
|
"net461",
|
||||||
|
"net462",
|
||||||
|
"net47",
|
||||||
|
"net471",
|
||||||
|
"net472",
|
||||||
|
"net48",
|
||||||
|
"net481"
|
||||||
|
],
|
||||||
|
"assetTargetFallback": true,
|
||||||
|
"warn": true,
|
||||||
|
"downloadDependencies": [
|
||||||
|
{
|
||||||
|
"name": "Microsoft.AspNetCore.App.Ref",
|
||||||
|
"version": "[9.0.8, 9.0.8]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"frameworkReferences": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"privateAssets": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.109/PortableRuntimeIdentifierGraph.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
obj/FinalBattle.csproj.nuget.g.props
Normal file
15
obj/FinalBattle.csproj.nuget.g.props
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||||
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/xp986/.nuget/packages/</NuGetPackageRoot>
|
||||||
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/xp986/.nuget/packages/</NuGetPackageFolders>
|
||||||
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.4</NuGetToolVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<SourceRoot Include="/home/xp986/.nuget/packages/" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
2
obj/FinalBattle.csproj.nuget.g.targets
Normal file
2
obj/FinalBattle.csproj.nuget.g.targets
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
||||||
78
obj/project.assets.json
Normal file
78
obj/project.assets.json
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"targets": {
|
||||||
|
"net9.0": {}
|
||||||
|
},
|
||||||
|
"libraries": {},
|
||||||
|
"projectFileDependencyGroups": {
|
||||||
|
"net9.0": []
|
||||||
|
},
|
||||||
|
"packageFolders": {
|
||||||
|
"/home/xp986/.nuget/packages/": {}
|
||||||
|
},
|
||||||
|
"project": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/FinalBattle.csproj",
|
||||||
|
"projectName": "FinalBattle",
|
||||||
|
"projectPath": "/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/FinalBattle.csproj",
|
||||||
|
"packagesPath": "/home/xp986/.nuget/packages/",
|
||||||
|
"outputPath": "/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/obj/",
|
||||||
|
"projectStyle": "PackageReference",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/home/xp986/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"originalTargetFrameworks": [
|
||||||
|
"net9.0"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net9.0": {
|
||||||
|
"targetAlias": "net9.0",
|
||||||
|
"projectReferences": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"warningProperties": {
|
||||||
|
"warnAsError": [
|
||||||
|
"NU1605"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"restoreAuditProperties": {
|
||||||
|
"enableAudit": "true",
|
||||||
|
"auditLevel": "low",
|
||||||
|
"auditMode": "direct"
|
||||||
|
},
|
||||||
|
"SdkAnalysisLevel": "9.0.100"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net9.0": {
|
||||||
|
"targetAlias": "net9.0",
|
||||||
|
"imports": [
|
||||||
|
"net461",
|
||||||
|
"net462",
|
||||||
|
"net47",
|
||||||
|
"net471",
|
||||||
|
"net472",
|
||||||
|
"net48",
|
||||||
|
"net481"
|
||||||
|
],
|
||||||
|
"assetTargetFallback": true,
|
||||||
|
"warn": true,
|
||||||
|
"downloadDependencies": [
|
||||||
|
{
|
||||||
|
"name": "Microsoft.AspNetCore.App.Ref",
|
||||||
|
"version": "[9.0.8, 9.0.8]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"frameworkReferences": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"privateAssets": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.109/PortableRuntimeIdentifierGraph.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
obj/project.nuget.cache
Normal file
10
obj/project.nuget.cache
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"dgSpecHash": "kGZ6oYhOJuw=",
|
||||||
|
"success": true,
|
||||||
|
"projectFilePath": "/home/xp986/programming/c#/tc#pg/chapter52/FinalBattle/FinalBattle.csproj",
|
||||||
|
"expectedPackageFiles": [
|
||||||
|
"/home/xp986/.nuget/packages/microsoft.aspnetcore.app.ref/9.0.8/microsoft.aspnetcore.app.ref.9.0.8.nupkg.sha512"
|
||||||
|
],
|
||||||
|
"logs": []
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user