From 3d51314af3e348300736d36660e04c336b86fe99 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 20 Feb 2023 14:59:22 +0100 Subject: CODE --- tools/gendata.js | 86 +++++++++++++++++++++++++-------------------------- tools/genpieces.mjs | 1 + tools/scale_tokens.sh | 82 ++++++++++++++++++++++++------------------------ tools/slice_tokens.sh | 13 +++++--- 4 files changed, 95 insertions(+), 87 deletions(-) (limited to 'tools') diff --git a/tools/gendata.js b/tools/gendata.js index 58340af..5d59674 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -1,120 +1,122 @@ +let fs = require("fs") + let data = {} +function to_ascii(s) { + return s.normalize("NFD").replace(/[\u0300-\u036f]/g, "") +} + const IMAP = { G: "Government", F: "FARC", A: "AUC", C: "Cartels" } -let initiative = null +let order = null let cards = [ null ] -function def_initiative(s) { - initiative = [ IMAP[s[0]], IMAP[s[1]], IMAP[s[2]], IMAP[s[3]] ] +function def_order(s) { + order = [ IMAP[s[0]], IMAP[s[1]], IMAP[s[2]], IMAP[s[3]] ] } function def_card(number, name) { - cards[number] = { number, name, initiative } + cards[number] = { number, name, order } } -def_initiative("GFAC") +def_order("GFAC") def_card(1, "1st Division") def_card(2, "Ospina & Mora") def_card(3, "Tapias") -def_initiative("GFCA") +def_order("GFCA") def_card(4, "Caño Limón - Coveñas") def_card(5, "Occidental & Ecopetrol") def_card(6, "Oil Spill") -def_initiative("GAFC") +def_order("GAFC") def_card(7, "7th Special Forces") def_card(8, "Fuerza Aérea Colombiana") def_card(9, "High Mountain Battalions") -def_initiative("GACF") +def_order("GACF") def_card(10, "Blackhawks") def_card(11, "National Defense & Security Council") def_card(12, "Plan Colombia") -def_initiative("GCFA") +def_order("GCFA") def_card(13, "Plan Meteoro") def_card(14, "Tres Esquinas") def_card(15, "War Tax") -def_initiative("GCAF") +def_order("GCAF") def_card(16, "Coffee Prices") def_card(17, "Madrid Donors") def_card(18, "NSPD-18") -def_initiative("FGAC") +def_order("FGAC") def_card(19, "General Offensive") def_card(20, "Mono Jojoy") def_card(21, "Raúl Reyes") -def_initiative("FGCA") +def_order("FGCA") def_card(22, "Alfonso Cano") def_card(23, "DoD Contractors") def_card(24, "Operación Jaque") -def_initiative("FAGC") +def_order("FAGC") def_card(25, "Ejército de Liberación Nacional") def_card(26, "Gramaje") def_card(27, "Misil Antiaéreo") -def_initiative("FACG") +def_order("FACG") def_card(28, "Hugo Chávez") def_card(29, "Kill Zone") def_card(30, "Peace Commission") -def_initiative("FCGA") +def_order("FCGA") def_card(31, "Betancourt") def_card(32, "Secuestrados") def_card(33, "Sucumbíos") -def_initiative("FCAG") +def_order("FCAG") def_card(34, "Airdropped AKs") def_card(35, "Crop Substitution") def_card(36, "Zona de Convivencia") -def_initiative("AGFC") +def_order("AGFC") def_card(37, "Former Military") def_card(38, "National Coordination Center") -def_card(39, "Soldados campesinos") -def_initiative("AGCF") +def_card(39, "Soldados Campesinos") +def_order("AGCF") def_card(40, "Demobilization") def_card(41, "Mancuso") def_card(42, "Senado & Cámara") -def_initiative("AFGC") +def_order("AFGC") def_card(43, "Calima Front") def_card(44, "Colombia Nueva") def_card(45, "Los Derechos Humanos") -def_initiative("AFCG") +def_order("AFCG") def_card(46, "Limpieza") def_card(47, "Pinto & del Rosario") def_card(48, "Unión Sindical Obrera") -def_initiative("ACGF") +def_order("ACGF") def_card(49, "Bloques") def_card(50, "Carabineros") def_card(51, "Pipeline Repairs") -def_initiative("ACFG") +def_order("ACFG") def_card(52, "Castaño") def_card(53, "Criminal Air Force") def_card(54, "Deserters & Defectors") -def_initiative("CGFA") +def_order("CGFA") def_card(55, "DEA Agents") def_card(56, "Drogas La Rebaja") def_card(57, "Op Millennium") -def_initiative("CGAF") +def_order("CGAF") def_card(58, "General Serrano") def_card(59, "Salcedo") def_card(60, "The Chess Player") -def_initiative("CFGA") +def_order("CFGA") def_card(61, "Air Bridge") def_card(62, "Amazonía") def_card(63, "Narco-War") -def_initiative("CFAG") +def_order("CFAG") def_card(64, "Cocaine Labs") def_card(65, "Poppies") def_card(66, "Tingo María") -def_initiative("CAGF") +def_order("CAGF") def_card(67, "Mexican Traffickers") def_card(68, "Narco-Subs") def_card(69, "Riverines & Fast Boats") -def_initiative("CAFG") +def_order("CAFG") def_card(70, "Ayahuasca Tourism") def_card(71, "Darién") def_card(72, "Sicarios") -initiative = null +order = null def_card(73, "Propaganda!") def_card(74, "Propaganda!") def_card(75, "Propaganda!") def_card(76, "Propaganda!") -console.log("const cards = {") -for (let c of cards) console.log(JSON.stringify(c) + ",") -console.log("}") - let spaces = [ ] let space_names = [ ] @@ -124,12 +126,12 @@ function add(list, item) { } function def_space(type, pop, name) { - spaces.push({ type, name, pop, adjacent: [] }) + spaces.push({ type, id: to_ascii(name), name, pop, adjacent: [] }) space_names.push(name) } function def_town(name) { - spaces.push({ type: "town", name, adjacent: [] }) + spaces.push({ type: "town", id: to_ascii(name), name, adjacent: [] }) space_names.push(name) } @@ -138,7 +140,7 @@ function def_loc(type, econ, cities, depts) { let loc_names = cities.concat(depts) let loc_spaces = loc_names.map(n => space_names.indexOf(n)) let ix = spaces.length - spaces.push({ type, name, econ, adjacent: loc_spaces.filter(x=>x>0) }) + spaces.push({ type, name, id: to_ascii(name), econ, adjacent: loc_spaces.filter(x=>x>0) }) for (let loc of loc_spaces) if (loc >= 0) add(spaces[loc].adjacent, ix) @@ -159,12 +161,12 @@ data.first_city = spaces.length def_space("city", 8, "Bogotá") def_space("city", 3, "Cali") +def_space("city", 3, "Medellín") def_space("city", 2, "Bucaramanga") def_space("city", 2, "Ibagué") def_space("city", 2, "Santa Marta") def_space("city", 1, "Cartagena") def_space("city", 1, "Cúcuta") -def_space("city", 1, "Medellín") def_space("city", 1, "Neiva") def_space("city", 1, "Pasto") def_space("city", 1, "Sincelejo") @@ -382,9 +384,7 @@ data.coastal_spaces = [ "Cesar", "Atlántico", "Chocó", "Nariño" ].map(n=>spac for (let i = 1; i < spaces.length; ++i) spaces[i].adjacent.sort((a,b)=>a-b) -console.log("const spaces = [") -for (let x of spaces) console.log(JSON.stringify(x) + ",") -console.log("]") +data.cards = cards +data.spaces = spaces -for (let k in data) - console.log("const", k, "=", JSON.stringify(data[k])) +fs.writeFileSync("data.js", "const data = " + JSON.stringify(data, 0, "\t") + "\nif (typeof module !== 'undefined') module.exports = data\n") diff --git a/tools/genpieces.mjs b/tools/genpieces.mjs index ec478f6..cf157c5 100644 --- a/tools/genpieces.mjs +++ b/tools/genpieces.mjs @@ -282,6 +282,7 @@ border("#80643e", "#token_prop_card") border("#d74729", "#token_oppose_plus_bases") border("#004e81", "#token_el_presidente") border("#6a8796", "#token_aid") +border("#01904b", ".token.shipment") border("#4b87c0", ".token.passive_support") border("#b75f61", ".token.passive_opposition") border("#0054a6", ".token.active_support") diff --git a/tools/scale_tokens.sh b/tools/scale_tokens.sh index 83bffdf..f6ccdb4 100644 --- a/tools/scale_tokens.sh +++ b/tools/scale_tokens.sh @@ -1,46 +1,48 @@ mkdir -p tokens.1x tokens.2x function loop() { - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_1.ppm $OUT/govt_control.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_1.ppm $OUT/farc_control.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_6.ppm $OUT/farc_zone.png - - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_7.ppm $OUT/unshaded_ndsc.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_8.ppm $OUT/unshaded_ospina.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_15.ppm $OUT/unshaded_tapias.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_16.ppm $OUT/unshaded_1st_div.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_23.ppm $OUT/unshaded_black_hawks.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_24.ppm $OUT/unshaded_7th_sf.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_32.ppm $OUT/unshaded_meteoro.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_40.ppm $OUT/unshaded_mtn_bns.png - - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_7.ppm $OUT/shaded_ndsc.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_8.ppm $OUT/shaded_ospina.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_15.ppm $OUT/shaded_tapias.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_16.ppm $OUT/shaded_1st_div.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_23.ppm $OUT/shaded_black_hawks.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_24.ppm $OUT/shaded_7th_sf.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_32.ppm $OUT/shaded_meteoro.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_40.ppm $OUT/shaded_mtn_bns.png - - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_30.ppm $OUT/oppose_plus_bases.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_31.ppm $OUT/aid.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_37.ppm $OUT/el_presidente.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_38.ppm $OUT/total_support.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_39.ppm $OUT/prop_card.png - - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_1.ppm $OUT/active_support.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_2.ppm $OUT/terror.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_4.ppm $OUT/active_opposition.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_5.ppm $OUT/reminder_senado_cartels.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_6.ppm $OUT/reminder_darien.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_8.ppm $OUT/reminder_senado_auc.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_11.ppm $OUT/reminder_senado_farc.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_17.ppm $OUT/reminder_sucumbios.png - - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_b_1.ppm $OUT/passive_support.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_b_2.ppm $OUT/sabotage.png - convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_b_4.ppm $OUT/passive_opposition.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/shipment.png $OUT/shipment.png + + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_1.png $OUT/govt_control.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_1.png $OUT/farc_control.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_6.png $OUT/farc_zone.png + + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_7.png $OUT/unshaded_ndsc.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_8.png $OUT/unshaded_ospina.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_15.png $OUT/unshaded_tapias.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_16.png $OUT/unshaded_1st_div.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_23.png $OUT/unshaded_black_hawks.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_24.png $OUT/unshaded_7th_sf.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_32.png $OUT/unshaded_meteoro.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_40.png $OUT/unshaded_mtn_bns.png + + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_7.png $OUT/shaded_ndsc.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_8.png $OUT/shaded_ospina.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_15.png $OUT/shaded_tapias.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_16.png $OUT/shaded_1st_div.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_23.png $OUT/shaded_black_hawks.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_24.png $OUT/shaded_7th_sf.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_32.png $OUT/shaded_meteoro.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_b_40.png $OUT/shaded_mtn_bns.png + + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_30.png $OUT/oppose_plus_bases.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_31.png $OUT/aid.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_37.png $OUT/el_presidente.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_38.png $OUT/total_support.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/five_a_39.png $OUT/prop_card.png + + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_1.png $OUT/active_support.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_2.png $OUT/terror.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_4.png $OUT/active_opposition.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_5.png $OUT/reminder_senado_cartels.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_6.png $OUT/reminder_darien.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_8.png $OUT/reminder_senado_auc.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_11.png $OUT/reminder_senado_farc.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_a_17.png $OUT/reminder_sucumbios.png + + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_b_1.png $OUT/passive_support.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_b_2.png $OUT/sabotage.png + convert -colorspace RGB -resize $SCALE -colorspace sRGB HIRES/tokens/half_b_4.png $OUT/passive_opposition.png } OUT=tokens.1x diff --git a/tools/slice_tokens.sh b/tools/slice_tokens.sh index 5218792..f9ff041 100644 --- a/tools/slice_tokens.sh +++ b/tools/slice_tokens.sh @@ -19,15 +19,20 @@ # 1/2" 576x576+12+12 # 5/8" 720x720+15+15 +# Circles! 825x825 -> trim to 800x800 @75dpi is 50x50 +# 3887+8670 - 4712+9495 + pngtopnm HIRES/tokens/sheet_a.png > /tmp/big.ppm +pnmcut 3887 8670 825 825 /tmp/big.ppm | pnmcut 12 12 800 800 | pnmtopng > HIRES/tokens/shipment.png + I=1 for L in 592 4192 4792 5392 5992 6592 do for T in 1360 5260 5860 do echo half $I $L $T - pnmcut $L $T 600 600 /tmp/big.ppm | pnmcut 12 12 576 576 | pnmtopng > HIRES/tokens/half_a_$I.ppm + pnmcut $L $T 600 600 /tmp/big.ppm | pnmcut 12 12 576 576 | pnmtopng > HIRES/tokens/half_a_$I.png I=$(expr $I + 1) done done @@ -38,7 +43,7 @@ do for T in 760 1746 2732 3718 4704 5692 6678 7664 do echo five $I $L $T - pnmcut $L $T 750 750 /tmp/big.ppm | pnmcut 15 15 720 720 | pnmtopng > HIRES/tokens/five_a_$I.ppm + pnmcut $L $T 750 750 /tmp/big.ppm | pnmcut 15 15 720 720 | pnmtopng > HIRES/tokens/five_a_$I.png I=$(expr $I + 1) done done @@ -51,7 +56,7 @@ do for T in 1360 5260 5860 do echo half $I $L $T - pnmcut $L $T 600 600 /tmp/big.ppm | pnmcut 12 12 576 576 | pnmtopng > HIRES/tokens/half_b_$I.ppm + pnmcut $L $T 600 600 /tmp/big.ppm | pnmcut 12 12 576 576 | pnmtopng > HIRES/tokens/half_b_$I.png I=$(expr $I + 1) done done @@ -62,7 +67,7 @@ do for T in 760 1746 2732 3718 4704 5692 6678 7664 do echo five $I $L $T - pnmcut $L $T 750 750 /tmp/big.ppm | pnmcut 15 15 720 720 | pnmtopng > HIRES/tokens/five_b_$I.ppm + pnmcut $L $T 750 750 /tmp/big.ppm | pnmcut 15 15 720 720 | pnmtopng > HIRES/tokens/five_b_$I.png I=$(expr $I + 1) done done -- cgit v1.2.3