Skip to content

Commit

Permalink
Merge branch '262-remove-rulestext' of github.com:DecentralCardGame/f…
Browse files Browse the repository at this point in the history
…rontend into 262-remove-rulestext-from-card-model
  • Loading branch information
lxgr-linux committed Jun 30, 2024
2 parents 14cfcb6 + a002093 commit 08cdf4c
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 213 deletions.
111 changes: 44 additions & 67 deletions src/components/elements/CardComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25654,8 +25654,8 @@

<script lang="ts">
import * as R from "ramda";
import { Card } from "@/model/Card";
import { useCardsRules } from "@/def-composables/useCardRules";
import {Card} from "@/model/Card";
import {useCardsRules} from "@/def-composables/useCardRules";

export default {
name: "CardComponent",
Expand All @@ -25678,7 +25678,7 @@ export default {
},
},
setup() {
const { rules } = useCardsRules();
const {rules} = useCardsRules();

return {
cardRules: rules,
Expand Down Expand Up @@ -25737,22 +25737,16 @@ export default {
},
},
created() {
let firstLetterToLower = (string: String) => {
return string[0].toLowerCase() + string.substring(1);
};

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

let FullArtfilter = (x) => (this.FullArt ? x : R.map(() => false, x));
let EntityFullArtfilter = (x) =>
Expand Down Expand Up @@ -25788,8 +25782,8 @@ export default {
};
cardType[tempType] = true;

let frameType = R.mergeAll(cardClass, { HQ: false, MultiClass: false });
let colorType = R.mergeAll(cardClass, { MultiClass: false });
let frameType = R.mergeAll(cardClass, {HQ: false, MultiClass: false});
let colorType = R.mergeAll(cardClass, {MultiClass: false});

if (R.countBy((x) => x === true)(R.values(this.model.Class)).true > 1) {
frameType = {
Expand Down Expand Up @@ -25819,11 +25813,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)(
Expand All @@ -25834,34 +25823,28 @@ 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;
this.IBG = this.Classes === 2 && !cardType.HQ ? cardClass : false;
this.BGGoldLines = true;
this.BGShadow = cardType;
this.ClassShadow = true;
this.ManaBall = frameType;
this.FullArtIllustrationMask = FullArtfilter(cardType);
this.ShadowFullArt = FullArtfilter(cardType);
this.FramedIllustrationMask = Framedfilter(cardType);
this.FullArtGradients = FullArtfilter(
this.Classes === 2 ? trueAt(Colors, this.PrimaryColor) : colorType,
);
this.FramedTextBox = Framedfilter(colorType);
this.HQFramedTextBox = cardType.HQ && !this.FullArt;
this.ShadowTextBox = cardType;
this.Tagsbar =
this.Classes <= 2 ? trueAt(Colors, this.PrimaryColor) : frameType;
this.ShadowFramed = Framedfilter(cardType);
this.FullArtFrames = EntityFullArtfilter(cardType);
this.FramedAddition = Framedfilter(cardType);
this.framed = colorType;
this.attackFrame = cardType.Entity;
this.healthFrame = NonActionFilter(frameType);
this.OBG = (this.Classes === 2 && !cardType.HQ) ? cardClass : frameType
this.GoldSquare = true
this.Border = frameType
this.IBG = (this.Classes === 2 && !cardType.HQ) ? cardClass : false
this.BGGoldLines = true
this.BGShadow = cardType
this.ClassShadow = true
this.ManaBall = frameType
this.FullArtIllustrationMask = FullArtfilter(cardType)
this.ShadowFullArt = FullArtfilter(cardType)
this.FramedIllustrationMask = Framedfilter(cardType)
this.FullArtGradients = FullArtfilter(this.Classes === 2 ? trueAt(Colors, this.PrimaryColor) : colorType)
this.FramedTextBox = Framedfilter(colorType)
this.HQFramedTextBox = cardType.HQ && !this.FullArt
this.ShadowTextBox = cardType
this.Tagsbar = this.Classes <= 2 ? trueAt(Colors, this.PrimaryColor) : frameType
this.ShadowFramed = Framedfilter(cardType)
this.FullArtFrames = EntityFullArtfilter(cardType)
this.FramedAddition = Framedfilter(cardType)
this.framed = colorType
this.attackFrame = cardType.Entity
this.healthFrame = NonActionFilter(frameType)
},
cardmouseleave() {
if (this.hoverBehavior === "none") return;
Expand Down Expand Up @@ -25898,9 +25881,9 @@ export default {
} else {
console.error(
"Invalid card type. Must be one of the following: " +
R.values(R.pluck("name", this.$cardRules.children)) +
". Instead is: " +
type,
R.values(R.pluck("name", this.$cardRules.children)) +
". Instead is: " +
type,
);
}
}
Expand Down Expand Up @@ -25985,16 +25968,12 @@ 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];
let amount = this.model.AdditionalCost[costType].Amount;
let costText = "Extra Cost - ";
costText += R.replace(
"§Amount",
amount,
rules.AdditionalCost.children[costType].interactionText,
);
let rulesText = []
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)
if (costType === "SacrificeCost")
costText = R.replace(
"card",
Expand All @@ -26005,10 +25984,10 @@ export default {

rulesText = R.append(costText, rulesText);
}
if (this.model.Abilities) {
this.model.Abilities.forEach((ability) => {
let keyword = R.keys(ability)[0];
let abilityText = getInteractionText(keyword);
if (this.model.Abilities && !R.isEmpty(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
Expand Down Expand Up @@ -26037,8 +26016,6 @@ export default {
abilityText[index],
);
}
} else {
console.log("block else", block);
}
});
rulesText = R.append(R.join(" ", abilityText), rulesText);
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 08cdf4c

Please sign in to comment.