Skip to content

Commit

Permalink
Add freerange plots
Browse files Browse the repository at this point in the history
Temporary solution for #13
  • Loading branch information
baatochan committed Apr 9, 2018
1 parent 75e46ef commit 3dbdad4
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
16 changes: 14 additions & 2 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ label {
background-color: rgba(173, 255, 47, 0.7);
}

/*noinspection CssUnusedSymbol*/
.freerange {
background-color: rgba(240, 230, 140, 0.7);
}

/*noinspection CssUnusedSymbol*/
.coop {
background-color: rgba(128, 128, 128, 0.7);
Expand All @@ -194,6 +199,11 @@ label {
background-color: rgba(220, 20, 60, 0.7);
}

/*noinspection CssUnusedSymbol*/
.plotFreerange {
background-color: rgba(240, 230, 140, 0.7);
}

.plotType {
display: none;
text-transform: capitalize;
Expand Down Expand Up @@ -290,7 +300,8 @@ label {
right: 0;
top: 150px;
border: rgba(0, 0, 0, 1) solid 1px;
border-radius: 3px;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
padding: 3px 5px;
line-height: 1;
background-color: rgba(65, 82, 95, 0.7);
Expand All @@ -301,7 +312,8 @@ label {
right: 0;
top: 150px;
border: rgba(0, 0, 0, 1) solid 1px;
border-radius: 3px;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
line-height: 1;
background-color: rgb(65, 82, 95);
color: white;
Expand Down
57 changes: 49 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ var defaultValuesPlots = [
'id': 'M5', 'leftPosition': 947, 'topPosition': 511, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'MW', 'leftPosition': 904, 'topPosition': 592, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'F1', 'leftPosition': 420, 'topPosition': 640, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'F2', 'leftPosition': 510, 'topPosition': 330, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'F3', 'leftPosition': 590, 'topPosition': 620, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'F4', 'leftPosition': 830, 'topPosition': 270, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'F5', 'leftPosition': 830, 'topPosition': 590, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'F6', 'leftPosition': 1090, 'topPosition': 560, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}, {
'id': 'F7', 'leftPosition': 1210, 'topPosition': 270, 'align': 'center', 'occupied': false, 'type': null, 'firstItem': null, 'secondItem': null, 'description': '', 'numberOfItems': 0
}
];

Expand Down Expand Up @@ -262,7 +276,10 @@ $(document).ready(function () {
$('#slimeCount').hide('slow');
});

$('#refreshSlimeCount').click(updateSlimeCountTable);
$('#refreshSlimeCount').click(function (e) {
e.preventDefault();
updateSlimeCountTable();
});
});

//region saveMenu
Expand Down Expand Up @@ -438,6 +455,7 @@ function showPlots() {
plot.find('.plotNumber').text(value.id);
plotTemplate.after(plot);
}
if(typeof value.id === 'string' && value.id.substr(0, 1) === 'F') plot.find('.plot').addClass('plotFreerange');
var leftPosition = value.leftPosition + leftOffset - plotBorder;
var topPosition = value.topPosition + topOffset - plotBorder;
plot.find('.plot').css('left', leftPosition + 'px');
Expand All @@ -462,7 +480,7 @@ function showMaximizedPlots() {
if (plot.length === 0) {
plot = regionTemplate.clone();
plot.attr('id', simplifiedName + '-region');
plot.css('z-index', -1);
plot.css('z-index', -2);
regionTemplate.after(plot);
}
var leftPosition = value.leftPosition + leftOffset - plotBorder;
Expand Down Expand Up @@ -522,9 +540,10 @@ function showMaximizedPlots() {
plot.find('.plotMaximized').css('top', topPosition + 'px');
plot.find('.plotMaximized').removeClass('corral garden coop pond silo incinerator');
plot.find('.plotMaximized').addClass(value.type);
if(typeof value.id === 'string' && value.id.substr(0, 1) === 'F') plot.find('.plotMaximized').addClass('plotMaximizedFreerange');
plot.find('.plotType').text(value.type);
plot.find('.plotType').css('display', 'block');
if(value.type === 'corral' && value.firstItem !== null && value.secondItem !== null) {
if((value.type === 'corral' || value.type === 'freerange') && value.firstItem !== null && value.secondItem !== null) {
plot.find('.plotContent').css('display', 'none');
plot.find('.corralContentFirstItem').empty();
plot.find('.corralContentFirstItem').append($('<img>', {
Expand Down Expand Up @@ -603,7 +622,7 @@ function updateSlimeCountTable() {

var numberOfCorrals = 0;
$.each(plots, function (key, value) {
if (value.occupied === true && value.type === 'corral') {
if (value.occupied === true && (value.type === 'corral' || value.type === 'freerange')) {
if (value.firstItem === slimeName || value.secondItem === slimeName) numberOfCorrals++;
}
});
Expand All @@ -629,6 +648,9 @@ function openSetUpForm(e) {
if (id.slice(-1) === 'W') {
$('#setupPlotNumber').text('- waterfall');
hideChoicesForWaterfall();
} else if (id.substr(0, 1) === 'F') {
$('#setupPlotNumber').text('- freerange');
hideChoicesForFreerange()
} else {
$('#setupPlotNumber').text(id);
showAllFirstChoices();
Expand All @@ -653,9 +675,12 @@ function openEditForm(e) {
var id = $(this).attr('id');
id = id.slice(15);
$('#editedPlotNumber').val(id);
if (id === 'W') {
if (id.slice(-1) === 'W') {
$('#setupPlotNumber').text('- waterfall');
hideChoicesForWaterfall();
} else if (id.substr(0, 1) === 'F') {
$('#setupPlotNumber').text('- freerange');
hideChoicesForFreerange()
} else {
$('#setupPlotNumber').text(id);
showAllFirstChoices();
Expand Down Expand Up @@ -703,17 +728,33 @@ function hideChoicesForWaterfall() {
$('#firstChoiceCoop').css('display', 'none');
$('#firstChoiceSilo').css('display', 'none');
$('#firstChoiceIncinerator').css('display', 'none');
$('#firstChoicePond').css('display', 'block');
}

/**
* Function that hides all the choices except for unselected and freerange from the first select menu.
*/
function hideChoicesForFreerange() {
$('#firstChoiceCorral').css('display', 'block');
$('#firstChoiceCorral').text('Freerange').attr('value', 'freerange');
$('#firstChoicePond').css('display', 'none');
$('#firstChoiceGarden').css('display', 'none');
$('#firstChoiceCoop').css('display', 'none');
$('#firstChoiceSilo').css('display', 'none');
$('#firstChoiceIncinerator').css('display', 'none');
}

/**
* Function that restores all the choices in the first select menu.
*/
function showAllFirstChoices() {
$('#firstChoiceCorral').text('Corral').attr('value', 'corral');
$('#firstChoiceCorral').css('display', 'block');
$('#firstChoiceGarden').css('display', 'block');
$('#firstChoiceCoop').css('display', 'block');
$('#firstChoiceSilo').css('display', 'block');
$('#firstChoiceIncinerator').css('display', 'block');
$('#firstChoicePond').css('display', 'block');
}

/**
Expand All @@ -739,7 +780,7 @@ function loadSecondAndThirdChoice() {
var secondChoice = $('#secondChoice');
var thirdChoice = $('#thirdChoice');

if (chosenFirstValue === 'corral') {
if (chosenFirstValue === 'corral' || chosenFirstValue === 'freerange') {
secondChoiceLabel.css('display', '');
secondChoiceLabel.text('Slime type:');
thirdChoiceLabel.css('display', '');
Expand Down Expand Up @@ -804,7 +845,7 @@ function updateOptions(type, selectHTML) {

var array;

if (type === 'corral') {
if (type === 'corral' || type === 'freerange') {
array = slimeTypes;
} else if (type === 'garden') {
array = foodTypes;
Expand Down Expand Up @@ -918,7 +959,7 @@ function savePlot() {
value.numberOfItems = 0;
} else {
value.firstItem = chosenSecondValue;
if (chosenThirdValue !== 'unselected' && chosenFirstValue === 'corral' && chosenThirdValue !== chosenSecondValue) {
if (chosenThirdValue !== 'unselected' && (chosenFirstValue === 'corral' || chosenFirstValue === 'freerange') && chosenThirdValue !== chosenSecondValue) {
value.secondItem = chosenThirdValue;
} else {
value.secondItem = null;
Expand Down

0 comments on commit 3dbdad4

Please sign in to comment.