Skip to content

Commit 1df5e04

Browse files
committed
troops overview - support
1 parent e5489dc commit 1df5e04

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
lines changed

overviews/units_support_detail/bbcodes.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ $("#defRestack").click(function () {
1111

1212
var request = "";
1313
$("tr.grandTotal", overviewTable).each(function () {
14-
if ($(this).is(":visible")) {
15-
var total = parseInt($(this).attr('population'), 10);
16-
if (restackTo - total > user_data.restack.requiredDifference) {
17-
var villageCoords = $(this).attr("village");
18-
counter++;
19-
request += counter + "[village]" + villageCoords + "[/village] (" + parseInt((restackTo - total) / 1000, 10) + trans.sp.defOverview.thousandSuffix + ")\n";
20-
}
14+
var self = $(this);
15+
var total = parseInt(self.attr('population'), 10);
16+
if (restackTo - total > user_data.restack.requiredDifference) {
17+
var villageCoords = self.attr("village");
18+
counter++;
19+
request += counter + "[village]" + villageCoords + "[/village] (" + parseInt((restackTo - total) / 1000, 10) + trans.sp.defOverview.thousandSuffix + ")\n";
2120
}
2221
});
2322

@@ -35,7 +34,11 @@ $("#defRestack").click(function () {
3534
$("#textsArea").html("");
3635
}
3736

38-
$("#textsArea").append("<textarea cols=50 rows=10 id=restackArea>" + request + "</textarea>");
37+
var title = trans.sp.troopOverview.restackTitle
38+
.replace("{to}", parseInt(restackTo / 1000, 10))
39+
.replace("{requiredDiff}", parseInt(user_data.restack.requiredDifference / 1000, 10));
40+
41+
$("#textsArea").append(title + "<br><textarea cols=50 rows=10 id=restackArea>" + request + "</textarea>");
3942

4043
$("#closeTextsArea").click(function() {
4144
$("#textsArea").parent().parent().remove();

overviews/units_support_detail/filter_own_villages.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,13 @@ $("#attackFilter").click(function () {
4747
* @param {boolean} reverseFilter reverse the above strategy
4848
* @param {function} [survivorRowStrategy] execute on all rows that are not being removed (gets passed the row and optional tag)
4949
* @param {*} [tag] this value is passed onto filterStrategy and survivorRowStrategy as the second parameter (row is the first param)
50-
* @param {boolean} [forceTotalCalcWithoutSupport] pass true if the total calculation needs to happen on villages without support also
5150
*/
52-
function filterMainRows(filterStrategy, reverseFilter, survivorRowStrategy, tag, forceTotalCalcWithoutSupportParam) {
53-
var forceTotalCalcWithoutSupport = forceTotalCalcWithoutSupportParam;
51+
function filterMainRows(filterStrategy, reverseFilter, survivorRowStrategy, tag) {
5452
if (!$("#defTotals").is(":disabled")) {
5553
$("#defTotals").click();
5654
}
5755

58-
var goners = $();
56+
/*var goners = $();
5957
$("tr.grandTotal", overviewTable).each(function () {
6058
var self = $(this),
6159
prev;
@@ -76,6 +74,30 @@ function filterMainRows(filterStrategy, reverseFilter, survivorRowStrategy, tag,
7674
}
7775
survivorRowStrategy(prev, tag);
7876
}
77+
});
78+
goners.remove();
79+
setTotalCount();*/
80+
81+
var lastRow = $("tr:last", overviewTable).get(0);
82+
var goners = $();
83+
$("tr.units_away", overviewTable).each(function () {
84+
var self = $(this);
85+
if (!reverseFilter != !filterStrategy(self, tag)) {
86+
goners = goners.add(self);
87+
88+
var nextRow = self.next();
89+
while (!nextRow.hasClass("units_away") && nextRow.get(0) !== lastRow) {
90+
goners = goners.add(nextRow);
91+
nextRow = nextRow.next();
92+
}
93+
}
94+
else if (survivorRowStrategy != null) {
95+
/*prev = self.prev();
96+
while (!prev.hasClass("units_away")) {
97+
prev = prev.prev();
98+
}*/
99+
survivorRowStrategy(self, tag);
100+
}
79101
});
80102
goners.remove();
81103
setTotalCount();
@@ -90,7 +112,7 @@ $("#defFilterTotalPop").click(function () {
90112
var compareTo = parseInt($("#defFilterTotalPopValue").val(), 10);
91113

92114
filterMainRows(
93-
function (row) { return (parseInt(row.attr("population"), 10) > compareTo); },
115+
function (row) { q(row.attr("village") + "is:" + row.attr("population")); return (parseInt(row.attr("population"), 10) > compareTo); },
94116
reverseFilter);
95117
});
96118

@@ -120,6 +142,5 @@ $("#defFilterDist").click(function () {
120142
// Adds the distance between OWN village and the user given coordinates
121143
mainRow.find("td:eq(1)").html("<b>" + trans.sp.defOverview.fieldsPrefix.replace("{0}", parseInt(tag.distance, 10)) + "</b>");
122144
},
123-
{ distance: 0 },
124-
true);
145+
{ distance: 0 });
125146
});

overviews/units_support_detail/other_features.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ $("#defTotals").click(function () {
6161
self.removeClass("row_b").addClass("row_a");
6262
}
6363

64+
// village attribute both to .units_away and .grandTotal rows ;)
65+
self.attr("village", villageCoord.coord);
66+
6467
var nextRow = self.next();
6568
if (nextRow.hasClass("units_away")) {
6669
if (user_data.restack.removeRowsWithoutSupport) {
6770
goners = goners.add(self);
68-
} else {
69-
self.attr("village", villageCoord.coord);
7071
}
7172
} else {
7273
// calculate total support
@@ -120,6 +121,7 @@ $("#defTotals").click(function () {
120121
}
121122
}
122123

124+
self.attr("population", grandTotal);
123125
var color = getStackColor(grandTotal);
124126
color = "<td style='background-color: " + color + "; border:1px solid black'>" + formatNumber(grandTotal) + "</td>";
125127

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.6.98
1+
4.6.108

0 commit comments

Comments
 (0)