diff --git a/frontend/src/components/Counter.vue b/frontend/src/components/Counter.vue
index 12920b1..4e66023 100644
--- a/frontend/src/components/Counter.vue
+++ b/frontend/src/components/Counter.vue
@@ -15,23 +15,23 @@ import ReverseButton from "@/components/buttons/ReverseButton.vue";
import StartButton from "@/components/buttons/StartButton.vue";
import StopButton from "@/components/buttons/StopButton.vue";
-import state from "@/state";
-import { formatSeconds, hoursToMilliseconds } from "@/utils";
+import { state } from "@/store";
+import { formatSeconds } from "@/utils";
const nowTime = ref(Date.now());
const isStopping = ref(false);
const currentDifference = computed(() => {
- const difference = state.refs.targetDate.value - nowTime.value;
+ const difference = state.targetDate.value - nowTime.value;
let distance = Math.abs(difference);
if (difference < 0) {
- distance *= state.computed.buff.value;
+ distance *= state.buff.value;
}
- return Math.sign(difference) * Math.min(distance, state.refs.maxTime.value);
+ return Math.sign(difference) * Math.min(distance, state.maxTime.value);
});
const isGameOn = computed(() => {
- return state.refs.isReverseOn.value || currentDifference.value > 500;
+ return state.isReverseOn.value || currentDifference.value > 500;
});
const view = computed(() => {
@@ -45,7 +45,7 @@ const time = computed(() => {
const elapsedSeconds = Math.round(elapsedMilliseconds / 1000);
return formatSeconds(elapsedSeconds);
} else {
- const seconds = state.refs.maxTime.value / 1000;
+ const seconds = state.maxTime.value / 1000;
return formatSeconds(seconds);
}
});
@@ -83,33 +83,23 @@ watchEffect(() => {
}
});
-function increaseMaxTime() {
- state.refs.maxTime.value = Math.min(state.refs.maxTime.maximum, state.refs.maxTime.value + hoursToMilliseconds(1));
-}
-
-function decreaseMaxTime() {
- state.refs.maxTime.value = Math.max(state.refs.maxTime.minimum, state.refs.maxTime.value - hoursToMilliseconds(1));
-}
-
function reverseTime() {
let difference = currentDifference.value;
- if (difference > 0) {
- difference /= state.computed.buff.value;
- }
- state.refs.targetDate.value = nowTime.value - difference;
+ (difference > 0) && (difference /= state.buff.value);
+ state.targetDate.value = nowTime.value - difference;
- state.refs.isReverseOn.value = !state.refs.isReverseOn.value;
+ state.isReverseOn.value = !state.isReverseOn.value;
}
function startGame() {
nowTime.value = Date.now();
- state.refs.targetDate.value = nowTime.value + state.refs.maxTime.value;
+ state.targetDate.value = nowTime.value + state.maxTime.value;
}
function stopGame() {
isStopping.value = false;
- state.refs.isReverseOn.value = false;
- state.refs.targetDate.value = nowTime.value;
+ state.isReverseOn.value = false;
+ state.targetDate.value = nowTime.value;
}
function toggleStopping() {
@@ -117,12 +107,12 @@ function toggleStopping() {
}
function nextBuff() {
- const [buff, prevBuff] = state.nextBuff();
- const difference = state.refs.targetDate.value - nowTime.value;
+ const [buff, prevBuff] = state.buff.next();
+ const difference = state.targetDate.value - nowTime.value;
let distance = Math.abs(difference);
if (difference < 0) {
distance = distance * prevBuff / buff;
- state.refs.targetDate.value = nowTime.value - distance;
+ state.targetDate.value = nowTime.value - distance;
}
}
@@ -133,8 +123,8 @@ function nextBuff() {
-
-
+ state.maxTime.increment()" />
+ state.maxTime.decrement()" />
diff --git a/frontend/src/components/buttons/BuffButton.vue b/frontend/src/components/buttons/BuffButton.vue
index 2fde8e9..65ef4b8 100644
--- a/frontend/src/components/buttons/BuffButton.vue
+++ b/frontend/src/components/buttons/BuffButton.vue
@@ -5,10 +5,10 @@ import { computed } from "vue";
import Button from "@/components/Button.vue";
-import state from "@/state";
+import { state } from "@/store";
const text = computed(() => {
- return `${state.computed.buff.value.toFixed(2)}x`;
+ return `${state.buff.value.toFixed(2)}x`;
});
diff --git a/frontend/src/components/buttons/DecreaseMaxTimeButton.vue b/frontend/src/components/buttons/DecreaseMaxTimeButton.vue
index 794e912..d84d9b2 100644
--- a/frontend/src/components/buttons/DecreaseMaxTimeButton.vue
+++ b/frontend/src/components/buttons/DecreaseMaxTimeButton.vue
@@ -3,12 +3,12 @@ defineEmits<{ click: [] }>();
import Button from "@/components/Button.vue";
-import state from "@/state";
+import { state } from "@/store";