/* Copyright 2020, Michele Santullo
 * This file is part of orotool.
 *
 * Orotool is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Orotool is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Orotool.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "datatypes.hpp"
#include <string_view>
#include <vector>
#include <string>
#include <optional>

namespace oro {
	enum class ItemType {
		Healing, //Healing items
		Unknown, //Unknown item type
		Usable, //Other usable items
		Etc, //Misc items
		Weapon, //Weapons
		Armor, //Armors
		Card, //Cards
		PetEgg, //Pet eggs
		PetArmor, //Pet accessories
		Unknown2, //Unknown items (unused)
		Ammo, //Ammunitions
		DelayConsume, //Consumable items (triggering additional actions)
		Cash //Cash shop items
	};

	enum class ItemSubtype {
		//For IT_WEAPON:
		Fist, //Unknown weapon (unused)
		Dagger, //Daggers
		OneHSword, //1-hand swords
		TwoHSword, //2-hand swords
		OneHSpear, //1-hand spears
		TwoHSpear, //2-hand spears
		OneHAxe, //1-hand axes
		TwoHAxe, //2-hand axes
		Mace, //1-hand maces
		TwoHMace, //2-hand maces
		Staff, //Staves
		TwoHStaff, //2-hand staves
		Bow, //Bows
		Knuckle, //Knuckles
		Musical, //Musical instruments
		Whip, //Whips
		Book, //Books
		Katar, //Katars
		Revolver, //Pistols
		Rifle, //Rifles
		Gatling, //Gatling guns
		Shotgun, //Shotguns
		Grenade, //Grenades
		Huuma, //Huuma shuriken

		//For IT_AMMO:
		Arrow, //Arrows
		ThrowingDagger, //Throwing daggers
		Bullet, //Bullets
		Shell, //Shells
		GrenadeAmmo, //Grenades
		Shuriken, //Shuriken
		Kunai, //Kunai
		Cannonball, //Cannon balls
		ThrowWeapon, //Other throwing weapons

		Unknown
	};

	struct ItemTypeWrapper {
		ItemTypeWrapper() = default;
		ItemTypeWrapper (const std::string& str);
		ItemTypeWrapper (std::string_view str);
		ItemTypeWrapper& operator= (const std::string& str);
		ItemTypeWrapper& operator= (std::string_view str);
		operator ItemType() const {return value;}
		ItemType value {ItemType::Unknown};
	};

	struct ItemSubtypeWrapper {
		ItemSubtypeWrapper() = default;
		ItemSubtypeWrapper (const std::string& str);
		ItemSubtypeWrapper (std::string_view str);
		ItemSubtypeWrapper& operator= (const std::string& str);
		ItemSubtypeWrapper& operator= (std::string_view str);
		operator ItemSubtype() const {return value;}
		operator int() const { return static_cast<int>(value); }
		ItemSubtype value {ItemSubtype::Unknown};
	};

	struct Item {
		unsigned int item_id;
		std::string unique_name;
		std::string name;
		ItemTypeWrapper type;
		std::optional<ItemSubtypeWrapper> subtype;
		unsigned int npc_price;
		std::optional<unsigned int> slots;
	};

	struct Items : BaseJsonReply {
		std::vector<Item> items;
	};
} //namespace oro
