mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +08:00
Added max/zero buttons to worker assignment and expedition supply packing to prevent eg having to click 50x to fill food supplies.
This commit is contained in:
@@ -296,8 +296,10 @@ var Outside = {
|
||||
numGatherers -= State.outside.workers[k];
|
||||
if(State.outside.workers[k] == 0) {
|
||||
$('.dnBtn', row).addClass('disabled');
|
||||
$('.zeroBtn', row).addClass('disabled');
|
||||
} else {
|
||||
$('.dnBtn', row).removeClass('disabled');
|
||||
$('.zeroBtn', row).removeClass('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,8 +312,10 @@ var Outside = {
|
||||
|
||||
if(numGatherers == 0) {
|
||||
$('.upBtn', '#workers').addClass('disabled');
|
||||
$('.maxBtn', '#workers').addClass('disabled');
|
||||
} else {
|
||||
$('.upBtn', '#workers').removeClass('disabled');
|
||||
$('.maxBtn', '#workers').removeClass('disabled');
|
||||
}
|
||||
|
||||
|
||||
@@ -338,8 +342,10 @@ var Outside = {
|
||||
$('<span>').text(num).appendTo(val);
|
||||
|
||||
if(name != 'gatherer') {
|
||||
$('<div>').addClass('maxBtn').appendTo(val).click(Outside.maxWorker);
|
||||
$('<div>').addClass('upBtn').appendTo(val).click(Outside.increaseWorker);
|
||||
$('<div>').addClass('dnBtn').appendTo(val).click(Outside.decreaseWorker);
|
||||
$('<div>').addClass('zeroBtn').appendTo(val).click(Outside.zeroWorker);
|
||||
}
|
||||
|
||||
$('<div>').addClass('clear').appendTo(row);
|
||||
@@ -376,6 +382,26 @@ var Outside = {
|
||||
}
|
||||
},
|
||||
|
||||
maxWorker: function(btn) {
|
||||
var worker = $(this).closest('.workerRow').children('.row_key').text();
|
||||
if(Outside.getNumGatherers() > 0) {
|
||||
Engine.log('maxing ' + worker);
|
||||
State.outside.workers[worker] += Outside.getNumGatherers();
|
||||
Outside.updateVillageIncome();
|
||||
Outside.updateWorkersView();
|
||||
}
|
||||
},
|
||||
|
||||
zeroWorker: function(btn) {
|
||||
var worker = $(this).closest('.workerRow').children('.row_key').text();
|
||||
if(State.outside.workers[worker] > 0) {
|
||||
Engine.log('zeroing ' + worker);
|
||||
State.outside.workers[worker] = 0;
|
||||
Outside.updateVillageIncome();
|
||||
Outside.updateWorkersView();
|
||||
}
|
||||
},
|
||||
|
||||
updateVillageRow: function(name, num, village) {
|
||||
var id = 'building_row_' + name.replace(' ', '-');
|
||||
var row = $('div#' + id, village);
|
||||
|
||||
@@ -194,13 +194,17 @@ var Path = {
|
||||
}
|
||||
if(num == 0) {
|
||||
$('.dnBtn', row).addClass('disabled');
|
||||
$('.zeroBtn', row).addClass('disabled');
|
||||
} else {
|
||||
$('.dnBtn', row).removeClass('disabled');
|
||||
$('.zeroBtn', row).removeClass('disabled');
|
||||
}
|
||||
if(num >= numAvailable || space < Path.getWeight(k)) {
|
||||
$('.upBtn', row).addClass('disabled');
|
||||
$('.maxBtn', row).addClass('disabled');
|
||||
} else if(space >= Path.getWeight(k)) {
|
||||
$('.upBtn', row).removeClass('disabled');
|
||||
$('.maxBtn', row).removeClass('disabled');
|
||||
}
|
||||
} else if(have == 0 && row.length > 0) {
|
||||
row.remove();
|
||||
@@ -225,6 +229,8 @@ var Path = {
|
||||
$('<span>').text(num).appendTo(val);
|
||||
$('<div>').addClass('upBtn').appendTo(val).click(Path.increaseSupply);
|
||||
$('<div>').addClass('dnBtn').appendTo(val).click(Path.decreaseSupply);
|
||||
$('<div>').addClass('maxBtn').appendTo(val).click(Path.maxSupply);
|
||||
$('<div>').addClass('zeroBtn').appendTo(val).click(Path.zeroSupply);
|
||||
$('<div>').addClass('clear').appendTo(row);
|
||||
|
||||
var numAvailable = Engine.getStore(name);
|
||||
@@ -259,6 +265,30 @@ var Path = {
|
||||
}
|
||||
},
|
||||
|
||||
maxSupply: function() {
|
||||
var supply = $(this).closest('.outfitRow').children('.row_key').text().replace('-', ' ');
|
||||
Engine.log('maxing ' + supply);
|
||||
var cur = Path.outfit[supply];
|
||||
cur = typeof cur == 'number' ? cur : 0;
|
||||
if(Path.getFreeSpace() >= Path.getWeight(supply) && cur < Engine.getStore(supply)) {
|
||||
var maxExtraByWeight = Math.floor(Path.getFreeSpace() / Path.getWeight(supply));
|
||||
var maxExtraByStore = Engine.getStore(supply) - cur;
|
||||
Path.outfit[supply] = cur + Math.min(maxExtraByWeight, maxExtraByStore);
|
||||
Path.updateOutfitting();
|
||||
}
|
||||
},
|
||||
|
||||
zeroSupply: function() {
|
||||
var supply = $(this).closest('.outfitRow').children('.row_key').text().replace('-', ' ');
|
||||
Engine.log('zeroing ' + supply);
|
||||
var cur = Path.outfit[supply];
|
||||
cur = typeof cur == 'number' ? cur : 0;
|
||||
if(cur > 0) {
|
||||
Path.outfit[supply] = 0;
|
||||
Path.updateOutfitting();
|
||||
}
|
||||
},
|
||||
|
||||
onArrival: function() {
|
||||
Path.setTitle();
|
||||
Path.updateOutfitting();
|
||||
|
||||
Reference in New Issue
Block a user