Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

262 remove rulestext #307

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"pinia": "^2.1.7",
"process": "^0.11.10",
"qrcode": "^1.5.3",
"query-string": "^9.0.0",
"ramda": "^0.29.1",
"vue": "^3.4.21",
"vue-advanced-cropper": "^2.8.8",
Expand Down
108 changes: 105 additions & 3 deletions src/components/elements/CardComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23208,15 +23208,16 @@ export default {

this.update()
this.textVisible = false
this.model.RulesTexts = this.generateRulesText()
console.log("rulestext", this.model.RulesTexts)
},
mounted() {
this.textVisible = true
},
methods: {
update() {
//console.log("model", this.model.CardName, this.model)
console.log("cardcomponent model", this.model.CardName, this.model)
this.FullArt = this.model.fullArt
//console.log("this.FullArt updated:", this.FullArt)

let FullArtfilter = x => this.FullArt ? x : R.map(() => false, x)
let EntityFullArtfilter = x => this.FullArt || cardType.Entity ? x : R.map(() => false, x)
Expand Down Expand Up @@ -23320,7 +23321,6 @@ export default {
this.framed = colorType
this.attackFrame = cardType.Entity
this.healthFrame = NonActionFilter(frameType)

},
cardmouseleave() {
if (this.hoverBehavior === 'none') return
Expand Down Expand Up @@ -23385,6 +23385,108 @@ export default {
getTags() {
return this.model.Tags.join(' - ').toUpperCase() || ''
},
generateRulesText() {
let deeper = element => {
if (typeof element === "object")
return element[R.keys(element)[0]]
else
return false
}
let decapital = x => {
return R.join("", R.over(R.lensIndex(0), R.toLower, x))
}
let effectsToText = Effects => {
let effectText = []
Effects.forEach(effect => {
let effectKeyword = R.keys(effect)[0]
let interaction = getInteractionText(effectKeyword)

let interactionBlock = []
interaction.forEach(element => {
if (R.includes("§", element)) {
let pure = R.join("", R.without(["§", "."], element))

let interactionNode = effect[effectKeyword][pure]

if (getRule(pure)) {
if (getRule(pure).type == "interface") {
let picked = R.keys(interactionNode)[0]
interactionBlock.push(getRule(picked).interactionText)
}
else
console.log("pure interaction?", getInteractionText(pure))
}
else {
let nextNode = deeper(interactionNode)

if (nextNode) {
interactionBlock.push(nextNode)
}
else {
interactionBlock.push(interactionNode)
}
}
}
else
interactionBlock.push(element)
})
effectText.push(R.join(" ", interactionBlock))
})
return effectText
}

let rules = this.cardRules.definitions
let getRule = key => this.cardRules.definitions[decapital(key)]
let getInteractionText = key => R.split(" ", rules[decapital(key)].interactionText)

let rulesText = ""
patrickwieth marked this conversation as resolved.
Show resolved Hide resolved
if (this.model.AdditionalCost) {
let costType = R.keys(this.model.AdditionalCost)[0]
let amount = this.model.AdditionalCost[costType].Amount
let costText = "Extra Cost - "
costText += R.replace("§Amount", amount, rules.AdditionalCost.children[costType].interactionText)
if (costType === "SacrificeCost")
costText = R.replace("card", amount > 1 ? "Entities." : "Entity.", costText)
else
costText += amount > 1 ? "s." : "."

rulesText = R.append(costText, rulesText)
}
if (this.model.Abilities) {
this.model.Abilities.forEach(ability => {
let keyword = R.keys(ability)[0]
let abilityText = getInteractionText(keyword)

abilityText.forEach((block, index) => {
// Effects can be nested a bit, so this needs more handling
if (R.includes("§Effects", block)) {
let effectText = effectsToText(ability[keyword].Effects)
abilityText[index] = R.replace("§Effects", R.join(". ", effectText), abilityText[index])
}
// Not effects, but something else that needs to be replaced with variable.
else if (R.includes("§", block)) {
let pure = R.join("", R.without(["§", ".", ":"], block))
let node = ability[keyword][pure]
if (deeper(node)) {
abilityText[index] = R.replace("§"+pure, deeper(node), abilityText[index])
}
else {
abilityText[index] = R.replace("§"+pure, node, abilityText[index])
}
}
else {
console.log("block else", block)
}
})
rulesText = R.append(R.join(" ", abilityText), rulesText)
})
}
else {
let effecttext = effectsToText(this.model.Effects)
rulesText = R.append(R.join(". ", effecttext), rulesText)
}
return rulesText
},
abilitiesLength() {
if (this.model.abilities) {
if (R.isEmpty(this.model.abilities)) {
Expand Down
3 changes: 1 addition & 2 deletions src/model/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ChainCard {
card.Health = parseInt(content[cardType].Health);
card.Attack = parseInt(content[cardType].Attack);
card.Delay = parseInt(content[cardType].Delay);
card.RulesTexts = content[cardType].RulesTexts;
card.RulesTexts = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's completely remove it from the card type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think it is being used by the CardCreator to put the rulesText together when you are assembling abilities?

card.Effects = content[cardType].Effects;
card.Keywords = [];
content[cardType].Keywords.forEach((keyword: string) => {
Expand Down Expand Up @@ -143,7 +143,6 @@ export class Card {
FlavourText: this.FlavourText,
Class: this.Class,
Keywords: [],
RulesTexts: this.RulesTexts,
});
this.Keywords.forEach((keyword) => {
cardContent.Keywords.push(JSON.stringify(keyword));
Expand Down
2 changes: 0 additions & 2 deletions src/views/Discord.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ import { CouncilStatus } from "decentralcardgame-cardchain-client-ts/DecentralCa
import axios from "axios";
import { useUrlSearchParams } from '@vueuse/core'
import { createReusableTemplate } from '@vueuse/core'
import queryString from 'query-string';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx



const [DefineRewardItem, RewardItem] = createReusableTemplate();

Expand Down
Loading