Started work on Player and Enemy classes, and also different moves.

This commit is contained in:
Tanner Van Teeffelen 2025-07-11 00:57:21 +00:00
parent 4b4b59b9a3
commit 53b53fc57d
15 changed files with 49 additions and 30 deletions

View file

@ -23,7 +23,7 @@ class Program
if (input == "Y")
{
user.UseHealingItem((HealingItem)user.Inventory.FirstOrDefault(m => m.Name == "Super Potion"));
user.UseHealingItem((HealingItem)user.Inventory.FirstOrDefault(m => m.Name == "Potion"));
}
user.DisplayStats();

Binary file not shown.

Binary file not shown.

View file

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("MiniRPG")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d65f1e71f6545910b66ab67a8d835b4d1e2c5f9")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4b4b59b9a31bfc76fb1db2b6e61846e0e23362d0")]
[assembly: System.Reflection.AssemblyProductAttribute("MiniRPG")]
[assembly: System.Reflection.AssemblyTitleAttribute("MiniRPG")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View file

@ -1 +1 @@
0dc65c6434da51f383575019fc82ae4b29b68e54caebc8f898b0bbe37447dce3
2f9f95c4d52ac0c3165163d219ccd0cd9cb08d53b12c9beccc5292d27ab9163e

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,15 @@
public class Character{
public string Name { get; set; }
public int MaxHealth { get; set; }
public int CurrentHealth { get; set; }
public int MaxMPoints { get; set; }
public int CurrentMPoints { get; set; }
public Character(string name, int maxhealth, int currenthealth, int maxmpoints, int currentmpoints){
Name = name;
MaxHealth = maxhealth;
CurrentHealth = currenthealth;
MaxMPoints = maxmpoints;
CurrentMPoints = currentmpoints;
}
}

View file

@ -0,0 +1,8 @@
public class Enemy : Character {
public List<Move> moves { get; set; }
public Enemy(string name, int maxhealth, int currenthealth, int maxmpoints, int currentmpoints) : base(name, maxhealth, currenthealth, maxmpoints, currentmpoints)
{
}
}

View file

@ -1,20 +1,12 @@
public class Player
public class Player : Character
{
public string Name { get; set; }
public List<Item> Inventory { get; set; }
public int MaxHealth { get; set; }
public int CurrentHealth { get; set; }
public int MaxMPoints { get; set; }
public int CurrentMPoints { get; set; }
public List<Move> moves { get; set; }
public Player(string name, List<Item> inventory, int maxhealth, int currenthealth, int maxmpoints, int currentmpoints)
public Player(string name, int maxhealth, int currenthealth, int maxmpoints, int currentmpoints, List<Item> inventory) : base(name, maxhealth, currenthealth, maxmpoints, currentmpoints)
{
Name = name;
Inventory = inventory;
MaxHealth = maxhealth;
CurrentHealth = currenthealth;
MaxMPoints = maxmpoints;
CurrentMPoints = currentmpoints;
}
//Returns the players inventory in a Dictionary.
@ -33,14 +25,25 @@ public class Player
//For using a healing item. Doesn't allow you to overheal.
public void UseHealingItem(HealingItem item)
{
if (Inventory.FirstOrDefault(m => m.Name == item?.Name) != null){
Inventory.Remove(Inventory.FirstOrDefault(m => m.Name == item.Name));
if ((CurrentHealth + item.HealingAmount) > MaxHealth)
{
CurrentHealth = MaxHealth;
} else {
}
else
{
CurrentHealth += item.HealingAmount;
}
Inventory.Remove(Inventory.FirstOrDefault(m => m.Name == item.Name));
Console.WriteLine($"Used one {item.Name}. Regained {item.HealingAmount} Health.\n");
}
else
{
Console.WriteLine($"{Name} does not have any of that in their inventory.");
}
}
//#####DEBUG METHODS#####//

View file

View file

@ -4,19 +4,12 @@ public class Move
public string Description { get; set; }
public int Power { get; set; }
public int MPCost { get; set; }
public MoveType Type { get; set; }
public virtual string Type { get; set; }
public enum MoveType {
Attack,
Heal,
Buff
}
public Move(string name, string description, int power, int mpcost, MoveType type){
public Move(string name, string description, int power, int mpcost){
Name = name;
Description = description;
Power = power;
MPCost = mpcost;
Type = type;
}
}

View file