WIP: Basic 2D game board #23
2 changed files with 76 additions and 16 deletions
|
@ -3,18 +3,36 @@
|
||||||
:class="zoneClass"
|
:class="zoneClass"
|
||||||
@dragenter.prevent="dragenter"
|
@dragenter.prevent="dragenter"
|
||||||
@dragleave.prevent="dragleave"
|
@dragleave.prevent="dragleave"
|
||||||
></section>
|
>
|
||||||
|
<CardImage
|
||||||
|
class="ccgcard"
|
||||||
|
v-for="(card, i) in cards"
|
||||||
|
:key="i + card.ID"
|
||||||
|
:id="card.ID"
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.zone {
|
.zone {
|
||||||
border: 2px solid rgba(255, 255, 255, 0.2);
|
border: 2px solid rgba(255, 255, 255, 0.2);
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
padding: 2px;
|
padding: 4px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
justify-content: center;
|
||||||
flex: 1;
|
}
|
||||||
|
|
||||||
|
.ccgcard {
|
||||||
|
cursor: grab;
|
||||||
|
transition: all 100ms;
|
||||||
|
max-width: none;
|
||||||
|
width: auto;
|
||||||
|
max-height: 100%;
|
||||||
|
margin: 0 10px;
|
||||||
|
&:active {
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dragging {
|
.dragging {
|
||||||
|
@ -23,13 +41,21 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue } from "vue-property-decorator";
|
import { Component, Vue, Prop } from "vue-property-decorator";
|
||||||
import { cardImageURL } from "@/mlpccg";
|
import { cardImageURL, Card } from "@/mlpccg";
|
||||||
|
import CardImage from "@/components/Cards/CardImage.vue";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {}
|
components: {
|
||||||
|
CardImage
|
||||||
|
}
|
||||||
})
|
})
|
||||||
export default class Zone extends Vue {
|
export default class Zone extends Vue {
|
||||||
|
@Prop({
|
||||||
|
default: []
|
||||||
|
})
|
||||||
|
private cards!: Card[];
|
||||||
|
|
||||||
private dragging!: boolean;
|
private dragging!: boolean;
|
||||||
|
|
||||||
private data() {
|
private data() {
|
||||||
|
|
|
@ -2,20 +2,36 @@
|
||||||
<section class="game">
|
<section class="game">
|
||||||
<section class="topbar"></section>
|
<section class="topbar"></section>
|
||||||
<section class="board">
|
<section class="board">
|
||||||
<Zone class="own-zone" id="own-home" />
|
<Zone class="opp-zone" :cards="zones['opp-home']" id="opp-home" />
|
||||||
<section class="problems">
|
<section class="problems">
|
||||||
<section class="problem own-problem">
|
<section class="problem own-problem">
|
||||||
<Zone class="own-zone" id="pown-own-zone" />
|
<Zone
|
||||||
|
class="opp-zone"
|
||||||
|
:cards="zones['own-problem-opp-zone']"
|
||||||
|
id="pown-opp-zone"
|
||||||
|
/>
|
||||||
<section class="problem-card"></section>
|
<section class="problem-card"></section>
|
||||||
<Zone class="opp-zone" id="pown-opp-zone" />
|
<Zone
|
||||||
|
class="own-zone"
|
||||||
|
:cards="zones['own-problem-own-zone']"
|
||||||
|
id="pown-own-zone"
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
<section class="problem opp-problem">
|
<section class="problem opp-problem">
|
||||||
<Zone class="own-zone" id="popp-own-zone" />
|
<Zone
|
||||||
|
class="opp-zone"
|
||||||
|
:cards="zones['opp-problem-opp-zone']"
|
||||||
|
id="popp-opp-zone"
|
||||||
|
/>
|
||||||
<section class="problem-card"></section>
|
<section class="problem-card"></section>
|
||||||
<Zone class="opp-zone" id="popp-opp-zone" />
|
<Zone
|
||||||
|
class="own-zone"
|
||||||
|
:cards="zones['opp-problem-own-zone']"
|
||||||
|
id="popp-own-zone"
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<Zone class="opp-zone" id="opp-home" />
|
<Zone class="own-zone" :cards="zones['own-home']" id="own-home" />
|
||||||
</section>
|
</section>
|
||||||
<section class="hand">
|
<section class="hand">
|
||||||
<article
|
<article
|
||||||
|
@ -68,11 +84,12 @@ $hand-max-height: 150px;
|
||||||
grid-row: 2;
|
grid-row: 2;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid: 1fr 2.5fr 1fr / 1fr;
|
grid: 1fr 2.5fr 1fr / 1fr;
|
||||||
|
max-height: 100vh;
|
||||||
|
|
||||||
.problems {
|
.problems {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
flex-flow: row-reverse;
|
flex-flow: row;
|
||||||
|
|
||||||
.problem {
|
.problem {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
@ -100,7 +117,6 @@ $hand-max-height: 150px;
|
||||||
grid-row: 3;
|
grid-row: 3;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(10px, max-content));
|
grid-template-columns: repeat(auto-fit, minmax(10px, max-content));
|
||||||
justify-content: center;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
padding-right: 100px;
|
padding-right: 100px;
|
||||||
|
@ -122,6 +138,10 @@ $hand-max-height: 150px;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.opp-zone {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 1200px) {
|
@media (max-width: 1200px) {
|
||||||
.game {
|
.game {
|
||||||
grid-template-columns: $side-min-size 5fr;
|
grid-template-columns: $side-min-size 5fr;
|
||||||
|
@ -147,15 +167,29 @@ import CardImage from "@/components/Cards/CardImage.vue";
|
||||||
})
|
})
|
||||||
export default class GameView extends Vue {
|
export default class GameView extends Vue {
|
||||||
private hand!: Card[];
|
private hand!: Card[];
|
||||||
|
private zones!: Record<string, Card[]>;
|
||||||
|
|
||||||
private data() {
|
private data() {
|
||||||
return {
|
return {
|
||||||
hand: []
|
hand: [],
|
||||||
|
zones: {
|
||||||
|
"own-home": [],
|
||||||
|
"opp-home": [],
|
||||||
|
"own-problem-own-zone": [],
|
||||||
|
"own-problem-opp-zone": [],
|
||||||
|
"opp-problem-own-zone": [],
|
||||||
|
"opp-problem-opp-zone": []
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async mounted() {
|
private async mounted() {
|
||||||
this.hand = (await getCards({ Sets: ["FF"] })).slice(0, 9);
|
this.hand = (await getCards({ Sets: ["FF"] })).slice(0, 9);
|
||||||
|
this.zones["own-home"] = (await getCards({ Sets: ["FF"] })).slice(0, 3);
|
||||||
|
this.zones["own-problem-opp-zone"] = (await getCards({
|
||||||
|
Sets: ["FF"]
|
||||||
|
})).slice(10, 11);
|
||||||
|
this.zones["opp-home"] = (await getCards({ Sets: ["FF"] })).slice(20, 23);
|
||||||
}
|
}
|
||||||
|
|
||||||
private imageURL(id: string) {
|
private imageURL(id: string) {
|
||||||
|
|
Loading…
Reference in a new issue