Permalink
Browse files

Current devel version, 4.3 compatible

  • Loading branch information...
1 parent 47963f9 commit fa6f40ce401647c164e5b8b11eb7a76ab5043b12 @lemartin committed Dec 16, 2011
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1 +1 @@
-window["CHARDEV_CORE_BUILD"]=321;
+window["CHARDEV_CORE_BUILD"]=338;
View
@@ -15,7 +15,7 @@ var locale;
*/
function MD5( str ){ return "";};
-var JSON = { stringify : function(){} };
+var JSON = { stringify : function(){ return "";} };
/**
* @param str
@@ -577,6 +577,121 @@ Character.prototype.toArray = function() {
return s;
};
+Character.prototype.toBattleNetProfile = function() {
+ var i, j, enchant, itemsObj = { 'averageItemLevel': 0, 'averageItemLevelEquipped': 0 },
+ slot, ttParamsObj, itm, talentObj,
+ talents = this._chrClass != null ? this._chrClass._talents : null, glyph,
+ glyphs = [[],[],[]], primaryProfessions= [];
+
+ for( i=0; i<INV_ITEMS; i++ ) {
+ itm = this._inventory._items[i][0];
+ if( itm == null ) {
+ continue;
+ }
+
+ slot = SLOT_TO_NAME[i];
+
+
+ ttParamsObj= {};
+
+ for( j=0; j<itm._enchants.length; j++ ) {
+ enchant = itm._enchants[j];
+ if( enchant._types[0] == 7 ) {
+ ttParamsObj['tinker'] = enchant._id;
+ }
+ else {
+ ttParamsObj['enchant'] = enchant._id;
+ }
+ }
+
+ for( j=0; j<3; j++ ) {
+ if( itm._gems[j] ) {
+ ttParamsObj['gem'+j] = itm._gems[j]._id;
+ }
+ }
+
+ if( itm.hasAdditionalSocket() ) {
+ ttParamsObj['extraSocket'] = true;
+ }
+
+ if( itm._reducedStat != -1 && itm._addedStat != -1 ) {
+ ttParamsObj['reforge'] = STAT_TO_REFORGABLE_STAT[itm._reducedStat] * 7 +
+ 113 + STAT_TO_REFORGABLE_STAT[itm._addedStat] - ( itm._addedStat > itm._reducedStat ? 1 : 0 )
+ ;
+ }
+
+ if( itm._selectedRandomEnchantment ) {
+ ttParamsObj['suffix'] = itm._selectedRandomEnchantment._id;
+ }
+
+ itemsObj[slot] = {
+ 'icon': itm._icon,
+ 'id':itm._id,
+ 'name':itm._name,
+ 'quality': itm._quality,
+ 'tooltipParams': ttParamsObj
+ };
+ }
+
+
+ if( this._chrClass ) {
+
+ for( i=0; i<this._chrClass._glyphs.length; i++ ) {
+ for( j=0; j<this._chrClass._glyphs[i].length; j++ ) {
+ glyph = this._chrClass._glyphs[i][j];
+ if( glyph ) {
+ glyphs[i].push({
+ 'glyph': glyph._id,
+ 'item': glyph._itemId,
+ 'name': glyph._spell.getName(),
+ 'icon': glyph._spell._icon
+ });
+ }
+ }
+ }
+ //TODO add missing values to talent obj
+ talentObj = [{
+ 'selected': true,
+ 'name':talents._selectedTree != -1 ? talents._treeNames[talents._selectedTree] : "None",
+ 'icon': "",
+ 'build':talents.getDistribution(true).join(""),
+ 'trees': [],
+ 'glyphs': {
+ 'prime':glyphs[2],
+ 'major':glyphs[0],
+ 'minor':glyphs[1]
+ }
+ }];
+ }
+ else {
+ talentObj = null;
+ }
+
+ for( i=0; i<2; i++ ) {
+ var p = this._professions[i];
+ if( p ) {
+ primaryProfessions.push({
+ 'id': p._id,
+ 'name': ID_TO_PROFESSION[p._id],
+ 'rank': p._level
+ });
+ }
+ }
+
+ return JSON.stringify({
+ 'name': this._name,
+ 'race': ( this._chrRace != null ? this._chrRace._id : 0 ),
+ 'class': ( this._chrClass != null ? this._chrClass._id : 0 ),
+ 'level': this._level,
+ 'items': itemsObj,
+ 'talents':talentObj,
+ 'professions':{
+ 'primary': primaryProfessions,
+ 'secondary': []
+ }
+ });
+};
+
Character.prototype.toJSONProfile = function() {
var talents = this._chrClass != null ? this._chrClass._talents : null;
@@ -610,7 +725,7 @@ Character.prototype.toJSONProfile = function() {
reforging = null;
}
- if( itm.hasAdditionalSocket ) {
+ if( itm.hasAdditionalSocket() ) {
switch( i ) {
case 7: enchants.push( 3717 ); break;
case 8: enchants.push( 3723 ); break;
@@ -0,0 +1,41 @@
+/**
+ * @constructor
+ * @param {numeric} cause
+ * @returns {InvalidItemException}
+ */
+function InvalidItemException( itm, cause ) {
+ this._cause = cause;
+ this._itm = itm;
+}
+InvalidItemException.prototype = {
+ _cause: null,
+ _itm: null
+};
+InvalidItemException.CAUSE_WRONG_CHARACTER_CLASS = 0;
+InvalidItemException.CAUSE_WRONG_ITEM_CLASS = 1;
+InvalidItemException.CAUSE_UNIQUE = 3;
+
+/**
+ * @param itm
+ * @param {numeric} cause
+ * @returns {InvalidReforgeException}
+ */
+function InvalidReforgeException( itm, red, add, cause ) {
+ this._cause = cause;
+ this._itm = itm;
+ this._added = add;
+ this._reduced = red;
+}
+InvalidReforgeException.prototype = {
+ _cause: null,
+ _itm: null,
+ _add: -1,
+ _red: -1
+};
+InvalidReforgeException.CAUSE_NO_REDUCE_STAT = 0;
+InvalidReforgeException.CAUSE_NO_ADD_STAT = 1;
+InvalidReforgeException.CAUSE_INVALID_REFORGE_STAT = 2;
+InvalidReforgeException.CAUSE_ADD_STAT_PRESENT = 3;
+InvalidReforgeException.CAUSE_REDUCE_STAT_NOT_PRESENT = 4;
+InvalidReforgeException.CAUSE_LOW_ITEM_LEVEL = 5;
+InvalidReforgeException.CAUSE_ALREADY_REFORGED = 6;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -7,8 +7,10 @@ function Glyph( serialized ) {
this._id = serialized[0];
this._type = serialized[1];
this._spell = serialized[2] ? new Spell(serialized[2]) : null;
+ this._itemId = serialized[3];
}
Glyph.prototype._id = 0;
Glyph.prototype._type = 0;
-Glyph.prototype._spell = null;
+Glyph.prototype._spell = null;
+Glyph.prototype._itemId = 0;
@@ -1217,4 +1217,4 @@ Item.prototype.hasAdditionalSocket = function() {
}
}
return g > s;
-}
+};
@@ -93,6 +93,8 @@ Stats.prototype._parry = 0;
Stats.prototype._block = 0;
Stats.prototype._itemLevel = 0;
Stats.prototype._armorModPerCent = 0;
+Stats.prototype._resilienceRating = 0;
+Stats.prototype._resilienceDamageReduction = 0;
Stats.prototype._hitTillMeleeCap = 0;
Stats.prototype._expTillDodgeCap = 0;
@@ -187,6 +189,8 @@ Stats.prototype._reset = function() {
this._parry = 0;
this._block = 0;
this._armorModPerCent = 0;
+ this._resilienceRating = 0;
+ this._resilienceDamageReduction = 0;
this._rangedAttackPower = 0;
this._raMinDmg = 0;
@@ -838,7 +842,7 @@ Stats.prototype.calculate = function( preview, noBuffs ) {
);
}
- if( GameInfo.canParry(classId) ) {
+ if( GameInfo.canParry(classId) || classId == SHAMAN && selectedTree == 1 ) {
this._parryRating = this._ratings[3] + baseEffects[189][3];
switch(classId) {
case WARRIOR:
@@ -856,6 +860,13 @@ Stats.prototype.calculate = function( preview, noBuffs ) {
else {
this._dodge = baseEffects[49] + this._dodgeRating / COMBAT_RATINGS[2][level-1];
}
+ this._resilienceRating = this._ratings[24] +
+ Math.min(
+ this._ratings[14] + baseEffects[189][14],
+ this._ratings[15] + baseEffects[189][15],
+ this._ratings[16] + baseEffects[189][16]
+ );
+ this._resilienceDamageReduction = (1 - Math.pow( 0.99 , ( this._resilienceRating / COMBAT_RATINGS[15][level-1] )));
//
//#########################################################################
//
@@ -921,13 +932,7 @@ Stats.prototype.calculate = function( preview, noBuffs ) {
this._defense[2] = this._parry;
this._defense[3] = this._block;
- this._defense[4] =
- this._ratings[24] +
- Math.min(
- this._ratings[14] + baseEffects[189][14],
- this._ratings[15] + baseEffects[189][15],
- this._ratings[16] + baseEffects[189][16]
- ); //resilience
+ this._defense[4] = this._resilienceRating; //resilience
this._resistance[0] = this._resisSchool[6];
this._resistance[1] = this._resisSchool[2];
@@ -17,7 +17,7 @@ function Talents(id, serialized, isPet){
this._petId = -1;
this._isPet = isPet;
this._trees = (isPet ? 1 : 3);
- this._rows = (isPet ? 6 : 11);
+ this._rows = (isPet ? 6 : 7);
this._cols = 4;
this._minLevel = (isPet ? 20 : 10);
this._pointsPerTier = (isPet ? 3 : 5);
@@ -279,7 +279,7 @@ Talents.prototype._petId = 0;
Talents.prototype._id = 0;
Talents.prototype._trees = 3;
-Talents.prototype._rows = 11;
+Talents.prototype._rows = 7;
Talents.prototype._cols = 4;
Talents.prototype._minLevel = 10;
Talents.prototype._pointsPerLevel = 5;
@@ -852,7 +852,7 @@ function CTooltip(){
case 4:
html += Tools.addTr1(
TextIO.sprintf1( locale['TT_StatText']['Resilience'],
- TextIO.formatFloat2(stats._defense[4]/COMBAT_RATINGS[15][character._level-1])
+ TextIO.formatFloat2(stats._resilienceDamageReduction*100)
));
break;
}
Oops, something went wrong.

0 comments on commit fa6f40c

Please sign in to comment.