/*
	Rogue Trader.
	Copyright (c) 2007, Darragh Coy.
	All rights reserved.
	Original work(s), source code & author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in source and binary forms, with or without modification, are permitted 
	provided that the following conditions are met:

		* 	Redistributions of source code must retain the above copyright notice, this list of 
			conditions and the following disclaimer.
		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
		* 	The use of any third party libraries, modules or data files provided with the source 
			form of the program must follow and respect the individual licensing terms of these 
			components. You do not have permission to modify or circumvent the licensing terms for 
			provided third party components unless the third party licenses specifically allow this. 
			If you do not agree to the terms of provided third party components then you do not have 
			permission to use them in your derived work(s).
		* 	The terms of this license do not apply to separate (but related) distributions if supplied 
			by the author(s), only to the contents of this source distribution, derived works, and the 
			binaries produced by either modified or unmodified versions of the source code. The terms 
			of this license do not also apply to any third party libraries or components provided with 
			the source distribution. Such third party elements are licensed under their own separate 
			agreements.

	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef GOODSINVENTORY_H
#define GOODSINVENTORY_H

//##############################################################################
// C Includes
//##############################################################################

#include "MathLibrary.h"

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:  GoodsInventory
// Purpose:     Class that describes all the types of goods available in the game.
//              At a singleton level, this class contains the number, names and
//              base prices for all the goods in the game. At an instance level
//              this class holds the amount of each type of good that is in the
//              inventory.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class GoodsInventory
{

 public:

        //----------------------------------------------------------------------
        // Constants
        //----------------------------------------------------------------------

        // The number of different types of goods there are in the game

        static const unsigned NUM_ITEMS = 8;

        // Normal supply level for each good: price of good is at base price at this level of units available

        static const unsigned NORMAL_SUPPLY;

        //----------------------------------------------------------------------
        // Functions
        //----------------------------------------------------------------------

        // Default constructor: constructs an inventory with the count of all items at zero

        GoodsInventory();

        // Constructor: Constructs an inventory where the count of all items is randomised according to the seed given

        GoodsInventory( unsigned randomSeed );

        // Information on a particular item in the inventory:

        const char *    getItemName         ( unsigned itemNum );
        float           getItemBuyPrice     ( unsigned itemNum );
        float           getItemSellPrice    ( unsigned itemNum );
        unsigned        getItemAmount       ( unsigned itemNum );

        // Set the amount of an item available

        void setItemAmount( unsigned itemNum , unsigned amount );

        // Get the total number of goods in the inventory

        unsigned getTotalAmount();

        // Get the total value of all the goods in the inventory: does not take into
        // account stock amounts when calculating, just uses the base value for each
        // item in the inventory.

        float getTotalValue();

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

 protected:

        //----------------------------------------------------------------------
        // Structs
        //----------------------------------------------------------------------

        // Describes a type of good that exists in the game

        struct ItemDescriptor
        {
			// Variables:
        
            const char *	name;          // name of the good
            float			basePrice;     // price of the good per unit when supply is at normal levels		
        };

        //----------------------------------------------------------------------
        // Constants
        //----------------------------------------------------------------------

        // All of the different goods that are available in the game:

        static const ItemDescriptor ITEMS[];

        // Affects how much under / over supply affects the price of each good

        static const float PRICE_ATTENUATION;

        // How much of the buy price (in percent) goods can be sold for. This forms kind of a taxation on sales..

        static const float SALE_PRICE_PERCENT;

        //----------------------------------------------------------------------
        // Variables
        //----------------------------------------------------------------------

        // Instance variable: the amount of each good available for supply in this inventory

        unsigned itemCount[NUM_ITEMS];

}; // end of: class GoodsInventory{}

#endif // end of: ifndef GOODSINVENTORY_H
