Browse Source

fix them stupid chickens

master
Nero Ignis 3 years ago
parent
commit
8397423619
  1. 3
      src/components/BarnView.vue
  2. 15
      src/store/index.js

3
src/components/BarnView.vue

@ -44,7 +44,7 @@ export default { @@ -44,7 +44,7 @@ export default {
let productFromAnimal = AnimalService.getProductFromAnimalID(animal.id);
iziToast.info({
title: productFromAnimal.name+' can be collected '+ moment(animal.production.ready).fromNow(),
title: productFromAnimal.name+' can be collected '+ moment(animal.production.ready).fromNow() + ' ('+animal.production.percent+'%)',
image: productFromAnimal.icon,
});
@ -70,6 +70,7 @@ export default { @@ -70,6 +70,7 @@ export default {
});
animal.production = {
started: moment(),
ready: moment().add(animalData.production.time, 'minutes'),
percent: 0,
canBeCollected: false

15
src/store/index.js

@ -281,10 +281,9 @@ export default createStore({ @@ -281,10 +281,9 @@ export default createStore({
if (field.data.percentDone <= 100) {
let minutesSincePlanting = moment.duration(moment().diff(field.data.planted)).asMinutes();
field.data.percentDone =
Number(
Number(minutesSincePlanting) / Number(seed.cropData.timeToGrow) * 100
).toFixed(2);
field.data.percentDone = Number(
Number(minutesSincePlanting) / Number(seed.cropData.timeToGrow) * 100
).toFixed(2);
if (field.data.percentDone >= 100) {
field.data.percentDone = 100;
@ -333,6 +332,7 @@ export default createStore({ @@ -333,6 +332,7 @@ export default createStore({
let animalData = AnimalService.getAnimalByID(animal.id);
if (!animal.production) {
animal.production = {
started: moment(),
ready: moment().add(animalData.production.time, 'minutes'),
percent: 0,
canBeCollected: false
@ -344,8 +344,11 @@ export default createStore({ @@ -344,8 +344,11 @@ export default createStore({
}
if (animal.production.percent <= 100) {
let minutesLeft = moment.duration(moment(animal.production.ready).diff(moment())).asMinutes();
animal.production.percent = Number((Number(animalData.production.time) * 100) / Number(minutesLeft) - 100).toFixed(2);
let minutesSinceLastCollection = moment.duration(moment().diff(animal.production.started)).asMinutes();
animal.production.percent = Number(
Number(minutesSinceLastCollection) / Number(animalData.production.time) * 100
).toFixed(2);
if (animal.production.percent >= 100) {
animal.production.percent = 100;
animal.production.canBeCollected = true;

Loading…
Cancel
Save