Skip to content

Commit 701566c

Browse files
committed
fix: wall units displayed as smart numbers
1 parent 6c95d97 commit 701566c

File tree

1 file changed

+38
-20
lines changed

1 file changed

+38
-20
lines changed

modules/RepConvGRC.js

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function _RepConvGRC() {
77
var idleInterval = 1000*60*15;
88
var stopCount = 0;
99
var wonders = {};
10+
var typUnits = {1: ['defAtt', 'losAtt'], 2: ['defDef', 'losDef']};
1011

1112
function genCheckBox(pName, pChecked, pLabel) {
1213
return $('<div/>', {'class':'checkbox_new', 'style':'margin-bottom: 10px; display: block;'})
@@ -747,8 +748,9 @@ function _RepConvGRC() {
747748
RepConv.Debug && console.log(elemGr.getElementsByClassName('wall_report_unit').length);
748749
$.each($(elemGr).find($('.grcrt_wall_units')), function(indUn, elemUn) {
749750
var
750-
unitName = RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
751-
unitKill = $(elemUn).find($('.place_unit_black')).html();
751+
unitName = $(elemUn).find($('.wall_report_unit')).data('type'),//RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
752+
unitKill = $(elemUn).find($('.wall_report_unit')).data('unit_count');
753+
//$(elemUn).find($('.place_unit_black')).html();
752754
cookie[typUnits[indLi][indGr]][unitName] = unitKill;
753755
});
754756
});
@@ -759,8 +761,9 @@ function _RepConvGRC() {
759761
RepConv.Debug && console.log(elemGr.getElementsByClassName('wall_report_unit').length);
760762
$.each($(elemGr).find($('.grcrt_wall_units')), function(indUn, elemUn) {
761763
var
762-
unitName = RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
763-
unitKill = $(elemUn).find($('.place_unit_black')).html();
764+
unitName = $(elemUn).find($('.wall_report_unit')).data('type'),//RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
765+
unitKill = $(elemUn).find($('.wall_report_unit')).data('unit_count');
766+
//$(elemUn).find($('.place_unit_black')).html();
764767
cookie[typUnits[indLi][indGr + 1]][unitName] = unitKill;
765768
});
766769
});
@@ -833,6 +836,7 @@ function _RepConvGRC() {
833836

834837
RepConv.Debug && console.log('Load wall...');
835838
var unitDiff;
839+
var hun = require("helpers/unit_numbers");
836840
$.each(RCGP.getJQElement().find($('div#building_wall li.odd')), function(indLi, elemLi) {
837841
if (indLi > 0) {
838842
// lewa strona
@@ -842,16 +846,17 @@ function _RepConvGRC() {
842846
RepConv.Debug && console.log(elemGr.getElementsByClassName('wall_report_unit').length);
843847
$.each($(elemGr).find($('.grcrt_wall_units')), function(indUn, elemUn) {
844848
var
845-
unitName = RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
846-
unitKill = $(elemUn).find($('.place_unit_black')).html(),
849+
unitName = $(elemUn).find($('.wall_report_unit')).data('type'),//RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
850+
unitKill = $(elemUn).find($('.wall_report_unit')).data('unit_count'),
851+
//$(elemUn).find($('.place_unit_black')).html(),
847852
unitSave = units[typUnits[indLi][indGr]][unitName];
848853
RepConv.Debug && console.log(unitName + ' ' + unitSave + '/' + unitKill);
849854
unitDiff = unitKill;
850855
if (unitSave != undefined) {
851856
unitDiff = unitKill - unitSave;
852857
}
853858
RepConv.Debug && console.log('unitDiff = ' + unitDiff);
854-
$(elemUn).find($('.grcrt_wall_diff')).html((unitDiff != 0) ? unitDiff : '');
859+
$(elemUn).find($('.grcrt_wall_diff')).html((unitDiff != 0) ? hun.shortenNumber(unitDiff) : '');
855860
});
856861
});
857862
// prawa strona
@@ -861,16 +866,17 @@ function _RepConvGRC() {
861866
RepConv.Debug && console.log(elemGr.getElementsByClassName('wall_report_unit').length);
862867
$.each($(elemGr).find($('.grcrt_wall_units')), function(indUn, elemUn) {
863868
var
864-
unitName = RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
865-
unitKill = $(elemUn).find($('.place_unit_black')).html(),
869+
unitName = $(elemUn).find($('.wall_report_unit')).data('type'),//RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit'))),
870+
unitKill = $(elemUn).find($('.wall_report_unit')).data('unit_count'),
871+
//$(elemUn).find($('.place_unit_black')).html(),
866872
unitSave = units[typUnits[indLi][indGr + 1]][unitName];
867873
RepConv.Debug && console.log(unitName + ' ' + unitSave + '/' + unitKill);
868874
unitDiff = unitKill;
869875
if (unitSave != undefined) {
870876
unitDiff = unitKill - unitSave;
871877
}
872878
RepConv.Debug && console.log('unitDiff = ' + unitDiff);
873-
$(elemUn).find($('.grcrt_wall_diff')).html((unitDiff != 0) ? unitDiff : '');
879+
$(elemUn).find($('.grcrt_wall_diff')).html((unitDiff != 0) ? hun.shortenNumber(unitDiff) : '');
874880
});
875881
});
876882
}
@@ -888,6 +894,7 @@ function _RepConvGRC() {
888894
var
889895
units = RepConvTool.getItem(RepConv.Cookie),
890896
_walls = RepConvTool.getItem(RepConv.CookieWall) || [];
897+
// var typUnits = {1: ['defAtt', 'losAtt'], 2: ['defDef', 'losDef']};
891898
if ((loadTimeStamp == _curTimestamp)) {
892899
units = _currWallValues;
893900
} else {
@@ -897,6 +904,7 @@ function _RepConvGRC() {
897904
}
898905
})
899906
}
907+
var hun = require("helpers/unit_numbers");
900908
saveBtn.disable(!(loadTimeStamp == _curTimestamp));
901909
$.each(RCGP.getJQElement().find($('div#building_wall li.odd')), function(indLi, elemLi) {
902910
if (indLi > 0) {
@@ -907,9 +915,13 @@ function _RepConvGRC() {
907915
RepConv.Debug && console.log(elemGr.getElementsByClassName('wall_report_unit').length);
908916
$.each($(elemGr).find($('.grcrt_wall_units')), function(indUn, elemUn) {
909917
var
910-
unitName = RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit')));
911-
$(elemUn).find($('.place_unit_black')).html(units[typUnits[indLi][indGr]][unitName]),
912-
$(elemUn).find($('.place_unit_white')).html(units[typUnits[indLi][indGr]][unitName]);
918+
unitName = $(elemUn).find($('.wall_report_unit')).data('type');
919+
// RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit')));
920+
if(units[typUnits[indLi][indGr]][unitName]){
921+
$(elemUn).find($('.wall_report_unit')).data('unit_count',units[typUnits[indLi][indGr]][unitName]),
922+
$(elemUn).find($('.place_unit_black')).html(hun.shortenNumber(units[typUnits[indLi][indGr]][unitName])),
923+
$(elemUn).find($('.place_unit_white')).html(hun.shortenNumber(units[typUnits[indLi][indGr]][unitName]));
924+
}
913925
});
914926
});
915927
// prawa strona
@@ -920,8 +932,11 @@ function _RepConvGRC() {
920932
$.each($(elemGr).find($('.grcrt_wall_units')), function(indUn, elemUn) {
921933
var
922934
unitName = RepConvTool.getUnitName($(elemUn).find($('.wall_report_unit')));
923-
$(elemUn).find($('.place_unit_black')).html(units[typUnits[indLi][indGr + 1]][unitName]),
924-
$(elemUn).find($('.place_unit_white')).html(units[typUnits[indLi][indGr + 1]][unitName]);
935+
if(units[typUnits[indLi][indGr]][unitName]){
936+
$(elemUn).find($('.wall_report_unit')).data('unit_count',units[typUnits[indLi][indGr + 1]][unitName]),
937+
$(elemUn).find($('.place_unit_black')).html(hun.shortenNumber(units[typUnits[indLi][indGr + 1]][unitName])),
938+
$(elemUn).find($('.place_unit_white')).html(hun.shortenNumber(units[typUnits[indLi][indGr + 1]][unitName]));
939+
}
925940
});
926941
});
927942
}
@@ -2177,21 +2192,24 @@ function _RepConvGRC() {
21772192

21782193
function townPopup(){
21792194
if (RepConv.settings[RepConv.Cookie+'_town_popup']){
2180-
var acc = {}, alliance_name = MM.checkAndPublishRawModel('Player',{id:Game.player_id}).getAllianceName()
2195+
var acc = {},
2196+
alliance_name = MM.checkAndPublishRawModel('Player',{id:Game.player_id}).getAllianceName()
21812197
$.each(ITowns.towns, function(ind,town){
21822198
var cc = town;
2183-
cc.points = cc.getPoints();
2184-
cc.player_name = Game.player_name
2185-
cc.alliance_name = alliance_name
2186-
cc.tooltip = new MousePopup(WMap.createTownTooltip('town',cc))
2199+
cc.points = cc.getPoints(),
2200+
cc.player_name = Game.player_name,
2201+
cc.alliance_name = alliance_name,
2202+
cc.tooltip = new MousePopup(WMap.createTownTooltip('town',cc)),
21872203
acc[ind]=cc
2204+
21882205
})
21892206
$.each($('#town_groups_list .item.town_group_town:not(.grcrtPopup)'), function(it,et){
21902207
var cc = acc[$(et).data('townid')];
21912208
// $(et).find($('.town_name')).mousePopup(new MousePopup(WMap.createTownTooltip('town',cc)))
21922209
$(et).find($('.town_name')).mousePopup(cc.tooltip)
21932210
$(et).addClass('grcrtPopup')
21942211
})
2212+
21952213
}
21962214
}
21972215

0 commit comments

Comments
 (0)