Added in WeaponItem, and additional testing functions.
This commit is contained in:
parent
0d65f1e71f
commit
4b4b59b9a3
15 changed files with 49 additions and 9 deletions
4
Main.cs
4
Main.cs
|
|
@ -12,10 +12,10 @@ class Program
|
|||
Player user = new("Tanner", [], 100, 90, 20, 20);
|
||||
user.DisplayStats();
|
||||
|
||||
user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Potion"));
|
||||
user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Super Potion"));
|
||||
user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Hyper Potion"));
|
||||
user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Elixir"));
|
||||
user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Dagger"));
|
||||
|
||||
Console.WriteLine("Do you want to use your Potion? (Y/N)");
|
||||
string? input = Console.ReadLine().ToUpper();
|
||||
|
|
@ -23,7 +23,7 @@ class Program
|
|||
|
||||
if (input == "Y")
|
||||
{
|
||||
user.UseHealingItem((HealingItem)user.Inventory.FirstOrDefault(m => m.Name == "Potion"));
|
||||
user.UseHealingItem((HealingItem)user.Inventory.FirstOrDefault(m => m.Name == "Super Potion"));
|
||||
}
|
||||
|
||||
user.DisplayStats();
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -21,5 +21,11 @@
|
|||
"Name": "Elixir",
|
||||
"Description": "A simple potion.",
|
||||
"Type": "Support"
|
||||
},
|
||||
{
|
||||
"Name": "Dagger",
|
||||
"Description": "Stabby.",
|
||||
"Type": "Weapon",
|
||||
"Damage": 5
|
||||
}
|
||||
]
|
||||
|
|
@ -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+b44401c8d7d108f0c10a5464d7c3d52644511ce0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0d65f1e71f6545910b66ab67a8d835b4d1e2c5f9")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("MiniRPG")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("MiniRPG")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
c3f2c804e2ee64e4e07e15b987abb29b0956207f6714fc9b00396faa7781a1ea
|
||||
0dc65c6434da51f383575019fc82ae4b29b68e54caebc8f898b0bbe37447dce3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
552d7776ba252b8ba7a98c694923b3d159470fb983c96ce88fa765b810f80c32
|
||||
6b3357f22fac92c605e1eb42055d105ac36a261e46edee8677ddb0fa786a34ba
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -26,6 +26,10 @@ public class ItemConverter : JsonConverter<Item>
|
|||
item = new SupportItem("", "");
|
||||
break;
|
||||
|
||||
case "Weapon":
|
||||
item = new WeaponItem("", "", 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new JsonSerializationException($"Unknown item type: {type}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,9 @@ public class HealingItem : Item
|
|||
{
|
||||
Console.WriteLine("Healing item has been used");
|
||||
}
|
||||
|
||||
public override Item Clone()
|
||||
{
|
||||
return new HealingItem(Name, Description, HealingAmount);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,23 @@ public class Item
|
|||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int Amount { get; set; }
|
||||
public virtual string Type { get; set; }
|
||||
|
||||
public Item(string name, string description){
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public virtual void Action()
|
||||
{
|
||||
Console.WriteLine("Item has been used");
|
||||
}
|
||||
|
||||
public Item(string name, string description){
|
||||
Name = name;
|
||||
Description = description;
|
||||
public virtual Item Clone()
|
||||
{
|
||||
return new Item(Name, Description)
|
||||
{
|
||||
Type = this.Type
|
||||
};
|
||||
}
|
||||
}
|
||||
18
scripts/objects/items/WeaponItem.cs
Normal file
18
scripts/objects/items/WeaponItem.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
public class WeaponItem : Item
|
||||
{
|
||||
public int Damage { get; set; }
|
||||
public override string Type => "Weapon";
|
||||
public WeaponItem(string name, string description, int damage) : base(name, description){
|
||||
Damage = damage;
|
||||
}
|
||||
|
||||
public override void Action()
|
||||
{
|
||||
Console.WriteLine("Weapon item has been used");
|
||||
}
|
||||
|
||||
public override Item Clone()
|
||||
{
|
||||
return new WeaponItem(Name, Description, Damage);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue