Skip to content

Commit

Permalink
Merge branch 'master' of github.com:DecentralCardGame/frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Sep 28, 2023
2 parents 151bc61 + 07bba68 commit f0e3358
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export const normalizeCoins = (coins: Coin[]) => {
})
return newCoins
}

export function isASCII(str) {
return /^[\x00-\x7F]*$/.test(str);
}
39 changes: 32 additions & 7 deletions src/views/CardCreatorPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ import { useTx } from "@/def-composables/useTx";
import { useNotifications } from "@/def-composables/useNotifications";
import { validAddress } from "@/utils/validation";
import { useQuery } from "@/def-composables/useQuery";
import { isASCII } from '@/utils/utils';
const { saveCardContent, addArtwork } = useTx();
const { queryQUser } = useQuery();
Expand Down Expand Up @@ -805,8 +806,8 @@ export default {
},
getGenericCostRange(key: string) {
return R.range(
cardRules.Card.children[this.getRulesType()].children.AdditionalCost.children[key].children.Amount.min || 0,
cardRules.Card.children[this.getRulesType()].children.AdditionalCost.children[key].children.Amount.max + 1
this.cardRules.Card.children[this.getRulesType()].children.AdditionalCost.children[key].children.Amount.min || 0,
this.cardRules.Card.children[this.getRulesType()].children.AdditionalCost.children[key].children.Amount.max + 1
);
},
getSpecialCostRange() {
Expand Down Expand Up @@ -882,7 +883,11 @@ export default {
return printString.length > 1 ? R.dropLast(1, printString) : "";
},
showBuyFrameModal() {
this.isBuyFrameModalVisible = true;
if (!this.address) {
this.notifyFail("Unable to buy Card Frame", "You must be logged in with an activated account for this.");
}
else
this.isBuyFrameModalVisible = true;
},
closeBuyFrameModal() {
this.isBuyFrameModalVisible = false;
Expand Down Expand Up @@ -1100,7 +1105,6 @@ export default {
return;
}
if (!this.model.FlavourText[0] && !this.abilities) {
console.log("abilities mecker:" , this.model)
this.notifyFail(
"No Flavor Text",
"Card has no flavor text and no abilities, please enter something."
Expand Down Expand Up @@ -1204,8 +1208,21 @@ export default {
this.updateRulesTexts();
}
newModel.image = this.model.image;
newModel.balanceAnchor = this.model.balanceAnchor;
newModel.image = this.model.image
newModel.balanceAnchor = this.model.balanceAnchor
let checkASCII = (string, origin) => {
string.split('').forEach(char => {
if (!isASCII(char)) {
console.error("char "+char+" is not ASCII compatible.")
this.notifyFail("INVALID CHARACTER", "You used symbol "+char+" in "+origin+" and it is not supported.")
}
})
}
checkASCII(newModel.FlavourText, "Flavour Text")
checkASCII(newModel.CardName, "Card Name")
let newCard = newModel.toChainCard();
newCard.artist = this.designateArtist ? this.artistAddress : this.address;
console.log("newCard", newCard);
Expand All @@ -1219,7 +1236,11 @@ export default {
saveCardContent(this.model.id, newCard, this.resetCard, handleErr);
if (!this.designateArtist) addArtwork(this.model.id, newCard.image, newCard.fullArt, this.resetCard, handleErr);
} else {
}
else if (!this.address) {
this.notifyFail("Unable publish Card", "You must be logged in with an activated account!");
}
else {
queryQUser(this.address).then((res: User) => {
if (R.isEmpty(res.ownedCardSchemes)) {
this.notifyFail("YOU MUST CONSTRUCT ADDITIONAL PYLONS", "You don't own any Card Frames. Please buy one before publishing.");
Expand All @@ -1234,6 +1255,10 @@ export default {
saveCardContent(id, newCard, this.resetCard, handleErr);
if (!this.designateArtist) addArtwork(id, newCard.image, newCard.fullArt, this.resetCard, handleErr);
}
})
.catch(err => {
console.error(err);
this.notifyFail("Publish Card failed", err);
});
}
},
Expand Down

0 comments on commit f0e3358

Please sign in to comment.