Corpus-Cypher-Executable/cce/Program.cs

148 lines
5.5 KiB
C#
Raw Normal View History

2022-04-18 00:09:42 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.IO;
using System.Windows.Forms;
using static System.Console;
using static System.Threading.Thread;
namespace cce {
class Program {
static internal string title = "Corpus Cypher Executable (CCE)";
2022-04-18 14:53:21 +00:00
[STAThread]
2022-04-18 00:09:42 +00:00
static void Main(string[] args) {
byte choice = 255;
while (true) {
SetBufferSize(240, 60);
SetWindowSize(120, 30);
Clear();
CursorVisible = false;
Utils.LagWrite("Welcome to the " + title, true);
//WriteLine("Welcome to the Corpus cypher executable.");
WriteCrypto();
if (choice == 255) choice = Chooser();
CursorVisible = false;
var entry = "";
if ((new int[] {1,2}).Contains(choice)) {
Utils.LagWrite("Please enter the sentence: ");
CursorVisible = true;
//Write("Please enter the sentence: ");
entry = ReadLine();
CursorVisible = false;
}
if (choice == 1) { Transcoder.Encode(entry); Utils.Clip(Transcoder.result); }
else if (choice == 2) Transcoder.Decode(entry);
else if (choice == 5) Transcoder.Teacher();
else if (choice == 9) Transcoder.head_transcribe();
else if (choice == 255) Help();
else if (choice == 0) { Beep(4000, 200); return; }
SetCursorPosition(0, WindowHeight - 2);
Utils.LagWrite("\nPress enter to continue, press any other key to exit"); CursorVisible = false;
var cki = ReadKey();
choice = 255;
var options = new char[] { '0','1','2','3','4','9'};
if (options.Contains(cki.KeyChar)) choice = byte.Parse(cki.KeyChar.ToString());
else if (cki.Key != ConsoleKey.Enter) break;
}
}
static byte Chooser() {
while (true) {
Utils.LagWrite("[1] Encode"
+"\n[2] Decode"
+"\n-------------------------"
+"\n[5] Teach new words"
+"\n-------------------------"
2022-04-18 14:53:21 +00:00
+"\n[8] Settings"
2022-04-18 00:09:42 +00:00
+"\n[9] DEV: Update JSON files using sorted files from python"
2022-04-18 14:53:21 +00:00
+"\n[?] Help"
2022-04-18 00:09:42 +00:00
+"\n[0] Exit"
+"\n>>> ");
/*Write(@"Options?
[1] Encode
[2] Decode
-------------------------
[5] Teach new words
-------------------------
[9] DEV: Update JSON files using sorted files from python
[0] Exit
>> ");*/
CursorVisible = true;
var choice = ReadKey().KeyChar;
WriteLine();
switch (choice) {
case '1':
case '2':
case '5':
case '9':
2022-04-18 14:53:21 +00:00
case '8':
2022-04-18 00:09:42 +00:00
case '0':
case '?':
case '/':
case '-':
case ',':
if ((new char[] { '?','/','-',','}).Contains(choice)) return 255;
return byte.Parse(choice.ToString());
default:
WriteLine("Not a valid option");
break;
}
}
}
static void WriteCrypto()
{
var pos = (CursorLeft, CursorTop);
var crypto = new string[] {"###########################",
"# #",
"# Corpus Cypher #",
"# #",
"###########################",
"# ENG = COR #",
"# A = A G = J M = S #",
"# B = T H = K N = T #",
"# C = Y I = I O = O #",
"# D = P J = T P = K #",
"# E = E K = K Q = R #",
"# F = T L = P R = T #",
"# #",
"# S = Y W = J #",
"# T = P X = K #",
"# U = U Y = Y #",
"# V = T Z = B #",
"# #",
"###########################"};
for (int i = 0; i < crypto.Length; i++)
{
CursorTop = i + 2;
CursorLeft = WindowWidth - crypto[i].Length - 2;
foreach (char c in crypto[i]) {
Write(c);
2022-04-18 14:53:21 +00:00
if (Utils.rng.NextDouble()>0.8 && c != ' ') Sleep(1);
2022-04-18 00:09:42 +00:00
}
}
SetCursorPosition(pos.CursorLeft, pos.CursorTop);
}
static void Help() {
Clear();
var help = $@"Welcome to help for {title}
This executable was made to help you encrypt something into the Corpus Cypher
and to give you idea of what the person on the other end was trying to say.
This executable isn't fool proof and some mistakes in the code might've slipped
through my fingers. Still I hope it is atleast somewhat useful.
Encoding: Encoded text takes on the capitalization of the entered text.
Decoding: Decoded text takes on the capitalization of the entered text.
Teaching: First you enter in the encrypted word and then you give it the translation. It will remember the word.";
help = help.Replace("\r\n", "\n");
Utils.LagWrite(help);
}
}
}