Integrate draft/network stack via Vuex #26
7 changed files with 91 additions and 13 deletions
12
src/store/draft/actions.ts
Normal file
12
src/store/draft/actions.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { ActionTree } from "vuex";
|
||||||
|
import { AppState } from "../types";
|
||||||
|
import { DraftState } from "./types";
|
||||||
|
import { Card } from "@/mlpccg";
|
||||||
|
|
||||||
|
const actions: ActionTree<DraftState, AppState> = {
|
||||||
|
pickCard({ commit }, card: Card) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default actions;
|
12
src/store/draft/getters.ts
Normal file
12
src/store/draft/getters.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { GetterTree } from "vuex";
|
||||||
|
import { AppState } from "../types";
|
||||||
|
import { DraftState } from "./types";
|
||||||
|
import { createPonyheadURL } from "@/mlpccg";
|
||||||
|
|
||||||
|
const getters: GetterTree<DraftState, AppState> = {
|
||||||
|
ponyheadURL(state): string {
|
||||||
|
return createPonyheadURL(state.picks);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getters;
|
|
@ -4,16 +4,24 @@ import { Module } from "vuex";
|
||||||
|
|
||||||
const namespaced = true;
|
const namespaced = true;
|
||||||
|
|
||||||
|
import actions from "./actions";
|
||||||
|
import mutations from "./mutations";
|
||||||
|
import getters from "./getters";
|
||||||
|
|
||||||
export const state: DraftState = {
|
export const state: DraftState = {
|
||||||
picks: []
|
cards: [],
|
||||||
|
picks: [],
|
||||||
|
pod: [],
|
||||||
|
packCount: 0,
|
||||||
|
currentPack: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
export const draft: Module<DraftState, AppState> = {
|
export const draft: Module<DraftState, AppState> = {
|
||||||
namespaced,
|
namespaced,
|
||||||
state
|
state,
|
||||||
//actions,
|
actions,
|
||||||
//mutations,
|
mutations,
|
||||||
//getters,
|
getters
|
||||||
};
|
};
|
||||||
|
|
||||||
export default draft;
|
export default draft;
|
||||||
|
|
37
src/store/draft/mutations.ts
Normal file
37
src/store/draft/mutations.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { MutationTree } from "vuex";
|
||||||
|
import { DraftState, PlayerStatus } from "./types";
|
||||||
|
import { Card } from "@/mlpccg";
|
||||||
|
|
||||||
|
const mutations: MutationTree<DraftState> = {
|
||||||
|
playerPicked(state, payload: { name: string; picked: boolean }) {
|
||||||
|
const idx = state.pod.findIndex(p => p.name == payload.name);
|
||||||
|
state.pod[idx].picked = payload.picked;
|
||||||
|
},
|
||||||
|
|
||||||
|
resetPickStatus(state) {
|
||||||
|
state.pod = state.pod.map(p => ({ ...p, picked: false }));
|
||||||
|
},
|
||||||
|
|
||||||
|
setCardPool(state, pool: Card[]) {
|
||||||
|
state.cards = pool;
|
||||||
|
},
|
||||||
|
|
||||||
|
setPackInfo(state, payload: { current: number; total: number }) {
|
||||||
|
state.currentPack = payload.current;
|
||||||
|
state.packCount = payload.total;
|
||||||
|
},
|
||||||
|
|
||||||
|
addPicks(state, pick: Card) {
|
||||||
|
state.picks.push(pick);
|
||||||
|
},
|
||||||
|
|
||||||
|
setPod(state, pod: PlayerStatus[]) {
|
||||||
|
state.pod = pod;
|
||||||
|
},
|
||||||
|
|
||||||
|
resetPicks(state) {
|
||||||
|
state.picks = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default mutations;
|
|
@ -3,5 +3,19 @@ import { Card } from "@/mlpccg";
|
||||||
|
|
||||||
export interface DraftState {
|
export interface DraftState {
|
||||||
session?: Session;
|
session?: Session;
|
||||||
|
|
||||||
|
pod: PlayerStatus[];
|
||||||
|
cards: Card[];
|
||||||
picks: Card[];
|
picks: Card[];
|
||||||
|
|
||||||
|
// Multiple pack draft
|
||||||
|
packCount: number;
|
||||||
|
currentPack: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlayerStatus {
|
||||||
|
name: string;
|
||||||
|
isBot: boolean;
|
||||||
|
isMe: boolean;
|
||||||
|
picked: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { AppState } from "../types";
|
||||||
import { Module } from "vuex";
|
import { Module } from "vuex";
|
||||||
|
|
||||||
import actions from "./actions";
|
import actions from "./actions";
|
||||||
|
import mutations from "./mutations";
|
||||||
import getters from "./getters";
|
import getters from "./getters";
|
||||||
|
|
||||||
const namespaced = true;
|
const namespaced = true;
|
||||||
|
@ -16,7 +17,7 @@ export const network: Module<NetworkState, AppState> = {
|
||||||
namespaced,
|
namespaced,
|
||||||
state,
|
state,
|
||||||
actions,
|
actions,
|
||||||
//mutations,
|
mutations,
|
||||||
getters
|
getters
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -152,13 +152,7 @@ import { Component, Vue } from "vue-property-decorator";
|
||||||
import { getCards, CardSlot, cardLimit, Card } from "@/mlpccg";
|
import { getCards, CardSlot, cardLimit, Card } from "@/mlpccg";
|
||||||
import CardPicker from "@/components/DeckBuilder/CardPicker.vue";
|
import CardPicker from "@/components/DeckBuilder/CardPicker.vue";
|
||||||
import DeckList from "@/components/DeckBuilder/DeckList.vue";
|
import DeckList from "@/components/DeckBuilder/DeckList.vue";
|
||||||
|
import { PlayerStatus } from "@/store/draft/types";
|
||||||
interface PlayerStatus {
|
|
||||||
name: string;
|
|
||||||
isBot: boolean;
|
|
||||||
isMe: boolean;
|
|
||||||
picked: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
|
|
Loading…
Reference in a new issue