Browse Source

WIP;

master
Nero Ignis 3 years ago
parent
commit
ea24b49f75
  1. BIN
      public/assets/gui/border_dark.png
  2. BIN
      public/assets/gui/border_light.png
  3. BIN
      public/assets/gui/border_steel.png
  4. 71
      src/components/CropField.vue
  5. 35
      src/components/CropInformation.vue
  6. 46
      src/components/InventoryDialog.vue
  7. 2
      src/components/MenuBar.vue
  8. 300
      src/data/Items.js
  9. 45
      src/data/ItemsIDs.js
  10. 3
      src/models/Item.js
  11. 15
      src/services/ItemService.js
  12. 0
      src/services/SeasonService.js
  13. 2
      src/store/index.js
  14. 5
      src/views/GameView.vue
  15. 2
      tests/unit/getSeason.spec.js

BIN
public/assets/gui/border_dark.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
public/assets/gui/border_light.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
public/assets/gui/border_steel.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

71
src/components/CropField.vue

@ -15,23 +15,18 @@ @@ -15,23 +15,18 @@
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content steel-border">
<div class="modal-header">
<h5 class="modal-title" id="cropInventoryModalLabel">Select a crop to be planted</h5>
</div>
<div class="modal-body">
<div class="row">
<div class="col-6 pixel-border-static"
<div v-on:click="plantSeed(seed)"
v-for="seed in $store.getters.getSeedsInInventory"
v-bind:key="seed"
data-bs-dismiss="modal">
<div v-on:click="plantSeed(seed)">
<div class="float-end">
<img :src="seed.assetsFolder+'/6.png'" :alt="seed.name">
data-bs-dismiss="modal"
class="crop-item-wrapper" :style="'background-image: url('+seed.assetsFolder+'/6.png)'">
<div class="crop-item" >
<div>
<span class="growtime-display">{{ seed.cropData.timeToGrow }}</span>
<span class="quantity-display">{{ seed.quantity }}</span>
</div>
{{ seed.name }}<br/>
{{ seed.cropData.timeToGrow }} minutes<br/>
({{ seed.quantity }} left)
</div>
</div>
<div v-if="!$store.getters.getSeedsInInventory.length">
@ -40,8 +35,8 @@ @@ -40,8 +35,8 @@
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pixel-border" data-bs-dismiss="modal">Cancel</button>
<div class="modal-footer" v-if="!$store.getters.getSeedsInInventory.length">
<button type="button" class="btn btn-pixel-border" data-bs-dismiss="modal">K, bye</button>
</div>
</div>
</div>
@ -77,17 +72,6 @@ export default { @@ -77,17 +72,6 @@ export default {
harvestField(field) {
this.$store.commit('harvestSeed', field);
},
// cropInformation(id) {
// this.$store.commit('selectField', id);
//
// if (!this.$store.getters.selectedField.data) {
// return false;
// }
//
// const modal = new Modal(document.getElementById('cropInformationModal'))
// modal.toggle();
// return false;
// },
getCropAsset(field) {
let seed = this.$store.state.itemCatalogue.find((item) => {
return item.id === field.data.seed_id;
@ -155,4 +139,41 @@ export default { @@ -155,4 +139,41 @@ export default {
background-color: green;
height: 0.2em;
}
.crop-item-wrapper {
align-content: center;
width: 3.7em;
height: 3.7em;
margin: 3px auto;
padding: 0;
position: relative;
}
.crop-item {
background-repeat: no-repeat;
background-size: 100%;
}
.growtime-display {
position: absolute;
bottom: 0;
left: 0;
z-index: 500;
padding: 0 0.4em;
margin-bottom: -0.5em;
background-color: green;
border-radius: 15px;
}
.quantity-display {
position: absolute;
bottom: 0;
right: 0;
z-index: 500;
padding: 0 0.4em;
margin-bottom: -0.5em;
background-color: yellow;
border-radius: 15px;
}
</style>

35
src/components/CropInformation.vue

@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
<template>
<div class="modal fade"
id="cropInformationModal"
tabindex="-1"
aria-labelledby="cropInformationModalLabel"
aria-hidden="true"
v-if="$store.getters.selectedField">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content steel-border">
<div class="modal-header">
<h5 class="modal-title" id="cropInformationModalLabel">Crop information</h5>
</div>
<div class="modal-body" v-if="$store.getters.selectedField.data">
Seed: {{ $store.getters.selectedFieldSeed.name }}<br/>
Percent done: {{ $store.getters.selectedField.data.percentDone }}<br/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pixel-border" data-bs-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "CropInformation"
}
</script>
<style scoped>
</style>

46
src/components/InventoryDialog.vue

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
<template>
<div class="modal fade" id="inventoryModal" tabindex="-1" aria-labelledby="inventoryModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content steel-border">
<div class="modal-header">
<h5 class="modal-title" id="inventoryModalLabel">Inventory</h5>
</div>
<div class="modal-body">
<div class="row">
<div class="col-6 pixel-border-static"
v-for="item in $store.getters.getInventoryWithItemData"
v-bind:key="item"
data-bs-dismiss="modal">
<div class="">
<div class="float-end">
<img :src="item.icon" :alt="item.name">
</div>
{{ item.name }}<br/>
{{ item.quantity }}
</div>
</div>
<div v-if="$store.state.inventory.length === 0">
You don't have any items yet.
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pixel-border" data-bs-dismiss="modal">Exit</button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "InventoryDialog",
}
</script>
<style scoped>
</style>

2
src/components/MenuBar.vue

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
</div>
<div class="menu-item">
Item
<a href="javascript:" v-on:click="openModal('inventoryModal')">Inventory</a>
</div>
<div class="menu-center">

300
src/data/Items.js

@ -1,13 +1,16 @@ @@ -1,13 +1,16 @@
import Seasons from "@/data/Seasons";
import ItemTypes from "@/data/ItemTypes";
import {CropAssets} from "@/data/Paths";
import {Seeds, FieldProducts} from "@/data/ItemsIDs";
export default [
{
id: Seeds.WheatSeeds,
name: 'Wheat seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'wheat/',
icon: CropAssets + 'wheat/1.png',
economy: {
buy: 5,
sell: 10
@ -15,10 +18,11 @@ export default [ @@ -15,10 +18,11 @@ export default [
cropData: {
timeToGrow: 1,
season: Seasons.Summer,
product_id: 2
product_id: FieldProducts.Wheat
}
},
{
id: FieldProducts.Wheat,
name: 'Wheat',
type: ItemTypes.FieldProducts,
description: '',
@ -30,10 +34,12 @@ export default [ @@ -30,10 +34,12 @@ export default [
}
},
{
id: Seeds.RiceSeeds,
name: 'Rice seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'rice/',
icon: CropAssets + 'rice/',
economy: {
buy: 5,
sell: 10,
@ -41,10 +47,11 @@ export default [ @@ -41,10 +47,11 @@ export default [
cropData: {
timeToGrow: 2,
season: Seasons.Summer,
product_id: 4
product_id: FieldProducts.Rice
}
},
{
id: FieldProducts.Rice,
name: 'Rice',
type: ItemTypes.FieldProducts,
description: '',
@ -56,241 +63,496 @@ export default [ @@ -56,241 +63,496 @@ export default [
}
},
{
id: Seeds.TurnipSeeds,
name: 'Turnip seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'turnip/',
icon: CropAssets + 'turnip/',
economy: {
buy: 10,
sell: 20,
},
cropData: {
timeToGrow: 3,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Turnip
}
},
{
id: FieldProducts.Turnip,
name: 'Turnip',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'turnip/',
icon: CropAssets + 'turnip/6.png',
economy: {
buy: 10,
sell: 20,
}
},
{
id: Seeds.PotatoSeeds,
name: 'Potato seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'potato/',
icon: CropAssets + 'potato/',
economy: {
buy: 10,
sell: 20,
},
cropData: {
timeToGrow: 3,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Potato
}
},
{
id: FieldProducts.Potato,
name: 'Potato',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'potato/',
icon: CropAssets + 'potato/6.png',
economy: {
buy: 10,
sell: 20,
}
},
{
id: Seeds.CornSeeds,
name: 'Corn seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'corn/',
icon: CropAssets + 'corn/',
economy: {
buy: 15,
sell: 25,
},
cropData: {
timeToGrow: 7,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Corn
}
},
{
id: FieldProducts.Corn,
name: 'Corn',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'corn/',
icon: CropAssets + 'corn/6.png',
economy: {
buy: 15,
sell: 25,
}
},
{
id: Seeds.EggplantSeeds,
name: 'Eggplant seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'eggplant/',
icon: CropAssets + 'eggplant/',
economy: {
buy: 15,
sell: 25,
},
cropData: {
timeToGrow: 9,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Eggplant
}
},
{
id: FieldProducts.Eggplant,
name: 'Eggplant',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'eggplant/',
icon: CropAssets + 'eggplant/6.png',
economy: {
buy: 15,
sell: 25,
}
},
{
id: Seeds.GrapeSeeds,
name: 'Grapes seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'grapes/',
icon: CropAssets + 'grapes/',
economy: {
buy: 15,
sell: 25,
},
cropData: {
timeToGrow: 9,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Grapes
}
},
{
id: FieldProducts.Grapes,
name: 'Grapes',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'grapes/',
icon: CropAssets + 'grapes/6.png',
economy: {
buy: 15,
sell: 25,
}
},
{
id: Seeds.TomatoSeeds,
name: 'Tomato seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'tomato/',
icon: CropAssets + 'tomato/',
economy: {
buy: 20,
sell: 35,
},
cropData: {
timeToGrow: 10,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Tomato
}
},
{
id: FieldProducts.Tomato,
name: 'Tomato',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'tomato/',
icon: CropAssets + 'tomato/6.png',
economy: {
buy: 20,
sell: 35,
}
},
{
id: Seeds.CucumberSeeds,
name: 'Cucumber seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'cucumber/',
icon: CropAssets + 'cucumber/',
economy: {
buy: 30,
sell: 55,
},
cropData: {
timeToGrow: 15,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Cucumber
}
},
{
id: FieldProducts.Cucumber,
name: 'Cucumber',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'cucumber/',
icon: CropAssets + 'cucumber/6.png',
economy: {
buy: 30,
sell: 55,
}
},
{
id: Seeds.StrawberrySeeds,
name: 'Strawberry seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'strawberry/',
icon: CropAssets + 'strawberry/',
economy: {
buy: 60,
sell: 140,
},
cropData: {
timeToGrow: 60,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Strawberry
}
},
{
id: FieldProducts.Strawberry,
name: 'Strawberries',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'strawberry/',
icon: CropAssets + 'strawberry/6.png',
economy: {
buy: 60,
sell: 140,
}
},
{
id: Seeds.OrangeSeeds,
name: 'Orange seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'orange/',
icon: CropAssets + 'orange/',
economy: {
buy: 60,
sell: 140,
},
cropData: {
timeToGrow: 60,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Orange
}
},
{
id: FieldProducts.Orange,
name: 'Orange',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'orange/',
icon: CropAssets + 'orange/6.png',
economy: {
buy: 60,
sell: 140,
}
},
{
id: Seeds.LemonSeeds,
name: 'Lemon seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'lemon/',
icon: CropAssets + 'lemon/',
economy: {
buy: 60,
sell: 140,
},
cropData: {
timeToGrow: 60,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Lemon
}
},
{
id: FieldProducts.Lemon,
name: 'Lemon',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'lemon/',
icon: CropAssets + 'lemon/6.png',
economy: {
buy: 60,
sell: 140,
}
},
{
id: Seeds.PineappleSeeds,
name: 'Pineapple seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'pineapple/',
icon: CropAssets + 'pineapple/',
economy: {
buy: 60,
sell: 140,
},
cropData: {
timeToGrow: 60,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Pineapple
}
},
{
id: FieldProducts.Pineapple,
name: 'Pineapple',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'pineapple/',
icon: CropAssets + 'pineapple/6.png',
economy: {
buy: 60,
sell: 140,
}
},
{
id: Seeds.MelonSeeds,
name: 'Melon seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'melon/',
icon: CropAssets + 'melon/',
economy: {
buy: 60,
sell: 140,
},
cropData: {
timeToGrow: 60,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Melon
}
},
{
id: FieldProducts.Melon,
name: 'Melon',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'melon/',
icon: CropAssets + 'melon/6.png',
economy: {
buy: 60,
sell: 140,
}
},
{
id: Seeds.CoffeeSeeds,
name: 'Coffee seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'coffee/',
icon: CropAssets + 'coffee/',
economy: {
buy: 60,
sell: 140,
},
cropData: {
timeToGrow: 60,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.CoffeeBeans
}
},
{
id: FieldProducts.CoffeeBeans,
name: 'Coffee beans',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'coffee/',
icon: CropAssets + 'coffee/6.png',
economy: {
buy: 60,
sell: 140,
}
},
{
id: Seeds.CassavaSeeds,
name: 'Cassava seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'cassava/',
icon: CropAssets + 'cassava/',
economy: {
buy: 60,
sell: 140,
},
cropData: {
timeToGrow: 60,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Cassava
}
},
{
id: FieldProducts.Cassava,
name: 'Cassava',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'cassava/',
icon: CropAssets + 'cassava/6.png',
economy: {
buy: 60,
sell: 140,
}
},
{
id: Seeds.SunflowerSeeds,
name: 'Sunflower seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'sunflower/',
icon: CropAssets + 'sunflower/',
economy: {
buy: 10,
sell: 20,
},
cropData: {
timeToGrow: 5,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Sunflower
}
},
{
id: FieldProducts.Sunflower,
name: 'Sunflower',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'sunflower/',
icon: CropAssets + 'sunflower/6.png',
economy: {
buy: 10,
sell: 20,
}
},
{
id: Seeds.RoseSeeds,
name: 'Roses seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'rose/',
icon: CropAssets + 'rose/',
economy: {
buy: 10,
sell: 20,
},
cropData: {
timeToGrow: 5,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Rose
}
},
{
id: FieldProducts.Rose,
name: 'Rose',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'rose/',
icon: CropAssets + 'rose/6.png',
economy: {
buy: 10,
sell: 20,
}
},
{
id: Seeds.TulipSeeds,
name: 'Tulips seeds',
type: ItemTypes.Seeds,
description: '',
assetsFolder: CropAssets + 'tulip/',
icon: CropAssets + 'tulip/',
economy: {
buy: 10,
sell: 20,
},
cropData: {
timeToGrow: 5,
season: Seasons.Summer
season: Seasons.Summer,
product_id: FieldProducts.Tulip
}
},
{
id: FieldProducts.Tulip,
name: 'Tulip',
type: ItemTypes.FieldProducts,
description: '',
assetsFolder: CropAssets + 'tulip/',
icon: CropAssets + 'tulip/6.png',
economy: {
buy: 10,
sell: 20,
}
},
]

45
src/data/ItemsIDs.js

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// SEEDS
export const Seeds = {
WheatSeeds: 1,
RiceSeeds: 3,
TurnipSeeds: 5,
PotatoSeeds: 7,
CornSeeds: 9,
EggplantSeeds: 11,
GrapeSeeds: 13,
TomatoSeeds: 15,
CucumberSeeds: 17,
StrawberrySeeds: 19,
OrangeSeeds: 21,
LemonSeeds: 23,
PineappleSeeds: 25,
MelonSeeds: 27,
CoffeeSeeds: 29,
CassavaSeeds: 31,
SunflowerSeeds: 33,
RoseSeeds: 35,
TulipSeeds: 37,
}
// FIELD PRODUCTS
export const FieldProducts = {
Wheat: 2,
Rice: 4,
Turnip: 6,
Potato: 8,
Corn: 10,
Eggplant: 12,
Grapes: 14,
Tomato: 16,
Cucumber: 18,
Strawberry: 20,
Orange: 22,
Lemon: 24,
Pineapple: 26,
Melon: 28,
CoffeeBeans: 30,
Cassava: 32,
Sunflower: 34,
Rose: 36,
Tulip: 38,
}

3
src/models/Item.js

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
export default class {
}

15
src/services/ItemService.js

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
import Items from "@/data/Items";
export default class {
getItemByID(id) {
return Items.find((item) => {
return item.id === id;
});
}
getItemsByType(type) {
return Items.filter((item) => {
return item.type === type;
});
}
}

0
src/tools/SeasonService.js → src/services/SeasonService.js

2
src/store/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import {createStore} from 'vuex'
import moment from "moment";
import {SeasonService} from "@/tools/SeasonService";
import {SeasonService} from "@/services/SeasonService";
import ItemTypes from "@/data/ItemTypes";
import Items from "@/data/Items";

5
src/views/GameView.vue

@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@
<CropField/>
</div>
<MenuBar/>
<!-- <CropInformation/>-->
<ItemShop/>
<InventoryDialog/>
</template>
<script>
@ -14,10 +14,11 @@ import StatusBar from "@/components/StatusBar"; @@ -14,10 +14,11 @@ import StatusBar from "@/components/StatusBar";
import CropField from "@/components/CropField";
import MenuBar from "@/components/MenuBar";
import ItemShop from "@/components/ItemShop";
import InventoryDialog from "@/components/InventoryDialog"
export default {
name: "GameView",
components: {ItemShop, MenuBar, CropField, StatusBar},
components: {InventoryDialog, ItemShop, MenuBar, CropField, StatusBar},
data() {
return {
time: null,

2
tests/unit/getSeason.spec.js

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import {Seasons, SeasonService} from "@/tools/SeasonService";
import {Seasons, SeasonService} from "@/services/SeasonService";
test('expect week 1 to return season spring', () => {
expect(SeasonService.getSeasonByWeek(1)).toBe(Seasons.Spring);

Loading…
Cancel
Save