Skip to content

Commit

Permalink
Trimmed card database; accents are no longer free and will correspond…
Browse files Browse the repository at this point in the history
… to letters
  • Loading branch information
suitangi committed Aug 1, 2024
1 parent 048b84a commit 28678e5
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ The script accepts the following flags:

### Misc/Bugs
- Better daily share copy pasta (emojis!)/discord spoilers mode
- Add more characters to the keyboard, allowing for AE, dashes and accents
- More Easter eggs

### Options menu:
Expand All @@ -32,6 +31,7 @@ The script accepts the following flags:

# Changelog
```
7/31/2024: Trimmed card database; accents are no longer free and will correspond to letters
7/29/2024: Routine card update; a couple more new Dailies; added maintenance
6/3/2024: Routine card update; new Dailies
4/13/2024: Routine card update; new Daily
Expand Down
2 changes: 1 addition & 1 deletion cardList.json

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions maintenance/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,31 @@ function start() {
let setTypeExclude = ['memorabilia', 'token'];
let layoutExclude = ['vanguard', 'token', 'double_faced_token', 'art_series', 'scheme', 'planar', 'emblem',
'reversible_card', 'host', 'augment'];
let setNameExclude = ['Mystery Booster Playtest Cards 2021', 'Mystery Booster Playtest Cards 2019'];
let setNameExclude = ['Mystery Booster Playtest Cards 2021', 'Mystery Booster Playtest Cards 2019', 'Unfinity Sticker Sheets'];
let setExcludeDaily = ['Unfinity', 'Unhinged', 'Unsanctioned', 'Unstable', 'Unglued', 'The List (Unfinity Foil Edition)'];
let dfc = ['transform', 'modal_dfc'];

let toKeep = ['name', 'layout', 'mana_cost', 'colors', 'type_line'];
let img_uri = 'image_uris';
let toKeepImg = ['normal', 'art_crop']
let toKeepImg = ['normal', 'art_crop'];
let bannedChars = ['_', '®'];

let cleanList = [];
let idList = [];

let progress = 1;
console.log('Started list building and card processing .. ');
for (var i = 0; i < d.length; i++) {

let banned = false;
bannedChars.forEach((c) => {
if (d[i].name.includes(c)) {
banned = true;
}
});
if (banned) //exclude cards with banned characters in the name
continue;

if (setTypeExclude.includes(d[i].set_type) || layoutExclude.includes(d[i].layout) || setNameExclude.includes(d[i].set_name) ||
d[i].oversized || d[i].content_warning || d[i].games == undefined || !d[i].games.includes('paper') || d[i].flavor_name != undefined) {
//excluded lists, oversized, content_warning, not paper, cards with flavor names
Expand All @@ -119,7 +131,7 @@ function start() {
continue;
} else { //include the card
let card = d[i];

let toPush = {
id: card.id
};
Expand Down Expand Up @@ -205,7 +217,8 @@ function start() {
card = cleanList.pop();
console.log(card);
if ((card['type_line'] != undefined && !card['type_line'].includes('Basic')) && //not basic lands
!historical.includes(card.id) // not in historical
!historical.includes(card.id) && // not in historical
!setExcludeDaily.includes(card.set_name) // not in excluded sets
) {
dailyList.list.push(card);
historical.push(card);
Expand Down
72 changes: 55 additions & 17 deletions scripts/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const canVibrate = window.navigator.vibrate;
const befuddleAppVersion = "2024.7.29";
const befuddleAppVersion = "2024.7.31";

//Helper: Get Query
function getParameterByName(name, url) {
Expand Down Expand Up @@ -112,6 +112,7 @@ function isAlpha(char) {
//function to load the card data into memory
function loadCard(data) {

let multiFace = ['transform', 'modal_dfc'];
if (data) {
//setup new mtg card object
window.mtgCard = {};
Expand All @@ -122,7 +123,8 @@ function loadCard(data) {
window.mtgCard.name = data['name'];
window.mtgCard.colors = data['colors'];

if (window.mtgCard['layout'] == 'transform' || window.mtgCard['layout'] == 'modal_dfc') {

if (multiFace.includes(window.mtgCard['layout'])) {
window.mtgCard.card_faces = [];
for (var i = 0; i < data['card_faces'].length; i++) {
window.mtgCard.card_faces.push({
Expand Down Expand Up @@ -175,13 +177,13 @@ function loadCard(data) {
document.getElementById('seeCard').style = 'display:none;';
window.mtgCard.cf = -1;

// select card face if MDFC or transform
if (window.mtgCard['layout'] == 'transform' || window.mtgCard['layout'] == 'modal_dfc') {
if (getParameterByName('cf'))
// select card face if multiface
if (multiFace.includes(window.mtgCard['layout'])) {
if (getParameterByName('cf')) //if there's a cardFace parameter, use that
window.mtgCard.cf = parseInt(getParameterByName('cf'));
else if (window.game.mode == 'daily')
else if (window.game.mode == 'daily') //daily mode always front face
window.mtgCard.cf = 0;
else
else //random which card face
window.mtgCard.cf = Math.floor(Math.random() * window.mtgCard['card_faces'].length);
let cf = window.mtgCard['card_faces'][window.mtgCard.cf];
window.mtgCard['mana_cost'] = cf['mana_cost'];
Expand Down Expand Up @@ -254,6 +256,13 @@ function loadCard(data) {
window.gameSesh.hiddenName = hideName(str, '_');

document.getElementById("cardName").innerText = window.gameSesh.hiddenName;

if (window.gameSesh.hiddenName.length > 30) { //accomodate longer names
document.getElementById("cardName").style = "font-size: min(25px, 5vw);";
} else {
document.getElementById("cardName").style = "";
}

document.getElementById('card').style = "";

//save loaded game if daily
Expand Down Expand Up @@ -288,17 +297,23 @@ function submitLetter(char) {
//search in real card name and replace with correct letter
let uChar = char.toUpperCase();
let s = window.mtgCard.name;
let r = '';
let r = '',
ch;
for (var i = 0; i < s.length; i++) {
if (s.charAt(i) == char || s.charAt(i) == uChar) {
ch = s.charAt(i);
if (ch == char || ch == uChar || window.reverseAccentMap[ch] == char) {
found = true;
r += s.charAt(i);
r += ch;
} else {
if (!window.gameSesh.hideBlanks)
if (!window.gameSesh.hideBlanks) //not hidden mode
r += window.gameSesh.hiddenName.charAt(i);
else {
if (window.gameSesh.guesses.includes(s.toLowerCase().charAt(i)) || !isAlpha(s.charAt(i)))
r += s.charAt(i);
else { //hidden mode
if (
window.gameSesh.guesses.includes(ch.toLowerCase()) || //letter has been guessed
(window.accentedChars.has(ch) && window.gameSesh.guesses.includes(window.reverseAccentMap(ch).toLowerCase())) || //is accented char and accented char's mapped letter has been guessed
(!isAlpha(ch) && !window.accentedChars.has(ch)) //not alpha and not an accented character
)
r += ch;
}
}
}
Expand Down Expand Up @@ -785,12 +800,15 @@ function getWinTerms(ind) {

//function to hide the name of the card
function hideName(str, c) {
let r = '';

let r = '',
ch;
for (var i = 0; i < str.length; i++) {
if (isAlpha(str.charAt(i)))
ch = str.charAt(i);
if (isAlpha(ch) || window.accentedChars.has(ch))
r += c;
else
r += str.charAt(i);
r += ch;
}
return r;
}
Expand Down Expand Up @@ -2118,6 +2136,26 @@ $(document).ready(function() {
[]
];

window.accentMap = {
'a': ['à', 'á'],
'e': ['é'],
'i': ['í', 'ï'],
'o': ['ó', 'ö'],
'u': ['ú', 'û', 'ü'],
'n': ['ñ'],
'E': ['É']
}

window.reverseAccentMap = {};


Object.keys(window.accentMap).forEach((letter) => {
window.accentMap[letter].forEach((aLetter) => {
window.reverseAccentMap[aLetter] = letter;
});
});
window.accentedChars = new Set(Object.keys(window.reverseAccentMap));

for (var i = 0; i < 25; i++) {
window.stats.free.wr[0].push([0, 0]);
window.stats.free.wr[1].push([0, 0]);
Expand Down

0 comments on commit 28678e5

Please sign in to comment.