/*
 *   /d/Genesis/std/gems.c
 *
 *   This is the heap object for gems.
 */

#pragma strict_types

inherit "/std/heap";
inherit "/lib/keep";

#include <pl.h>
#include <macros.h>
#include <stdproperties.h>
#include <language.h>
#include "gem.h"

static int gem_rarity = POPULARNY;
static string gem_name;
    int wartosc;
/*
 * Function name: query_gem
 * Description:   Sprawdza czy obiekt jest gemem -> kamieniem szlachetnym
 * Returns:       1
 */
public nomask int
query_gem()
{
    return 1;
}

/*
 * Function name: query_gem_rarity
 * Description:   Sprawdza rzadkosc kamienia
 * Returns:       Rzadkosc
 */
public int
query_gem_rarity()
{
    return gem_rarity;
}

/*
 * Function name: query_gem_name
 * Description  : Zwraca "name" kamienia. Jest to nazwa pliku (bez .c)
 *                ktora definiuje kamien. (Tak naprawde to nie sadze
 *                zeby to dzialalo jak powinno)
 * Returns      : string - nazwa.
 */
public string
query_gem_name()
{
    return gem_name;
}

/*
 * Function name: config_gems
 * Description:   Konfiguracja kamienia
 * Arguments:     string colour  - Kolor w liczbie poj. rodz. meskiego
 *                Jesli nie podany to nie podawac tez stringa pcolour
 *                string pcolour - Kolor w liczbie mnogiej rodzaju meskiego
 *                Jesli nie poda sie poprzednich 2 stringow to sie wysypuje
 *                int rarity     - Rzadkosc kamienia
 *                int minvalue   - Minimalna wartosc kamienia w miedziakach
 *                int maxvalue   - Maksymalna wartosc kamienia w miedziakach
 *                int volume     - Objetosc
 *                int weight     - Waga
 */
varargs public void
config_gems(string colour, string pcolour, int minvalue, int maxvalue,
            int rarity, int volume, int weight)
{
//    int value_real;


    wartosc = minvalue+random(maxvalue-minvalue);
    gem_rarity = rarity;

//    if(wartosc < minvalue)
//    wartosc = minvalue;
//    if(wartosc > maxvalue)
//    wartosc = maxvalue;

    if (strlen(colour) && strlen(pcolour))
    {
        dodaj_przym(colour,pcolour);
    }

//    value_real = wartosc;
    add_prop(HEAP_S_UNIQUE_ID, "_gem_" + "_" + colour);
    add_prop(HEAP_I_UNIT_VALUE, wartosc);

    mark_state();
    add_prop(HEAP_I_UNIT_VOLUME, random(volume)+25);
    add_prop(HEAP_I_UNIT_WEIGHT, this_object()->query_prop(HEAP_I_UNIT_VOLUME));
    update_state();
}

/*
 * Function name: create_gems
 * Description  : Called at creation of the gem(s).
 */
public void
create_gems()
{
}

/*
 * Function name: default_gem_long
 * Description:   Give a simple, default description for the gems
 * Returns:       The description
 */
/*
public string
default_gem_long()
{
    if (num_heap() > 1)
    {
        return "These are " + plural_short() + ".";
    }

    return "It is " + LANG_ADDART(ustaw_nazwe()) + ".";
}
*/
/*
 * Function name: create_heap
 * Description  : Constructor for heap objects.
 */
public nomask void
create_heap()
{
    gem_name = extract(MASTER, strlen(GEM_OBJ_DIR), -1);

    set_name("gem");
    set_pname("gems");
//    set_keep(1);
    set_heap_size(1);

    ustaw_nazwe(({"kamien", "kamienia", "kamieniowi",
                  "kamien", "kamieniu", "kamieniem"}),
                ({"kamienie", "kamieni", "kamieniom",
                  "kamienie", "kamieniach", "kamieniami"}),
                  PL_MESKI_NOS_NZYW);
    set_long("Nie powinienes tego widziec.\n");
//    set_long("@@default_gem_long@@\n");

    create_gems();

    if (query_prop(HEAP_I_UNIT_VALUE) >= 144)
    {
        add_name("_gem_ingredient");
    }
}

/*
 * Function name: reset_gems
 * Description  : Redefine this to reset the gem heap.  Note that you
 *                will have to call enable_reset() in create_gems() for
 *                this to be called.
 */
public void
reset_gems()
{
}

/*
 * Function name: reset_heap
 * Description  : Called to make this heap reset. You may not mask this
 *                function, so use reset_gems() instead.
 */
public nomask
void reset_heap()
{
    reset_gems();
}

/*
 * Function name: query_auto_load
 * Description  : Get the autoload string for the gems
 * Returns      : string - the auto-load string.
 */
public string
query_auto_load()
{
    return MASTER + ":" + num_heap();
}

/*
 * Function name: init_arg
 * Description:   Initialize autoloading gems
 * Arguments:     string arg - the autoload argument
 */
public void
init_arg(string arg)
{
    set_heap_size(max(1, atoi(arg)));
}

int
query_kaska()
{
return wartosc;
}
