diff --git a/src/App.vue b/src/App.vue index a753dba..3d00c20 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@ diff --git a/src/data/Items.js b/src/data/Items.js new file mode 100644 index 0000000..00a13db --- /dev/null +++ b/src/data/Items.js @@ -0,0 +1,3 @@ +export const ITEM_IRON_ORE = 1; +export const ITEM_IRON_BAR = 2; +export const ITEM_COAL = 3; diff --git a/src/models/Cluster.js b/src/models/Cluster.js new file mode 100644 index 0000000..9b72794 --- /dev/null +++ b/src/models/Cluster.js @@ -0,0 +1,18 @@ +export default class Cluster { + constructor() { + this.inventory = []; + this.factories = []; + } + + startAll() { + this.factories.forEach((factory) => { + factory.start(); + }) + } + + stopAll() { + this.factories.forEach((factory) => { + factory.stop(); + }) + } +} diff --git a/src/models/Factory.js b/src/models/Factory.js index 8636aa2..ecea16a 100644 --- a/src/models/Factory.js +++ b/src/models/Factory.js @@ -1,8 +1,6 @@ -const ITEM_IRON_ORE = 1; -const ITEM_IRON_BAR = 2; -const ITEM_COAL = 3; +import {ITEM_COAL, ITEM_IRON_BAR, ITEM_IRON_ORE} from "@/data/Items"; -class Factory { +export default class Factory { static get price() { return 400; } @@ -102,43 +100,3 @@ class Factory { return this.inventory.length >= this.inventoryLimit; } } - -class Cluster { - constructor() { - this.inventory = []; - this.factories = []; - } - - startAll() { - this.factories.forEach((factory) => { - factory.start(); - }) - } - - stopAll() { - this.factories.forEach((factory) => { - factory.stop(); - }) - } -} - -class Game { - constructor() { - this.money = 1_000; - this.cluster = new Cluster(); - this.inventory = []; - } - - buyFactory() { - if (this.money >= Factory.price) { - this.cluster.factories.push(new Factory()); - this.money -= Factory.price; - } else { - console.warn('💰 Not enough money to buy a factory'); - } - } -} - -let game = new Game(); -game.buyFactory(); -game.cluster.startAll(); diff --git a/src/models/Game.js b/src/models/Game.js new file mode 100644 index 0000000..2696233 --- /dev/null +++ b/src/models/Game.js @@ -0,0 +1,19 @@ +import Cluster from "@/models/Cluster"; +import Factory from "@/models/Factory"; + +export default class Game { + constructor() { + this.money = 1_000; + this.cluster = new Cluster(); + this.inventory = []; + } + + buyFactory() { + if (this.money >= Factory.price) { + this.cluster.factories.push(new Factory()); + this.money -= Factory.price; + } else { + console.warn('💰 Not enough money to buy a factory'); + } + } +} diff --git a/src/router/index.js b/src/router/index.js index d7a8d0a..effa809 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -8,12 +8,12 @@ const routes = [ component: HomeView }, { - path: '/about', + path: '/game', name: 'about', // route level code-splitting // this generates a separate chunk (about.[hash].js) for this route // which is lazy-loaded when the route is visited. - component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue') + component: () => import(/* webpackChunkName: "about" */ '../views/GameView.vue') } ] diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue deleted file mode 100644 index 3fa2807..0000000 --- a/src/views/AboutView.vue +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/src/views/GameView.vue b/src/views/GameView.vue new file mode 100644 index 0000000..e5b3b3f --- /dev/null +++ b/src/views/GameView.vue @@ -0,0 +1,27 @@ + + +