Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- public enum ItemType
- {
- NONE = 0,
- GOD_HAMMER_ELITE = 1000,
- DEAVIL_HAMMER = 1001,
- SPEAR_OF_FIRE = 2000,
- ARMOR_OF_ANGEL_DEFENCE = 3000,
- GOOD_BUCKLER = 3001,
- NECKLACE_OF_FROST = 4000
- }
- public enum WeaponType
- {
- NONE = 0,
- ARMOR = 1,
- SPEAR = 2,
- HAMMER = 3,
- JEWELERY = 4
- }
- public static class ItemHelper
- {
- public static IEnumerable getAllValues()
- {
- return Enum.GetValues(typeof(ItemType));
- }
- public static bool IsWeapon(Item itemType, out Weapon weapon)
- {
- if(itemType is Weapon currentWeapon)
- {
- weapon = currentWeapon;
- return true;
- }
- weapon = null;
- return false;
- }
- }
- public class Item
- {
- protected ItemType itemType;
- protected Item(ItemType type)
- {
- itemType = type;
- }
- public string GetDescription()
- {
- return ItemDescription.GetDescription(itemType);
- }
- }
- public class Weapon : Item
- {
- public Weapon(ItemType type) : base (type)
- {
- itemType = type;
- }
- public WeaponType GetType()
- {
- switch (itemType)
- {
- case ItemType.GOD_HAMMER_ELITE:
- case ItemType.DEAVIL_HAMMER:
- return WeaponType.HAMMER;
- case ItemType.SPEAR_OF_FIRE:
- return WeaponType.SPEAR;
- case ItemType.ARMOR_OF_ANGEL_DEFENCE:
- case ItemType.GOOD_BUCKLER:
- return WeaponType.ARMOR;
- default:
- return WeaponType.NONE;
- }
- }
- }
- public static class ItemDescription
- {
- private const string GOD_HAMMER_ELITE_DESC = "Hand tool consisting of a solid head set crosswise on a handle and used for pounding";
- private const string SPEAR_OF_FIRE_DESC = "Weapon with a pointed tip, typically of steel, and a long shaft, used for thrusting or throwing.";
- public static string GetDescription(ItemType itemType)
- {
- switch (itemType)
- {
- case ItemType.GOD_HAMMER_ELITE: return GOD_HAMMER_ELITE_DESC;
- case ItemType.SPEAR_OF_FIRE: return SPEAR_OF_FIRE_DESC;
- default:
- throw new ArgumentOutOfRangeException(nameof(itemType), itemType, null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement