e15c6299c2
Update .gitignore, LICENSE, and 6 more files...
259 lines
8.7 KiB
C#
259 lines
8.7 KiB
C#
using System.Globalization;
|
|
using ESCPOS_NET;
|
|
using ESCPOS_NET.Emitters;
|
|
using ESCPOS_NET.Utilities;
|
|
|
|
namespace NibblePoker.GoatseReceipt;
|
|
|
|
internal static class Program {
|
|
private const string PrinterPort = "COM10";
|
|
private const int PrinterBaudRate = 38400;
|
|
|
|
private static readonly string[] AdresseRues = [
|
|
"Route de Luxembourg" // Route connue depuis 30+ ans dans la région
|
|
];
|
|
|
|
private static readonly string[] AdresseNumeros = [
|
|
"Dans les fougeres",
|
|
"Hute du fermier",
|
|
"La grange",
|
|
"Ma boite a malice",
|
|
"Votre voiture"
|
|
];
|
|
|
|
private static readonly string[] FauxSites = [
|
|
// 1 entrée censurée
|
|
"gourgandine.be",
|
|
"gourgandineries.be",
|
|
"prostipute.be"
|
|
];
|
|
|
|
private static readonly string[] NomDeFilleDeJoie = [
|
|
"Crystalle",
|
|
"Mariette",
|
|
"Crystalle"
|
|
];
|
|
|
|
private static readonly string[] Monnaies = [
|
|
"vbucks",
|
|
"robux",
|
|
"euros"
|
|
];
|
|
|
|
private static readonly string[][] ActesPrincipaux = [
|
|
["Un p'tit wrap", "7.60"],
|
|
["Limace baveuse", "50.00"],
|
|
["Turlutte", "25.00"],
|
|
["Helicoptere Bulgare", "75.00"],
|
|
["Kama-trouee", "30.00"],
|
|
["Pelure d'oignon", "30.00"],
|
|
["Ouverture boite a malice", "60.00"],
|
|
["P'tit classique", "20.00"],
|
|
["Lechouille de velour", "35.00"]
|
|
];
|
|
|
|
private static readonly string[][] ActesSecondaires = [
|
|
["Pastille pour l'haleine", "2.99"],
|
|
["Service de nuit", "25.00"],
|
|
["Supplement mouille", "5.00"],
|
|
["Pause cloppe", "10.00"],
|
|
["Mouchoir pour larmes", "5.00"],
|
|
["Tour de magie", "7.50"],
|
|
["Pre-lavage de la fosse", "25.00"],
|
|
["Mots doux", "5.00"],
|
|
["Odeur de camioneuse", "5.00"],
|
|
["Canette de Carapils", "1.50"],
|
|
["Brossage de criniere", "7.50"],
|
|
["Supplement dents", "-2.50"],
|
|
["Parfum poissoniere", "2.50"],
|
|
["Parfum note brune", "7.50"],
|
|
["Supplement griffe", "7.50"]
|
|
];
|
|
|
|
private static void Main(string[] _) {
|
|
Console.WriteLine("Preparing stuff...");
|
|
|
|
var printer = new SerialPrinter(portName: PrinterPort, baudRate: PrinterBaudRate);
|
|
var e = new EPSON();
|
|
|
|
Random rand = new Random();
|
|
|
|
|
|
Console.WriteLine("Printing...");
|
|
|
|
// En-tête mis à part car l'image cause beaucoup de soucis dans la librairie...
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.SetStyles(PrintStyle.None),
|
|
e.CenterAlign(),
|
|
e.PrintImage(File.ReadAllBytes("./logo01.png"), true, maxWidth: 480),
|
|
e.PrintLine(""),
|
|
e.CodePage(CodePage.ISO8859_2_LATIN2),
|
|
|
|
e.PrintLine("Vas-y S.P.R.L"),
|
|
e.PrintLine(AdresseRues[rand.Next(AdresseRues.Length)] + ", " + AdresseNumeros[rand.Next(AdresseNumeros.Length)]),
|
|
e.PrintLine("6700 Arlon, Belgique"),
|
|
|
|
// Numéro original censuré
|
|
e.PrintLine("+32 00 00 00 00 / +32 00 00 00 00"),
|
|
|
|
e.PrintLine("Remboursement uniquement en liquide"),
|
|
e.PrintLine("Conditions sur " + FauxSites[rand.Next(FauxSites.Length)]),
|
|
e.PrintLine(""),
|
|
|
|
e.LeftAlign(),
|
|
e.PrintLine(" Caissier/ere N° Date Heure"),
|
|
e.PrintLine(" " + NomDeFilleDeJoie[rand.Next(NomDeFilleDeJoie.Length)].PadRight(21) +
|
|
$"{rand.Next(8999) + 1000} {rand.Next(20) + 10}/{rand.Next(2) + 7}/25 {rand.Next(5) + 18}:{rand.Next(49) + 10}"),
|
|
e.PrintLine(""),
|
|
e.PrintLine(" -----------------------------------------")
|
|
)
|
|
);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.Clear()
|
|
)
|
|
);
|
|
|
|
|
|
// En-tête des colonnes avec le détail des "articles"
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.SetStyles(PrintStyle.None),
|
|
e.PrintLine(""),
|
|
e.SetStyles(PrintStyle.Condensed | PrintStyle.None),
|
|
e.CenterAlign(),
|
|
e.PrintLine("Ticket de caisse"),
|
|
e.SetStyles(PrintStyle.None),
|
|
//e.PrintLine(""),
|
|
e.LeftAlign(),
|
|
e.PrintLine(" Description Qte Montant"),
|
|
e.PrintLine(" EUR"),
|
|
e.CenterAlign(),
|
|
e.PrintLine(" -----------------------------------------")
|
|
)
|
|
);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.Clear()
|
|
)
|
|
);
|
|
|
|
|
|
// Impression des articles, et calcul du prix total
|
|
void PrintArticle(string nom, string prix) {
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.LeftAlign(),
|
|
e.PrintLine(
|
|
" " + nom.PadRight(27) +
|
|
" 1" + prix.PadLeft(11)
|
|
)
|
|
)
|
|
);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.Clear()
|
|
)
|
|
);
|
|
}
|
|
|
|
double total = 0.00;
|
|
|
|
int iArticle = rand.Next(ActesPrincipaux.Length);
|
|
total += Double.Parse(ActesPrincipaux[iArticle][1].Replace(".", ","));
|
|
PrintArticle(ActesPrincipaux[iArticle][0], ActesPrincipaux[iArticle][1]);
|
|
|
|
int nbSupplements = rand.Next(3 - 1) + 2;
|
|
var lSupplements = ActesSecondaires.Select(inner => inner).ToList();
|
|
|
|
for(int i = 0; i < nbSupplements; i++) {
|
|
int iSupplement = rand.Next(lSupplements.Count);
|
|
string[] sipplementItem = lSupplements[iSupplement];
|
|
total += Double.Parse(sipplementItem[1].Replace(".", ","));
|
|
PrintArticle(sipplementItem[0], sipplementItem[1]);
|
|
lSupplements.RemoveAt(iSupplement);
|
|
}
|
|
|
|
|
|
// Impression du total HTVA, TVA et TTC
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.LeftAlign(),
|
|
e.PrintLine(" -----------------------------------------"),
|
|
e.PrintLine(" TOTAL HTVA".PadRight(31) + $"{total.ToString("F2", CultureInfo.InvariantCulture)}".PadLeft(11)),
|
|
e.PrintLine(" TVA (21%)".PadRight(31) + $"{(total * 0.12).ToString("F2", CultureInfo.InvariantCulture)}".PadLeft(11)),
|
|
e.PrintLine(""),
|
|
e.SetStyles(PrintStyle.Bold),
|
|
e.PrintLine(" TOTAL TTC".PadRight(31) + $"{(total * 1.12).ToString("F2", CultureInfo.InvariantCulture)}".PadLeft(11)),
|
|
e.SetStyles(PrintStyle.None),
|
|
e.PrintLine(" -----------------------------------------")
|
|
)
|
|
);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.Clear()
|
|
)
|
|
);
|
|
|
|
|
|
// Petit texte sur les points de fidélité
|
|
int ptsInitial = rand.Next(250);
|
|
int ptsNouveau = rand.Next(25);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.PrintLine(""),
|
|
e.SetStyles(PrintStyle.Condensed | PrintStyle.None),
|
|
e.CenterAlign(),
|
|
e.PrintLine("Programme fidelite"),
|
|
e.SetStyles(PrintStyle.None),
|
|
e.LeftAlign(),
|
|
e.PrintLine(" Solde initial".PadRight(31) + $"{ptsInitial}".PadLeft(11)),
|
|
e.PrintLine(" Points epargnees".PadRight(31) + $"{ptsNouveau}".PadLeft(11)),
|
|
e.PrintLine(" Solde final".PadRight(31) + $"{ptsInitial + ptsNouveau}".PadLeft(11)),
|
|
e.PrintLine(""),
|
|
e.CenterAlign(),
|
|
e.SetStyles(PrintStyle.Italic),
|
|
e.PrintLine("Une MST offerte par tranche de 150 points"),
|
|
e.PrintLine($"Et une taxe de 75 {Monnaies[rand.Next(Monnaies.Length)]} tous les 350"),
|
|
e.PrintLine("points pour un avortement"),
|
|
e.LeftAlign(),
|
|
e.PrintLine(" -----------------------------------------")
|
|
)
|
|
);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.Clear()
|
|
)
|
|
);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.CenterAlign(),
|
|
e.PrintLine(""),
|
|
e.FullCutAfterFeed(1)
|
|
)
|
|
);
|
|
|
|
printer.Write(
|
|
ByteSplicer.Combine(
|
|
e.Clear()
|
|
)
|
|
);
|
|
|
|
Console.WriteLine("Done :)");
|
|
|
|
|
|
// Printing tends to fail if we directly exit, go figure...
|
|
while(true) {
|
|
//Thread.Sleep(10);
|
|
}
|
|
}
|
|
}
|