From 68eb2fa1b431ccd0106b2f484787213c6b26770c Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 21 Oct 2019 17:01:10 +1100 Subject: [PATCH 01/67] wip --- server/src/img.rs | 93 +++++++++++++++++++++++++++++++++++++++++++++++ server/src/mtx.rs | 2 +- 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/server/src/img.rs b/server/src/img.rs index c10d8e57..5a707a1d 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -257,6 +257,94 @@ fn _hieroglyph() -> String { return s; } + +pub fn smiley(id: Uuid) -> Result { + let mut rng = thread_rng(); + let mut svg = Vec::new(); + + // distribution for lightness + // bellcurve around 75% + let l_dist = Normal::new(50.0, 10.0); + let s_dist = Normal::new(50.0, 20.0); + + + // basic layout is 2000x1000 box w/ 50 padding + // 2:1 for each x,y + + // left eye is top left + // x = 50 left padding + point offset + // y = 750 + 50 top padding + point offset + + // right eye is top right + // x = 50 left padding + 1500 + point offset + // y = 50 top padding + point offset + + // mouth is bottom centre + // x = 50 + 500 + xoffset + // y = 50 + 750 + yoffset + + write!(&mut svg, "")?; + + let n_points = rng.gen_range(3, 5); + let left_eye_path: String = std::iter::repeat(()) + .map(|()| { + let x = 50 + (rng.gen_range(0, 5) * 100); + let y = 50 + (rng.gen_range(0, 5) * 50); + format!("{} {}", x, y) + }) + .take(n_points) + .collect::>() + .join(","); + + // left eye + write!(&mut svg, + "", + left_eye_path)?; + + let n_points = rng.gen_range(3, 5); + let right_eye_path: String = std::iter::repeat(()) + .map(|()| { + let x = 50 + 1500 + (rng.gen_range(0, 5) * 100); + let y = 50 + (rng.gen_range(0, 5) * 50); + format!("{} {}", x, y) + }) + .take(n_points) + .collect::>() + .join(","); + + // right eye + write!(&mut svg, + "", + right_eye_path)?; + + let n_points = rng.gen_range(3, 5); + let mouth_path: String = std::iter::repeat(()) + .map(|()| { + let x = 50 + 500 + (rng.gen_range(0, 10) * 100); + let y = 50 + 750 + (rng.gen_range(0, 5) * 50); + format!("{} {}", x, y) + }) + .take(n_points) + .collect::>() + .join(","); + + // mouth + write!(&mut svg, + "", + mouth_path)?; + + write!(&mut svg, "")?; + + let dest = format!("/var/lib/mnml/public/imgs/{}.svg", id); + println!("/var/lib/mnml/public/imgs/{}.svg", id); + + let mut file = File::create(dest)?; + file.write_all(&svg)?; + + Ok(id) +} + + pub fn exists(id: Uuid) -> bool { std::path::Path::new(&format!("/var/lib/mnml/public/imgs/{}.svg", id)).exists() } @@ -283,6 +371,11 @@ mod tests { // shapes_write(Uuid::new_v4()).unwrap(); // } // } + + #[test] + fn smiley_test() { + smiley(Uuid::new_v4()).unwrap(); + } } diff --git a/server/src/mtx.rs b/server/src/mtx.rs index 239e1fe7..a6acd9a9 100644 --- a/server/src/mtx.rs +++ b/server/src/mtx.rs @@ -159,7 +159,7 @@ pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, const match mtx.variant { MtxVariant::Invader => img::invader_write(construct.img)?, MtxVariant::Molecular => img::molecular_write(construct.img)?, - MtxVariant::Shapes => img::shapes_write(construct.img)?, + MtxVariant::Shapes => img::smiley(construct.img)?, _ => construct.img, }; From d8bad68216f751bb4f50f447ecea4807972efce0 Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 25 Oct 2019 16:09:30 +1100 Subject: [PATCH 02/67] wip --- server/src/img.rs | 54 ++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/server/src/img.rs b/server/src/img.rs index 5a707a1d..c9c78046 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -267,8 +267,15 @@ pub fn smiley(id: Uuid) -> Result { let l_dist = Normal::new(50.0, 10.0); let s_dist = Normal::new(50.0, 20.0); + let eyes = [ + ("50 800, 300 550, 550 800", 1), + ("50 550, 300 800, 550 550", 1), + ]; + let shape_dist = WeightedIndex::new(eyes.iter().map(|v| v.1))?; - // basic layout is 2000x1000 box w/ 50 padding + + + // basic layout is 2000x2000 box w/ 50 padding // 2:1 for each x,y // left eye is top left @@ -283,60 +290,31 @@ pub fn smiley(id: Uuid) -> Result { // x = 50 + 500 + xoffset // y = 50 + 750 + yoffset - write!(&mut svg, "")?; + write!(&mut svg, "")?; - let n_points = rng.gen_range(3, 5); - let left_eye_path: String = std::iter::repeat(()) - .map(|()| { - let x = 50 + (rng.gen_range(0, 5) * 100); - let y = 50 + (rng.gen_range(0, 5) * 50); - format!("{} {}", x, y) - }) - .take(n_points) - .collect::>() - .join(","); + let left_eye_path = "50 800, 300 550, 550 800"; // left eye write!(&mut svg, - "", + "", left_eye_path)?; - let n_points = rng.gen_range(3, 5); - let right_eye_path: String = std::iter::repeat(()) - .map(|()| { - let x = 50 + 1500 + (rng.gen_range(0, 5) * 100); - let y = 50 + (rng.gen_range(0, 5) * 50); - format!("{} {}", x, y) - }) - .take(n_points) - .collect::>() - .join(","); - + let right_eye_path = "1550 800, 1800 550, 2050 800"; // right eye write!(&mut svg, - "", + "", right_eye_path)?; - let n_points = rng.gen_range(3, 5); - let mouth_path: String = std::iter::repeat(()) - .map(|()| { - let x = 50 + 500 + (rng.gen_range(0, 10) * 100); - let y = 50 + 750 + (rng.gen_range(0, 5) * 50); - format!("{} {}", x, y) - }) - .take(n_points) - .collect::>() - .join(","); - + let mouth_path = "550 1550, 1550 1550"; // mouth write!(&mut svg, - "", + "", mouth_path)?; write!(&mut svg, "")?; + // let dest = format!("/var/lib/mnml/face.svg"); let dest = format!("/var/lib/mnml/public/imgs/{}.svg", id); - println!("/var/lib/mnml/public/imgs/{}.svg", id); let mut file = File::create(dest)?; file.write_all(&svg)?; From 7f159f6914b5866ec6be2fba831bef9c9e1253ed Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 27 Oct 2019 21:13:15 +1100 Subject: [PATCH 03/67] faces --- server/src/img.rs | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/server/src/img.rs b/server/src/img.rs index c9c78046..383e1f7f 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -267,13 +267,24 @@ pub fn smiley(id: Uuid) -> Result { let l_dist = Normal::new(50.0, 10.0); let s_dist = Normal::new(50.0, 20.0); - let eyes = [ - ("50 800, 300 550, 550 800", 1), - ("50 550, 300 800, 550 550", 1), + let eyes_left = [ + ("M50,800 L300,550 L550,800", 1), // ^ + ("M50,550 L300,800 L550,550", 1), // v + ("M50,550 L300,800 L550,550", 1), // v ]; - let shape_dist = WeightedIndex::new(eyes.iter().map(|v| v.1))?; + let eye_left_dist = WeightedIndex::new(eyes_left.iter().map(|v| v.1))?; + let eyes_right = [ + ("M1550,800 L1800,550 L2050,800", 1), // ^ + ("M1550,550 L1800,800 L2050,550", 1), // v + ("M1550,550 L1800,800 L2050,550", 1), // v + ]; + let eye_right_dist= WeightedIndex::new(eyes_right.iter().map(|v| v.1))?; + let mouths = [ + ("M550,1800 L1550,1800", 1), // ^ + ]; + let mouth_dist = WeightedIndex::new(mouths.iter().map(|v| v.1))?; // basic layout is 2000x2000 box w/ 50 padding // 2:1 for each x,y @@ -290,25 +301,25 @@ pub fn smiley(id: Uuid) -> Result { // x = 50 + 500 + xoffset // y = 50 + 750 + yoffset - write!(&mut svg, "")?; + write!(&mut svg, "")?; - let left_eye_path = "50 800, 300 550, 550 800"; + let left_eye_path = eyes_left[eye_left_dist.sample(&mut rng)].0; // left eye write!(&mut svg, - "", + "", left_eye_path)?; - let right_eye_path = "1550 800, 1800 550, 2050 800"; + let right_eye_path = eyes_right[eye_right_dist.sample(&mut rng)].0; // right eye write!(&mut svg, - "", + "", right_eye_path)?; - let mouth_path = "550 1550, 1550 1550"; + let mouth_path = mouths[mouth_dist.sample(&mut rng)].0; // mouth write!(&mut svg, - "", + "", mouth_path)?; write!(&mut svg, "")?; From 200e4b4cb79e2aa67e4e71e60397de8bb9d54674 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 31 Oct 2019 19:50:52 +1100 Subject: [PATCH 04/67] it's happening --- server/src/img.rs | 67 +++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/server/src/img.rs b/server/src/img.rs index 383e1f7f..7065832f 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -267,60 +267,69 @@ pub fn smiley(id: Uuid) -> Result { let l_dist = Normal::new(50.0, 10.0); let s_dist = Normal::new(50.0, 20.0); + // let stroke_width = rng.gen_range(1, 3); + let stroke_width = 3; + + // basic layout is 200x200 box w/ 100 padding + // 2:1 for each x,y + + // left eye is at 0,0 + // 50W 25H let eyes_left = [ - ("M50,800 L300,550 L550,800", 1), // ^ - ("M50,550 L300,800 L550,550", 1), // v - ("M50,550 L300,800 L550,550", 1), // v + ("M0,0 L25,25 L50,0", 1), // v + ("M0,25 L25,0 L50,25", 1), // ^ + ("M0,0 L50,0", 1), // - + ("M0,25 L50,25", 1), // _ + ("M0,0 L50,25 M50,0 L0,25", 1), // x + ("M0,0 L50,12.5 L0,25", 1), // > + ("M50,0 L0,12.5 L50,25", 1), // < ]; let eye_left_dist = WeightedIndex::new(eyes_left.iter().map(|v| v.1))?; + // right eye is 150,0 + // 50W 25H let eyes_right = [ - ("M1550,800 L1800,550 L2050,800", 1), // ^ - ("M1550,550 L1800,800 L2050,550", 1), // v - ("M1550,550 L1800,800 L2050,550", 1), // v + ("M150,0 L175,25 L200,0", 1), // v + ("M150,25 L175,0 L200,25", 1), // ^ + ("M150,0 L200,0", 1), // - + ("M150,25 L200,25", 1), // - + ("M150,0 L200,25 M200,0 L150,25", 1), // x + ("M150,0 L200,12.5 L150,25", 1), // > + ("M200,0 L150,12.5 L200,25", 1), // < ]; let eye_right_dist= WeightedIndex::new(eyes_right.iter().map(|v| v.1))?; + // mouth is 50,75 + // 100W 25H let mouths = [ - ("M550,1800 L1550,1800", 1), // ^ + ("M50,100 L150,100", 1), // _ + ("M50,75 L150,75 L150,100 L50,100 L50,75", 1), // box + ("M50,75 L75,100 L100,75 L125,100 L150,75", 1), // w + ("M50,75 L75,75 L75,87.5 M75,75 L125,75 L125,87.5 M125,75 L150,75", 1), // vamp + ("M75,75 L125,75 L125,100 L75,100 L75,75", 1), // o ]; let mouth_dist = WeightedIndex::new(mouths.iter().map(|v| v.1))?; - // basic layout is 2000x2000 box w/ 50 padding - // 2:1 for each x,y - - // left eye is top left - // x = 50 left padding + point offset - // y = 750 + 50 top padding + point offset - - // right eye is top right - // x = 50 left padding + 1500 + point offset - // y = 50 top padding + point offset - - // mouth is bottom centre - // x = 50 + 500 + xoffset - // y = 50 + 750 + yoffset - - write!(&mut svg, "")?; + write!(&mut svg, "")?; let left_eye_path = eyes_left[eye_left_dist.sample(&mut rng)].0; // left eye write!(&mut svg, - "", - left_eye_path)?; + "", + stroke_width, left_eye_path)?; let right_eye_path = eyes_right[eye_right_dist.sample(&mut rng)].0; // right eye write!(&mut svg, - "", - right_eye_path)?; + "", + stroke_width, right_eye_path)?; let mouth_path = mouths[mouth_dist.sample(&mut rng)].0; // mouth write!(&mut svg, - "", - mouth_path)?; + "", + stroke_width, mouth_path)?; write!(&mut svg, "")?; From 9d2da3249ad23958b4c53e462376b4362856875b Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 31 Oct 2019 19:59:40 +1100 Subject: [PATCH 05/67] colour faces --- server/src/img.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/server/src/img.rs b/server/src/img.rs index 7065832f..259ce6ae 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -270,6 +270,16 @@ pub fn smiley(id: Uuid) -> Result { // let stroke_width = rng.gen_range(1, 3); let stroke_width = 3; + let h = rng.gen_range(0, 360); + let s = s_dist.sample(&mut rng) as usize; + let l = l_dist.sample(&mut rng) as usize; + let eye_colour = format!("hsl({:}, {:}%, {:}%)", h, s, l); + + let h = rng.gen_range(0, 360); + let s = s_dist.sample(&mut rng) as usize; + let l = l_dist.sample(&mut rng) as usize; + let mouth_colour = format!("hsl({:}, {:}%, {:}%)", h, s, l); + // basic layout is 200x200 box w/ 100 padding // 2:1 for each x,y @@ -307,6 +317,7 @@ pub fn smiley(id: Uuid) -> Result { ("M50,75 L75,100 L100,75 L125,100 L150,75", 1), // w ("M50,75 L75,75 L75,87.5 M75,75 L125,75 L125,87.5 M125,75 L150,75", 1), // vamp ("M75,75 L125,75 L125,100 L75,100 L75,75", 1), // o + ("M50,75 L150,100 M150,75 L50,100", 1), // x ]; let mouth_dist = WeightedIndex::new(mouths.iter().map(|v| v.1))?; @@ -316,20 +327,20 @@ pub fn smiley(id: Uuid) -> Result { // left eye write!(&mut svg, - "", - stroke_width, left_eye_path)?; + "", + eye_colour, stroke_width, left_eye_path)?; let right_eye_path = eyes_right[eye_right_dist.sample(&mut rng)].0; // right eye write!(&mut svg, - "", - stroke_width, right_eye_path)?; + "", + eye_colour, stroke_width, right_eye_path)?; let mouth_path = mouths[mouth_dist.sample(&mut rng)].0; // mouth write!(&mut svg, - "", - stroke_width, mouth_path)?; + "", + mouth_colour, stroke_width, mouth_path)?; write!(&mut svg, "")?; From bfecea9a4e39790ed5ff85719e317da1f54047ce Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 31 Oct 2019 20:35:41 +1100 Subject: [PATCH 06/67] add smile mtx --- server/src/img.rs | 6 +++--- server/src/mtx.rs | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/src/img.rs b/server/src/img.rs index 259ce6ae..e2908acf 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -258,7 +258,7 @@ fn _hieroglyph() -> String { } -pub fn smiley(id: Uuid) -> Result { +pub fn smile(id: Uuid) -> Result { let mut rng = thread_rng(); let mut svg = Vec::new(); @@ -382,8 +382,8 @@ mod tests { // } #[test] - fn smiley_test() { - smiley(Uuid::new_v4()).unwrap(); + fn smile_test() { + smile(Uuid::new_v4()).unwrap(); } } diff --git a/server/src/mtx.rs b/server/src/mtx.rs index a6acd9a9..f3591563 100644 --- a/server/src/mtx.rs +++ b/server/src/mtx.rs @@ -19,9 +19,10 @@ pub const FREE_MTX: [MtxVariant; 2] = [ MtxVariant::Shapes, ]; -pub const SHOP_LISTINGS: [Listing; 2] = [ +pub const SHOP_LISTINGS: [Listing; 3] = [ Listing { variant: MtxVariant::Molecular, credits: 10 }, Listing { variant: MtxVariant::Invader, credits: 10 }, + Listing { variant: MtxVariant::Smile, credits: 10 }, ]; const NEW_IMAGE_COST: i64 = 1; @@ -46,6 +47,7 @@ pub enum MtxVariant { Molecular, Invader, Shapes, + Smile, } impl MtxVariant { @@ -63,6 +65,7 @@ impl TryFrom for MtxVariant { "Rename" => Ok(MtxVariant::Rename), "Molecular" => Ok(MtxVariant::Molecular), "Invader" => Ok(MtxVariant::Invader), + "Smile" => Ok(MtxVariant::Smile), "Shapes" => Ok(MtxVariant::Shapes), _ => Err(format_err!("mtx variant not found variant={:?}", v)), } @@ -159,7 +162,8 @@ pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, const match mtx.variant { MtxVariant::Invader => img::invader_write(construct.img)?, MtxVariant::Molecular => img::molecular_write(construct.img)?, - MtxVariant::Shapes => img::smiley(construct.img)?, + MtxVariant::Shapes => img::shapes_write(construct.img)?, + MtxVariant::Smile => img::smile(construct.img)?, _ => construct.img, }; @@ -181,6 +185,7 @@ pub fn account_apply(tx: &mut Transaction, account: &Account, variant: MtxVarian MtxVariant::Invader => img::invader_write(account.img)?, MtxVariant::Molecular => img::molecular_write(account.img)?, MtxVariant::Shapes => img::shapes_write(account.img)?, + MtxVariant::Smile => img::smile(account.img)?, _ => account.img, }; From ef5e5170cf4ebdff41143a76266da6c0b89e557f Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 31 Oct 2019 20:41:21 +1100 Subject: [PATCH 07/67] remove molecular mtx --- ops/fetch.molecules.js | 82 ------------ ops/fix.molecule.holes.js | 12 -- .../20191031203812_remove-molecular.js | 10 ++ ops/molecules.js | 18 --- server/src/img.rs | 125 +----------------- server/src/mtx.rs | 8 +- 6 files changed, 12 insertions(+), 243 deletions(-) delete mode 100644 ops/fetch.molecules.js delete mode 100644 ops/fix.molecule.holes.js create mode 100644 ops/migrations/20191031203812_remove-molecular.js delete mode 100644 ops/molecules.js diff --git a/ops/fetch.molecules.js b/ops/fetch.molecules.js deleted file mode 100644 index 5b9b7ba2..00000000 --- a/ops/fetch.molecules.js +++ /dev/null @@ -1,82 +0,0 @@ -const fs = require('fs'); -const renderer = require('sdftosvg'); - -const SVG_OPTS = { - backgroundColor: 'none', -} - -function convert(i) { - const output = `./../client/assets/molecules/${i}.svg`; - - return new Promise((resolve, reject) => { - fs.readFile(`./molecules/mol${i}`, 'utf8', function rfCb(err, sdf) { - if (err) return reject(err); - // write svg - renderer.renderSdfToSvg(sdf, SVG_OPTS, function(err, svg) { - if (err) return reject(err); - fs.writeFile(output, svg, function written(err) { - if (err) reject(err); - resolve(); - }); - }); - }) - }); -} - -async function loop() { - for (var i = 10000; i >= 0; i--) { - try { - await convert(i); - console.log('finished record', i); - } catch (e) { - console.error('record error', i, e); - } - } -} - -loop(); - -// const request = require('request'); -// const fs = require('fs'); -// const renderer = require('sdftosvg'); - -// const SVG_OPTS = { -// backgroundColor: 'none', -// } - -// function fetch(i) { -// return new Promise((resolve, reject) => { -// const url = `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/CID/${i}/record/SDF/?record_type=2d&response_type=save&response_basename=Structure2D_CID_2519`; -// const output = `./../client/assets/molecules/${i}.svg`; - -// request(url, function cb(err, res, body) { -// if (err) reject(err); - -// // write file -// fs.writeFile(`./molecules/Structure2D_CID_${i}.sdf`, body, function written(err) { -// if (err) reject(err); -// }); - -// // write svg -// renderer.renderSdfToSvg(body, SVG_OPTS, function(err, svg) { -// if (err) reject(err); -// fs.writeFile(output, svg, function written(err) { -// if (err) reject(err); -// resolve(); -// }); -// }); -// }); -// }); -// } - -// async function loop() { -// for (var i = 10000; i >= 0; i--) { -// try { -// await fetch(i); -// console.log('finished record', i); -// } catch (e) { -// console.error(e); -// } -// } -// } - diff --git a/ops/fix.molecule.holes.js b/ops/fix.molecule.holes.js deleted file mode 100644 index f3c07006..00000000 --- a/ops/fix.molecule.holes.js +++ /dev/null @@ -1,12 +0,0 @@ -const fs = require('fs'); - -for (let i = 10000; i >= 0; i--) { - fs.access(`./../client/assets/molecules/${i}.svg`, (err) => { - if (err) { - fs.copyFileSync(`./../client/assets/molecules/726.svg`, `./../client/assets/molecules/${i}.svg`); - console.log('defaulted', i); - } - return true; - }) -} - diff --git a/ops/migrations/20191031203812_remove-molecular.js b/ops/migrations/20191031203812_remove-molecular.js new file mode 100644 index 00000000..194db918 --- /dev/null +++ b/ops/migrations/20191031203812_remove-molecular.js @@ -0,0 +1,10 @@ +const uuidv4 = require('uuid/v4'); + +// give everybody the shapes mtx +exports.up = async knex => { + await knex.raw(` + DELETE from mtx + WHERE variant = 'Molecular'; + `); +}; +exports.down = async () => {}; \ No newline at end of file diff --git a/ops/molecules.js b/ops/molecules.js deleted file mode 100644 index 39c7d1b5..00000000 --- a/ops/molecules.js +++ /dev/null @@ -1,18 +0,0 @@ -const renderer = require('sdftosvg'); -const uuidv4 = require('uuid/v4'); -const fs = require('fs'); - -function convert(f) { - const uuid = uuidv4(); - const input = `./molecules/${f}`; - const output = `./../client/assets/molecules/${uuid}.svg`; - fs.readFile(input, 'utf8', (err, sdf) => { - renderer.renderSdfToSvg(sdf, {}, function(err, svg) { - if (err) console.error(input, err); - fs.writeFile(output, svg, 'utf8', err => { - if (err) console.error(err); - }); - }); - }); -} - diff --git a/server/src/img.rs b/server/src/img.rs index e2908acf..5e0603a2 100644 --- a/server/src/img.rs +++ b/server/src/img.rs @@ -1,5 +1,4 @@ use std::f64; -use std::fs::copy; use std::fs::File; use std::io::prelude::*; use std::char::from_u32; @@ -9,25 +8,7 @@ use rand::prelude::*; use rand::distributions::{Normal, WeightedIndex}; use failure::Error; -use failure::err_msg; - -pub fn molecular_write(id: Uuid) -> Result { - let mut rng = thread_rng(); - - for _i in 0..100 { - let mol: u32 = rng.gen_range(0, 10000); - let src = format!("/var/lib/mnml/data/molecules/{}.svg", mol); - let dest = format!("/var/lib/mnml/public/imgs/{}.svg", id); - debug!("molecule src={:?}", src); - debug!("molecule dest={:?}", dest); - if let Ok(_bytes) = copy(&src, &dest) { - info!("new molecule img generated src={:?} dest={:?}", src, dest); - return Ok(id); - } - } - - return Err(err_msg("too many missing molecules. wrong directory?")) -} +// use failure::err_msg; pub fn invader_write(id: Uuid) -> Result { let mut rng = thread_rng(); @@ -361,7 +342,6 @@ pub fn exists(id: Uuid) -> bool { #[cfg(test)] mod tests { use super::*; - // #[test] // fn invader_img_test() { // for i in 0..100 { @@ -386,106 +366,3 @@ mod tests { smile(Uuid::new_v4()).unwrap(); } } - - - -// function createColor() { -// //saturation is the whole color spectrum -// var h = Math.floor(rand() * 360); -// //saturation goes from 40 to 100, it avoids greyish colors -// var s = ((rand() * 60) + 40) + '%'; -// //lightness can be anything from 0 to 100, but probabilities are a bell curve around 75% -// var l = ((rand()+rand()+rand()+rand()) * 25) + '%'; - -// var color = 'hsl(' + h + ',' + s + ',' + l + ')'; -// return color; -// } - -// function createImageData(size) { -// var width = size; // Only support square icons for now -// var height = size; - -// var dataWidth = Math.ceil(width / 2); -// var mirrorWidth = width - dataWidth; - -// var data = []; -// for(var y = 0; y < height; y++) { -// var row = []; -// for(var x = 0; x < dataWidth; x++) { -// // this makes foreground and background color to have a 43% (1/2.3) probability -// // spot color has 13% chance -// row[x] = Math.floor(rand()*2.3); -// } -// var r = row.slice(0, mirrorWidth); -// r.reverse(); -// row = row.concat(r); - -// for(var i = 0; i < row.length; i++) { -// data.push(row[i]); -// } -// } - -// return data; -// } - -// function buildOpts(opts) { -// var newOpts = {}; - -// newOpts.seed = opts.seed || Math.floor((Math.random()*Math.pow(10,16))).toString(16); - -// seedrand(newOpts.seed); - -// newOpts.size = opts.size || 8; -// newOpts.scale = opts.scale || 4; -// newOpts.color = opts.color || createColor(); -// newOpts.bgcolor = opts.bgcolor || createColor(); -// newOpts.spotcolor = opts.spotcolor || createColor(); - -// return newOpts; -// } -// ], -// - _ => vec![ -// - (ItemAction::RerollStamina, 1), -// - (ItemAction::RerollPhysDamage, 1), -// - (ItemAction::RerollSpellDamage, 1), -// - (ItemAction::RerollSpeed, 1), -// - (ItemAction::RerollArmour, 1), -// - (ItemAction::RerollSpellShield, 1), -// - (ItemAction::RerollEvasion, 1), -// - ], -// + // _ => vec![ -// + // (ItemAction::RerollStamina, 1), -// + // (ItemAction::RerollPhysDamage, 1), -// + // (ItemAction::RerollSpellDamage, 1), -// + // (ItemAction::RerollSpeed, 1), -// + // (ItemAction::RerollArmour, 1), -// + // (ItemAction::RerollSpellShield, 1), -// + // (ItemAction::RerollEvasion, 1), -// + // ], -// } -// } - -// -pub fn item_drop(tx: &mut Transaction, account_id: Uuid, mode: GameMode) -> Result { -// +pub fn item_drop(tx: &mut Transaction, account_id: Uuid, mode: GameMode) -> Result<(), Error> { -// let mut rng = thread_rng(); - -// - let actions = mode_drops(mode); -// + let log_normal = LogNormal::new(1.0, 1.0); -// + let num_drops = log_normal.sample(&mut rng).floor() as usize; -// + -// + println!("{:?} drops", num_drops); - -// - let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap(); -// - let kind = actions[dist.sample(&mut rng)].0; -// - let item = Item::new(kind, account_id); -// + for _i in 0..num_drops { -// + let actions = mode_drops(mode); - -// - println!("{:?} dropped {:?}", account_id, item); -// + let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap(); -// + let kind = actions[dist.sample(&mut rng)].0; -// + let item = Item::new(kind, account_id); - -// - return item_create(item, tx, account_id); -// + println!("{:?} dropped {:?}", account_id, item); -// + item_create(item, tx, account_id)?;V \ No newline at end of file diff --git a/server/src/mtx.rs b/server/src/mtx.rs index f3591563..b47daa5f 100644 --- a/server/src/mtx.rs +++ b/server/src/mtx.rs @@ -19,8 +19,7 @@ pub const FREE_MTX: [MtxVariant; 2] = [ MtxVariant::Shapes, ]; -pub const SHOP_LISTINGS: [Listing; 3] = [ - Listing { variant: MtxVariant::Molecular, credits: 10 }, +pub const SHOP_LISTINGS: [Listing; 2] = [ Listing { variant: MtxVariant::Invader, credits: 10 }, Listing { variant: MtxVariant::Smile, credits: 10 }, ]; @@ -44,7 +43,6 @@ pub struct Listing { #[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)] pub enum MtxVariant { Rename, - Molecular, Invader, Shapes, Smile, @@ -63,7 +61,6 @@ impl TryFrom for MtxVariant { fn try_from(v: String) -> Result { match v.as_ref() { "Rename" => Ok(MtxVariant::Rename), - "Molecular" => Ok(MtxVariant::Molecular), "Invader" => Ok(MtxVariant::Invader), "Smile" => Ok(MtxVariant::Smile), "Shapes" => Ok(MtxVariant::Shapes), @@ -84,7 +81,6 @@ impl Mtx { match variant { _ => Mtx { id: Uuid::new_v4(), account, variant }, // MtxVariant::Invader => Mtx { id: Uuid::new_v4(), account, variant: self }, - // MtxVariant::Molecular => Mtx { id: Uuid::new_v4(), account, variant: self }, } } @@ -161,7 +157,6 @@ pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, const match mtx.variant { MtxVariant::Invader => img::invader_write(construct.img)?, - MtxVariant::Molecular => img::molecular_write(construct.img)?, MtxVariant::Shapes => img::shapes_write(construct.img)?, MtxVariant::Smile => img::smile(construct.img)?, _ => construct.img, @@ -183,7 +178,6 @@ pub fn account_apply(tx: &mut Transaction, account: &Account, variant: MtxVarian match mtx.variant { MtxVariant::Invader => img::invader_write(account.img)?, - MtxVariant::Molecular => img::molecular_write(account.img)?, MtxVariant::Shapes => img::shapes_write(account.img)?, MtxVariant::Smile => img::smile(account.img)?, _ => account.img, From 9294471f47218263fd66b6a830f5f745fbc74554 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 31 Oct 2019 21:17:15 +1100 Subject: [PATCH 08/67] combine mtx available list --- client/src/components/reshape.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/src/components/reshape.jsx b/client/src/components/reshape.jsx index d45bd4d4..68ca09b0 100644 --- a/client/src/components/reshape.jsx +++ b/client/src/components/reshape.jsx @@ -117,8 +117,6 @@ function Reshape(args) {
{shop.owned.map(useMtx)} -
-
{shop.available.map(availableMtx)}
From 18f2ab5f7a1e1a21e9e697825fca77685aff4398 Mon Sep 17 00:00:00 2001 From: ntr Date: Sat, 2 Nov 2019 15:22:29 +1100 Subject: [PATCH 09/67] player widths calc --- WORKLOG.md | 2 +- client/assets/styles/game.less | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WORKLOG.md b/WORKLOG.md index 174a7073..e74e910a 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -3,7 +3,6 @@ *PRODUCTION* -* vbox phase skill list navigator (overlay maybe?) * can't reset password without knowing password =\ * mobile styles @@ -19,6 +18,7 @@ * ACP * essential + * audio * treats * susbcriber gold name in instance diff --git a/client/assets/styles/game.less b/client/assets/styles/game.less index 65ad6b25..17d9aeeb 100644 --- a/client/assets/styles/game.less +++ b/client/assets/styles/game.less @@ -19,6 +19,9 @@ /* stops overflow */ min-height: 0; min-width: 0; + + // timer is 0.25 w/ 1em margin + width: calc(90% - 1.25em); } .player { @@ -28,7 +31,6 @@ position: absolute; bottom: 0; height: 50%; - width: 90%; } .opponent { @@ -37,7 +39,6 @@ position: absolute; top: 0; height: 35%; - width: 90%; margin-top: 0.5em; .game-construct { From 76fb5918448fa32f370d3338111c7186263c2463 Mon Sep 17 00:00:00 2001 From: ntr Date: Sat, 2 Nov 2019 15:52:50 +1100 Subject: [PATCH 10/67] notifications added to events.notify --- client/assets/styles/game.less | 2 +- client/src/events.jsx | 11 +++++++++++ client/src/socket.jsx | 9 +++++---- server/src/rpc.rs | 1 + server/src/warden.rs | 4 ++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/client/assets/styles/game.less b/client/assets/styles/game.less index 17d9aeeb..fe5dd570 100644 --- a/client/assets/styles/game.less +++ b/client/assets/styles/game.less @@ -12,7 +12,7 @@ // "player "; } -.game .team { +.game .team, .faceoff .team { display: grid; grid-template-columns: repeat(3, 1fr); diff --git a/client/src/events.jsx b/client/src/events.jsx index 0cc1e4a0..5515ddba 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -12,6 +12,13 @@ const { tutorialVbox } = require('./tutorial.utils'); function registerEvents(store) { function notify(msg) { + if (Notification && Notification.permission === 'granted') { + const n = new Notification('MNML', { + body: msg, + tag: 'MNML', + }); + } + return infoToast(msg); } @@ -130,6 +137,10 @@ function registerEvents(store) { if (account) { LogRocket.init('yh0dy3/mnml'); LogRocket.identify(account.id, account); + + if (Notification) { + Notification.requestPermission(); + } } store.dispatch(actions.setAccount(account)); diff --git a/client/src/socket.jsx b/client/src/socket.jsx index 85d81154..340310b8 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -264,13 +264,14 @@ function createSocket(events) { Pong: onPong, Demo: onDemo, - QueueRequested: () => events.notify('pvp queue request received'), - QueueJoined: () => events.notify('you have joined the pvp queue'), - InviteRequested: () => events.notify('pvp invite request received'), + QueueRequested: () => events.notify('PVP queue request received.'), + QueueJoined: () => events.notify('You have joined the PVP queue.'), + QueueFound: () => events.notify('Your PVP game has started.'), + InviteRequested: () => events.notify('PVP invite request received.'), Invite: code => events.setInvite(code), InstanceChat: chat => events.setInstanceChat(chat), ChatWheel: wheel => events.setChatWheel(wheel), - Joining: () => events.notify('searching for instance...'), + // Joining: () => events.notify('Searching for instance...'), Processing: () => true, Error: errHandler, diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 54602215..29d89d34 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -65,6 +65,7 @@ pub enum RpcMessage { QueueRequested(()), QueueJoined(()), QueueCancelled(()), + QueueFound(()), InviteRequested(()), Invite(String), diff --git a/server/src/warden.rs b/server/src/warden.rs index 38779346..ff4b2760 100644 --- a/server/src/warden.rs +++ b/server/src/warden.rs @@ -112,6 +112,10 @@ impl Warden { pair.0.tx.send(msg.clone())?; pair.1.tx.send(msg)?; + // send msgs for browser notifications + pair.0.tx.send(RpcMessage::QueueFound(()))?; + pair.1.tx.send(RpcMessage::QueueFound(()))?; + Ok(()) } } From 18af9fb2c0e97794bbcb8c4b3ff9adad2ff65363 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 09:42:20 +1000 Subject: [PATCH 11/67] worklog --- WORKLOG.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/WORKLOG.md b/WORKLOG.md index e74e910a..019cc499 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -5,14 +5,34 @@ * can't reset password without knowing password =\ -* mobile styles +* mobile + - 2 pages vbox / equip + - vbox page as current with equip button at bottom + - equip page with inventory and all 3 construct avatars + - click one of the avatars to expand out skill / spec slots + - show the info pane at the bottom or as an overlay + * mobile info page -* fix info page for tablet layout * Invert recharge ## SOON +* change cooldowns to delay & recharge + - delay is cooldown before skill can first be used + - recharge is cooldown after using skill + - every x speed reduces delay of skills + +* combo rework + - reduce number of items for creating t2/t3 items from 3 -> 2 + - add lost complexity by adding skill spec items + - Created by combining a skill with corresponding spec + e.g. + - Strike + PowerRR -> StrikePower (Will be the power symbol with strike text under) + - Construct does Y% more damage with Strike + - Strike + SpeedRR -> StrikeSpeed (strike has Y% more speed) + - Strike + LifeRR -> StrikeLife (Strike recharges X% of damage as red life) + * equip from shop (buy and equip without putting in your inventory) for bases * move item from one construct to another From a6473cb84c13c279304525a41371f2aae7b7a5b3 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 10:22:44 +1000 Subject: [PATCH 12/67] log --- WORKLOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WORKLOG.md b/WORKLOG.md index 019cc499..cdfa63f6 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -6,12 +6,15 @@ * can't reset password without knowing password =\ * mobile + - force to landscape view and try make everything fit + OR - 2 pages vbox / equip - vbox page as current with equip button at bottom - equip page with inventory and all 3 construct avatars - click one of the avatars to expand out skill / spec slots - show the info pane at the bottom or as an overlay + * mobile info page * Invert recharge From 7b1a6df40b1fd1b20cae8a7f6dfc4bf66390ddcb Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 10:27:22 +1000 Subject: [PATCH 13/67] landscape is the way --- client/assets/styles/game.less | 101 +--------------- client/assets/styles/instance.mobile.less | 141 +--------------------- client/assets/styles/menu.less | 26 ---- client/assets/styles/styles.mobile.less | 122 +------------------ 4 files changed, 3 insertions(+), 387 deletions(-) diff --git a/client/assets/styles/game.less b/client/assets/styles/game.less index fe5dd570..ce49b4b1 100644 --- a/client/assets/styles/game.less +++ b/client/assets/styles/game.less @@ -347,103 +347,4 @@ max-height: 100%; max-width: 100%; // height: 5em; -} - -@media (max-width: 1000px) { - .game { - grid-template-areas: - "opponent" - "target " - "player "; - - grid-template-rows: 1fr 0.2fr 1.5fr; - grid-template-columns: 1fr; - - .game-construct { - display: grid; - grid-template-columns: 1fr; - grid-template-rows: min-content 1fr; - - .left { - width: 100%; - grid-template-areas: - "skills" - "effects"; - grid-template-columns: 1fr; - grid-template-rows: min-content min-content; - } - - .skills { - button { - padding: 0 0.5em ; - margin: 0; - } - button.active { - background: #2c2c2c; - } - } - - .stats div { - padding: 0; - } - - .stats .max { - display: none; - } - - .stats .value { - display: flex; - } - - .stats svg { - height: 1em; - } - - .stats div { - margin: 0 0.2em; - } - - .effects { - font-size: 100%; - } - - .stats, .name { - font-size: 75%; - } - - .skills button { - font-size: 50%; - } - - .skill-description { - font-size: 65%; - } - } - - .player { - width: calc(100% - 1em); - bottom: 3em; - height: calc(50% - 3em); - } - - .opponent { - width: calc(100% - 1em); - .game-construct { - display: grid; - grid-template-columns: 1fr; - grid-template-rows: min-content 1fr; - } - } - - #targeting, .resolving-skill { - width: calc(100% - 1em); - } - - .player { - width: calc(100% - 1em); - bottom: 3em; - height: calc(50% - 3em); - } - } - -} +} \ No newline at end of file diff --git a/client/assets/styles/instance.mobile.less b/client/assets/styles/instance.mobile.less index 9fec777b..925b487f 100644 --- a/client/assets/styles/instance.mobile.less +++ b/client/assets/styles/instance.mobile.less @@ -17,9 +17,7 @@ @media (max-width: 800px) { .instance { - overflow-y: scroll; - font-size: 8pt; - display: grid; + font-size: 6pt; grid-template-columns: 1fr; grid-template-rows: min-content 1fr; grid-template-areas: @@ -30,141 +28,4 @@ display: none; } } - - .instance .nav-btn { display: initial; } - - .vbox { - grid-area: vbox; - margin-bottom: 0; - display: grid; - grid-template-rows: min-content min-content min-content min-content; - grid-template-columns: 1fr; - grid-template-areas: - "vbox" - "varrow" - "inventory" - "combiner"; - - &:not(.visible) { - display: none; - } - - .vbox-vbox { - margin-bottom: 1em; - } - } - - .vbox-arrow { - display: none; - } - - .vbox-inventory .vbox-hdr { - display: block; - } - - .vbox-arrow-mobile { - display: block; - grid-area: varrow; - width: 100%; - text-align: center; - margin: 0; - } - - .construct-list { - display: grid; - grid-auto-rows: 1fr; - - .instance-construct:not(.visible) { - display: none; - }; - } - - .vbox-inventory { - margin-left: 0; - } - - .vbox-combiner { - margin-left: 0; - } - - .equip .specs { - margin-top: 0.5em; - border: none; - border-bottom: 1px solid #444; - } - - .equip .skills { - border: none; - border-bottom: 1px solid #444; - } - - .instance-construct { - display: grid; - grid-template-rows: min-content min-content min-content 1fr min-content; - grid-template-areas: - "name " - "skills " - "specs " - "avatar " - "stats "; - - border: 0; - padding: 0; - - transition-property: all; - transition-duration: 0.25s; - transition-delay: 0; - transition-timing-function: ease; - } - - .instance-construct:first-child { - border-left-width: 0; - } - - .instance-construct:not(:last-child) { - border-right: 1px solid #222; - } - - .instance-construct .skills { - flex-flow: column; - } - - .instance-construct .skills button { - margin: 0; - } - - .instance-construct .specs { - margin: 0; - } - - .construct-list .stats { - flex-flow: row wrap; - text-align: center; - } - - .instance-construct .stats div.speed { - order: -1; - flex: 1 0 100%; - margin: 0; - } - - .instance-construct .stats div { - flex: 1 1 33%; - } - - .instance-nav { - display: flex; - grid-area: nav; - margin-right: 0; - border-top: 2px solid #444; - } - - .instance-nav button { - font-size: 150%; - border-right: 2px solid #444; - } - - .instance-nav button:last-child { - border: none; - } } \ No newline at end of file diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index 672e928e..5445b158 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -215,29 +215,3 @@ section { } } -@media (max-width: 800px) { - section { - grid-template-columns: 1fr; - - .list { - grid-template-columns: 1fr 1fr; - - &.play { - grid-template-columns: 1fr; - } - } - - } - - .menu .team { - grid-template-columns: 1fr; - - .construct { - height: 10em; - } - } - - .account { - grid-template-columns: 1fr; - } -} \ No newline at end of file diff --git a/client/assets/styles/styles.mobile.less b/client/assets/styles/styles.mobile.less index be259075..0eb2a954 100644 --- a/client/assets/styles/styles.mobile.less +++ b/client/assets/styles/styles.mobile.less @@ -4,127 +4,7 @@ } #mnml { - font-size: 12pt; - padding: 0; - grid-template-columns: 1fr; - grid-template-rows: 10fr 1fr; - grid-template-areas: - "main" - "footer"; - - height: 100vh; - max-height: initial; - min-height: initial; + font-size: 6pt; } - table td { - height: 2.5em; - } - - nav { - display: none; - } - - aside { - display: none; - } - - footer { - display: flex; - position: fixed; - bottom: 0; - width: 100%; - - button { - font-size: 90%; - } - } - - #nav-btn, #instance-nav { - display: unset; - } - - #mnml.nav-visible nav { - padding: 0.5em; - margin: 0; - display: block; - grid-area: main; - } - - #mnml.nav-visible main { - display: none; - } - - main { - overflow-x: hidden; - overflow-y: initial; - max-height: 100vh; - padding: 0 0.5em; - } - - .welcome .login { - width: 100%; - } - - .welcome .options { - width: 100%; - flex-flow: row wrap; - } - - .welcome .options button { - flex: 1 0 50%; - } - - .timer-container { - margin: 0.5em 0 0 0; - } - - .mobile-title { - display: block; - margin-bottom: 1em; - } - - .menu-instances { - display: grid; - - grid-template-columns: 1fr; - grid-template-areas: - "constructs" - "inventory" - "games"; - } - - .menu { - .options { - display: grid; - grid-template-columns: 1fr; - - button:not(:last-child) { - border: 2px solid #222; - } - - button.logo { - border: none; - margin-right: 0; - margin-top: 0.5em; - background-position: center; - } - } - } - - section { - .list { - grid-template-columns: 1fr; - } - } - - .account { - div { - padding: 0; - } - } - - .play-p { - display: none; - } } From 4fa13c20c29dbca73b63427d5cc262cdbbc010c9 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 13:25:23 +1000 Subject: [PATCH 14/67] misc --- client/assets/styles/styles.mobile.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/assets/styles/styles.mobile.less b/client/assets/styles/styles.mobile.less index 0eb2a954..218d90df 100644 --- a/client/assets/styles/styles.mobile.less +++ b/client/assets/styles/styles.mobile.less @@ -4,7 +4,7 @@ } #mnml { - font-size: 6pt; + font-size: 8pt; } } From 6f578f0747936ba0b025722c116388e7fb5568e4 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 14:33:06 +1000 Subject: [PATCH 15/67] init --- client/assets/styles/vbox.less | 2 +- client/src/components/instance.constructs.jsx | 2 +- client/src/components/vbox.component.jsx | 50 +++++++------------ 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/client/assets/styles/vbox.less b/client/assets/styles/vbox.less index fe62f0a2..0e0f9526 100644 --- a/client/assets/styles/vbox.less +++ b/client/assets/styles/vbox.less @@ -83,7 +83,7 @@ &.highlight { color: black; background: @white; - border: 1px solid @white; + // border: 1px solid @white; (this bangs around the vbox) // overwrite the classes on white svg elements svg { diff --git a/client/src/components/instance.constructs.jsx b/client/src/components/instance.constructs.jsx index 1e010061..a17aa221 100644 --- a/client/src/components/instance.constructs.jsx +++ b/client/src/components/instance.constructs.jsx @@ -223,7 +223,7 @@ function Construct(props) { const classes = `instance-construct ${mobileVisible ? 'visible' : ''}`; const avatarMouseOver = e => hoverInfo(e, `constructAvatar ${construct.name}`); return ( -
+
ev.preventDefault()} onDrop={onClick}>

hoverInfo(e, `constructName ${construct.name}`)}>{construct.name}

hoverInfo(e, 'constructSkills')} > diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index c2c1a51a..68f6dc5e 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -194,8 +194,6 @@ class Vbox extends preact.Component { e.stopPropagation(); setItemEquip(null); setCombiner([]); - - if (selected) return clearVboxSelected(); setInfo(vbox.free[group][index]); return setVboxSelected([group, index]); } @@ -217,28 +215,18 @@ class Vbox extends preact.Component { const classes = `${v.toLowerCase()} ${selected ? 'highlight' : ''} ${comboHighlight}`; - if (shapes[v]) { - return ( + const vboxObject = shapes[v] ? shapes[v]() : v; + return ( + ); } @@ -334,26 +322,19 @@ class Vbox extends preact.Component { const highlighted = combiner.indexOf(i) > -1; const border = buttons[removeTier(v)] ? buttons[removeTier(v)]() : ''; const classes = `${highlighted ? 'highlight' : border} ${comboHighlight}`; - if (shapes[v]) { - return ( + + const invObject = shapes[v] ? shapes[v]() : v; + + return ( +
- ); - } - - return ( - +
); } @@ -408,7 +389,10 @@ class Vbox extends preact.Component {
e.stopPropagation()} - style={vboxSelecting || (itemUnequip.length) ? { cursor: 'pointer' } : null}> + style={vboxSelecting || (itemUnequip.length) ? { cursor: 'pointer' } : null} + onDragOver={ev => ev.preventDefault()} + onDrop={inventoryClick} + >

e.target.scrollIntoView(true)} From 61b57827e314e221e1068d450893aeb4d2ddb98b Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 15:09:58 +1000 Subject: [PATCH 16/67] label --- client/src/components/vbox.component.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index 68f6dc5e..e9e8b8e7 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -326,7 +326,7 @@ class Vbox extends preact.Component { const invObject = shapes[v] ? shapes[v]() : v; return ( -
+
+ ); } From bb50037e0e99e7cf6f1c1e37a106bf7c17a1726b Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 16:02:48 +1000 Subject: [PATCH 17/67] drag equipped items --- client/assets/styles/instance.less | 7 ++++ client/src/components/instance.constructs.jsx | 36 ++++++++++--------- client/src/components/vbox.component.jsx | 3 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/client/assets/styles/instance.less b/client/assets/styles/instance.less index 0f05fc8b..841993a8 100644 --- a/client/assets/styles/instance.less +++ b/client/assets/styles/instance.less @@ -203,6 +203,9 @@ button { height: 3em; } + label { + display: flex; + } } .specs { @@ -228,6 +231,10 @@ font-size: 75%; line-height: initial; } + + label { + display: flex; + } } .stats { diff --git a/client/src/components/instance.constructs.jsx b/client/src/components/instance.constructs.jsx index a17aa221..ed43f62e 100644 --- a/client/src/components/instance.constructs.jsx +++ b/client/src/components/instance.constructs.jsx @@ -153,15 +153,17 @@ function Construct(props) { const classes = `${equipping ? 'equipping' : ''} ${!skill ? 'empty' : ''} ${border()}`; return ( - + ); }); @@ -195,13 +197,15 @@ function Construct(props) { return ( - + ); }); diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index e9e8b8e7..14cf1108 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -306,7 +306,8 @@ class Vbox extends preact.Component { // removing const combinerIndex = combiner.indexOf(i); if (combinerIndex > -1) { - return combinerChange(without(combiner, i)); + return true; + // return combinerChange(without(combiner, i)); } combiner.push(i); From 64ec68d823588d42c54eb8895e1e3868104d02f0 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 16:35:28 +1000 Subject: [PATCH 18/67] fix recharge immunity bug --- server/src/skill.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/skill.rs b/server/src/skill.rs index 1f655e6d..313b21a3 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -1392,7 +1392,7 @@ fn sustain(source: &mut Construct, target: &mut Construct, mut results: Resoluti if red > 0 || blue > 0 { EventStages::PostOnly } else { EventStages::NoStages } } - _ => panic!("not recharge") + _ => EventStages::NoStages, }; results.push(Resolution::new(source, target).event(e).stages(stages)); @@ -1411,7 +1411,7 @@ fn intercept(source: &mut Construct, target: &mut Construct, mut results: Resolu if red > 0 || blue > 0 { EventStages::PostOnly } else { EventStages::NoStages } } - _ => panic!("not recharge") + _ => EventStages::NoStages, }; results.push(Resolution::new(source, target).event(e).stages(stages)); @@ -1712,8 +1712,8 @@ fn reflect(source: &mut Construct, target: &mut Construct, mut results: Resoluti Event::Recharge { red, blue, skill: _ } => { if red > 0 || blue > 0 { EventStages::PostOnly } else { EventStages::NoStages } - } - _ => panic!("not recharge") + }, + _ => EventStages::NoStages, }; results.push(Resolution::new(source, target).event(e).stages(stages)); return results;; @@ -1728,7 +1728,7 @@ fn recharge(source: &mut Construct, target: &mut Construct, mut results: Resolut if red > 0 || blue > 0 { EventStages::AllStages } else { EventStages::StartEnd } } - _ => panic!("not recharge") + _ => EventStages::NoStages, }; results.push(Resolution::new(source, target).event(e).stages(stages)); return results; From 25b89da5c490f6a35f3181853ce05d4796709b3a Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 4 Nov 2019 18:00:40 +1100 Subject: [PATCH 19/67] fix buttons after curse and invert swap --- client/src/components/buttons.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/buttons.jsx b/client/src/components/buttons.jsx index c2f72b15..6cc063a9 100644 --- a/client/src/components/buttons.jsx +++ b/client/src/components/buttons.jsx @@ -31,9 +31,9 @@ module.exports = { // This will need to be edited if we change server recipes Restrict: () => 'red-border', Purge: () => 'green-border', Silence: () => 'blue-border', - Curse: () => 'red-green-border', + Invert: () => 'red-green-border', Decay: () => 'blue-green-border', - Invert: () => 'red-blue-border', + Curse: () => 'red-blue-border', // // Lifes Upgrades // LifeGG: () => 'green-border', From f0c0ce7dd1c892cb4b0ecf4981e9ee9714ff2c11 Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 4 Nov 2019 18:02:51 +1100 Subject: [PATCH 20/67] reminder msg --- client/src/components/buttons.jsx | 3 ++- server/src/item.rs | 45 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/client/src/components/buttons.jsx b/client/src/components/buttons.jsx index 6cc063a9..78232928 100644 --- a/client/src/components/buttons.jsx +++ b/client/src/components/buttons.jsx @@ -1,4 +1,5 @@ -module.exports = { // This will need to be edited if we change server recipes +// This will need to be edited if we change server recipes +module.exports = { // Attack Strike: () => 'red-border', Blast: () => 'blue-border', diff --git a/server/src/item.rs b/server/src/item.rs index 52b3bb8b..4d5604f0 100644 --- a/server/src/item.rs +++ b/server/src/item.rs @@ -620,70 +620,70 @@ impl Item { // Lifes Upgrades Item::LifeGG | Item::LifeGGPlus | - Item::LifeGGPlusPlus => format!("Increases construct GreenLife by {:?}. + Item::LifeGGPlusPlus => format!("Increases construct GreenLife by {:?}. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::LifeRR | Item::LifeRRPlus | - Item::LifeRRPlusPlus => format!("Increases construct RedLife by {:?}. + Item::LifeRRPlusPlus => format!("Increases construct RedLife by {:?}. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), - Item::LifeBB | - Item::LifeBBPlus | - Item::LifeBBPlusPlus => format!("Increases construct BlueLife by {:?}. + Item::LifeBB | + Item::LifeBBPlus | + Item::LifeBBPlusPlus => format!("Increases construct BlueLife by {:?}. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::LifeRG | Item::LifeRGPlus | - Item::LifeRGPlusPlus => format!("Increases construct RedLife and GreenLife by {:?}. + Item::LifeRGPlusPlus => format!("Increases construct RedLife and GreenLife by {:?}. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::LifeGB | Item::LifeGBPlus | - Item::LifeGBPlusPlus => format!("Increases construct GreenLife and BlueLife by {:?}. + Item::LifeGBPlusPlus => format!("Increases construct GreenLife and BlueLife by {:?}. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::LifeRB | Item::LifeRBPlus | - Item::LifeRBPlusPlus => format!("Increases construct RedLife and BlueLife by {:?}. + Item::LifeRBPlusPlus => format!("Increases construct RedLife and BlueLife by {:?}. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), // Power Upgrades - Item::PowerRR | - Item::PowerRRPlus | - Item::PowerRRPlusPlus => format!("Increases construct RedPower by {:?}%. + Item::PowerRR | + Item::PowerRRPlus | + Item::PowerRRPlusPlus => format!("Increases construct RedPower by {:?}%. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::PowerBB | Item::PowerBBPlus | - Item::PowerBBPlusPlus => format!("Increases construct BluePower by {:?}%. + Item::PowerBBPlusPlus => format!("Increases construct BluePower by {:?}%. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::PowerGG | Item::PowerGGPlus | - Item::PowerGGPlusPlus => format!("Increases construct GreenPower by {:?}%. + Item::PowerGGPlusPlus => format!("Increases construct GreenPower by {:?}%. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::PowerRG | Item::PowerRGPlus | - Item::PowerRGPlusPlus => format!("Increases construct GreenPower and RedPower by {:?}%. + Item::PowerRGPlusPlus => format!("Increases construct GreenPower and RedPower by {:?}%. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::PowerGB | Item::PowerGBPlus | - Item::PowerGBPlusPlus => format!("Increases construct GreenPower and BluePower by {:?}%. + Item::PowerGBPlusPlus => format!("Increases construct GreenPower and BluePower by {:?}%. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), Item::PowerRB | Item::PowerRBPlus | - Item::PowerRBPlusPlus => format!("Increases construct RedPower and BluePower by {:?}%. + Item::PowerRBPlusPlus => format!("Increases construct RedPower and BluePower by {:?}%. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), @@ -705,7 +705,7 @@ impl Item { Item::SpeedGGPlusPlus | Item::SpeedRGPlusPlus | Item::SpeedGBPlusPlus | - Item::SpeedRBPlusPlus => format!("Increases construct SpeedStat by {:?}%. + Item::SpeedRBPlusPlus => format!("Increases construct SpeedStat by {:?}%. If your team meets total colour thresholds the spec provides additional bonuses.", self.into_spec().unwrap().values().base()), @@ -796,7 +796,7 @@ impl Item { Item::Hybrid| Item::HybridPlus | Item::HybridPlusPlus => format!( - "Hybrid increases GreenPower by {:?}%. + "Hybrid increases GreenPower by {:?}%. Blue based Attack skills will blast again dealing {:?}% GreenPower as blue damage. Lasts {:?}T.", self.into_skill().unwrap().effect()[0].get_multiplier() - 100, @@ -823,7 +823,7 @@ impl Item { Item::Purge| Item::PurgePlus | Item::PurgePlusPlus => format!( - "Remove buffs from target construct. + "Remove buffs from target construct. Applies purge disabling target green skills for {:?}T.", self.into_skill().unwrap().effect()[0].get_duration()), @@ -836,7 +836,7 @@ impl Item { Item::Reflect| Item::ReflectPlus | Item::ReflectPlusPlus => format!( - "Reflect incoming blue skills to source. Lasts {:?}T. + "Reflect incoming blue skills to source. Lasts {:?}T. Recharges target BlueLife based on {:?}% BluePower.", self.into_skill().unwrap().effect()[0].get_duration(), self.into_skill().unwrap().multiplier()), @@ -943,6 +943,11 @@ impl Item { } } + // !!!!!! + // IF YOU CHANGE A COMBO + // BE SURE TO EDIT BUTTONS.JSX TOO + // !!!!!! + fn combo(&self) -> Vec { match self { Item::Intercept => vec![Item::Buff, Item::Red, Item::Red], From e29ce1e30cef39a71b4083af2e6f781661318b2c Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 4 Nov 2019 17:36:04 +1000 Subject: [PATCH 21/67] firefox drag --- client/src/components/instance.constructs.jsx | 5 ++++- client/src/components/vbox.component.jsx | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/components/instance.constructs.jsx b/client/src/components/instance.constructs.jsx index ed43f62e..d3844294 100644 --- a/client/src/components/instance.constructs.jsx +++ b/client/src/components/instance.constructs.jsx @@ -153,7 +153,10 @@ function Construct(props) { const classes = `${equipping ? 'equipping' : ''} ${!skill ? 'empty' : ''} ${border()}`; return ( -