/* ---------------------------------------------------------
    ¹«±â/µµ±¸ ¹× °³Á¶½Ä Å¬·¡½º

    LAST UPDATE : 2008.09.03
    CREATER     : [HG]ErrorDa
    MAIL TO     : hespnk@hanmail.net

    IE7.0¿¡¼­ Å×½ºÆ® µÈ ÄÚµåÀÔ´Ï´Ù.
    ¼Ò½ºÄÚµå¿¡ ´ëÇÏ¿©´Â ºÒÆß±ÝÁöÀÔ´Ï´Ù.
    »ç¿ëÀ» ¿øÇÏ½Ã´Â ºÐÀº À§ÀÇ ¸ÞÀÏ·Î ¿¬¶ôÁÖ¼¼¿ä.
--------------------------------------------------------- */


//-------------------------------------------------------
//
// °³Á¶³»¿ë Å¬·¡½º
//
//-------------------------------------------------------
clsRevamp = function( arg, who )
{
    this.article = new Array();

    this.name  = arg[0];
    this.start = arg[1];
    this.last  = arg[2];

    for(var nLoop = 1; nLoop < arg.length-2; nLoop++)
    {
        this.article[nLoop] = arg[nLoop+2];
        // WEAPON : 1 = MIN, 2 = MAX, 3 = BAL, 4 = CRI, 5 = DUR, 6 = EX1, 7 = EX2, 8 = EX3, 9 = EXP, 10 = GOLD
    }
    this.who = who;
}

clsRevamp.prototype =
{
    item : function( index )
    {
        if( index >=0 && index <= this.article.length )
        {
            return this.article[index];
        }
        return "";
    },

    Stat : function( index )
    {
        if( index >=1 && index <= this.article.length )
        {
            return this.article[index];
        }
        return "";
    },

    Exp : function()
    {
        return this.article[this.article.length-2];
    },

    Gold : function()
    {
        return this.article[this.article.length-1];
    }
}


//-------------------------------------------------------
//
// °³Á¶°á°ú Å¬·¡½º
//
//-------------------------------------------------------
clsWpCalc = function()
{
    //this.data = new Array();
    this.data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}

clsWpCalc.prototype =
{
    AddData : function( arg )
    {
        for(var nLoop = 1; nLoop <= arg.length; nLoop++)
        {
            if( isNaN(this.data[nLoop]) )
            {
                this.data[nLoop]=0;
            }

            this.data[nLoop] += arg[nLoop];
            if( (this.data[nLoop] < 0)                                              &&  // 0º¸´Ù ÀÛÀº °ªÀº 0À¸·Î Àç¼³Á¤
                (nLoop < CON_BASEITEM_CNT || parseInt(idxClass[0]/100) == 4)        &&  // ±âº»Ç×¸ñ¿¡¸¸ ¼³Á¤Åä·Ï (¿ø°Å¸® ¹«±âÀÇ È®ÀåÇ×¸ñÀº Æ÷ÇÔ)
                (parseInt(idxClass[0]/100) < 6 || parseInt(idxClass[0]/100 > 8)) )      // Ãµ¿Ê, °æ°©, Áß°©Àº Á¦¿Ü
            {
                this.data[nLoop] = 0;
            }
            this.data[nLoop] = fun_RoundPos(this.data[nLoop]);
        }
    }
}



//-------------------------------------------------------
//
// °³Á¶¾ÆÀÌÅÛ Å¬·¡½º (¹«±â/µµ±¸/¾Ç±â)
//
//-------------------------------------------------------
clsWeapon = function( arg )
{
    this.classType  = arg[0];
    this.weaponName = arg[1];
    this.upgradeCnt = arg[2];
    this.minDamage  = arg[3];
    this.maxDamage  = arg[4];
    this.balance    = arg[5];
    this.critical   = arg[6];
    this.durability = arg[7];

    this.effect1    = arg[8];
    this.effect2    = arg[9];
    this.effect3    = arg[10];

    this.linkImage  = arg[11];
    this.desc       = arg[12];

    this.normal     = arg[13];
    this.dropDragon = arg[14];
    this.useBlss    = arg[15];
    this.mopDrop    = arg[16];
    this.dTemDur    = arg[17];

    this.useBrood   = arg[18];
    this.repair     = arg[19];

    this.revamps    = new Array();
    this.methods    = new Array();

    //this.gemUpgrade = [-1, -1];
    this.gemUpgrade = new Array();
}

clsWeapon.prototype =
{
    toString : function()
    {
        return this.weaponName;
    },

    item : function( col )
    {
        switch( col )
        {
            case 0 : return this.weaponName;
            case 1 : return this.minDamage;
            case 2 : return this.maxDamage;
            case 3 : return this.balance;
            case 4 : return this.critical;
            case 5 : return this.durability;
            case 6 : return this.effect1;
            case 7 : return this.effect2;
            case 8 : return this.effect3;
            case 9 : return this.linkImage;
            case 10: return this.desc;
        }
        return "";
    },

    addRevamp : function( node )
    {
        this.revamps[this.revamps.length] = node;
    },

    addMethod : function( node )
    {
        this.methods[this.methods.length] = node;
    },

    getRevamp : function( index )
    {
        if( this.revamps.length )
        {
            if( index >= 0 && index < this.revamps.length )
            {
                return this.revamps[index];
            }
        }
        return null;
    },

    getMethod : function( index )
    {
        if( this.methods.length )
        {
            if( index >= 0 && index < this.methods.length )
            {
                return this.methods[index];
            }
        }
        return null;
    },

    getRvCount : function()
    {
        return this.revamps.length;
    },

    getMethodCount : function()
    {
        return this.methods.length;
    },

    addJewel : function( up )
    {
    	if(up.length > 0) 
    	{
    		for(var i = 0; i < up.length; i++) 
    		{
		        this.gemUpgrade[i] = up[i];
	    	}
    	}
    },

    isGem : function()
    {
    	for( var i = 0; i < this.gemUpgrade.length; i++ )
    	{
			if( this.gemUpgrade[i] > 0 )
			{
				return true;
			}    	
    	}
        return false;
    },

	getGemCount : function()
	{
		return this.gemUpgrade.length;
	},
	
    getMaxGemUpgrade : function()
    {
        if( this.isGem() )
        {
        	var nMax = 0;
        	
        	for(var i = 0; i < this.gemUpgrade.length; i++)
        	{
        		if( nMax < gem[this.gemUpgrade[i]][2] )
        		{
        			nMax = gem[this.gemUpgrade[i]][2];
        		}
        	}
        	return nMax;
        }

        return -1;
    }
}



//-------------------------------------------------------
//
// °³Á¶¾ÆÀÌÅÛ Å¬·¡½º (¹æ¾î±¸/¹æÆÐ)
//
//-------------------------------------------------------
clsDefence = function( arg )
{
    this.classType  = arg[0];
    this.thisName   = arg[1];
    this.upgradeCnt = arg[2];
    this.protect    = arg[3];
    this.safeGuard  = arg[4];
    this.durability = arg[5];

    this.effect1    = arg[6];
    this.effect2    = arg[7];
    this.effect3    = arg[8];

    this.linkImage  = arg[9];
    this.desc       = arg[10];

    this.normal     = arg[11];
    this.dropDragon = arg[12];
    this.useBlss    = arg[13];
    this.mopDrop    = arg[14];
    this.dTemDur    = arg[15];

    this.useBrood   = arg[16];
    this.repair     = arg[17];

    this.revamps    = new Array();
    this.methods    = new Array();

    this.gemUpgrade = new Array();
}

clsDefence.prototype =
{
    toString : function()
    {
        return this.weaponName;
    },

    item : function( col )
    {
        switch( col )
        {
            case 0 : return this.thisName;
            case 1 : return this.protect;
            case 2 : return this.safeGuard;
            case 3 : return this.durability;
            case 4 : return this.effect1;
            case 5 : return this.effect2;
            case 6 : return this.effect3;
            case 7 : return this.linkImage;
            case 8 : return this.desc;
        }
        return "";
    },

    addRevamp : function( node )
    {
        this.revamps[this.revamps.length] = node;
    },

    addMethod : function( node )
    {
        this.methods[this.methods.length] = node;
    },

    getRevamp : function( index )
    {
        if( this.revamps.length )
        {
            if( index >= 0 && index < this.revamps.length )
            {
                return this.revamps[index];
            }
        }
        return null;
    },

    getMethod : function( index )
    {
        if( this.methods.length )
        {
            if( index >= 0 && index < this.methods.length )
            {
                return this.methods[index];
            }
        }
        return null;
    },

    getRvCount : function()
    {
        return this.revamps.length;
    },

    getMethodCount : function()
    {
        return this.methods.length;
    },

    isGem : function()
    {
    	for( var i = 0; i < this.gemUpgrade.length; i++ )
    	{
			if( this.gemUpgrade[i] > 0 )
			{
				//alert("1");
				return true;
			}    	
    	}
		//alert("0");
        return false;
    },
    
    addJewel : function( up )
    {
    	if(up.length > 0) 
    	{
    		for(var i = 0; i < up.length; i++) 
    		{
		        this.gemUpgrade[i] = up[i];
	    	}
    	}
    },    

	getGemCount : function()
	{
		return this.gemUpgrade.length;
	},

    getMaxGemUpgrade : function()
    {
        if( this.isGem() )
        {
        	var nMax = 0;
        	
        	for(var i = 0; i < this.gemUpgrade.length; i++)
        	{
        		if( nMax < gem[this.gemUpgrade[i]][2] )
        		{
        			nMax = gem[this.gemUpgrade[i]][2];
        		}
        	}
        	return nMax;
        }

        return -1;
    }
}

