
8 changed files with 72 additions and 52 deletions
@ -0,0 +1,3 @@ |
|||||||
|
export const ITEM_IRON_ORE = 1; |
||||||
|
export const ITEM_IRON_BAR = 2; |
||||||
|
export const ITEM_COAL = 3; |
@ -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(); |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
@ -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'); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,5 +0,0 @@ |
|||||||
<template> |
|
||||||
<div class="about"> |
|
||||||
<h1>This is an about page</h1> |
|
||||||
</div> |
|
||||||
</template> |
|
@ -0,0 +1,27 @@ |
|||||||
|
<template> |
||||||
|
<div class="about"> |
||||||
|
<h1>Vactory</h1> |
||||||
|
<button v-on:click="startGame">Start Gamne</button> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import Game from "@/models/Game"; |
||||||
|
|
||||||
|
export default { |
||||||
|
data() { |
||||||
|
return { |
||||||
|
game: null, |
||||||
|
} |
||||||
|
}, |
||||||
|
mounted() { |
||||||
|
this.game = new Game(); |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
startGame() { |
||||||
|
this.game.buyFactory(); |
||||||
|
this.game.cluster.startAll(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
Loading…
Reference in new issue