using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TeamProejct_Dungeon
{
public enum ItemType
{
Armour,
Weapon,
Consumable
}
public class IItem
{
public virtual string name { get; set; }
public virtual double buyPrice { get; set; }
public virtual double sellPrice { get; set; }
public virtual ItemType type { get; set; }
public virtual string Description() { return null; }
public virtual IItem DeepCopy()
{
return null;
}
public virtual void Use() { }
public virtual void UnUse() { }
}
public class Armour : IItem
{
public override string name { get; set; }
public override double buyPrice { get; set; }
public override double sellPrice { get; set; }
public override ItemType type { get; set; }
public int defend;
public override string Description() { return $"방어력이 {defend}만큼 상승하였습니다."; }
public override void Use() { GameManager.player.equipDfs += defend; }
public override void UnUse() { GameManager.player.equipDfs -= defend; }
public Armour(string name, double buyPrice, int defend = 0)
{
this.name = name;
this.buyPrice = buyPrice;
this.sellPrice = Math.Round(buyPrice * 0.85);
this.defend = defend;
type = ItemType.Armour;
}
public override IItem DeepCopy()
{
return new Armour(this.name, this.buyPrice, this.defend);
}
}
public class Weapon : IItem
{
public override string name { get; set; }
public override double buyPrice { get; set; }
public override double sellPrice { get; set; }
public int attack;
public override ItemType type { get; set; }
public override string Description() { return $"공격력이 {attack}만큼 상승하였습니다"; }
public override void Use() { GameManager.player.equipAtk += attack; }
public override void UnUse() { GameManager.player.equipAtk -= attack; }
public Weapon(string name, double buyPrice, int attack = 0)
{
this.name = name;
this.buyPrice = buyPrice;
this.sellPrice = Math.Round(buyPrice * 0.85);
this.attack = attack;
type = ItemType.Weapon;
}
public override IItem DeepCopy()
{
return new Weapon(this.name, this.buyPrice, this.attack);
}
}
public class Consumable : IItem
{
public override string name { get; set; }
public override double buyPrice { get; set; }
public override double sellPrice { get; set; }
public override ItemType type { get; set; }
public static int amt = 0;
public int pHeatlh;
public int pStrength;
public override string Description() { return null; }
public override void Use()
{
if (amt <= 0)
{
Console.WriteLine("포션이 없습니다. 포션을 구매해주세요.");
return;
}
if (pHeatlh > 0)
{
GameManager.player.hp += pHeatlh;
Text.TextingLine($"{this.pHeatlh} 를 회복했습니다.", ConsoleColor.Green);
}
if (pStrength > 0)
{
GameManager.player.atk += pStrength;
Text.TextingLine($"{this.pStrength} 만큼 공격력이 상승했습니다.", ConsoleColor.Green);
}
if (GameManager.player.hp > GameManager.player.maxHp)
{
GameManager.player.hp = GameManager.player.maxHp;
}
amt--;
}
public Consumable(string name, double buyPrice, int health, int strength, int amount = 1)
{
this.name = name;
this.buyPrice = buyPrice;
sellPrice = Math.Round(buyPrice * 0.85);
pHeatlh = health;
pStrength = strength;
type = ItemType.Consumable;
amt += amount;
}
public override IItem DeepCopy()
{
return new Consumable(this.name, this.buyPrice, this.pHeatlh, this.pStrength);
}
}
public static class ItemDatabase
{
static public List<Armour> armourList = new List<Armour>
{
new Armour("천 갑옷",100,3),
new Armour("불사의 갑옷",200,5),
new Armour("스파르타의 갑옷",300,10)
};
static public List<Weapon> weaponList = new List<Weapon>
{
new Weapon("나무 칼",50,3),
new Weapon("여포의 창",100, 7),
new Weapon("스파르타의 칼", 200 ,10)
};
static public List<Consumable> consumableList = new List<Consumable>
{
new Consumable("힐링 포션",50,30,0),
new Consumable("힘 포션",100,0,7),
new Consumable("만병통치약",200,10,10)
};
}
}