Skip to content

Commit

Permalink
fix keyword descriptions, update cardobject
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickwieth committed Jun 28, 2024
1 parent 346b924 commit a002093
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 162 deletions.
50 changes: 6 additions & 44 deletions src/components/elements/CardComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23195,28 +23195,15 @@ export default {
}
},
created() {
let firstLetterToLower = (string: String) => {
return string[0].toLowerCase() + string.substring(1)
}
this.model.Keywords.forEach((ability: Array<String>) => {
ability.forEach((keyword: String) => {
this.keywordDescriptions = R.concat(this.keywordDescriptions,
keyword + " - " + this.cardRules.definitions[firstLetterToLower(keyword)].description + " \\n "
)
})
})

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

let FullArtfilter = x => this.FullArt ? x : R.map(() => false, x)
Expand Down Expand Up @@ -23283,11 +23270,6 @@ export default {
}
}

//console.log("frameType", frameType)
//console.log("cardClass", cardClass)
//console.log("cardType", cardType)
//console.log("colorType", colorType)

// here begins the part where the components are activated
this.Class = cardClass
this.Classes = R.countBy(x => x === true)(R.values(this.model.Class)).true
Expand All @@ -23296,9 +23278,6 @@ export default {
this.SecondaryColor = R.last(classTrueKeys ? classTrueKeys : [])
this.PrimaryColor = R.head(classTrueKeys ? classTrueKeys : [])

//console.log("primary color:", this.PrimaryColor)
//console.log("secondary color:", this.SecondaryColor)

this.OBG = (this.Classes === 2 && !cardType.HQ) ? cardClass : frameType
this.GoldSquare = true
this.Border = frameType
Expand Down Expand Up @@ -23440,8 +23419,8 @@ export default {
let getInteractionText = key => R.split(" ", rules[decapital(key)].interactionText)

let rulesText = []
if (this.model.AdditionalCost) {
let costType = R.keys(this.model.AdditionalCost)[0]
if (this.model.AdditionalCost && !R.isEmpty(this.model.AdditionalCost)) {
let costType = R.keys(this.model.AdditionalCost)
let amount = this.model.AdditionalCost[costType].Amount
let costText = "Extra Cost - "
costText += R.replace("§Amount", amount, rules.AdditionalCost.children[costType].interactionText)
Expand All @@ -23452,7 +23431,7 @@ export default {

rulesText = R.append(costText, rulesText)
}
if (this.model.Abilities) {
if (this.model.Abilities && !R.isEmpty(this.model.Abilities)) {
this.model.Abilities.forEach(ability => {
let keyword = R.keys(ability)[0]
let abilityText = getInteractionText(keyword)
Expand All @@ -23475,15 +23454,15 @@ export default {
}
}
else {
console.log("block else", block)
//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)
let effectText = effectsToText(this.model.Effects)
rulesText = R.append(R.join(". ", effectText), rulesText)
}
return rulesText
},
Expand Down Expand Up @@ -23566,23 +23545,6 @@ export default {
return colors[this.SecondaryColor]
}
},
getKeywords() {
let additionalCostPseudoKeyword = [[]]

if (this.model.AdditionalCost) {
if (this.model.AdditionalCost.SacrificeCost) {
additionalCostPseudoKeyword[0].push("Tribute")
} else if (this.model.AdditionalCost.DiscardCost) {
additionalCostPseudoKeyword[0].push("DiscardPay")
} else if (this.model.AdditionalCost.VoidCost) {
additionalCostPseudoKeyword[0].push("Dissolve")
}
}

return additionalCostPseudoKeyword[0].length > 0 ?
R.concat(additionalCostPseudoKeyword, this.model.Keywords) :
this.model.Keywords
},
fontSize(rawText) {
let text = R.type(rawText) === "String" ? rawText : R.join(" ", rawText)
if (text.length < 100)
Expand Down
53 changes: 41 additions & 12 deletions src/components/elements/KeywordComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
import * as R from "ramda";
import { useCardsRules } from "@/def-composables/useCardRules";
import { onMounted, reactive, watch } from "vue";
import { Card } from "@/model/Card";
const { rules } = useCardsRules();
const props = withDefaults(
defineProps<{
keywords: Array<Array<string>>;
card: Card;
}>(),
{
keywords: () => [],
card: new Card(),
}
);
Expand All @@ -38,21 +39,49 @@ const initialState: {
const state = reactive(initialState);
const init = () => {
state.keywordDescriptions = R.map(
let decapital = x => {
return R.join("", R.over(R.lensIndex(0), R.toLower, x))
}
let getInteractionText = key => R.split(" ", rules.value.definitions[decapital(key)].interactionText)
let card = props.card
let keywords = []
if (card.AdditionalCost && !R.isEmpty(card.AdditionalCost)) {
let costType = R.keys(card.AdditionalCost)[0]
state.keywordDescriptions = [costType,
rules.value.definitions[costType].description]
}
if (card.Abilities) {
card.Abilities.forEach(ability => {
let keyword = R.keys(ability)[0]
keywords.push(keyword)
let abilityText = getInteractionText(keyword)
abilityText.forEach((block, index) => {
if (R.includes("§Effects", block)) {
ability[keyword].Effects.forEach(effect => {
keywords.push(R.keys(effect)[0])
})
}
})
})
}
if (card.Effects) {
card.Effects.forEach(effect => {
let effectKeyword = R.keys(effect)[0]
keywords.push(effectKeyword)
})
}
keywords = R.uniq(R.flatten(keywords))
state.keywordDescriptions = R.prepend(state.keywordDescriptions, R.map(
(keyword) => [
keyword,
rules.value.definitions[firstLetterToLower(keyword as String)]
.description,
rules.value.definitions[decapital(keyword)].description,
],
R.uniq(R.flatten(props.keywords))
);
};
const firstLetterToLower = (string: String) => {
return string[0].toLowerCase() + string.substring(1);
keywords))
};
watch(props, init);
onMounted(init);
</script>
</script>
4 changes: 2 additions & 2 deletions src/components/modals/CardviewModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
Used Keywords
</p>
<br>
<KeywordComponent :keywords="state.card.Keywords" />
<KeywordComponent :card="state.card" />
</div>
</div>
<div
Expand Down Expand Up @@ -144,7 +144,7 @@ onMounted(checkAndLoadCard);
watch(() => props.id, checkAndLoadCard);
const loadCard = async () => {
state.card = await getCard(props.id);
state.card = await getCard(props.id)
};
const edit = () => {
Expand Down
Loading

0 comments on commit a002093

Please sign in to comment.