Skip to content

Commit

Permalink
Show scaled food with tip in object inspetor - closes #182
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Apr 13, 2020
1 parent 7ceee06 commit ece97d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion process/src/GameData.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class GameData {
biomeIds: this.biomes.map(b => b.id),
biomeNames: this.biomes.map(b => b.name()),
foodBonus: parseInt(process.env.ONETECH_FOOD_BONUS),
foodScale: parseInt(process.env.ONETECH_FOOD_SCALE),
foodScale: parseFloat(process.env.ONETECH_FOOD_SCALE),
};
}

Expand Down
33 changes: 17 additions & 16 deletions src/components/ObjectInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
</div>

<ul v-if="object.data">
<li v-if="foodWithBonus">
Food: {{foodWithBonus}}
<span class="details" v-if="hasFoodBonus">({{foodBase}}+{{foodBonus}} bonus)</span>
<span class="details" v-else>(without bonus)</span>
<li v-if="foodValue">
Food: {{foodValue}}
<span class="helpTip" v-tippy :title="foodValueTip">?</span>
</li>
<li v-if="object.data.heatValue">Heat: {{object.data.heatValue}}</li>
<li v-if="object.clothingPart()">Clothing: {{object.clothingPart()}}</li>
Expand Down Expand Up @@ -224,19 +223,21 @@ export default {
modName() {
return process.env.ONETECH_MOD_NAME;
},
hasFoodBonus() {
return parseInt(GameObject.foodBonus) > 0;
},
foodBonus() {
return GameObject.foodBonus;
},
foodBase() {
if (!this.object.data.foodValue) return;
return this.object.data.foodValue;
foodValue() {
let foodValue = this.object.data.foodValue;
if (!foodValue) {
return null;
}
if (GameObject.foodScale) {
foodValue = Math.ceil(foodValue * parseFloat(GameObject.foodScale));
}
if (GameObject.foodBonus) {
foodValue += parseInt(GameObject.foodBonus);
}
return foodValue;
},
foodWithBonus() {
if (!this.foodBase) return;
return this.foodBase + this.foodBonus;
foodValueTip() {
return `${this.object.data.foodValue} (food) x ${GameObject.foodScale} (scale) + ${GameObject.foodBonus} (bonus)`;
},
totalFood() {
if (!this.foodValue || !this.numUses) return;
Expand Down
1 change: 1 addition & 0 deletions src/models/GameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class GameObject {
this.date = new Date(data.date);
this.versions = data.versions;
this.foodBonus = data.foodBonus;
this.foodScale = data.foodScale;
this.legacyObjectsMap = {};
callback(data);
});
Expand Down

0 comments on commit ece97d6

Please sign in to comment.