Browse Source

add more items; add description to itemdetails; prevent trashing 0 items;

master
Nero Ignis 3 years ago
parent
commit
0ed3332f56
  1. 2
      src/components/CropShopView.vue
  2. 16
      src/components/InventoryView.vue
  3. 6
      src/data/ItemTypes.js
  4. 62
      src/data/Items.js
  5. 9
      src/data/ItemsIDs.js
  6. 10
      src/store/index.js

2
src/components/CropShopView.vue

@ -108,7 +108,7 @@ export default { @@ -108,7 +108,7 @@ export default {
},
computed: {
items() {
return ItemService.getItemsByType([ItemTypes.Seeds, ItemTypes.AnimalProducts]);
return ItemService.getItemsByType([ItemTypes.Seeds, ItemTypes.AnimalProducts, ItemTypes.PreparedMeals]);
}
}
}

16
src/components/InventoryView.vue

@ -68,8 +68,10 @@ @@ -68,8 +68,10 @@
</div>
<div class="modal-body" v-if="selectedItem">
<div class="row">
<div class="col-12" v-if="selectedItem.description" v-html="selectedItem.description">
<div class="col-12" v-if="selectedItem.description">
<small class="text-muted">Description</small><br>
{{ selectedItem.description }}
<hr>
</div>
<div class="col-12" v-if="selectedItem.cropData">
<div class="float-end">
@ -136,6 +138,11 @@ export default { @@ -136,6 +138,11 @@ export default {
name: 'Animal products',
type: ItemTypes.AnimalProducts,
items: this.$store.getters.getAnimalProductsInInventory
},
{
name: 'Prepared meals',
type: ItemTypes.PreparedMeals,
items: this.$store.getters.getPreparedMealsInInventory
}
]
},
@ -162,9 +169,12 @@ export default { @@ -162,9 +169,12 @@ export default {
showItemInfo(item) {
this.selectedItem = item;
openModal('itemInfoModal');
console.log(item);
},
trashItems() {
if (this.trashQuantity <= 0) {
return false;
}
this.$store.commit('removeItemFromInventory', {item: this.selectedItem, quantity: this.trashQuantity});
iziToast.success({
title: 'Threw away '+this.trashQuantity+' of '+this.selectedItem.name

6
src/data/ItemTypes.js

@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
export const ItemTypes = {
Seeds: 'SEEDS',
FieldProducts: 'FIELD_PRODUCTS',
AnimalProducts: 'ANIMAL_PRODUCTS'
AnimalProducts: 'ANIMAL_PRODUCTS',
PreparedMeals: 'PREPARED_MEALS'
}
export const ItemTypeFrameClasses = {
SEEDS: 'pixel-border-green ',
FIELD_PRODUCTS: 'pixel-border-red ',
ANIMAL_PRODUCTS: 'pixel-border-blue '
ANIMAL_PRODUCTS: 'pixel-border-blue ',
PREPARED_MEALS: 'pixel-border-magenta '
}

62
src/data/Items.js

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import {Seasons} from "@/services/SeasonService";
import {ItemTypes} from "@/data/ItemTypes";
import {CropAssets, FoodAssets} from "@/data/Paths";
import {Seeds, FieldProducts, AnimalProducts} from "@/data/ItemsIDs";
import {Seeds, FieldProducts, AnimalProducts, PreparedMeals} from "@/data/ItemsIDs";
export default [
{
@ -66,7 +66,7 @@ export default [ @@ -66,7 +66,7 @@ export default [
id: Seeds.TurnipSeeds,
name: 'Turnip seeds',
type: ItemTypes.Seeds,
description: '',
description: 'Plant them to get turnips, obviously.',
assetsFolder: CropAssets + 'turnip/',
icon: CropAssets + 'turnip/1.png',
economy: {
@ -559,7 +559,7 @@ export default [ @@ -559,7 +559,7 @@ export default [
id: AnimalProducts.Egg,
name: 'Egg',
type: ItemTypes.AnimalProducts,
description: '',
description: 'Which came first?',
assetsFolder: FoodAssets + 'egg_whole_brown.png',
icon: FoodAssets + 'egg_whole_brown.png',
economy: {
@ -567,5 +567,61 @@ export default [ @@ -567,5 +567,61 @@ export default [
sell: 50,
}
},
{
id: PreparedMeals.Sushi,
name: 'Sushi',
type: ItemTypes.PreparedMeals,
description: 'Fishy business.',
assetsFolder: FoodAssets + 'sushi_roll.png',
icon: FoodAssets + 'sushi_roll.png',
economy: {
buy: 300,
sell: 150,
},
cooking: {
time: 5,
ingredients: [
]
}
},
{
id: PreparedMeals.Nigiri,
name: 'Nigiri',
type: ItemTypes.PreparedMeals,
description: '',
assetsFolder: FoodAssets + 'sushi_nigiri.png',
icon: FoodAssets + 'sushi_nigiri.png',
economy: {
buy: 300,
sell: 150,
},
cooking: {
time: 5,
ingredients: [
{id: FieldProducts.Rice, amount: 2},
{id: FieldProducts.Rice, amount: 1},
]
}
},
{
id: AnimalProducts.RawFish,
name: 'Raw fish',
type: ItemTypes.AnimalProducts,
description: '',
assetsFolder: FoodAssets + 'sushi_nigiri.png',
icon: FoodAssets + 'sushi_nigiri.png',
economy: {
buy: 300,
sell: 150,
},
cooking: {
time: 5,
ingredients: [
{id: FieldProducts.Rice, amount: 2},
{id: FieldProducts.Rice, amount: 1},
]
}
},
]

9
src/data/ItemsIDs.js

@ -46,5 +46,12 @@ export const FieldProducts = { @@ -46,5 +46,12 @@ export const FieldProducts = {
// ANIMAL PRODUCTS
export const AnimalProducts = {
Egg: 39 // 💙
Egg: 39, // 💙
RawFish: 42
}
// PREPARED MEALS
export const PreparedMeals = {
Sushi: 40,
Nigiri: 41
}

10
src/store/index.js

@ -77,6 +77,16 @@ export default createStore({ @@ -77,6 +77,16 @@ export default createStore({
}).map((inventoryItem) => {
let item = ItemService.getItemByID(inventoryItem.id);
item.quantity = inventoryItem.quantity;
return item;
}) ?? [];
},
getPreparedMealsInInventory(state) {
return state.inventory.filter((inventoryItem) => {
return inventoryItem.type === ItemTypes.PreparedMeals && inventoryItem.quantity > 0;
}).map((inventoryItem) => {
let item = ItemService.getItemByID(inventoryItem.id);
item.quantity = inventoryItem.quantity;
return item;
}) ?? [];

Loading…
Cancel
Save