From 1510db69af6e67a538bf4d05b5ba6aaefd57e1b2 Mon Sep 17 00:00:00 2001 From: Navruc Dimitri Alexis Date: Thu, 4 Mar 2021 20:57:08 +0200 Subject: [PATCH] Partial code documentation in native language Project pretty functional no critical errors to take care of, just code stuff. Keep in mind this is an international project so most of the code is in english but dev comments are in our native language. (Romanian) --- engine.js | 28 ++++++++++++++++++---------- index.html | 2 +- libs/InteractionHandler.js | 1 + libs/countup.js | 23 +++++++++++++++-------- libs/isMobile.min.js | 2 +- libs/tinygesture.js | 1 + libs/tock.js | 1 + supplementary.js | 2 +- 8 files changed, 39 insertions(+), 21 deletions(-) diff --git a/engine.js b/engine.js index a9b3bba..ee174b2 100644 --- a/engine.js +++ b/engine.js @@ -6,7 +6,7 @@ let $playfield = document.querySelector(".playfield"), }; let mobile = isMobile().any; -//fuck citar +// main kbd = desktop keyboard lista de posibilitati combinatii let Password = { current: [], @@ -28,7 +28,7 @@ let Password = { solved() { return Password.current.every((cell) => cell.solved); }, - +// modul generare combinatii generate() { let keys = Password.type ? Array.through(Game.difficulty.length, 1) @@ -52,10 +52,10 @@ let Game = { timer: null, countup: null, - +// de aici se poate ajusta dificultatea in functie de timp si lungime string difficulty: { - time: 5, //5 def - length: 8, //8 def + time: 5, //5 default + length: 8, //8 default set: { time(value) { @@ -145,13 +145,16 @@ let Game = { Game.status = "ongoing"; }, +// Triggers pentru eventuri +//fs lose lose() { $playfield.classList.add("failed"); Game.status = "lost"; }, + //fs succeed succeed() { let reward = (Game.difficulty.length / Game.difficulty.time) * 20; @@ -160,6 +163,7 @@ let Game = { Game.resolve(); }, + //fs start start() { Game.score.reset(); @@ -170,6 +174,7 @@ let Game = { $score.classList.add("visible"); }, + //fs pause pause() { Game.timer.pause(); @@ -178,6 +183,7 @@ let Game = { Game.status = "paused"; }, + //fs unpause unpause() { Game.timer.unpause(); @@ -185,7 +191,9 @@ let Game = { Game.status = "ongoing"; }, - +/* Formula pentru key-uri gresite: + * penalty == ( / 10) == ( * 100) + */ foul() { let penalty = Game.difficulty.time * 100; @@ -202,7 +210,7 @@ let Game = { save() {}, }; - +// actiuni/event-uri let ActionHandler = { _pressed: [], @@ -217,7 +225,7 @@ let ActionHandler = { action[Game.status](); }, - +// mobile things TODO: de schimbat swipe down in instantele chrome mobile forteaza 2 actiuni, una dintre acestea este refresh. swipeup() { let action = { initial: Game.start, @@ -229,7 +237,7 @@ let ActionHandler = { action[Game.status](); }, - +// FIXME: de rectificat (vezi TODO de mai sus) swipedown() { if (Game.status == "ongoing") Game.pause(); }, @@ -375,7 +383,7 @@ let handler = new InteractionHandler(); handler.register("keydown", { key: "space" }, ActionHandler.contextual); handler.register("keydown", { key: "mod" }, Game.settings); - +// in caz de apasari accidentale anti-foul module handler.register("keydown", { key: "shift" }, function () { /* noop */ }); diff --git a/index.html b/index.html index 79c9fe9..661952e 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@
passwd
- +
diff --git a/libs/InteractionHandler.js b/libs/InteractionHandler.js index c204b64..a53176f 100644 --- a/libs/InteractionHandler.js +++ b/libs/InteractionHandler.js @@ -150,3 +150,4 @@ class InteractionHandler { return response; } } +//responsabil pentru transmutarea actiunilor desktop->mobile \ No newline at end of file diff --git a/libs/countup.js b/libs/countup.js index a88e133..d2ad23c 100644 --- a/libs/countup.js +++ b/libs/countup.js @@ -27,7 +27,7 @@ class CountUp { suffix: "", }; - instance.finalEndVal = null; + instance.finalEndVal = null; //easing instance.easing = true; instance.countDown = false; instance.error = ""; @@ -40,7 +40,7 @@ class CountUp { var progress = timestamp - instance.startTime; instance.remaining = instance.duration - progress; - +//if easing vezi #30 if (instance.easing) { if (instance.countDown) { instance.frameVal = @@ -60,6 +60,7 @@ class CountUp { ); } } else { + //ATENTIE! nu merge mai mult decat endVal pt ca progresu' poate depasii timer in ultimu' frame if (instance.countDown) { instance.frameVal = instance.startVal - @@ -84,22 +85,24 @@ class CountUp { ? instance.endVal : instance.frameVal; } - +//punct decimal instance.frameVal = Math.round(instance.frameVal * instance.decimalMult) / instance.decimalMult; - +//formatare si afisare valoare instance.printValue(instance.frameVal); - +//continua? if (progress < instance.duration) { instance.rAF = requestAnimationFrame(instance.count); } else if (instance.finalEndVal !== null) { + //easing #30 instance.update(instance.finalEndVal); } else if (instance.callback) { instance.callback(); } }; + //format simplu si functii easing instance.formatNumber = function (num) { var neg = num < 0 ? "-" : ""; @@ -108,7 +111,7 @@ class CountUp { let result = Math.abs(num) .toFixed(instance.options.decimalPlaces) .toString(); - + //result += ''; let x = result.split("."); let x1 = x[0]; @@ -126,7 +129,7 @@ class CountUp { x1 = x3; } - + //instanta opt. de substitutie 'numerals' if (instance.options.numerals && instance.options.numerals.length) { x1 = x1.replace(/[0-9]/g, function (w) { return instance.options.numerals[+w]; @@ -182,6 +185,7 @@ class CountUp { } } + //determina unde incepe smart easing si daca numara crescator sau descrescator determineDirectionAndSmartEasing() { var end = this.finalEndVal ? this.finalEndVal : this.endVal; @@ -209,6 +213,7 @@ class CountUp { } } + //incepe animatia start(callback) { if (this.error) return; @@ -223,6 +228,7 @@ class CountUp { } } + //mai multa animatie :P (self explanatory) pauseResume() { if (!this.paused) { cancelAnimationFrame(this.rAF); @@ -238,7 +244,7 @@ class CountUp { this.paused = !this.paused; } - +//se resetaza catre startVal ca animatia sa poata fi reluata reset() { cancelAnimationFrame(this.rAF); @@ -249,6 +255,7 @@ class CountUp { this.printValue(this.startVal); } + //updateaza endVal si incepe animatia update(newEndVal) { cancelAnimationFrame(this.rAF); diff --git a/libs/isMobile.min.js b/libs/isMobile.min.js index c7207d5..30e4575 100644 --- a/libs/isMobile.min.js +++ b/libs/isMobile.min.js @@ -114,4 +114,4 @@ function isMobile(a) { f ); } -//TODO: Ineficient, check browser modifiers OS code similar to AdGuard browser obfuscator +// Fitty detection, putin modificat, acest modul regleaza modul de joc in functie de device-ul de pe care este accesat site-ul \ No newline at end of file diff --git a/libs/tinygesture.js b/libs/tinygesture.js index 7ad8111..8179741 100644 --- a/libs/tinygesture.js +++ b/libs/tinygesture.js @@ -235,3 +235,4 @@ try { }) ); } catch (err) {} +//TODO: def actiuni tap,longpress etc... \ No newline at end of file diff --git a/libs/tock.js b/libs/tock.js index a51680a..02b6a25 100644 --- a/libs/tock.js +++ b/libs/tock.js @@ -1,3 +1,4 @@ +//Tock este implementat din libraria publica accesibila aici: https://github.com/mrchimp/tock [Tock este un "ceas" cu functie de tip countdown/timer] let delta = function (source = 0) { return Date.now() - source; }; diff --git a/supplementary.js b/supplementary.js index 77eb3b8..71005cf 100644 --- a/supplementary.js +++ b/supplementary.js @@ -48,7 +48,7 @@ Array.through = function (length = 0, from = 0, step = 1) { (item, index) => from + index * step ); }; - +// String.prototype.belongsTo = function (array) { return array.includes(this.valueOf()) }; Object.prototype.belongsTo = function (array) { return array.includes(this.valueOf()); };