Skip to content

Commit

Permalink
Update RuleMorse.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
TMBilalTM authored Aug 6, 2024
1 parent 3355735 commit 2594ea0
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions rules/RuleMorse/RuleMorse.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
import Rule from "../Rule";

const morse = {
a: ".-", b: "-...", c: "-.-.", d: "-..", e: ".", f: "..-.", g: "--.", h: "....",
i: "..", j: ".---", k: "-.-", l: ".-..", m: "--", n: "-.", o: "---", p: ".--.",
q: "--.-", r: ".-.", s: "...", t: "-", u: "..-", v: "...-", w: ".--", x: "-..-", y: "-.--", z: "--.."
}

export default class RuleMorse extends Rule{
constructor(){
super("Şifrenizde ilk 3 İngilizce alfabenin Mors kodu bulunmalıdır. (. ve - kullanın)");
export default class RuleMorse extends Rule {
constructor() {
super("Şifrenizde 12. ve 14. elementlerin birleşimi olmalıdır ifadesi bulunmalıdır.");
}

check(txt){
let letters = txt.match(/[A-Za-z]/g)?.slice(0, 3);

if (letters?.length === 3) {
let code = `${morse[letters[0].toLowerCase()]} ${morse[letters[1].toLowerCase()]} ${morse[letters[2].toLowerCase()]}`;
let exp = code.replace(/\./g, "\\.").replace(/-/g, "\\-");

console.log("morse:", exp);
let r = new RegExp(exp);

check(txt) {
// Şifreyi küçük harfe çevir
const lowerTxt = txt.toLowerCase();

return r.test(txt);
}
return false;
// İlgili ifadeleri kontrol et
return (
lowerTxt.includes("mgsi") ||
lowerTxt.includes("magnezyumsilisyum") ||
txt.includes("MgSi") ||
txt.includes("MAGNEZYUMSILISYUM")
);
}
}

0 comments on commit 2594ea0

Please sign in to comment.