Skip to content

Commit

Permalink
#135 Introduced usage of card class to new card page and fixed sequen…
Browse files Browse the repository at this point in the history
…cy shit
  • Loading branch information
lxgr-linux committed Jan 9, 2023
1 parent 12207e7 commit 6d95d6a
Show file tree
Hide file tree
Showing 7 changed files with 552 additions and 102 deletions.
1 change: 1 addition & 0 deletions src/components/elements/CardComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23216,6 +23216,7 @@ export default {
let firstLetterToLower = string => {
return string[0].toLowerCase() + string.substring(1)
}
console.log(this.model)
this.model.Keywords.forEach(ability => {
ability.forEach(keyword => {
this.keywordDescriptions = R.concat(this.keywordDescriptions,
Expand Down
70 changes: 67 additions & 3 deletions src/model/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ChainCard {
card.Attack = parseInt(content[cardType].Attack);
card.Delay = parseInt(content[cardType].Delay);
card.RulesTexts = content[cardType].RulesTexts;
card.Effects = content[cardType].Effects;
card.Keywords = [];
content[cardType].Keywords.forEach(keyword => {
card.Keywords.push(JSON.parse(keyword));
Expand Down Expand Up @@ -50,7 +51,7 @@ exports.ChainCard = ChainCard;
class Card {
constructor() {
this.notes = "";
this.type = "";
this.type = "Entity";
this.owner = "";
this.status = "";
this.artist = "";
Expand All @@ -66,21 +67,67 @@ class Card {
this.underpoweredVotes = 0;
this.votePool = new Coin_1.Coin();
this.Abilities = [];
this.CardName = "";
this.CardName = "Name";
this.FlavourText = "";
this.Tags = [];
this.Class = new CardClass();
this.Class = CardClass.technology();
this.CastingCost = -1;
this.AdditionalCost = {};
this.Health = 0;
this.Attack = 0;
this.Delay = 0;
this.RulesTexts = [];
this.Keywords = [];
this.Effects = [];
}
static from(json) {
return Object.assign(new Card(), json);
}
toChainCard() {
console.log("trying to parse ", this);
let cardContent = Object.assign(new CardContent(), {
CardName: this.CardName,
Tags: this.Tags.filter(tag => {
return tag != null;
}),
FlavourText: this.FlavourText,
Class: this.Class,
Keywords: [],
RulesTexts: this.RulesTexts
});
this.Keywords.forEach(keyword => {
cardContent.Keywords.push(JSON.stringify(keyword));
});
// in the following part we check things that are only required for specific card types
if (this.type !== "Headquarter") {
cardContent.CastingCost = this.CastingCost;
if (!this.AdditionalCost) {
cardContent.AdditionalCost = this.AdditionalCost;
}
}
if (this.type !== "Action") {
cardContent.Health = this.Health;
cardContent.Abilities = this.Abilities;
}
if (this.type === "Entity") {
cardContent.Attack = this.Attack;
}
else if (this.type === "Action") {
cardContent.Effects = this.Effects;
}
else if (this.type === "Headquarter") {
cardContent.Delay = this.Delay;
}
let cc = new ChainCard();
cc.content = {
[this.type]: cardContent
};
cc.image = this.image ? this.image : "if you read this, someone was able to upload a card without proper image...";
cc.fullArt = this.fullArt;
cc.notes = this.notes;
console.log("parsed into:", cc);
return cc;
}
}
exports.Card = Card;
class CardClass {
Expand Down Expand Up @@ -115,3 +162,20 @@ class CardClass {
}
}
exports.CardClass = CardClass;
class CardContent {
constructor() {
this.Abilities = [];
this.CardName = "";
this.FlavourText = "";
this.Tags = [];
this.Class = new CardClass();
this.CastingCost = -1;
this.AdditionalCost = undefined;
this.Health = 0;
this.Attack = 0;
this.Delay = 0;
this.RulesTexts = [];
this.Keywords = [];
this.Effects = [];
}
}
71 changes: 67 additions & 4 deletions src/model/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class ChainCard {
owner: string;
status: string;
artist: string;
content: string;
content: any;
image: string;
fullArt: boolean;
nerflevel: string;
Expand Down Expand Up @@ -37,6 +37,7 @@ export class ChainCard {
card.Attack = parseInt(content[cardType].Attack);
card.Delay = parseInt(content[cardType].Delay);
card.RulesTexts = content[cardType].RulesTexts;
card.Effects = content[cardType].Effects;
card.Keywords = [];
content[cardType].Keywords.forEach(keyword => {
card.Keywords.push(JSON.parse(keyword));
Expand Down Expand Up @@ -66,7 +67,7 @@ export class ChainCard {

export class Card {
notes: string = "";
type: string = "";
type: string = "Entity";
owner: string = "";
status: string = "";
artist: string = "";
Expand All @@ -83,21 +84,67 @@ export class Card {
votePool: Coin = new Coin();

Abilities: Array<any> = [];
CardName: string = "";
CardName: string = "Name";
FlavourText: string = "";
Tags: Array<string> = [];
Class: CardClass = new CardClass();
Class: CardClass = CardClass.technology();
CastingCost: number = -1;
AdditionalCost: any = {};
Health: number = 0;
Attack: number = 0;
Delay: number = 0;
RulesTexts: Array<string> = [];
Keywords: Array<Array<string>> = [];
Effects: Array<any> = [];

static from(json) {
return Object.assign(new Card(), json);
}

toChainCard() {
console.log("trying to parse ", this);
let cardContent = Object.assign(new CardContent(), {
CardName: this.CardName,
Tags: this.Tags.filter(tag => {
return tag != null;
}),
FlavourText: this.FlavourText,
Class: this.Class,
Keywords: [],
RulesTexts: this.RulesTexts
});
this.Keywords.forEach(keyword => {
cardContent.Keywords.push(JSON.stringify(keyword));
});
// in the following part we check things that are only required for specific card types
if (this.type !== "Headquarter") {
cardContent.CastingCost = this.CastingCost;
if (!this.AdditionalCost) {
cardContent.AdditionalCost = this.AdditionalCost;
}
}
if (this.type !== "Action") {
cardContent.Health = this.Health;
cardContent.Abilities = this.Abilities;
}
if (this.type === "Entity") {
cardContent.Attack = this.Attack;
} else if (this.type === "Action") {
cardContent.Effects = this.Effects;
} else if (this.type === "Headquarter") {
cardContent.Delay = this.Delay;
}

let cc = new ChainCard();
cc.content = {
[this.type]: cardContent
};
cc.image = this.image ? this.image : "if you read this, someone was able to upload a card without proper image...";
cc.fullArt = this.fullArt;
cc.notes = this.notes;
console.log("parsed into:", cc);
return cc;
}
}

export class CardClass {
Expand Down Expand Up @@ -136,3 +183,19 @@ export class CardClass {
return obj;
}
}

class CardContent {
Abilities: Array<any> = [];
CardName: string = "";
FlavourText: string = "";
Tags: Array<string> = [];
Class: CardClass = new CardClass();
CastingCost: number = -1;
AdditionalCost: any = undefined;
Health: number = 0;
Attack: number = 0;
Delay: number = 0;
RulesTexts: Array<string> = [];
Keywords: Array<string> = [];
Effects: Array<any> = [];
}
4 changes: 2 additions & 2 deletions src/plugins/cardChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { entropyToMnemonic } from 'bip39'
//import { signTx, createWalletFromMnemonic } from '@tendermint/sig/dist/web'
//import { coin } from "@cosmjs/proto-signing";
// import { Coin } from "../store/generated/cosmos/cosmos-sdk/cosmos.bank.v1beta1/module/types/cosmos/base/v1beta1/coin.js"
import { creditsFromCoins, emptyCard } from '../components/utils/utils.js'
import {GenericAuthorization} from "../store/generated/cosmos/cosmos-sdk/cosmos.authz.v1beta1/module/types/cosmos/authz/v1beta1/authz.js"
import { creditsFromCoins } from '@/components/utils/utils.js'
import { GenericAuthorization } from "../store/generated/cosmos/cosmos-sdk/cosmos.authz.v1beta1/module/types/cosmos/authz/v1beta1/authz.js"
import { Card, ChainCard } from "@/model/Card";
//import {Any} from "../store/generated/cosmos/cosmos-sdk/cosmos.authz.v1beta1/module/types/google/protobuf/any.js"

Expand Down
Loading

0 comments on commit 6d95d6a

Please sign in to comment.