// ################################
// ##      Objekty predmetu      ##
// ##  a funkce s nimi spojene   ##
// ################################

#pragma once
#ifndef ITEMS_H
#define ITEMS_H

#include "common.h"
#include "independent_constants.h"

#include "context.h"
#include "players_realms.h"
#include "items_patterns.h"

using namespace std;

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

class energeticSystemClass;

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

enum items
{
	ENERGETIC_ACCUMULATOR,
	NAVIGATION_COMPUTER,
	QUARK_GLUON_CORE,
	SUBSPACE_BEACON,
	INERTIAL_DAMPERS,
	IMPULS_JET_ENGINE,
	MECHANICAL_DAMPERS,
	DEFLECTOR_SHIELDS,
	WEAPON_CIRCUIT,
	DRONE_MISSILE_LAUNCHER,
	DRONE_MISSILES,
	LASER_GUN,
	TRANSPORT_BEAM_GENERATOR,
	MAGNETICAL_COLLECTORS_OF_PLASMA,
	SUBMERSIBLE_FILTRATION_TANK,
	SUBMARINE_MINING_MACHINE,
	UNDERGROUND_DRILLING_MACHINE,
	PROBE,
	HIGH_RESOLUTION_SENSORS,
	LONG_RANGE_SENSORS,
	CLOAKING_DEVICE,
	ANDROIDS,
	MAGNETICAL_GRID,
	TRANSPORT_CONTAINER,
	ENERGETIC_CELL,
	PLASMA_FILTER,
	SCIENTIFIC_LAB,
	LIFE_SUPPORT,
	SUBSPACE_TRANSMITTER,
	MAINFRAME,
	HANGAR,
	MAGNETICAL_FILTER,
	DEUTERIUM_DECOMPOSER,
	ZIRCONIUM_REACTOR,
	ILMENITE_FURNACE
};

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

// ..:: JEDNOTKY ::..
// Neni-li uvedeno jinak, plati toto:
// quark-gluonova plasma ~ mg
// kontejnerove suroviny ~ kg
// energie               ~ TJ
// vzdalenost            ~ km
// sila                  ~ N
// zrychleni             ~ m / (s * s)
// spotreba/produkce X   ~ X / s

#define RANGE_ENERGETIC_ACCUMULATOR_ACCUMULATOR_MIN       500000
#define RANGE_ENERGETIC_ACCUMULATOR_ACCUMULATOR_MAX       100000000
#define RANGE_ENERGETIC_ACCUMULATOR_CHARGING_MIN          5000               // v gigawattech
#define RANGE_ENERGETIC_ACCUMULATOR_CHARGING_MAX          1000000            // v gigawattech

// --------------------------------
													   
#define RANGE_QUARK_GLUON_CORE_SPEED_MIN                  1                  // v nasobcich C
#define RANGE_QUARK_GLUON_CORE_SPEED_MAX                  8000               // v nasobcich C
#define RANGE_QUARK_GLUON_CORE_CONSUMPTION_MIN            1
#define RANGE_QUARK_GLUON_CORE_CONSUMPTION_MAX            100
													   
#define RANGE_NAVIGATION_COMPUTER_SPEED_MIN               1                  // v nasobcich C
#define RANGE_NAVIGATION_COMPUTER_SPEED_MAX               8000               // v nasobcich C

#define RANGE_SUBSPACE_BEACON_SPEED_MIN                   1                  // v nasobcich C
#define RANGE_SUBSPACE_BEACON_SPEED_MAX                   8000               // v nasobcich C
													   
#define RANGE_INERTIAL_DAMPERS_SPEED_MIN                  1                  // v nasobcich C
#define RANGE_INERTIAL_DAMPERS_SPEED_MAX                  8000               // v nasobcich C

// --------------------------------
													   
#define RANGE_IMPULS_ENGINE_FORCE_MIN                     100                // v giganewtonech
#define RANGE_IMPULS_ENGINE_FORCE_MAX                     10000              // v giganewtonech
#define RANGE_IMPULS_ENGINE_CONSUMPTION_MIN               10
#define RANGE_IMPULS_ENGINE_CONSUMPTION_MAX               1000
													   
#define RANGE_MECHANICAL_DAMPERS_ACCELERATION_MIN         200
#define RANGE_MECHANICAL_DAMPERS_ACCELERATION_MAX         4000

// --------------------------------
													   
#define RANGE_DEFLECTOR_SHIELDS_ACCUMULATOR_MIN           200000
#define RANGE_DEFLECTOR_SHIELDS_ACCUMULATOR_MAX           20000000
#define RANGE_DEFLECTOR_SHIELDS_CHARGING_MIN              20
#define RANGE_DEFLECTOR_SHIELDS_CHARGING_MAX              1024
#define DEFLECTOR_SHIELDS_LEAK_TO_ACCUMULATOR     (double)0.0000005f         // tenhle pomer je pro terawatty, ale jinak to je ulozene v megawattech
// s temi 20 je to totez jako u zbrani

// --------------------------------

#define RANGE_WEAPON_ENERGY_CIRCUIT_CHARGING_MIN          20
#define RANGE_WEAPON_ENERGY_CIRCUIT_CHARGING_MAX          2048
// tech 20 by sice mohlo byt nepresnych, ale to moc nevadi, na 5% nemusi zbrane uz strilet

#define DRONE_MISSILES_DAMAGE_TO_LAUNCH_RATIO             2
#define DRONE_MISSILES_MIN_DAMAGE                         20000
#define DRONE_MISSILES_MAX_DAMAGE                         200000
#define DRONE_MISSILES_MIN_RANGE                          100000
#define DRONE_MISSILES_MAX_RANGE                          10000000
													   
#define RANGE_DRONE_MISSILE_LAUNCHER_ACCUMULATOR_MIN      10000
#define RANGE_DRONE_MISSILE_LAUNCHER_ACCUMULATOR_MAX      100000
#define RANGE_DRONE_MISSILE_LAUNCHER_CHARGING_MIN         10
#define RANGE_DRONE_MISSILE_LAUNCHER_CHARGING_MAX         128
													   
#define RANGE_LASER_GUN_ACCUMULATOR_MIN                   10000
#define RANGE_LASER_GUN_ACCUMULATOR_MAX                   100000
#define RANGE_LASER_GUN_CHARGING_MIN                      10
#define RANGE_LASER_GUN_CHARGING_MAX                      128
#define RANGE_LASER_GUN_RANGE_MIN                         50000
#define RANGE_LASER_GUN_RANGE_MAX                         1000000

// --------------------------------

#define RANGE_TRANSPORT_BEAM_GENERATOR_ACCUMULATOR_MIN    100000
#define RANGE_TRANSPORT_BEAM_GENERATOR_ACCUMULATOR_MAX    100000000
#define RANGE_TRANSPORT_BEAM_GENERATOR_CHARGING_MIN       100
#define RANGE_TRANSPORT_BEAM_GENERATOR_CHARGING_MAX       100000
#define RANGE_TRANSPORT_BEAM_GENERATOR_RANGE_MIN          2
#define RANGE_TRANSPORT_BEAM_GENERATOR_RANGE_MAX          32768

// --------------------------------

#define MAGNETICAL_COLLECTORS_OF_PLASMA_RANGE             50
#define MAGNETICAL_COLLECTORS_OF_PLASMA_MIN_WINDING_SPEED 32                 // v miligramech za sekundu 
#define MAGNETICAL_COLLECTORS_OF_PLASMA_MAX_WINDING_SPEED 3200               // v miligramech za sekundu

#define SUBMERSIBLE_FILTRATION_TANK_MIN_RANGE             100000
#define SUBMERSIBLE_FILTRATION_TANK_MAX_RANGE             30000000
#define SUBMERSIBLE_FILTRATION_TANK_MIN_WINDING_SPEED     10
#define SUBMERSIBLE_FILTRATION_TANK_MAX_WINDING_SPEED     100

#define SUBMARINE_MINING_MACHINE_MIN_RANGE                100000 
#define SUBMARINE_MINING_MACHINE_MAX_RANGE                30000000
#define SUBMARINE_MINING_MACHINE_MIN_WINDING_SPEED        200                // v gramech za vterinu
#define SUBMARINE_MINING_MACHINE_MAX_WINDING_SPEED        2000               // v gramech za vterinu

#define UNDERGROUND_DRILLING_MACHINE_MIN_RANGE            100000
#define UNDERGROUND_DRILLING_MACHINE_MAX_RANGE            30000000
#define UNDERGROUND_DRILLING_MACHINE_MIN_WINDING_SPEED    10000              // v gramech za vterinu
#define UNDERGROUND_DRILLING_MACHINE_MAX_WINDING_SPEED    100000             // v gramech za vterinu

// --------------------------------

#define RANGE_HIGH_RESOLUTION_SENSORS_RANGE_MIN           149598             // v megametrech
#define RANGE_HIGH_RESOLUTION_SENSORS_RANGE_MAX           19148527           // v megametrech
#define RANGE_HIGH_RESOLUTION_SENSORS_CONSUMPTION_MIN     10000              // v megawattech
#define RANGE_HIGH_RESOLUTION_SENSORS_CONSUMPTION_MAX     100000             // v megawattech
														
#define RANGE_LONG_RANGE_SENSORS_RANGE_MIN                19                 // v terametrech
#define RANGE_LONG_RANGE_SENSORS_RANGE_MAX                41296              // v terametrech
#define RANGE_LONG_RANGE_SENSORS_CONSUMPTION_MIN          10000              // v megawattech
#define RANGE_LONG_RANGE_SENSORS_CONSUMPTION_MAX          100000             // v megawattech

// --------------------------------
														
#define RANGE_CLOAKING_DEVICE_CONSUMPTION_MIN             10000000           // v megawattech
#define RANGE_CLOAKING_DEVICE_CONSUMPTION_MAX             100000000          // v megawattech

// --------------------------------

#define ANDROIDS_MIN_CONSUMPTION                          500000             // ve wattech
#define ANDROIDS_MAX_CONSUMPTION                          1000000            // ve wattech

// --------------------------------

#define MAGNETICAL_GRID_CAPACITY                          2000000            // v miligramech

#define TRANSPORT_CONTAINER_CAPACITY                      512                // v metrech krychlovych

#define ENERGETIC_CELL_CAPACITY                           1000000            // v tera joulech

// --------------------------------

#define PLASMA_FILTER_MIN_FILTERING_SPEED         (double)1   / (double)3600 // ulrei za vterinu
#define PLASMA_FILTER_MAX_FILTERING_SPEED         (double)10  / (double)3600 // ulrei za vterinu
#define PLASMA_FILTER_WARP_MODIFIER                       100                // nasobek

#define SCIENTIFIC_LAB_WEIGHT_FOR_ONE_CAPACITY            1000

#define RANGE_LIFE_SUPPORT_CAPACITY_MIN                   100
#define RANGE_LIFE_SUPPORT_CAPACITY_MAX                   1000
#define RANGE_LIFE_SUPPORT_CONSUMPTION_MIN                5000               // v kilowattech na cloveka
#define RANGE_LIFE_SUPPORT_CONSUMPTION_MAX                50000              // v kilowattech na cloveka
// podpora zivota zere tolik energie, protoze zajistuje i umelou gravitaci a takove veci

#define SUBSPACE_MESSAGE_COST                             1

// --------------------------------

#define RANGE_MAINFRAME_BIO_NODES_MIN                     134217728
#define RANGE_MAINFRAME_BIO_NODES_MAX                     1073741824
#define RANGE_MAINFRAME_PREDICTION_MIN                    0
#define RANGE_MAINFRAME_PREDICTION_MAX                    524288
#define RANGE_MAINFRAME_TIME_REUSABILITY_MIN              0
#define RANGE_MAINFRAME_TIME_REUSABILITY_MAX              262144
#define RANGE_MAINFRAME_CONSUMPTION_MIN                   10000              // v megawattech
#define RANGE_MAINFRAME_CONSUMPTION_MAX                   100000             // v megawattech

// --------------------------------

#define MAGNETICAL_FILTER_MIN_PRODUCTION          (double)1   / (double)3600 // ulrei za vterinu
#define MAGNETICAL_FILTER_MAX_PRODUCTION          (double)100 / (double)3600 // ulrei za vterinu

#define DEUTERIUM_DECOMPOSER_MIN_PRODUCTION               10                 // v kilogramech za vterinu
#define DEUTERIUM_DECOMPOSER_MAX_PRODUCTION               100                // v kilogramech za vterinu
#define DEUTERIUM_DECOMPOSER_MIN_METAMORPHOSIS    (double)1 / (double)4      // prevod je z kg na kg
#define DEUTERIUM_DECOMPOSER_MAX_METAMORPHOSIS    (double)1 / (double)2      // prevod je z kg na kg

#define ZIRCONIUM_REACTOR_MIN_PRODUCTION          (double)1 / (double)2      // v terajoulech za vterinu
#define ZIRCONIUM_REACTOR_MAX_PRODUCTION          (double)32                 // v terajoulech za vterinu
#define ZIRCONIUM_REACTOR_MIN_METAMORPHOSIS       (double)2                  // prevod je z kg na TJ
#define ZIRCONIUM_REACTOR_MAX_METAMORPHOSIS       (double)16                 // prevod je z kg na TJ

#define ILMENITE_FURNACE_MIN_PRODUCTION                   1                  // v kilogramech za vterinu
#define ILMENITE_FURNACE_MAX_PRODUCTION                   10                 // v kilogramech za vterinu
#define ILMENITE_FURNACE_MIN_METAMORPHOSIS        (double)0.13               // prevod je z kg na kg
#define ILMENITE_FURNACE_MAX_METAMORPHOSIS        (double)0.3                // prevod je z kg na kg

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

#define REPAIRING_CHECKPOINT_PART                 (double)0.25

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

class nullItem
{
	// tato trida slouzi jen pro oddeleni NULLoveho konstruktoru pro vsechny itemy
	// obcas je treba pouzivat cilene vynulovane itemy (v sekcich lodi a zakladen)
	// tato trida slouzi pouze k tomu, aby se oddelily specialni item-konstruktory
	// ze kterych ma vypadnout vynulovany item; aby nemohlo dojit k zamene s jinym
};

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

class commonItemClass : public dataListObjectClass
{
protected:
	dtIdentifier                 patternID_;
	unsigned long                weight_;

	itemsPatternClass          * getPattern();
public:
	virtual ~commonItemClass() {};
	commonItemClass() {};
	commonItemClass(dtIdentifier patternID, unsigned long weight)
	  { patternID_ = patternID; weight_ = weight; };

	virtual dtIdentifier         getPatternID()              { return patternID_;                                };
	virtual unsigned long        getWeight()                 { return weight_;                                   };
	virtual unsigned long        getSize()                   { return getWeight() / ulHandleZero(getDensity());  };
	virtual unsigned long        getDensity()                { return getPattern()->getDensity();                };
	virtual unsigned long long   getTransport()              { return getPattern()->getTransport();              };
	virtual unsigned long long   getConstructionUlrei()      { return getPattern()->getConstructionUlrei();      };
	virtual unsigned long long   getConstructionTitanium()   { return getPattern()->getConstructionTitanium();   };
	virtual unsigned long long   getConstructionDeuterium()  { return getPattern()->getConstructionDeuterium();  };
	virtual unsigned long long   getConstructionHeavyWater() { return getPattern()->getConstructionHeavyWater(); };
	virtual unsigned long        getRepairability()          { return getPattern()->getRepairability();          };
	virtual unsigned long        getMounting()               { return getPattern()->getMounting();               };
	virtual          bool        isNull()                          = 0;
	virtual          bool        isStackable()                     = 0;
	virtual unsigned long long   getCount()                        = 0; // pocet predmetu na stacku ( u separate je jeden )
	virtual unsigned long long   getTotalUniversalWeight()         = 0; // hmotnost celeho stacku ci jednotliveho predmetu
	virtual unsigned long long   getTotalUniversalSize()           = 0; // velikost celeho stacku ci jednotliveho predmetu
	virtual          void        harm(unsigned short damagePerc)   = 0; // poskozeni predmetu
	virtual          void        repair(unsigned long long points) = 0; // oprava predmetu
	virtual unsigned long long   pointsToCheckpoint()              = 0; // kolik bodu zbyva do dalsiho checkpointu opravy

	virtual void          DB_Load       (  unsigned long ID                );
	virtual void          DB_Save       (  unsigned long ID                );
	virtual void          DB_Insert     (  unsigned long ID                );
};

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

class separateItemClass : public commonItemClass
{
protected:
	double         damage_;        // od 0 do 1 ; 1 je uplne zniceni
	double         shadowDamage_;  // tohle je tu kvuli opravam, protoze se opravuje po kusech a ne prubezne, sem se ukladaji opravene a nezapocitane casti
	// shadowDamage je z opravenych predmetu, takze sd <= 1 - damage_
public:
	virtual ~separateItemClass() {};
	separateItemClass():
	  commonItemClass(0, 0)
	  { damage_ = 0; shadowDamage_ = 0; };
	separateItemClass(dtIdentifier patternID, unsigned long weight, double damage):
	  commonItemClass(patternID, weight)
	  { damage_ = damage; shadowDamage_ = 0; };
	separateItemClass(dtIdentifier patternID, unsigned long weight):
	  commonItemClass(patternID, weight)
	  { damage_ = 0; shadowDamage_ = 0; };

//	virtual void           setDamage(double newDamage)   { damage_ = max((double)0, min((double)1, newDamage));                                                                                                                                                       };
	virtual double             getDamage()               { return damage_;                                                                                                                                                                                            };
	virtual double             getStatus()               { return (1 - damage_);                                                                                                                                                                                      };
	virtual          bool      isTotallyDevastated()     { return (1 == damage_);                                                                                                                                                                                     };
	virtual unsigned long long getCount()                { return 1; /* separate item je vzdy jeden */                                                                                                                                                                };
	virtual          bool      isStackable()             { if (this->getPattern()->isItemStackable()) errLogicalError("Item (ID %u) incompatible with it's pattern (ID %u).", (unsigned long long)this->getID(), (unsigned long long)this->getPatternID()); return 0; };
	virtual unsigned long long getTotalUniversalWeight() { return getWeight();                                                                                                                                                                                        };
	virtual unsigned long long getTotalUniversalSize()   { return getSize();                                                                                                                                                                                          };
	virtual          void      harm(unsigned short damagePerc);
	virtual          void      repair(unsigned long long points);
	virtual unsigned long long pointsToCheckpoint();

	virtual void          DB_Load       (  unsigned long ID                );
	virtual void          DB_Save       (  unsigned long ID                );
	virtual void          DB_Insert     (  unsigned long ID                );
};

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

class stackableItemClass : public commonItemClass
{
protected:
	unsigned long long working_;
	unsigned long long damaged_;
	unsigned long long shadowDamaged_; // tohle je tu kvuli opravam, protoze se opravuje po kusech a ne prubezne, sem se ukladaji opravene a nezapocitane casti
	// shadowDamage je cast opravenych predmetu, jejichz oprava jeste nebyla zapocitana; shadowDamaged_ <= working_
public:
	virtual ~stackableItemClass() {};
	stackableItemClass():
	  commonItemClass(0, 0)
	  { working_ = 0; damaged_ = 0; shadowDamaged_ = 0; };
	stackableItemClass(dtIdentifier patternID, unsigned long weight, unsigned long long working, unsigned long long damaged):
	  commonItemClass(patternID, weight)
	  { working_ = working; damaged_ = damaged; shadowDamaged_ = 0; };

	virtual void               setWorking(unsigned long long newWorking) { working_ = newWorking;                                                                                                                                                                                    };
	virtual void               setDamaged(unsigned long long newDamaged) { damaged_ = newDamaged;                                                                                                                                                                                    };
//	virtual void               repair(unsigned long count)          { shiftPile(damaged_, working_, count);                                                                                                                                                                     };
//	virtual void               shatter(unsigned long count)         { shiftPile(working_, damaged_, count);                                                                                                                                                                     };
	virtual void               addWorking(unsigned long long count)      { working_ += count;                                                                                                                                                                                        };
	virtual void               addDamaged(unsigned long long count)      { damaged_ += count;                                                                                                                                                                                        };
	virtual unsigned long long subWorking(unsigned long long count)      { count = min(count, working_); working_ -= count;                                                 return count;                                                                                            };
	virtual unsigned long long subDamaged(unsigned long long count)      { count = min(count, damaged_); damaged_ -= count; shadowDamaged_ = min(shadowDamaged_, damaged_); return count;                                                                                            };
	virtual unsigned long long getCount()                                { return working_ + damaged_;                                                                                                                                                                               };
	virtual unsigned long long getWorking()                              { return working_;                                                                                                                                                                                          };
	virtual unsigned long long getDamaged()                              { return damaged_;                                                                                                                                                                                          };
	virtual unsigned long long getAllStackedItemsTotalWeight()           { return (unsigned long long)getCount() * (unsigned long long)getWeight();                                                                                                                                  };
	virtual unsigned long long getAllStackedItemsTotalSize()             { return (unsigned long long)getCount() * (unsigned long long)getSize();                                                                                                                                    };
	virtual          bool      isStackable()                             { if (this->getPattern()->isItemSeparate()) errLogicalError("Item (ID %u) incompatible with it's pattern (ID %u).", (unsigned long long)this->getID(), (unsigned long long)this->getPatternID()); return 1; };
	virtual unsigned long long getTotalUniversalWeight()                 { return getAllStackedItemsTotalWeight();                                                                                                                                                                   };
	virtual unsigned long long getTotalUniversalSize()                   { return getAllStackedItemsTotalSize();                                                                                                                                                                     };
	virtual          void      harm(unsigned short damagePerc);
	virtual          void      repair(unsigned long long points);
	virtual unsigned long long pointsToCheckpoint();
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass() = 0;

	virtual void          DB_Load       (  unsigned long ID                );
	virtual void          DB_Save       (  unsigned long ID                );
	virtual void          DB_Insert     (  unsigned long ID                );
};

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

class energeticAccumulatorClass : public separateItemClass
{
private:
	unsigned long long accumulator_;
	unsigned long      charging_;	 // v giga wattech
//	unsigned long long energy_;
public:
	virtual ~energeticAccumulatorClass() {};
	energeticAccumulatorClass() {};
	energeticAccumulatorClass(unsigned long weight, unsigned long long accumulator, unsigned long charging):
	  separateItemClass(PATTERN_ID_ENERGETIC_ACCUMULATOR, weight, 0)
	  { accumulator_ = accumulator; charging_ = charging; };
	energeticAccumulatorClass(nullItem ni):
	  separateItemClass(PATTERN_ID_ENERGETIC_ACCUMULATOR, 0, 0)
	  { accumulator_ = 0; charging_ = 0; };

	                 bool      isNull() { return 0; };

//	void               setEnergy(unsigned long long newEnergy)              { energy_ = newEnergy;                                        };
	virtual unsigned long long actualAccumulator()                                  { return ullRound(accumulator_ * getStatus());                };
	virtual double             actualCharging()                                     { return (double)charging_ * getStatus() / (double)1000;      };
	virtual unsigned long long clientAccumulator()                                  { return accumulator_;                                        };
	virtual double             clientCharging()                                     { return (double)charging_               / (double)1000;      };
//	unsigned long long actualEnergy(energeticSystemClass * energeticSystem) { energeticSystem->energyDistributionPhase(); return energy_; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullEnergeticAccumulatorClass : public energeticAccumulatorClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual          void        setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long long   actualAccumulator()                { return 0;  };
	virtual double               actualCharging()                   { return 0;  };
	virtual unsigned long long   clientAccumulator()                { return 0;  };
	virtual double               clientCharging()                   { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullEnergeticAccumulatorClass() {};
    nullEnergeticAccumulatorClass() : energeticAccumulatorClass(nullItem()) {};
};

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

class navigationComputerClass : public separateItemClass
{
private:
	double maxSpeedToC_;
public:	
	virtual ~navigationComputerClass() {};
	navigationComputerClass() {};
	navigationComputerClass(unsigned long weight, double maxSpeedToC):
	  separateItemClass(PATTERN_ID_NAVIGATION_COMPUTER, weight, 0)
	  { maxSpeedToC_ = maxSpeedToC; };
	navigationComputerClass(nullItem ni):
	  separateItemClass(PATTERN_ID_NAVIGATION_COMPUTER, 0, 0)
	  { maxSpeedToC_ = 0; };

	                 bool      isNull() { return 0; };

	virtual double actualMaxSpeedToC() { return (maxSpeedToC_ * getStatus()); };
	virtual double clientMaxSpeedToC() { return maxSpeedToC_;                 };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullNavigationComputerClass : public navigationComputerClass
{
public:
    /* override metod common itemu */
		             bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual double actualMaxSpeedToC()                              { return 0;  };
	virtual double clientMaxSpeedToC()                              { return 0;  };
	virtual void   harm(unsigned short damagePerc)                  { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullNavigationComputerClass() {};
    nullNavigationComputerClass() : navigationComputerClass(nullItem()) {};
};


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

class quarkGluonCoreClass : public separateItemClass
{
private:
	double         maxSpeedToC_;
	unsigned short consumption_; // miligramy plasmy za sekundu
public:
	virtual ~quarkGluonCoreClass() {};
	quarkGluonCoreClass() {};
	quarkGluonCoreClass(unsigned long weight, double maxSpeedToC, unsigned short consumption):
	  separateItemClass(PATTERN_ID_QUARK_GLUON_CORE, weight, 0)
	  { maxSpeedToC_ = maxSpeedToC; consumption_ = consumption; };
	quarkGluonCoreClass(nullItem ni):
	  separateItemClass(PATTERN_ID_QUARK_GLUON_CORE, 0, 0)
	  { maxSpeedToC_ = 0; consumption_ = 0; };

	                 bool      isNull() { return 0; };

	virtual double         actualMaxSpeedToC() { return (maxSpeedToC_ * getStatus()); };
	virtual unsigned short actualConsumption() { return consumption_;                 };
	virtual double         clientMaxSpeedToC() { return maxSpeedToC_;                 };
	virtual unsigned short clientConsumption() { return consumption_;                 };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullQuarkGluonCoreClass : public quarkGluonCoreClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual double         actualMaxSpeedToC()                      { return 0;  };
	virtual unsigned short actualConsumption()                      { return 0;  };
	virtual double         clientMaxSpeedToC()                      { return 0;  };
	virtual unsigned short clientConsumption()                      { return 0;  };
	virtual void           harm(unsigned short damagePerc)          { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullQuarkGluonCoreClass() {};
    nullQuarkGluonCoreClass() : quarkGluonCoreClass(nullItem()) {};
};


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

class subspaceBeaconClass : public separateItemClass
{
private:
	double maxSpeedToC_;
public:
	virtual ~subspaceBeaconClass() {};
	subspaceBeaconClass() {};
	subspaceBeaconClass(unsigned long weight, double maxSpeedToC):
	  separateItemClass(PATTERN_ID_SUBSPACE_BEACON, weight, 0)
	  { maxSpeedToC_ = maxSpeedToC; };
	subspaceBeaconClass(nullItem):
	  separateItemClass(PATTERN_ID_SUBSPACE_BEACON, 0, 0)
	  { maxSpeedToC_ = 0; };

	                 bool      isNull() { return 0; };

	virtual double actualMaxSpeedToC() { return (maxSpeedToC_ * getStatus()); };
	virtual double clientMaxSpeedToC() { return maxSpeedToC_;                 };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullSubspaceBeaconClass : public subspaceBeaconClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual double         actualMaxSpeedToC()                      { return 0;  };
	virtual double         clientMaxSpeedToC()                      { return 0;  };
	virtual void           harm(unsigned short damagePerc)          { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullSubspaceBeaconClass() {};
    nullSubspaceBeaconClass() : subspaceBeaconClass(nullItem()) {};
};

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

class inertialDampersClass : public separateItemClass
{
private:
	double maxSpeedToC_;
public:
	virtual ~inertialDampersClass() {};
	inertialDampersClass() {};
	inertialDampersClass(unsigned long weight, double maxSpeedToC):
	  separateItemClass(PATTERN_ID_INERTIAL_DAMPERS, weight, 0)
	  { maxSpeedToC_ = maxSpeedToC; };
	inertialDampersClass(nullItem ni):
	  separateItemClass(PATTERN_ID_INERTIAL_DAMPERS, 0, 0)
	  { maxSpeedToC_ = 0; };

	                 bool      isNull() { return 0; };

	virtual double actualMaxSpeedToC() { return (maxSpeedToC_ * getStatus()); };
	virtual double clientMaxSpeedToC() { return maxSpeedToC_;                 };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullInertialDampersClass : public inertialDampersClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual double         actualMaxSpeedToC()                      { return 0;  };
	virtual double         clientMaxSpeedToC()                      { return 0;  };
	virtual void           harm(unsigned short damagePerc)          { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullInertialDampersClass() {};
    nullInertialDampersClass() : inertialDampersClass(nullItem()) {};
};

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

class impulsJetEngineClass : public separateItemClass
{
private:
	unsigned long consumption_; // kilogramu deuteria za sekundu
	unsigned long force_;       // giga newtonu
public:
	virtual ~impulsJetEngineClass() {};
	impulsJetEngineClass() {};
	impulsJetEngineClass(unsigned long weight, unsigned long consumption, unsigned long force):
	  separateItemClass(PATTERN_ID_IMPULS_JET_ENGINE, weight, 0)
	  { consumption_ = consumption; force_ = force; };
	impulsJetEngineClass(nullItem ni):
	  separateItemClass(PATTERN_ID_IMPULS_JET_ENGINE, 0, 0)
	  { consumption_ = 0; force_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualConsumption() { return consumption_;                  };
	virtual unsigned long actualForceInGN()   { return ulRound(force_ * getStatus()); };
	virtual unsigned long clientConsumption() { return consumption_;                  };
	virtual unsigned long clientForceInGN()   { return force_;                        };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullImpulsJetEngineClass : public impulsJetEngineClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualConsumption()                { return 0;  };
	virtual unsigned long        actualForce()                      { return 0;  };
	virtual unsigned long        clientConsumption()                { return 0;  };
	virtual unsigned long        clientForceInGN()                  { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullImpulsJetEngineClass() {};
    nullImpulsJetEngineClass() : impulsJetEngineClass(nullItem()) {};
};


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

class mechanicalDampersClass : public separateItemClass
{
private:
	unsigned short maxAcceleration_;
public:
	virtual ~mechanicalDampersClass() {};
	mechanicalDampersClass() {};
	mechanicalDampersClass(unsigned long weight, unsigned short maxAcceleration):
	  separateItemClass(PATTERN_ID_MECHANICAL_DAMPERS, weight, 0)
	  { maxAcceleration_ = maxAcceleration; };
	mechanicalDampersClass(nullItem ni):
	  separateItemClass(PATTERN_ID_MECHANICAL_DAMPERS, 0, 0)
	  { maxAcceleration_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned short actualMaxAcceleration() { return (unsigned short) ulRound(maxAcceleration_ * getStatus()); };
	virtual unsigned short clientMaxAcceleration() { return maxAcceleration_;                                         };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullMechanicalDampersClass : public mechanicalDampersClass
{
public:
    /* override metod common itemu */
		             bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned short       actualMaxAcceleration()            { return 0;  };
	virtual unsigned short       clientMaxAcceleration()            { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullMechanicalDampersClass() {};
    nullMechanicalDampersClass() : mechanicalDampersClass(nullItem()) {};
};

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

class deflectorShieldsGeneratorClass : public separateItemClass
{
private:
	unsigned long  solidity_;    // v hernich jednotkach
	unsigned long  accumulator_; // v tera joulech
	unsigned long  charging_;    // v tera wattech
	unsigned long  leak_;        // v mega wattech
//	unsigned long  energy_;      // v tera joulech
public:
	virtual ~deflectorShieldsGeneratorClass() {};
	deflectorShieldsGeneratorClass() {};
	deflectorShieldsGeneratorClass(unsigned long weight, unsigned long solidity, unsigned long accumulator, unsigned long charging, double leak):
	  separateItemClass(PATTERN_ID_DEFLECTOR_SHIELDS, weight, 0)
	  { solidity_ = solidity; accumulator_ = accumulator; charging_ = charging; leak_ = ulRound(1000000 * leak); };
	deflectorShieldsGeneratorClass(nullItem ni):
	  separateItemClass(PATTERN_ID_DEFLECTOR_SHIELDS, 0, 0)
	  { solidity_ = 0; accumulator_ = 0; charging_ = 0; leak_ = 0; };

	                 bool      isNull() { return 0; };

//	void          setEnergy(unsigned long newEnergy)                   { energy_ = newEnergy;                                        };
	virtual unsigned long actualSolidity()                                     { return ulRound(solidity_    * getStatus());                 };
	virtual unsigned long actualAccumulator()                                  { return ulRound(accumulator_ * getStatus());                 };
	virtual unsigned long actualCharging()                                     { return ulRound(charging_    * getStatus());                 };
	virtual double        actualLeak()                                         { return (double)leak_        / (double)1000000;              };
	virtual unsigned long clientSolidity()                                     { return solidity_;                                           };
	virtual unsigned long clientAccumulator()                                  { return accumulator_;                                        };
	virtual unsigned long clientCharging()                                     { return charging_;                                           };
	virtual double        clientLeak()                                         { return (double)leak_        / (double)1000000;              };
	virtual double        maxPossibleConsumption()                             { return charging_;                                           };
//	unsigned long actualEnergy(energeticSystemClass * energeticSystem) { energeticSystem->energyDistributionPhase(); return energy_; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullDeflectorShieldsGeneratorClass : public deflectorShieldsGeneratorClass
{
public:
    /* override metod common itemu */
		             bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long actualSolidity()                          { return 0;  };
	virtual unsigned long actualAccumulator()                       { return 0;  };
	virtual unsigned long actualCharging()                          { return 0;  };
	virtual double        actualLeak()                              { return 0;  };
	virtual unsigned long clientSolidity()                          { return 0;  };
	virtual unsigned long clientAccumulator()                       { return 0;  };
	virtual unsigned long clientCharging()                          { return 0;  };
	virtual double        clientLeak()                              { return 0;  };
	virtual double        maxPossibleConsumption()                  { return 0;  };
	virtual void          harm(unsigned short damagePerc)           { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };


    virtual ~nullDeflectorShieldsGeneratorClass() {};
    nullDeflectorShieldsGeneratorClass() : deflectorShieldsGeneratorClass(nullItem()) {};
};


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

class weaponEnergyCircuitClass : public separateItemClass
{
private:
	unsigned long charging_; // v tera joulech
public:
	virtual ~weaponEnergyCircuitClass() {};
	weaponEnergyCircuitClass() {};
	weaponEnergyCircuitClass(unsigned long weight, unsigned long charging):
	  separateItemClass(PATTERN_ID_WEAPON_ENERGY_CIRCUIT, weight, 0)
	  { charging_ = charging; };
	weaponEnergyCircuitClass(nullItem ni):
	  separateItemClass(PATTERN_ID_WEAPON_ENERGY_CIRCUIT, 0, 0)
	  { charging_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualCharging()         { return ulRound(charging_ * getStatus()); };
	virtual unsigned long clientCharging()         { return charging_;                        };
	virtual double        maxPossibleConsumption() { return charging_;                        };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullWeaponEnergyCircuitClass : public weaponEnergyCircuitClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualCharging()                   { return 0;  };
	virtual unsigned long        clientCharging()                   { return 0;  };
	virtual double               maxPossibleConsumption()           { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };


    virtual ~nullWeaponEnergyCircuitClass() {};
    nullWeaponEnergyCircuitClass() : weaponEnergyCircuitClass(nullItem()) {};
};


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

class droneMissileLauncherClass : public separateItemClass
{
private:
	unsigned long  accumulator_; // v tera joulech
	unsigned long  charging_;    // v tera wattech
//	unsigned long  energy_;      // v tera joulech
public:
	virtual ~droneMissileLauncherClass() {};
	droneMissileLauncherClass() {};
	droneMissileLauncherClass(unsigned long weight, unsigned long accumulator, unsigned long charging):
	  separateItemClass(PATTERN_ID_DRONE_MISSILE_LAUNCHER, weight, 0)
	  { accumulator_ = accumulator; charging_ = charging; };	
	droneMissileLauncherClass(nullItem ni):
	  separateItemClass(PATTERN_ID_DRONE_MISSILE_LAUNCHER, 0, 0)
	  { accumulator_ = 0; };

	                 bool      isNull() { return 0; };

//	void          setEnergy(unsigned long newEnergy)                   { energy_ = newEnergy;                                        };
	virtual unsigned long actualAccumulator()                          { return ulRound(accumulator_ * getStatus());                 };
	virtual unsigned long actualCharging()                             { return ulRound(charging_    * getStatus());                 };
	virtual unsigned long clientAccumulator()                          { return accumulator_;                                        };
	virtual unsigned long clientCharging()                             { return charging_;                                           };
//	unsigned long actualEnergy(energeticSystemClass * energeticSystem) { energeticSystem->energyDistributionPhase(); return energy_; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullDroneMissileLauncherClass : public droneMissileLauncherClass
{
public:
    /* override metod common itemu */
		             bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long actualAccumulator()                       { return 0;  };
	virtual unsigned long actualCharging()                          { return 0;  };
	virtual unsigned long clientAccumulator()                       { return 0;  };
	virtual unsigned long clientCharging()                          { return 0;  };

	virtual void          harm(unsigned short damagePerc)           { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };


    virtual ~nullDroneMissileLauncherClass() {};
    nullDroneMissileLauncherClass() : droneMissileLauncherClass(nullItem()) {};
};

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

class droneMissilesClass : public stackableItemClass
{
private:
//	unsigned long launch_;    // v tera joulech , mozna bude obecne ve vede , ne v lodi
//	unsigned long range_;     // v kilometrech
//	unsigned long precision_; // v hernich jednotkach
//	unsigned long speed_;
//	unsigned long damage_;    // v tera joulech
	// tyhle privatni polozky budou mozna spise brany z parametru hrace podle vedy
	unsigned long damage2Launch       (unsigned long damage) { return damage / DRONE_MISSILES_DAMAGE_TO_LAUNCH_RATIO;                                                           };
	unsigned long scienceLevel2Range  (double        sciLev) { return ulNumberFromScale(DRONE_MISSILES_MIN_RANGE , DRONE_MISSILES_MAX_RANGE , MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
	unsigned long scienceLevel2Damage (double        sciLev) { return ulNumberFromScale(DRONE_MISSILES_MIN_DAMAGE, DRONE_MISSILES_MAX_DAMAGE, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~droneMissilesClass() {};
	droneMissilesClass() {};
	droneMissilesClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_DRONE_MISSILES, weight, working, damaged)
	  {};
	droneMissilesClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_DRONE_MISSILES, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long actualLaunch(dtIdentifier realmID)    { return damage2Launch(actualDamage(realmID));                                                                                                                                           };
	// client
	virtual unsigned long actualRange(dtIdentifier realmID)     { return scienceLevel2Range(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_DRONE_MISSILES, INDEX_DRONE_MISSILES_RANGE));    };
	// client
	virtual unsigned long actualPrecision(dtIdentifier realmID) { return (unsigned long)(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_DRONE_MISSILES, INDEX_DRONE_MISSILES_PRECISION));   };
	// client
//	unsigned long actualSpeed()                         { return speed_;                        };
	virtual unsigned long actualDamage(dtIdentifier realmID)    { return scienceLevel2Damage(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_DRONE_MISSILES, INDEX_DRONE_MISSILES_DAMAGE));  };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullDroneMissilesClass : public droneMissilesClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualLaunch(dtIdentifier realmID)     { return 0;     };
	virtual unsigned long        actualRange(dtIdentifier realmID)      { return 0;     };
	virtual unsigned long        actualPrecision(dtIdentifier realmID)  { return 0;     };
	virtual unsigned long        actualDamage(dtIdentifier realmID)     { return 0;     };
	virtual void                 harm(unsigned short damagePerc)        { ;             };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullDroneMissilesClass() {};
    nullDroneMissilesClass() : droneMissilesClass(nullItem()) {};
};

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

class laserGunClass : public separateItemClass
{
private:
	unsigned long  accumulator_; // v tera joulech
	unsigned long  charging_;    // v tera wattech
	unsigned long  range_;       // v kilometrech
	unsigned long  precision_;   // v hernich jednotkach
	unsigned long  forcibility_; // v hernich jednotkach
//	unsigned long  energy_;      // v tera joulech
public:
	virtual ~laserGunClass() {};
	laserGunClass() {};
	laserGunClass(unsigned long weight, unsigned long accumulator, unsigned long charging, unsigned long range, unsigned long precision, unsigned long forcibility):
	  separateItemClass(PATTERN_ID_LASER_GUN, weight, 0)
	  { accumulator_ = accumulator; charging_ = charging; range_ = range; precision_ = precision; forcibility_ = forcibility; };
	laserGunClass(nullItem ni):
	  separateItemClass(PATTERN_ID_LASER_GUN, 0, 0)
	  { accumulator_ = 0; range_ = 0; precision_ = 0; forcibility_ = 0; };

	                 bool      isNull() { return 0; };

//	void          setEnergy(unsigned long newEnergy)                   { energy_ = newEnergy;                                        };
	virtual unsigned long actualAccumulator()                                  { return ulRound(accumulator_ * getStatus()); };
	virtual unsigned long actualCharging()                                     { return ulRound(charging_    * getStatus()); };
	virtual unsigned long actualRange()                                        { return         range_                     ; };
	virtual unsigned long actualPrecision()                                    { return         precision_                 ; };
	virtual unsigned long actualForcibility()                                  { return ulRound(forcibility_ * getStatus()); };
//	unsigned long actualEnergy(energeticSystemClass * energeticSystem) { energeticSystem->energyDistributionPhase(); return energy_; };
	virtual unsigned long clientAccumulator()                                  { return accumulator_;                        };
	virtual unsigned long clientCharging()                                     { return charging_;                           };
	virtual unsigned long clientRange()                                        { return range_;                              };
	virtual unsigned long clientPrecision()                                    { return precision_;                          };
	virtual unsigned long clientForcibility()                                  { return forcibility_;                        };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullLaserGunClass : public laserGunClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualAccumulator()                { return 0;  };
	virtual unsigned long        actualCharging()                   { return 0;  };
	virtual unsigned long        actualRange()                      { return 0;  };
	virtual unsigned long        actualPrecision()                  { return 0;  };
	virtual unsigned long        actualForcibility()                { return 0;  };
	virtual unsigned long        clientAccumulator()                { return 0;  };
	virtual unsigned long        clientCharging()                   { return 0;  };
	virtual unsigned long        clientRange()                      { return 0;  };
	virtual unsigned long        clientPrecision()                  { return 0;  };
	virtual unsigned long        clientForcibility()                { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };


    virtual ~nullLaserGunClass() {};
    nullLaserGunClass() : laserGunClass(nullItem()) {};
};


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

class transportBeamGeneratorClass : public separateItemClass
{
private:
	unsigned long  accumulator_; // v tera joulech
	unsigned long  charging_;    // v tera wattech
	unsigned long  range_;       // v kilometrech
	unsigned long  precision_;   // v hernich jednotkach
	unsigned long  forcibility_; // v hernich jednotkach
//	unsigned long  energy_;      // v tera joulech
public:
	virtual ~transportBeamGeneratorClass() {};
	transportBeamGeneratorClass() {};
	transportBeamGeneratorClass(unsigned long weight, unsigned long accumulator, unsigned long charging, unsigned long range, unsigned long precision, unsigned long forcibility):
	  separateItemClass(PATTERN_ID_TRANSPORT_BEAM_GENERATOR, weight, 0)
	  { accumulator_ = accumulator; charging_ = charging; range_ = range; precision_ = precision; forcibility_ = forcibility; };
	transportBeamGeneratorClass(nullItem ni):
	  separateItemClass(PATTERN_ID_TRANSPORT_BEAM_GENERATOR, 0, 0)
	  { accumulator_ = 0; charging_ = 0; range_ = 0; precision_ = 0; forcibility_ = 0; };

	                 bool      isNull() { return 0; };

//	void          setEnergy(unsigned long newEnergy)                   { energy_ = newEnergy;                                        };
	virtual unsigned long actualAccumulator()                                  { return ulRound(accumulator_ * getStatus()); };
	virtual unsigned long actualCharging()                                     { return ulRound(charging_    * getStatus()); };
	virtual unsigned long actualRange()                                        { return         range_                     ; };
	virtual unsigned long actualPrecision()                                    { return         precision_                 ; };
	virtual unsigned long actualForcibility()                                  { return ulRound(forcibility_ * getStatus()); };
	virtual unsigned long clientAccumulator()                                  { return accumulator_;                        };
	virtual unsigned long clientCharging()                                     { return charging_;                           };
	virtual unsigned long clientRange()                                        { return range_;                              };
	virtual unsigned long clientPrecision()                                    { return precision_;                          };
	virtual unsigned long clientForcibility()                                  { return forcibility_;                        };
	virtual double        maxPossibleConsumption()                             { return charging_;                           };
//	unsigned long actualEnergy(energeticSystemClass * energeticSystem) { energeticSystem->energyDistributionPhase(); return energy_; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullTransportBeamGeneratorClass : public transportBeamGeneratorClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualAccumulator()                { return 0;  };
	virtual unsigned long        actualCharging()                   { return 0;  };
	virtual unsigned long        actualRange()                      { return 0;  };
	virtual unsigned long        actualPrecision()                  { return 0;  };
	virtual unsigned long        actualForcibility()                { return 0;  };
	virtual unsigned long        clientAccumulator()                { return 0;  };
	virtual unsigned long        clientCharging()                   { return 0;  };
	virtual unsigned long        clientRange()                      { return 0;  };
	virtual unsigned long        clientPrecision()                  { return 0;  };
	virtual unsigned long        clientForcibility()                { return 0;  };
	virtual double               maxPossibleConsumption()           { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullTransportBeamGeneratorClass() {};
    nullTransportBeamGeneratorClass() : transportBeamGeneratorClass(nullItem()) {};
};

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

class magneticalCollectorsOfPlasmaClass : public stackableItemClass
{
private:
//	unsigned long range_;        // v kilometrech
//	unsigned long windingSpeed_; // rychlost tezby v miligramech za sekundu
	// tyhle primarni polozky budou dost mozna brany z parametru vedy
	unsigned long scienceLevel2WindingSpeed (double sciLev) { return ulNumberFromScale(MAGNETICAL_COLLECTORS_OF_PLASMA_MIN_WINDING_SPEED, MAGNETICAL_COLLECTORS_OF_PLASMA_MAX_WINDING_SPEED, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~magneticalCollectorsOfPlasmaClass() {};
	magneticalCollectorsOfPlasmaClass() {};
	magneticalCollectorsOfPlasmaClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_MAGNETICAL_COLLECTORS_OF_PLASMA, weight, working, damaged)
	  {};
	magneticalCollectorsOfPlasmaClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_MAGNETICAL_COLLECTORS_OF_PLASMA, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long      actualRange(dtIdentifier realmID)                         { return MAGNETICAL_COLLECTORS_OF_PLASMA_RANGE;                                                                                                                                                                                                        };
	// client
	virtual unsigned long long actualTotalWindingSpeedInMilligrams(dtIdentifier realmID) { return getWorking() * scienceLevel2WindingSpeed(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_MAGNETICAL_COLLECTORS_OF_PLASMA, INDEX_MAGNETICAL_COLLECTORS_OF_PLASMA_WINDING_SPEED));  };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullMagneticalCollectorsOfPlasmaClass : public magneticalCollectorsOfPlasmaClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualRange(dtIdentifier realmID)                         { return 0;         };
	virtual unsigned long long   actualTotalWindingSpeedInMilligrams(dtIdentifier realmID) { return 0;         };
	virtual void                 harm(unsigned short damagePerc)                           { ;                 };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullMagneticalCollectorsOfPlasmaClass() {};
    nullMagneticalCollectorsOfPlasmaClass() : magneticalCollectorsOfPlasmaClass(nullItem()) {};
};


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

class submersibleFiltrationTankClass : public stackableItemClass
{
private:
//	unsigned long range_;        // v kilometrech
//	unsigned long windingSpeed_; // rychlost tezby v gramech za sekundu
	// tyhle primarni polozky budou dost mozna brany z parametru vedy
	unsigned long scienceLevel2Range        (double sciLev) { return ulNumberFromScale(SUBMERSIBLE_FILTRATION_TANK_MIN_RANGE        , SUBMERSIBLE_FILTRATION_TANK_MAX_RANGE        , MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
	unsigned long scienceLevel2WindingSpeec (double sciLev) { return ulNumberFromScale(SUBMERSIBLE_FILTRATION_TANK_MIN_WINDING_SPEED, SUBMERSIBLE_FILTRATION_TANK_MAX_WINDING_SPEED, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~submersibleFiltrationTankClass() {};
	submersibleFiltrationTankClass() {};
	submersibleFiltrationTankClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_SUBMERSIBLE_FILTRATION_TANK, weight, working, damaged)
	  {};
	submersibleFiltrationTankClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_SUBMERSIBLE_FILTRATION_TANK, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long      actualRange(dtIdentifier realmID)             { return scienceLevel2Range       (actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_SUBMERSIBLE_FILTRATION_TANK, INDEX_SUBMERSIBLE_FILTRATION_TANK_RANGE        ));                };
	// client
	virtual unsigned long long actualTotalWindingSpeed(dtIdentifier realmID) { return getWorking() * scienceLevel2WindingSpeec(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_SUBMERSIBLE_FILTRATION_TANK, INDEX_SUBMERSIBLE_FILTRATION_TANK_WINDING_SPEED)); };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullSubmersibleFiltrationTankClass : public submersibleFiltrationTankClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualRange(dtIdentifier realmID)                      { return 0;         };
	virtual unsigned long long   actualTotalWindingSpeed(dtIdentifier realmID)          { return 0;         };
	virtual void                 harm(unsigned short damagePerc)                        { ;                 };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullSubmersibleFiltrationTankClass() {};
    nullSubmersibleFiltrationTankClass() : submersibleFiltrationTankClass(nullItem()) {};
};


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

class submarineMiningMachineClass : public stackableItemClass
{
private:
//	unsigned long range_;        // v kilometrech
//	unsigned long windingSpeed_; // rychlost tezby v gramech za sekundu
	// tyhle primarni polozky budou dost mozna brany z parametru vedy
	unsigned long scienceLevel2Range        (double sciLev) { return ulNumberFromScale(SUBMARINE_MINING_MACHINE_MIN_RANGE        , SUBMARINE_MINING_MACHINE_MAX_RANGE        , MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
	unsigned long scienceLevel2WindingSpeed (double sciLev) { return ulNumberFromScale(SUBMARINE_MINING_MACHINE_MIN_WINDING_SPEED, SUBMARINE_MINING_MACHINE_MAX_WINDING_SPEED, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~submarineMiningMachineClass() {};
	submarineMiningMachineClass() {};
	submarineMiningMachineClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_SUBMARINE_MINING_MACHINE, weight, working, damaged)
	  {};	
	submarineMiningMachineClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_SUBMARINE_MINING_MACHINE, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long      actualRange(dtIdentifier realmID)                    { return scienceLevel2Range       (actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_SUBMARINE_MINING_MACHINE, INDEX_SUBMARINE_MINING_MACHINE_RANGE        ));                };
	// client
	virtual unsigned long long actualTotalWindingSpeedInGrams(dtIdentifier realmID) { return getWorking() * scienceLevel2WindingSpeed(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_SUBMARINE_MINING_MACHINE, INDEX_SUBMARINE_MINING_MACHINE_WINDING_SPEED)); };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullSubmarineMiningMachineClass : public submarineMiningMachineClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long      actualRange(dtIdentifier realmID)                    { return 0;     };
	virtual unsigned long long actualTotalWindingSpeedInGrams(dtIdentifier realmID) { return 0;     };
	virtual void               harm(unsigned short damagePerc)                      { ;             };
	virtual          void      repair(unsigned long long points)                    { ;             };
	virtual unsigned long long pointsToCheckpoint()                                 { return 0;     };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullSubmarineMiningMachineClass() {};
    nullSubmarineMiningMachineClass() : submarineMiningMachineClass(nullItem()) {};
};


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

class undergroundDrillingMachineClass : public stackableItemClass
{
private:
//	unsigned long range_;        // v kilometrech
//	unsigned long windingSpeed_; // rychlost tezby v gramech za sekundu
	// tyhle primarni polozky budou dost mozna brany z parametru vedy
	unsigned long scienceLevel2Range        (double sciLev) { return ulNumberFromScale(UNDERGROUND_DRILLING_MACHINE_MIN_RANGE        , UNDERGROUND_DRILLING_MACHINE_MAX_RANGE        , MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
	unsigned long scienceLevel2WindingSpeed (double sciLev) { return ulNumberFromScale(UNDERGROUND_DRILLING_MACHINE_MIN_WINDING_SPEED, UNDERGROUND_DRILLING_MACHINE_MAX_WINDING_SPEED, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~undergroundDrillingMachineClass() {};
	undergroundDrillingMachineClass() {};
	undergroundDrillingMachineClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_UNDERGROUND_DRILLIG_MACHINE, weight, working, damaged)
	  {};
	undergroundDrillingMachineClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_UNDERGROUND_DRILLIG_MACHINE, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long      actualRange(dtIdentifier realmID)                    { return scienceLevel2Range       (actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_UNDERGROUND_DRILLING_MACHINE, INDEX_UNDERGROUND_DRILLING_MACHINE_RANGE        ));                };
	// client
	virtual unsigned long long actualTotalWindingSpeedInGrams(dtIdentifier realmID) { return getWorking() * scienceLevel2WindingSpeed(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_UNDERGROUND_DRILLING_MACHINE, INDEX_UNDERGROUND_DRILLING_MACHINE_WINDING_SPEED)); };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullUndergroundDrillingMachineClass : public undergroundDrillingMachineClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long      actualRange(dtIdentifier realmID)                    { return 0;     };
	virtual unsigned long long actualTotalWindingSpeedInGrams(dtIdentifier realmID) { return 0;     };
	virtual void               harm(unsigned short damagePerc)                      { ;             };
	virtual          void      repair(unsigned long long points)                    { ;             };
	virtual unsigned long long pointsToCheckpoint()                                 { return 0;     };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullUndergroundDrillingMachineClass() {};
    nullUndergroundDrillingMachineClass() : undergroundDrillingMachineClass(nullItem()) {};
};


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

class probeClass : public separateItemClass
{
private:
	unsigned long level_; // v hednich jednotkach
public:
	virtual ~probeClass() {};
	probeClass() {};
	probeClass(unsigned long weight, unsigned long level):
	  separateItemClass(PATTERN_ID_PROBE, weight, 0)
	  { level_ = level; };
	probeClass(nullItem ni):
	  separateItemClass(PATTERN_ID_PROBE, 0, 0)
	  { level_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualLevel() { return ulRound(level_ * getStatus()); };
	virtual unsigned long clientLevel() { return level_;                        };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullProbeClass : public probeClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualLevel()                      { return 0;  };
	virtual unsigned long        clientLevel()                      { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullProbeClass() {};
    nullProbeClass() : probeClass(nullItem()) {};
};

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

class highResolutionSensorsClass : public separateItemClass
{
private:
	unsigned long range_;       // v mega metrech
	unsigned long level_;       // v hernich jednotkach
	unsigned long consumption_; // v mega wattech
public:
	virtual ~highResolutionSensorsClass() {};
	highResolutionSensorsClass() {};
	highResolutionSensorsClass(unsigned long weight, unsigned long range, unsigned long level, unsigned long consumption):
	  separateItemClass(PATTERN_ID_HIGH_RESOLUTION_SENSORS, weight, 0)
	  { range_ = range; level_ = level; consumption_ = consumption; };
	highResolutionSensorsClass(nullItem ni):
	  separateItemClass(PATTERN_ID_HIGH_RESOLUTION_SENSORS, 0, 0)
	  { range_ = 0; level_ = 0; consumption_ = 0; };

	                 bool      isNull() { return 0; };

	virtual dist_t        actualRange()            { return ulRound(range_       * getStatus() * 1000); };
	virtual unsigned long actualLevel()            { return ulRound(level_       * getStatus())       ; };
	virtual double        actualConsumption()      { return (double)consumption_ / (double)1000000    ; };
	virtual dist_t        clientRange()            { return range_ * 1000;                              };
	virtual unsigned long clientLevel()            { return level_;                                     };
	virtual double        clientConsumption()      { return (double)consumption_ / (double)1000000;     };
	virtual double        maxPossibleConsumption() { return (double)consumption_ / (double)1000000;     };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullHighResolutionSensorsClass : public highResolutionSensorsClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual dist_t               actualRange()                      { return 0;  };
	virtual unsigned long        actualLevel()                      { return 0;  };
	virtual double               actualConsumption()                { return 0;  };
	virtual dist_t               clientRange()                      { return 0;  };
	virtual unsigned long        clientLevel()                      { return 0;  };
	virtual double               clientConsumption()                { return 0;  };
	virtual double               maxPossibleConsumption()           { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { 0;         };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullHighResolutionSensorsClass() {};
    nullHighResolutionSensorsClass() : highResolutionSensorsClass(nullItem()) {};
};

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

class longRangeSensorsClass : public separateItemClass
{
private:
	unsigned long range_;       // v tera metrech
	unsigned long level_;       // v hernich jednotkach
	unsigned long consumption_; // v mega wattech
public:
	virtual ~longRangeSensorsClass() {};
	longRangeSensorsClass() {};
	longRangeSensorsClass(unsigned long weight, unsigned long range, unsigned long level, unsigned long consumption):
	  separateItemClass(PATTERN_ID_LONG_RANGE_SENSORS, weight, 0)
	  { range_ = range; level_ = level; consumption_ = consumption; };
	longRangeSensorsClass(nullItem ni):
	  separateItemClass(PATTERN_ID_LONG_RANGE_SENSORS, 0, 0)
	  { range_ = 0; level_ = 0; consumption_ = 0; };

	                 bool      isNull() { return 0; };

	virtual dist_t        actualRange()            { return (double)range_       * getStatus()  *      1000000000; };
	virtual unsigned long actualLevel()            { return ulRound(level_       * getStatus())                  ; };
	virtual double        actualConsumption()      { return (double)consumption_                / (double)1000000; };
	virtual dist_t        clientRange()            { return (double)range_                      *      1000000000; };
	virtual unsigned long clientLevel()            { return level_                                               ; };
	virtual double        clientConsumption()      { return (double)consumption_                / (double)1000000; };
	virtual double        maxPossibleConsumption() { return (double)consumption_                / (double)1000000; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullLongRangeSensorsClass : public longRangeSensorsClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual dist_t               actualRange()                      { return 0;  };
	virtual unsigned long        actualLevel()                      { return 0;  };
	virtual double               actualConsumption()                { return 0;  };
	virtual dist_t               clientRange()                      { return 0;  };
	virtual unsigned long        clientLevel()                      { return 0;  };
	virtual double               clientConsumption()                { return 0;  };
	virtual double               maxPossibleConsumption()           { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { 0;         };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullLongRangeSensorsClass() {};
    nullLongRangeSensorsClass() : longRangeSensorsClass(nullItem()) {};
};

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

class cloakingDeviceClass : public separateItemClass
{
private:
	unsigned long level_;       // v hernich jednotkach
	unsigned long consumption_; // v mega wattech
public:
	virtual ~cloakingDeviceClass() {};
	cloakingDeviceClass() {};
	cloakingDeviceClass(unsigned long weight, unsigned long level, unsigned long consumption):
	  separateItemClass(PATTERN_ID_CLOAKING_DEVICE, weight, 0)
	  { level_ = level; consumption_ = consumption; };
	cloakingDeviceClass(nullItem ni):
	  separateItemClass(PATTERN_ID_CLOAKING_DEVICE, 0, 0)
	  { level_ = 0; consumption_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualLevel()            { return ulRound(level_       * getStatus());    };
	virtual double        actualConsumption()      { return (double)consumption_ / (double)1000000; };
	virtual unsigned long clientLevel()            { return level_;                                 };
	virtual double        clientConsumption()      { return (double)consumption_ / (double)1000000; };
	virtual double        maxPossibleConsumption() { return (double)consumption_ / (double)1000000; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullCloakingDeviceClass : public cloakingDeviceClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualLevel()                      { return 0;  };
	virtual double               actualConsumption()                { return 0;  };
	virtual unsigned long        clientLevel()                      { return 0;  };
	virtual double               clientConsumption()                { return 0;  };
	virtual double               maxPossibleConsumption()           { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullCloakingDeviceClass() {};
    nullCloakingDeviceClass() : cloakingDeviceClass(nullItem()) {};
};


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

class androidsClass : public stackableItemClass
{
private:	
//	unsigned long level_;       // v hernich jednotkach
//	unsigned long consumption_; // v kilo wattech
	unsigned long scienceLevel2Consumption (double sciLev) { return ulNumberFromScale(ANDROIDS_MIN_CONSUMPTION, ANDROIDS_MAX_CONSUMPTION, MAX_TOTAL_SCIENCE_LEVEL, MAX_TOTAL_SCIENCE_LEVEL - sciLev); };
public:
	virtual ~androidsClass() {};
	androidsClass() {};
	androidsClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_ANDROIDS, weight, working, damaged)
	  {};
	androidsClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_ANDROIDS, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long actualLevel(dtIdentifier realmID)              { return (unsigned long)(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_ANDROIDS, INDEX_ANDROIDS_LEVEL));                 };
	// client
	virtual unsigned long actualPointsPerSecond(fortressClass * owner)                                                                                                                                                                                           ;
	// client
	virtual double        actualWorkingConsumption(dtIdentifier realmID) { return actualConsumption(realmID) * (double)getWorking();                                                                                                                            };
	// client
	virtual double        actualConsumption(dtIdentifier realmID)        { return (double)consumptionInWatts(realmID) / (double)1000000000000;                                                                                                                  };
	// client
	virtual double        maxPossibleConsumption()                       { return (double)ANDROIDS_MAX_CONSUMPTION / (double)1000000000000 * (double)this->getCount();                                                                                          };
	virtual unsigned long consumptionInWatts(dtIdentifier realmID)       { return scienceLevel2Consumption(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_ANDROIDS, INDEX_ANDROIDS_CONSUMPTION));  };
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullAndroidsClass : public androidsClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long actualLevel(dtIdentifier realmID)                 { return 0;     };
	virtual unsigned long actualPointsPerSecond(dtIdentifier realmID)       { return 0;     };
	virtual double        actualWorkingConsumption(dtIdentifier realmID)    { return 0;     };
	virtual double        actualConsumption(dtIdentifier realmID)           { return 0;     };
	virtual unsigned long consumptionInWatts(dtIdentifier realmID)          { return 0;     };
	virtual double        maxPossibleConsumption()                          { return 0;     };
	virtual void          harm(unsigned short damagePerc)                   { ;             };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullAndroidsClass() {};
    nullAndroidsClass() : androidsClass(nullItem()) {};
};


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

class magneticalGridClass : public stackableItemClass
{
private:	
//	unsigned long capacity_; // v gramech
public:
	virtual ~magneticalGridClass() {};
	magneticalGridClass() {};
	magneticalGridClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_MAGNETICAL_GRID, weight, working, damaged)
	  {};
	magneticalGridClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_MAGNETICAL_GRID, 0, 0, 0)
	  {};

  	                 bool      isNull() { return 0; };

	virtual unsigned long actualCapacity()                 { return MAGNETICAL_GRID_CAPACITY; };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullMagneticalGridClass : public magneticalGridClass
{
public:
    /* override metod common itemu */
		             bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long actualCapacity()                              { return 0;     };
	virtual void          harm(unsigned short damagePerc)               { ;             };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullMagneticalGridClass() {};
    nullMagneticalGridClass() : magneticalGridClass(nullItem()) {};
};

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

class transportContainerClass : public stackableItemClass
{
private:	
//	unsigned long capacity_; // v metrech krychlovych
public:
	virtual ~transportContainerClass() {};
	transportContainerClass() {};
	transportContainerClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_TRANSPORT_CONTAINER, weight, working, damaged)
	  {};
	transportContainerClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_TRANSPORT_CONTAINER, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long actualCapacity()                 { return TRANSPORT_CONTAINER_CAPACITY;  };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullTransportContainerClass : public transportContainerClass
{
public:
    /* override metod common itemu */
		             bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long actualCapacity()                              { return 0;     };
	virtual void          harm(unsigned short damagePerc)               { ;             };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullTransportContainerClass() {};
    nullTransportContainerClass() : transportContainerClass(nullItem()) {};
};

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

class energeticCellClass : public stackableItemClass
{
private:	
//	unsigned long capacity_; // v tera joulech
public:
	virtual ~energeticCellClass() {};
	energeticCellClass() {};
	energeticCellClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_ENERGETIC_CELL, weight, working, damaged)
	  {};
	energeticCellClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_ENERGETIC_CELL, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long actualCapacity()                 { return ENERGETIC_CELL_CAPACITY;  };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullEnergeticCellClass : public energeticCellClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long actualCapacity()                              { return 0;     };
	virtual void          harm(unsigned short damagePerc)               { ;             };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullEnergeticCellClass() {};
    nullEnergeticCellClass() : energeticCellClass(nullItem()) {};
};


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

class plasmaFilterClass : public separateItemClass
{
private:
	double scienceLevel2FilteringSpeed (double sciLev) { return dNumberFromScale(PLASMA_FILTER_MIN_FILTERING_SPEED, PLASMA_FILTER_MAX_FILTERING_SPEED, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~plasmaFilterClass() {};
	plasmaFilterClass() {};
	plasmaFilterClass(unsigned long weight):
	  separateItemClass(PATTERN_ID_PLASMA_FILTER, weight, 0)
	  {};
	plasmaFilterClass(nullItem ni):
	  separateItemClass(PATTERN_ID_PLASMA_FILTER, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual double        actualTotalFilteringSpeed(dtIdentifier realmID, bool isInWarp) { double fs = scienceLevel2FilteringSpeed(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_MAGNETICAL_FILTER, INDEX_MAGNETICAL_FILTER_PRODUCTION)); if (isInWarp) return PLASMA_FILTER_WARP_MODIFIER * fs; else return fs; };
	// client

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullPlasmaFilterClass : public plasmaFilterClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual double               actualTotalFilteringSpeed(dtIdentifier realmID, bool isInWarp) { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullPlasmaFilterClass() {};
    nullPlasmaFilterClass() : plasmaFilterClass(nullItem()) {};
};


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

class scientificLabClass : public separateItemClass
{
private:
	unsigned long level_;    // v hernich jednotkach
	unsigned long capacity_; // kolik vedcu pojme
public:
	virtual ~scientificLabClass() {};
	scientificLabClass() {};
	scientificLabClass(unsigned long weight, unsigned long level, unsigned long capacity):
	  separateItemClass(PATTERN_ID_SCIENTIFIC_LAB, weight, 0)
	  { level_ = level; capacity_ = capacity; };
	scientificLabClass(nullItem ni):
	  separateItemClass(PATTERN_ID_SCIENTIFIC_LAB, 0, 0)
	  { level_ = 0; capacity_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualLevel()    { return ulRound(level_ * getStatus());    };
	virtual unsigned long clientLevel()    { return level_;                           };
	virtual unsigned long actualCapacity() { return ulRound(capacity_ * getStatus()); };
	virtual unsigned long clientCapacity() { return capacity_;                        };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullScientificLabClass : public scientificLabClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualLevel()                      { return 0;  };
	virtual unsigned long        clientLevel()                      { return 0;  };
	virtual unsigned long        actualCapacity()                   { return 0;  };
	virtual unsigned long        clientCapacity()                   { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullScientificLabClass() {};
    nullScientificLabClass() : scientificLabClass(nullItem()) {};
};


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

class lifeSupportClass : public separateItemClass
{
private:
	unsigned long capacity_;    // kolik lidi udrzi
	unsigned long consumption_; // v kilo wattech - NA CLOVEKA, NE CELKOVA SPOTREBA!!!!
public:
	virtual ~lifeSupportClass() {};
	lifeSupportClass() {};
	lifeSupportClass(unsigned long weight, unsigned long capacity, unsigned long consumption):
	  separateItemClass(PATTERN_ID_LIFE_SUPPORT, weight, 0)
	  { capacity_ = capacity; consumption_ = consumption; };
	lifeSupportClass(nullItem ni):
	  separateItemClass(PATTERN_ID_LIFE_SUPPORT, 0, 0)
	  { capacity_ = 0; consumption_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualCapacity()                       { return capacity_                                                                                                                                                         ; };
	virtual double        actualConsumption(unsigned long lifes) { return (double)consumption_ * (double)min(lifes, capacity_) * ((double)1 + getDamage() * (double)9) / (double)1000000000                                                 ; };
	virtual unsigned long lifesByConsumption(double consumption) { double maxConsumption = actualConsumption(capacity_); double ratio = min(consumption, maxConsumption) / maxConsumption; return (unsigned long)(ratio * (double)capacity_); };
	virtual unsigned long clientCapacity()                       { return capacity_;                                                                                                                                                          };
	virtual double        clientConsumptionForOnePerson()        { return (double)consumption_                                                                         / (double)1000000000                                                 ; };
	virtual double        maxPossibleConsumption()               { return (double)consumption_ * (double)   (       capacity_) * ((double)1 + 1           * (double)9) / (double)1000000000                                                 ; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullLifeSupportClass : public lifeSupportClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;  };
	virtual dtIdentifier         getPatternID()                         { return 0;  };
	virtual unsigned long        getWeight()                            { return 0;  };
	virtual unsigned long        getSize()                              { return 0;  };
	virtual unsigned long        getDensity()                           { return 0;  };
	virtual unsigned long long   getTransport()                         { return 0;  };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;  };
	virtual unsigned long long   getConstructionTitanium()              { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;  };
	virtual unsigned long        getRepairability()                     { return 0;  };
	virtual unsigned long        getMounting()                          { return 0;  };
    virtual unsigned long long   getCount()                             { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)            { ;          };
	virtual double               getDamage()                            { return 1;  };
	virtual double               getStatus()                            { return 0;  };
	virtual          bool        isTotallyDevastated()                  { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualCapacity()                       { return 0;  };
	virtual double               actualConsumption(unsigned long lifes) { return 0;  };
	virtual unsigned long        lifesByConsumption(double consumption) { return 0;  };
	virtual unsigned long        clientCapacity()                       { return 0;  };
	virtual double               clientConsumptionForOnePerson()        { return 0;  };
	virtual double               maxPossibleConsumption()               { return 0;  };
	virtual void                 harm(unsigned short damagePerc)        { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullLifeSupportClass() {};
    nullLifeSupportClass() : lifeSupportClass(nullItem()) {};
};


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

class subspaceTransmitterClass : public separateItemClass
{
private:
	unsigned long messageCost_; // v tera joulech
public:
	virtual ~subspaceTransmitterClass() {};
	subspaceTransmitterClass() {};
	subspaceTransmitterClass(unsigned long weight, unsigned long messageCost):
	  separateItemClass(PATTERN_ID_SUBSPACE_TRANSMITTER, weight, 0)
	  { messageCost_ = messageCost; };
	subspaceTransmitterClass(nullItem ni):
	  separateItemClass(PATTERN_ID_SUBSPACE_TRANSMITTER, 0, 0)
	  { messageCost_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualMessageCost() { return ulRound(messageCost_ * (1 + getDamage() * 99)); };
	virtual unsigned long clientMessageCost() { return messageCost_;                                   };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullSubspaceTransmitterClass : public subspaceTransmitterClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualMessageCost()                { return 0;  };
	virtual unsigned long        clientMessageCost()                { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullSubspaceTransmitterClass() {};
    nullSubspaceTransmitterClass() : subspaceTransmitterClass(nullItem()) {};
};

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

class mainframeClass : public separateItemClass
{
private:
	unsigned long bioNodes_;        // bez jednotek , proste pocet uzlu
	unsigned long prediction_;      // nejaka imaginarni jednotka
	unsigned long timeReusability_; // nejaka imaginarni jednotka
	unsigned long consumption_;     // v mega wattech
public:
	virtual ~mainframeClass() {};
	mainframeClass() {};
	mainframeClass(unsigned long weight, unsigned long bioNodes, unsigned long prediction, unsigned long timeReusability, unsigned long consumption):
	  separateItemClass(PATTERN_ID_MAINFRAME, weight, 0)
	  { bioNodes_ = bioNodes; prediction_ = prediction; timeReusability_ = timeReusability; consumption_ = consumption; };
	mainframeClass(nullItem ni):
	  separateItemClass(PATTERN_ID_MAINFRAME, 0, 0)
	  { bioNodes_ = 0; prediction_ = 0; timeReusability_ = 0; consumption_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualBioNodes()         { return         bioNodes_                         ; };
	virtual unsigned long actualPrediction()       { return ulRound(prediction_      * getStatus())   ; };
	virtual unsigned long actualTimeReusability()  { return ulRound(timeReusability_ * getStatus())   ; };
	virtual double        actualConsumption()      { return (double)consumption_     / (double)1000000; };
	virtual unsigned long clientBioNodes()         { return bioNodes_;                                  };
	virtual unsigned long clientPrediction()       { return prediction_;                                };
	virtual unsigned long clientTimeReusability()  { return timeReusability_;                           };
	virtual double        clientConsumption()      { return (double)consumption_     / (double)1000000; };
	virtual double        maxPossibleConsumption() { return (double)consumption_     / (double)1000000; };

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullMainframeClass : public mainframeClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long        actualBioNodes()                   { return 0;  };
	virtual unsigned long        actualPrediction()                 { return 0;  };
	virtual unsigned long        actualTimeReusability()            { return 0;  };
	virtual double               actualConsumption()                { return 0;  };
	virtual unsigned long        clientBioNodes()                   { return 0;  };
	virtual unsigned long        clientPrediction()                 { return 0;  };
	virtual unsigned long        clientTimeReusability()            { return 0;  };
	virtual double               clientConsumption()                { return 0;  };
	virtual double               maxPossibleConsumption()           { return 0;  };
	virtual void                 harm(unsigned short damagePerc)    { ;          };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullMainframeClass() {};
    nullMainframeClass() : mainframeClass(nullItem()) {};
};


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

class fortressClass;

// ================================

enum itemsCreationResult
{
	ICR_OK,
	ICR_INVALID_PARAMS,
	ICR_FULL_HANGAR,
	ICR_NOT_ENOUGH_ULREI,
	ICR_NOT_ENOUGH_TITANIUM,
	ICR_NOT_ENOUGH_DEUTERIUM,
	ICR_NOT_ENOUGH_HEAVY_WATER
};

// ================================

class hangarClass : public separateItemClass
{
private:
	unsigned long       level_;  // v hernich jednotkach
	unsigned long       length_; // delka hangaru
	unsigned long       width_;  // sirka hangaru
	unsigned long       height_; // vyska hangaru

	dtIdentifier        dockingShipID_;            // IDcko kotvici lodi

	dtIdentifier        newShipClassID_;           // trida vyrabene lodi
	dtIdentifier        newItemPatternID_;         // pattern vyrabeneho itemu
	unsigned long long  pointsConstructed_;        // vyrobenost (v konstrukcnich bodech) noveho itemu
	dv_time::datetime   pointsConstructedUpdate_;  // update time pro aktualni vyrobenost
	itemDimensionsClass newItemDimensions_;        // rozmery vyrabeneho itemu
	unsigned long       newItemsCount_;            // pocet vyrabenych itemu (separatni po jednom)
	dtIdentifier        mainframeForBaseID_;       // mainframe pro jadro zakladny
	dv_time::datetime   checkConstructionTrigger_; // cas nejblizsiho triggeru

	double              buildingGradient_;         // neukladat do db, klient si updatuje i vyzada

	void                saveConstructedShip             (fortressClass * constructingFortress);
	bool                finishShipConstruction          (fortressClass * constructingFortress);
	void                saveConstructedItem             (fortressClass * constructingFortress);
	bool                finishItemConstruction          (fortressClass * constructingFortress);
	void                setConstructionTriggerIfItIsToBe(fortressClass * constructingFortress);
	unsigned long long  androidsPowerPerGameSecondInThisHangarForActualItem(fortressClass * constructingFortress);
	unsigned long long  actualShipTotalCost() const;
	unsigned long long  actualItemTotalCost() const;
	unsigned long long  actualConstructionTotalCost() const { return actualShipTotalCost() + actualItemTotalCost(); /* jeden scitanec bude nulovy */ };
	unsigned long long  science2Value  (double science, unsigned long long lowEnd, unsigned long long highEnd,                                                                                                                      unsigned long long weight, unsigned long long maxWeight, unsigned long long minWeight)                                                                                                                                                             ;
	unsigned long long  science2Value  (double science, unsigned long long lowEnd, unsigned long long highEnd, unsigned long long nativeInfluence, unsigned long long bestNativeInfluence, unsigned long long worstNativeInfluence, unsigned long long weight, unsigned long long maxWeight, unsigned long long minWeight)                                                                                                                                                             ;
	unsigned long       ulScience2Value(double science, unsigned long long lowEnd, unsigned long long highEnd,                                                                                                                      unsigned long long weight, unsigned long long maxWeight, unsigned long long minWeight) { return (unsigned long)science2Value(science, lowEnd, highEnd,                                                             weight, maxWeight, minWeight); };
	unsigned long       ulScience2Value(double science, unsigned long long lowEnd, unsigned long long highEnd, unsigned long long nativeInfluence, unsigned long long bestNativeInfluence, unsigned long long worstNativeInfluence, unsigned long long weight, unsigned long long maxWeight, unsigned long long minWeight) { return (unsigned long)science2Value(science, lowEnd, highEnd, nativeInfluence, bestNativeInfluence, worstNativeInfluence, weight, maxWeight, minWeight); };

    unsigned long long constructionTriggerIdentificator;
public:
	virtual ~hangarClass() {};
	hangarClass() { constructionTriggerIdentificator = 0; };
	hangarClass(unsigned long weight, unsigned long level, unsigned long length, unsigned long width, unsigned long height):
	  separateItemClass(PATTERN_ID_HANGAR, weight, 0)
	  { constructionTriggerIdentificator = 0; level_ = level; length_ = length; width_ = width; height_ = height; newItemPatternID_ = 0; newShipClassID_ = 0; dockingShipID_ = 0; checkConstructionTrigger_ = 0; buildingGradient_ = 0; };
	hangarClass(nullItem ni):
	  separateItemClass(PATTERN_ID_HANGAR, 0, 0)
	  { constructionTriggerIdentificator = 0; level_ = 0; length_ = 0; width_ = 0; height_ = 0; newItemPatternID_ = 0; newShipClassID_ = 0; dockingShipID_ = 0; checkConstructionTrigger_ = 0; buildingGradient_ = 0; };

	                 bool      isNull() { return 0; };

	virtual unsigned long actualLevel()                     { return ulRound(level_  * getStatus());    };
	virtual unsigned long actualLength()                    { return length_;                           };
	virtual unsigned long actualWidth()                     { return width_;                            };
	virtual unsigned long actualHeight()                    { return height_;                           };
	virtual unsigned long clientLevel()                     { return level_;                            };
	virtual unsigned long clientLength()                    { return length_;                           };
	virtual unsigned long clientWidth()                     { return width_;                            };
	virtual unsigned long clientHeight()                    { return height_;                           };
	virtual unsigned long actualPointsPerSecond()           { return actualLevel();                     };
	virtual bool          isShipInDock()                    { return NOT_VALID_ID != dockingShipID_;    };
	virtual bool          isShipUnderConstruction()         { return NOT_VALID_ID != newShipClassID_;   };
	virtual bool          isItemUnderConstruction()         { return NOT_VALID_ID != newItemPatternID_; };
	virtual bool          isWhateverUnderConstruction()     { return isShipUnderConstruction() || isItemUnderConstruction(); };
	virtual bool          isHangerFree()                    { return (!isItemUnderConstruction()) && (!isShipInDock()) && (!isShipUnderConstruction()); };
	virtual bool          canShipDock(fortressClass * ship);

	virtual double              getGradient()       { return this->buildingGradient_;                                                                             };
	virtual double              getCreationsSize()  { if (this->isWhateverUnderConstruction()) return this->newItemDimensions_.getSize();          else return 0; };
	virtual unsigned long       getCreationsCount() { if (this->isWhateverUnderConstruction()) return max((unsigned long)1, this->newItemsCount_); else return 0; };
	virtual bool                dockAShip(fortressClass * ship);
	virtual bool                unboundAShip();
	virtual itemsCreationResult createNewShip(fortressClass * constructingFortress, dtIdentifier newShipClassID, unsigned long long buildingTitanium);
	virtual itemsCreationResult createNewItem(fortressClass * constructingFortress, dtIdentifier newItemPatternID, unsigned long itemsCount, itemDimensionsClass itemDimensions);
	virtual void                cancelConstruction() { newShipClassID_ = NOT_VALID_ID; newItemPatternID_ = NOT_VALID_ID; checkConstructionTrigger_ = 0; };
	virtual bool                checkConstruction(fortressClass * constructingFortress);

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;

	dtIdentifier getDockingShipID()                  const          { return dockingShipID_;                };
	dtIdentifier getItemUnderConstructionPatternID() const			{ return newItemPatternID_;             };
	dtIdentifier getShipUnderConstructionClassID()   const			{ return newShipClassID_;               };
	unsigned long long getActualConstructedPoints()  const			{ return pointsConstructed_;            };
	unsigned long long getTargetConstructedPoints()  const			{ return actualConstructionTotalCost(); };
	itemDimensionsClass getConstructedItemDimensions() const		{ return newItemDimensions_; };
};

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

class nullHangarClass : public hangarClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                           { return 1;  };
	virtual dtIdentifier         getPatternID()                     { return 0;  };
	virtual unsigned long        getWeight()                        { return 0;  };
	virtual unsigned long        getSize()                          { return 0;  };
	virtual unsigned long        getDensity()                       { return 0;  };
	virtual unsigned long long   getTransport()                     { return 0;  };
	virtual unsigned long long   getConstructionUlrei()             { return 0;  };
	virtual unsigned long long   getConstructionTitanium()          { return 0;  };
	virtual unsigned long long   getConstructionDeuterium()         { return 0;  };
	virtual unsigned long long   getConstructionHeavyWater()        { return 0;  };
	virtual unsigned long        getRepairability()                 { return 0;  };
	virtual unsigned long        getMounting()                      { return 0;  };
    virtual unsigned long long   getCount()                         { return 0;  };
    virtual unsigned long long   getTotalUniversalWeight()          { return 0;  };
    virtual unsigned long long   getTotalUniversalSize()            { return 0;  };

    /* override metod separate itemu */
	virtual void                 setDamage(double newDamage)        { ;          };
	virtual double               getDamage()                        { return 1;  };
	virtual double               getStatus()                        { return 0;  };
	virtual          bool        isTotallyDevastated()              { return 1;  };

    /* override metody zdedeneho itemu */
	virtual void                 setLevel(unsigned long newLevel)   { ;                 };
	virtual unsigned long        actualLevel()                      { return 0;         };
	virtual unsigned long        actualLength()                     { return 0;         };
	virtual unsigned long        actualWidth()                      { return 0;         };
	virtual unsigned long        actualHeight()                     { return 0;         };
	virtual unsigned long        clientLevel()                      { return 0;         };
	virtual unsigned long        clientLength()                     { return 0;         };
	virtual unsigned long        clientWidth()                      { return 0;         };
	virtual unsigned long        clientHeight()                     { return 0;         };
	virtual unsigned long        actualPointsPerSecond()            { return 0;         };
	virtual bool                 isShipInDock()                     { return false;     };
	virtual bool                 isShipUnderConstruction()          { return false;     };
	virtual bool                 isItemUnderConstruction()          { return false;     };
	virtual bool                 isWhateverUnderConstruction()      { return false;     };
	virtual bool                 isHangerFree()                     { return false;     };
    virtual bool                 canShipDock(fortressClass * ship)  { return false;     };
	virtual void                 harm(unsigned short damagePerc)    { ;                 };
	virtual          void        repair(unsigned long long points)  { ;                 };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;         };

	virtual double               getGradient()                      { return 0;         };
	virtual double               getCreationsSize()                 { return 0;         };
	virtual unsigned long        getCreationsCount()                { return 0;         };
	virtual bool                 dockAShip(fortressClass * ship)    { return false;     };
	virtual bool                 unboundAShip()                     { return false;     };
	virtual itemsCreationResult  createNewShip(fortressClass * constructingFortress, dtIdentifier newShipClassID, unsigned long long buildingTitanium)                              { return ICR_FULL_HANGAR; };
	virtual itemsCreationResult  createNewItem(fortressClass * constructingFortress, dtIdentifier newItemPatternID, unsigned long itemsCount, itemDimensionsClass itemDimensions)   { return ICR_FULL_HANGAR; };
	virtual void                 cancelConstruction()               { };
    virtual bool                 checkConstruction(fortressClass * constructingFortress) { return false; };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };


    virtual ~nullHangarClass() {};
    nullHangarClass() : hangarClass(nullItem()) {};
};


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

class magneticalFilterClass : public stackableItemClass
{
private:	
//	unsigned long production_;
	double scienceLevel2Production (double sciLev) { return dNumberFromScale(MAGNETICAL_FILTER_MIN_PRODUCTION, MAGNETICAL_FILTER_MAX_PRODUCTION, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~magneticalFilterClass() {};
	magneticalFilterClass() {};
	magneticalFilterClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_MAGNETICAL_FILTER, weight, working, damaged)
	  {};
	magneticalFilterClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_MAGNETICAL_FILTER, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual double actualTotalProduction(dtIdentifier realmID) { return getWorking() * scienceLevel2Production(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_MAGNETICAL_FILTER, INDEX_MAGNETICAL_FILTER_PRODUCTION)); };
	// client
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullMagneticalFilterClass : public magneticalFilterClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual double actualTotalProduction(dtIdentifier realmID)          { return 0;     };
	virtual void          harm(unsigned short damagePerc)               { ;             };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullMagneticalFilterClass() {};
    nullMagneticalFilterClass() : magneticalFilterClass(nullItem()) {};
};


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

class deuteriumDecomposerClass : public stackableItemClass
{
private:
//	unsigned long production_;
//	double        metamorphosisEffectivity_;
	unsigned long scienceLevel2Production(double sciLev)    { return ulNumberFromScale(DEUTERIUM_DECOMPOSER_MIN_PRODUCTION   , DEUTERIUM_DECOMPOSER_MAX_PRODUCTION   , MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
	double        scienceLevel2Metamorphosis(double sciLev) { return dNumberFromScale (DEUTERIUM_DECOMPOSER_MIN_METAMORPHOSIS, DEUTERIUM_DECOMPOSER_MAX_METAMORPHOSIS, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~deuteriumDecomposerClass() {};
	deuteriumDecomposerClass() {};
	deuteriumDecomposerClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_DEUTERIUM_DECOMPOSER, weight, working, damaged)
	  {};
	deuteriumDecomposerClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_DEUTERIUM_DECOMPOSER, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long long actualTotalProduction(dtIdentifier realmID)                                      { return getWorking() * scienceLevel2Production   (actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_DEUTERIUM_DECOMPOSER, INDEX_DEUTERIUM_DECOMPOSER_PRODUCTION   ));  };
	// client
	virtual double             actualMetamorphosisEffectivity(dtIdentifier realmID)                             { return scienceLevel2Metamorphosis(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_DEUTERIUM_DECOMPOSER, INDEX_DEUTERIUM_DECOMPOSER_METAMORPHOSIS));                 };
	// client
	virtual double             actualSpaceMetamorphosisEffectivity(dtIdentifier realmID)                        { double eff = actualMetamorphosisEffectivity(realmID); return eff * (double)HEAVY_WATER_DENSITY / (double)DEUTERIUM_DENSITY;                                                                                                     };
	virtual unsigned long long actualTotalConsumption(dtIdentifier realmID)                                     { double eff = actualMetamorphosisEffectivity(realmID); double pro = (double)actualTotalProduction(realmID); if (0 < eff) return ullUpRound(pro / eff); else return 0;                                                            };
	virtual unsigned long long getProductionByConsumption(dtIdentifier realmID, unsigned long long consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return (unsigned long long)((double)consumption * actualMetamorphosisEffectivity(realmID));                                                                    };
	virtual unsigned long long getWeightLossByConsumption(dtIdentifier realmID, unsigned long long consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return consumption - getProductionByConsumption(realmID, consumption);                                                                                         };
	virtual double             getSpaceLossByConsumption (dtIdentifier realmID, unsigned long long consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return (double)consumption / (double)HEAVY_WATER_DENSITY - (double)getProductionByConsumption(realmID, consumption) / (double)DEUTERIUM_DENSITY;               };
	virtual double             getConsumptionByConProDiff(dtIdentifier realmID, double diff)                    { double eff = actualMetamorphosisEffectivity(realmID); return diff / dHandleZero(1 - eff);                                                                                                                                       };
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullDeuteriumDecomposerClass : public deuteriumDecomposerClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long long actualTotalProduction(dtIdentifier realmID)                                      { return 0;   };
	virtual double             actualMetamorphosisEffectivity(dtIdentifier realmID)                             { return 0;   };
	virtual double             actualSpaceMetamorphosisEffectivity(dtIdentifier realmID)                        { return 0;   };
	virtual unsigned long long actualTotalConsumption(dtIdentifier realmID)                                     { return 0;   };
	virtual unsigned long long getProductionByConsumption(dtIdentifier realmID, unsigned long long consumption) { return 0;   };
	virtual unsigned long long getWeightLossByConsumption(dtIdentifier realmID, unsigned long long consumption) { return 0;   };
	virtual double             getSpaceLossByConsumption (dtIdentifier realmID, unsigned long long consumption) { return 0;   };
	virtual double             getConsumptionByConProDiff(dtIdentifier realmID, double diff)                    { return 0;   };
	virtual void               harm(unsigned short damagePerc)                                                  { ;           };
	virtual          void      repair(unsigned long long points)                                                { ;           };
	virtual unsigned long long pointsToCheckpoint()                                                             { return 0;   };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullDeuteriumDecomposerClass() {};
    nullDeuteriumDecomposerClass() : deuteriumDecomposerClass(nullItem()) {};
};


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

class zirconiumReactorClass : public stackableItemClass
{
private:	
//	unsigned long production_;
//	double        metamorphosisEffectivity_;
	double scienceLevel2Production   (double sciLev) { return dNumberFromScale(ZIRCONIUM_REACTOR_MIN_PRODUCTION   , ZIRCONIUM_REACTOR_MAX_PRODUCTION   , MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
	double scienceLevel2Metamorphosis(double sciLev) { return dNumberFromScale(ZIRCONIUM_REACTOR_MIN_METAMORPHOSIS, ZIRCONIUM_REACTOR_MAX_METAMORPHOSIS, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~zirconiumReactorClass() {};
	zirconiumReactorClass() {};
	zirconiumReactorClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_ZIRCONIUM_REACTOR, weight, working, damaged)
	  {};
	zirconiumReactorClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_ZIRCONIUM_REACTOR, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual double        actualTotalProduction(dtIdentifier realmID)                          { return getWorking() * scienceLevel2Production   (actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_ZIRCONIUM_REACTOR, INDEX_ZIRCONIUM_REACTOR_PRODUCTION   ));  };
	// client
	virtual double        actualMetamorphosisEffectivity(dtIdentifier realmID)                 { return scienceLevel2Metamorphosis(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_ZIRCONIUM_REACTOR, INDEX_ZIRCONIUM_REACTOR_METAMORPHOSIS));                 };
	// client
	virtual double        actualSpaceMetamorphosisEffectivity(dtIdentifier realmID)            { return 0;                                                                                                                                                                                                                 };
	virtual double        actualTotalConsumption(dtIdentifier realmID)                         { double eff = actualMetamorphosisEffectivity(realmID); double pro = (double)actualTotalProduction(realmID); if (0 < eff) return pro / eff; else return 0;                                                                  };
	virtual double        getProductionByConsumption(dtIdentifier realmID, double consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return (double)consumption * (double)actualMetamorphosisEffectivity(realmID);                                                                            };
	virtual double        getWeightLossByConsumption(dtIdentifier realmID, double consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return (double)consumption;                                                                                                                              };
	virtual double        getSpaceLossByConsumption (dtIdentifier realmID, double consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return (double)consumption / (double)ZIRCONIUM_CRYSTAL_DENSITY;                                                                                          };
//	virtual double        getConsumptionByConProDiff(dtIdentifier realmID, double diff)        { double eff = actualMetamorphosisEffectivity(realmID); return diff / dHandleZero(1 - eff);                                                                                                                                 };
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullZirconiumReactorClass : public zirconiumReactorClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual double        actualTotalProduction(dtIdentifier realmID)                                 { return 0; };
	virtual double        actualMetamorphosisEffectivity(dtIdentifier realmID)                        { return 0; };
	virtual double        actualSpaceMetamorphosisEffectivity(dtIdentifier realmID)                   { return 0; };
	virtual double        actualTotalConsumption(dtIdentifier realmID)                                { return 0; };
	virtual double        getProductionByConsumption(dtIdentifier realmID, double consumption)        { return 0; };
	virtual double        getWeightLossByConsumption(dtIdentifier realmID, double consumption)        { return 0; };
	virtual double        getSpaceLossByConsumption (dtIdentifier realmID, double consumption)        { return 0; };
	virtual double        getConsumptionByConProDiff(dtIdentifier realmID, double diff)               { return 0; };
	virtual void          harm(unsigned short damagePerc)                      { ;         };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullZirconiumReactorClass() {};
    nullZirconiumReactorClass() : zirconiumReactorClass(nullItem()) {};
};


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

class ilmeniteFurnaceClass : public stackableItemClass
{
private:	
//	unsigned long production_;
//	double        metamorphosisEffectivity_;
	unsigned long scienceLevel2Production   (double sciLev) { return ulNumberFromScale(ILMENITE_FURNACE_MIN_PRODUCTION   , ILMENITE_FURNACE_MAX_PRODUCTION   , MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
	double        scienceLevel2Metamorphosis(double sciLev) { return dNumberFromScale (ILMENITE_FURNACE_MIN_METAMORPHOSIS, ILMENITE_FURNACE_MAX_METAMORPHOSIS, MAX_TOTAL_SCIENCE_LEVEL, sciLev); };
public:
	virtual ~ilmeniteFurnaceClass() {};
	ilmeniteFurnaceClass() {};
	ilmeniteFurnaceClass(unsigned long weight, unsigned long long working, unsigned long long damaged):
	  stackableItemClass(PATTERN_ID_ILMENITE_FURNACE, weight, working, damaged)
	  {};
	ilmeniteFurnaceClass(nullItem ni):
	  stackableItemClass(PATTERN_ID_ILMENITE_FURNACE, 0, 0, 0)
	  {};

	                 bool      isNull() { return 0; };

	virtual unsigned long long actualTotalProduction(dtIdentifier realmID)                                      { return getWorking() * scienceLevel2Production   (actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_ILMENITE_FURNACE, INDEX_ILMENITE_FURNACE_PRODUCTION   ));  };
	// client
	virtual double             actualMetamorphosisEffectivity(dtIdentifier realmID)                             { return scienceLevel2Metamorphosis(actx->cacheRealmsList.getItem<realmClass>(realmID)->getScientificTree()->getRealScienceLevel(SCIENCE_ENTITY_ILMENITE_FURNACE, INDEX_ILMENITE_FURNACE_METAMORPHOSIS));                 };
	// client
	virtual double             actualSpaceMetamorphosisEffectivity(dtIdentifier realmID)                        { double eff = actualMetamorphosisEffectivity(realmID); return eff * (double)ILMENITE_DENSITY / (double)TITANIUM_DENSITY;                                                                                                 };
	virtual unsigned long long actualTotalConsumption(dtIdentifier realmID)                                     { double eff = actualMetamorphosisEffectivity(realmID); double pro = (double)actualTotalProduction(realmID); if (0 < eff) return ullUpRound(pro / eff); else return 0;                                                    };
	virtual unsigned long long getProductionByConsumption(dtIdentifier realmID, unsigned long long consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return (unsigned long long)((double)consumption * actualMetamorphosisEffectivity(realmID));                                                            };
	virtual unsigned long long getWeightLossByConsumption(dtIdentifier realmID, unsigned long long consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return consumption - getProductionByConsumption(realmID, consumption);                                                                                 };
	virtual double             getSpaceLossByConsumption (dtIdentifier realmID, unsigned long long consumption) { consumption = min(consumption, actualTotalConsumption(realmID)); return (double)consumption * (double)ILMENITE_DENSITY - (double)getProductionByConsumption(realmID, consumption) / (double)TITANIUM_DENSITY;           };
	virtual double             getConsumptionByConProDiff(dtIdentifier realmID, double diff)                    { double eff = actualMetamorphosisEffectivity(realmID); return diff / dHandleZero(1 - eff);                                                                                                                               };
	virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass();

	virtual void          DB_Load       (  unsigned long ID                ) ;
	virtual void          DB_Save       (  unsigned long ID                ) ;
	virtual void          DB_Insert     (  unsigned long ID                ) ;
};

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

class nullIlmeniteFurnaceClass : public ilmeniteFurnaceClass
{
public:
    /* override metod common itemu */
	                 bool        isNull()                               { return 1;     };
	virtual dtIdentifier         getPatternID()                         { return 0;     };
	virtual unsigned long        getWeight()                            { return 0;     };
	virtual unsigned long        getSize()                              { return 0;     };
	virtual unsigned long        getDensity()                           { return 0;     };
	virtual unsigned long long   getTransport()                         { return 0;     };
	virtual unsigned long long   getConstructionUlrei()                 { return 0;     };
	virtual unsigned long long   getConstructionTitanium()              { return 0;     };
	virtual unsigned long long   getConstructionDeuterium()             { return 0;     };
	virtual unsigned long long   getConstructionHeavyWater()            { return 0;     };
	virtual unsigned long        getRepairability()                     { return 0;     };
	virtual unsigned long        getMounting()                          { return 0;     };
    virtual unsigned long long   getCount()                             { return 0;     };
    virtual unsigned long long   getTotalUniversalWeight()              { return 0;     };
    virtual unsigned long long   getTotalUniversalSize()                { return 0;     };

    /* override metod stackable itemu */
	virtual void                 setWorking(unsigned long long newWorking) { ;             };
    virtual void                 setDamaged(unsigned long long newDamaged) { ;             };
	virtual void                 repair(unsigned long count)               { ;             };
	virtual void                 shatter(unsigned long count)              { ;             };
	virtual void                 addWorking(unsigned long long count)      { ;             };
	virtual void                 addDamaged(unsigned long long count)      { ;             };
	virtual unsigned long long   subWorking(unsigned long long count)      { return 0;     };
	virtual unsigned long long   subDamaged(unsigned long long count)      { return 0;     };
	virtual unsigned long long   getWorking()                              { return 0;     };
	virtual unsigned long long   getDamaged()                              { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalWeight()           { return 0;     };
	virtual unsigned long long   getAllStackedItemsTotalSize()             { return 0;     };
    virtual stackableItemClass * createEmptyCopyOfItemOfTheSameClass()     { return this;  };

    /* override metody zdedeneho itemu */
	virtual unsigned long long   actualTotalProduction(dtIdentifier realmID)                                      { return 0; };
	virtual double               actualMetamorphosisEffectivity(dtIdentifier realmID)                             { return 0; };
	virtual double               actualSpaceMetamorphosisEffectivity(dtIdentifier realmID)                        { return 0; };
	virtual unsigned long long   actualTotalConsumption(dtIdentifier realmID)                                     { return 0; };
	virtual unsigned long long   getProductionByConsumption(dtIdentifier realmID, unsigned long long consumption) { return 0; };
	virtual unsigned long long   getWeightLossByConsumption(dtIdentifier realmID, unsigned long long consumption) { return 0; };
	virtual double               getSpaceLossByConsumption (dtIdentifier realmID, unsigned long long consumption) { return 0; };
	virtual double               getConsumptionByConProDiff(dtIdentifier realmID, double diff)                    { return 0; };
	virtual void                 harm(unsigned short damagePerc)                      { ;         };
	virtual          void        repair(unsigned long long points)  { ;          };
	virtual unsigned long long   pointsToCheckpoint()               { return 0;  };

    virtual void          DB_Load       (  unsigned long ID                ) { ; };
    virtual void          DB_Save       (  unsigned long ID                ) { ; };
    virtual void          DB_Insert     (  unsigned long ID                ) { ; };

    virtual ~nullIlmeniteFurnaceClass() {};
    nullIlmeniteFurnaceClass() : ilmeniteFurnaceClass(nullItem()) {};
};



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

#endif