Skip to content

Commit

Permalink
#135 Added card class
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Jan 8, 2023
1 parent 97e2528 commit 263ddef
Show file tree
Hide file tree
Showing 15 changed files with 336 additions and 209 deletions.
7 changes: 4 additions & 3 deletions src/components/elements/EncounterVotingComponent.vue
Expand Up @@ -10,7 +10,7 @@
<info-component
v-if="status === Status.VOTING"
class="ELement Info"
:current-card="currentCard"
:card="currentCard"
/>
<div
v-if="status === Status.VOTING"
Expand Down Expand Up @@ -74,6 +74,7 @@
import * as R from "ramda";
import CardComponent from "@/components/elements/CardComponent";
import InfoComponent from "@/components/elements/VotingComponents/InfoComponent.vue";
import { Card } from "@/model/Card";
const Status = {
"VOTING": 0,
Expand All @@ -91,7 +92,7 @@ export default {
Status: Status,
voteRights: [],
cards: [],
currentCard: {},
currentCard: new Card(),
config: {
minThrowOutDistance: 250,
maxThrowOutDistance: 300
Expand Down Expand Up @@ -194,7 +195,7 @@ export default {
return this.$cardChain.getCard(nextCard.cardId)
.then(res => {
console.log("res", res);
let parsedCard = this.$cardChain.cardObjectToWebModel(res);
let parsedCard = res
console.log("currentCard", parsedCard);
if (parsedCard) {
this.cards.push(parsedCard);
Expand Down
41 changes: 10 additions & 31 deletions src/components/elements/VotingComponents/InfoComponent.vue
@@ -1,62 +1,41 @@
<template>
<div>
<h3>{{ currentCard.CardName }}</h3>
<h3>{{ card.CardName }}</h3>
<p
v-if="currentCard.FlavourText"
v-if="card.FlavourText"
class="FlavourText"
>
"{{ currentCard.FlavourText }}"
"{{ card.FlavourText }}"
</p>
<br>
<h3>Advanced Card Information</h3>
<p>
Votepool: {{ votePool }} <br>
Status: {{ currentCard.status }} <br>
Votepool: {{ card.votePool.normalize().pretty() }} <br>
Status: {{ card.status }} <br>
</p>
<br><br>
<keyword-component
:keywords="currentCard.Keywords"
:keywords="card.Keywords"
/>
</div>
</template>

<script>
import KeywordComponent from "@/components/elements/KeywordComponent.vue";
import { Coin } from "@/utils/coins";
import { Card } from "@/model/Card";
export default {
name: "InfoComponent",
components: { KeywordComponent },
props: {
currentCard: {
type: Object,
card: {
type: Card,
default() {
return {};
return new Card();
}
}
},
data() {
return {
votePool: ""
};
},
watch: {
currentCard: {
handler() {
this.init();
},
deep: true
}
},
mounted() {
this.init();
},
methods: {
init() {
this.votePool = new Coin(this.currentCard.votePool).nornalize().pretty();
}
}
};
</script>

Expand Down
75 changes: 13 additions & 62 deletions src/components/utils/sampleCards.js
Expand Up @@ -18,6 +18,7 @@ import drDollyImg from './cardfiles/drDollyCard.jpg'
import belloImg from './cardfiles/bello.jpg'
import timeDeviceImg from './cardfiles/timeDeviceCard.jpg'
import sampleGradient from './cardfiles/sampleGradient.jpg'
import { Card, CardClass } from "@/model/Card";

export const sampleGradientImg = sampleGradient

Expand All @@ -41,7 +42,7 @@ export const cardJpgs = {
timeDeviceImg: timeDeviceImg
}

export const sampleCard = R.merge(emptyCard, {
export const sampleCard = Card.from({
CardName: 'Sample Card',
FlavourText: 'Whenever you play CrowdControl your happiness increases by 1.',
abilities: [],
Expand All @@ -62,116 +63,66 @@ export const sampleCard = R.merge(emptyCard, {
Health: 5,
Attack: 3
})
export const daisyData = R.merge(emptyCard, {
export const daisyData = Card.from({
CardName: 'Saint Daisy, Triplet',
FlavourText: 'ETB - Create a 1/1 pet for each human you control',
abilities: [],
Notes: '',
type: 'Entity',
Tags: ['HUMAN'],
tagDummy: '',
Class: {
Nature: false,
Culture: true,
Technology: false,
Mysticism: true,

},
Class: CardClass.culture(),
CastingCost: 7,
Health: 3,
Attack: 3
})
export const daisyPetData = R.merge(emptyCard, {
export const daisyPetData = Card.from({
CardName: 'Saint Daisy, Triplet',
FlavourText: 'PET',
abilities: [],
Notes: '',
type: 'Entity',
Tags: ['PET'],
tagDummy: '',
Class: {
Nature: false,
Culture: true,
Technology: false,
Mysticism: true,

},
Class: CardClass.mysticism(),
CastingCost: 7,
Health: 1,
Attack: 1
})
export const richardData = R.merge(emptyCard, {
export const richardData = Card.from({
CardName: 'Richard, Bot Commander',
FlavourText: 'When Richard is attacking, create a 1/1 Bot token that is also attacking. When Richard blocks, all Bots gain +0/+1.',
abilities: [],
Notes: '',
type: 'Entity',
Tags: ['TECHNOCRAT'],
tagDummy: 'TECHNOCRAT',
Class: {
Nature: false,
Culture: true,
Technology: true,
Mysticism: false,

},
Class: CardClass.technology(),
CastingCost: 7,
Health: 8,
Attack: 5
})
export const richardBotData = R.merge(emptyCard, {
export const richardBotData = Card.from({
CardName: 'Richard, Bot Commander',
FlavourText: 'BOT',
abilities: [],
Notes: '',
type: 'Entity',
Tags: ['TECHNOCRAT'],
tagDummy: 'TECHNOCRAT',
Class: {
Nature: false,
Culture: true,
Technology: true,
Mysticism: false,

},
Class: CardClass.technology(),
CastingCost: 7,
Health: 1,
Attack: 1
})
export const hurrwigData = R.merge(emptyCard, {
export const hurrwigData = Card.from({
CardName: 'Hurrwig, Bot Manufacturer',
FlavourText: 'Whenever an entity with the tag \'Bot\' enters the battlefield, you may deal 2 damage to target entity.',
abilities: [],
Notes: '',
type: 'Entity',
Tags: ['TECHNOCRAT','HUMAN'],
tagDummy: 'TECHNOCRAT',
Class: {
Nature: false,
Culture: true,
Technology: true,
Mysticism: false,

},
Class: CardClass.technology(),
CastingCost: 8,
Health: 5,
Attack: 3
})
export const assoultHorseData = R.merge(emptyCard, {
CardName: 'Assoult Horse',
FlavourText: 'Charge!',
abilities: [],
Notes: '',
type: 'Entity',
Tags: ['BOT'],
tagDummy: 'BOT',
Class: {
Nature: false,
Culture: false,
Technology: true,
Mysticism: false,

},
Class: CardClass.technology(),
CastingCost: 3,
Health: 3,
Attack: 2
Expand Down
117 changes: 117 additions & 0 deletions src/model/Card.js
@@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardClass = exports.Card = exports.ChainCard = void 0;
const Coin_1 = require("./Coin");
class ChainCard {
static from(json) {
return Object.assign(new ChainCard(), json);
}
toCard() {
let card = new Card();
if (this.content) {
let content = JSON.parse(this.content);
let cardType = Object.keys(content)[0];
card.CardName = content[cardType].CardName;
card.FlavourText = content[cardType].FlavourText;
card.Tags = content[cardType].Tags;
card.Class = Object.assign(new CardClass(), content[cardType].Class);
card.CastingCost = parseInt(content[cardType].CastingCost);
card.Abilities = content[cardType].Abilities;
card.AdditionalCost = content[cardType].AdditionalCost;
card.Health = parseInt(content[cardType].Health);
card.Attack = parseInt(content[cardType].Attack);
card.Delay = parseInt(content[cardType].Delay);
card.RulesTexts = content[cardType].RulesTexts;
card.Keywords = [];
content[cardType].Keywords.forEach(keyword => {
card.Keywords.push(JSON.parse(keyword));
});
card.type = cardType;
card.owner = this.owner;
card.status = this.status;
card.artist = this.artist;
card.Content = content;
card.image = this.image;
card.fullArt = this.fullArt;
card.nerflevel = parseInt(this.nerflevel);
card.notes = this.notes;
card.fairEnoughVotes = parseInt(this.fairEnoughVotes);
card.inappropriateVotes = parseInt(this.inappropriateVotes);
card.overpoweredVotes = parseInt(this.overpoweredVotes);
card.underpoweredVotes = parseInt(this.underpoweredVotes);
card.votePool = Object.assign(new Coin_1.Coin(), this.votePool);
card.voters = this.voters;
console.log("parsed card: ", card);
}
return card;
}
}
exports.ChainCard = ChainCard;
class Card {
constructor() {
this.notes = "";
this.type = "";
this.owner = "";
this.status = "";
this.artist = "";
this.Content = {};
this.image = "";
this.voters = [];
this.tagDummy = "";
this.fullArt = true;
this.nerflevel = 0;
this.fairEnoughVotes = 0;
this.inappropriateVotes = 0;
this.overpoweredVotes = 0;
this.underpoweredVotes = 0;
this.votePool = new Coin_1.Coin();
this.Abilities = [];
this.CardName = "";
this.FlavourText = "";
this.Tags = [];
this.Class = new CardClass();
this.CastingCost = -1;
this.AdditionalCost = {};
this.Health = 0;
this.Attack = 0;
this.Delay = 0;
this.RulesTexts = [];
this.Keywords = [];
}
static from(json) {
return Object.assign(new ChainCard(), json);
}
}
exports.Card = Card;
class CardClass {
constructor(type) {
this.Culture = false;
this.Mysticism = false;
this.Technology = false;
this.Nature = false;
if (type) {
this[type] = true;
}
}
static culture() {
let obj = new CardClass();
obj.Culture = true;
return obj;
}
static mysticism() {
let obj = new CardClass();
obj.Mysticism = true;
return obj;
}
static technology() {
let obj = new CardClass();
obj.Technology = true;
return obj;
}
static nature() {
let obj = new CardClass();
obj.Nature = true;
return obj;
}
}
exports.CardClass = CardClass;

0 comments on commit 263ddef

Please sign in to comment.