using System; using System.Drawing; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; using System.Windows.Forms; using das.login; using das.hra; using das.sit; using System.Collections; using System.Drawing.Drawing2D; using System.Timers; namespace das.gui { public static class t { private static Hashtable shluky_pismen = new Hashtable(); public static string _(string s) { s = s.Trim(); try { string r = (string)shluky_pismen[s.Trim()]; if (r == "") { return s; } else { return r; } } catch { return s; } } static t() { shluky_pismen["one"] = "One"; shluky_pismen["two"] = "Two"; shluky_pismen["tri"] = "Thirteen"; shluky_pismen["stoupls na ciziho kone"] = "Stoupnul jsi na koně protivníka"; shluky_pismen["stoupls na sveho kone"] = "Stoupnul jsi na svého koně"; shluky_pismen["Stoupl jsi na volneho kone"] = "Kůň bez majitele, chceš jej koupit?"; shluky_pismen["koupim dostih"] = "Koupím dostih"; shluky_pismen["Nemas celou staj"] = "Nemáš kompetní stáj, nelze koupit dostih"; shluky_pismen["Akceptuji"] = "Akceptuji"; shluky_pismen["Nekupuji"] = "Nechci koupit"; shluky_pismen["platim trenink"] = "Zaplatím za trénink"; shluky_pismen["Koupit prepravu"] = "Chceš koupit přepravu?"; shluky_pismen["kupuji prepravu"] = "Kupuji Přepravu"; shluky_pismen["Nekupuji"] = "Nechci koupit"; shluky_pismen["Koupit staje"] = "Chceš koupit stáje?"; shluky_pismen["kupuji staje"] = "Chci koupit stáje"; shluky_pismen["Nekupuji"] = "Nechci koupit"; shluky_pismen["Nahoda"] = "Náhoda"; shluky_pismen["Mas distanc\n pokracujes pote co hodis 6\n"] = "Máš distanc\n pokračuj poté, co hodíš 6\n"; shluky_pismen["Budiz"] = "Budiž"; shluky_pismen["ZAPLAT!!!"] = "Zaplať poplatek"; shluky_pismen["zaplatim"] = "Zaplatím"; shluky_pismen["kone:\n"] = "Koně:"; shluky_pismen["Nekupuj a pokracuj"] = "Nekupuj a pokračuj"; shluky_pismen["Kup kone"] = "Koupím koně"; shluky_pismen["Pokracujes"] = "Pokračuj ve hře"; shluky_pismen["pokracujes"] = "Pokračuj ve hře"; shluky_pismen["Hozeno"] = "Padla"; shluky_pismen["Hazej"] = "Hoď kostkou"; shluky_pismen["mas distanc"] = "Máš distanc"; shluky_pismen["ok"] = "ok"; shluky_pismen["Koupils kone"] = "Koupil jsi koně"; shluky_pismen["uloz"] = "Ulož hru"; shluky_pismen["nacti"] = "Načti hru"; shluky_pismen["Hra"] = "Hra"; shluky_pismen["Kone"] = "Koně"; shluky_pismen["Ostatni"] = "Ostatní"; shluky_pismen["zaplatim za trenera"] = "Zaplať za trenéra"; shluky_pismen["platim trenink"] = "Platím trénink"; shluky_pismen["zaplatim za prepravu"] = "Zaplať za přepravu"; shluky_pismen["platim za prepravu"] = "Platím přepravu"; shluky_pismen["zaplatim za staje"] = "Zaplať za ustájení"; shluky_pismen["platim staje"] = "Platím za ustájení"; shluky_pismen["pujceno"] = "Dostal jsi vypůjčené peníze"; shluky_pismen["zprava od banky"] = "Zpráva od banky"; shluky_pismen["dosli penize"] = "Banka již nedisponuje hotovostí"; shluky_pismen["nechci"] = "Děkuji, nemám zájem"; shluky_pismen["prodej koni"] = "Prodej koní:"; shluky_pismen["prodej sluzeb"] = "Prodej služeb:"; shluky_pismen["Vita"] = "Vítá Vás aplikace DAS, Dostihy a sázky"; shluky_pismen["nabidka kone"] = "Nabídka koně"; shluky_pismen["nabidka sluzby"] = "Nabídka služby"; shluky_pismen["chces koupit kone?"] = "Chceš koupit koně?"; shluky_pismen["chces koupit sluzbu?"] = " Chceš koupit službu?"; shluky_pismen["jmeno"] = "Jméno"; shluky_pismen["cekejte"] = "Čekejte"; shluky_pismen["majitel"] = "Majitel"; shluky_pismen["poplatek"] = "Poplatek"; shluky_pismen["staj"] = "Stáj"; shluky_pismen["oranzova"] = "Oranžová"; shluky_pismen["hneda"] = "Hnědá"; shluky_pismen["modra"] = "Modrá"; shluky_pismen["svetlezelena"] = "Světle zelená"; shluky_pismen["cervena"] = "Červená"; shluky_pismen["zluta"] = "Žlutá"; shluky_pismen["zelena"] = "Zelená"; shluky_pismen["fialova"] = "Fialová"; shluky_pismen["chces skoncit"] = "Chceš se vzdát a ukončit hru?"; shluky_pismen["chces skoncit server"] = "Chceš zastavit server a ukončit hru?"; shluky_pismen["kupuji trenera"] = "Koupím trenéra"; shluky_pismen["cena"] = "Cena"; shluky_pismen["poplatek dostih"] = "Poplatek za dostih"; shluky_pismen["poplatek dostih hlavni"] = "Poplatek za hlavní dostih"; shluky_pismen["ma celou staj"] = "Máš celou stáj"; shluky_pismen["1"] = "Ano"; shluky_pismen["0"] = "Ne"; shluky_pismen["koupit trenera"] = "Chceš koupit trenéra?"; shluky_pismen["trener cislo"] = "Trenér číslo"; shluky_pismen["zahajena hra"] = "Hra byla zahájena, hodně štěstí"; shluky_pismen["server zabit"] = "Server byl ukončen, hra také končí"; shluky_pismen["vzdal se"] = "Vzdal se hráč číslo "; //info hlasky shluky_pismen["ceka na tah"] = "Hráč čeká na tah"; shluky_pismen["stoupl na nahodu"] = "Stoupnul na Náhodu"; shluky_pismen["stoupl na finance"] = "Stoupnul na Finance"; shluky_pismen["ma distanc"] = "Má distanc"; shluky_pismen["tahne znovu"] = "Táhne znovu"; shluky_pismen["stoupl na veterinu"] = "Podstoupil veterinární vyšetřen"; shluky_pismen["koupil prepravu"] = "Koupil přepravu"; shluky_pismen["stoupl na prepravu"] = "Nechal se přepravit"; shluky_pismen["stoupl na staje"] = "Nechal se ustájit"; shluky_pismen["stoupl na trenera"] = "Trénuje"; shluky_pismen["koupil trenera"] = "Koupil trenéra"; shluky_pismen["stoupl na kone"] = "Stoupnul na koně"; shluky_pismen["stoupl na ciziho kone"] = "Prohlíží si stáje"; shluky_pismen["koupil dostih"] = "Koupil dostih"; shluky_pismen["koupil kone"] = "Koupil koně"; shluky_pismen["stoupl na nahodu"] = "Stoupnul na náhodu"; shluky_pismen["zaplatil"] = "Zaplatil"; shluky_pismen["plati za trenink"] = "Zaplatil za trénink"; shluky_pismen["koupil prepravu"] = "Koupil přepravu"; shluky_pismen["koupil staje"] = "Koupil stáje"; shluky_pismen["plati za staje"] = "Zaplatil za ustájení"; shluky_pismen["ceka na tah"] = "čeká na tah"; } } public class bod { public int x; public int y; public Color barva; public bod(int xx, int yy) { x = xx; y = yy; } } public class popiska { public bod b; public int hodnota; public popiska(bod x, Color c, int xx) { b = new bod(x.x, x.y); b.barva = c; hodnota = xx; } } public class TabPage2:TabPage { // SolidBrush b = new SolidBrush(Color.MidnightBlue); Image im; // Font f; bod[] panacek; bod[] konicek; popiska[] popisecka; bod[] sluzbicka; bod[] hazardicek; public TabPage2(string jmeno_packy, bod[] pan, bod[] kun, popiska[] pop, bod[] sluzba, bod[] sazky) { this.Text = jmeno_packy; // Color cB = Color.LightGray; string path = "plocha.jpg"; // b = new SolidBrush(cB); panacek = pan; konicek = kun; popisecka = pop; sluzbicka = sluzba; hazardicek = sazky; try { im = Image.FromFile(path); } catch { MessageBox.Show(this,"nemam "+path, "DAS", MessageBoxButtons.YesNo); Environment.Exit(1); } //f = new Font(new FontFamily("Times New Roman"), 10); this.BackColor = SystemColors.Control; } public void DrawCircle(Graphics g, int x, int y, int r, Color color) { int start = x - r; int end = y - r; int d = r + r; SolidBrush redBrush = new SolidBrush(color); g.FillEllipse(redBrush, start, end, d, d); } private PointF[] StarPoints(int pocet_bodu, Rectangle hranice) { PointF[] bdy = new PointF[pocet_bodu]; double rx = hranice.Width / 2; double ry = hranice.Height / 2; double cx = hranice.X + rx; double cy = hranice.Y + ry; double theta = -Math.PI / 2; double dtheta = 4 * Math.PI / pocet_bodu; for (int i = 0; i < pocet_bodu; i++) { bdy[i] = new PointF( (float)(cx + rx * Math.Cos(theta)), (float)(cy + ry * Math.Sin(theta))); theta += dtheta; } return bdy; } private void SketchDBuf() { int hh = 5, w = 600, h = 600; int posunx = 0, posuny = 0; SolidBrush hodnotabrush; Graphics g; Pen pen; GraphicsPath gp = new GraphicsPath(); Bitmap bm = new Bitmap(w + 2*hh, h + 2*hh); g = Graphics.FromImage(bm); g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.DrawImage(im, hh, hh, 600, 600); for (int i = 0; i < 6; i++) { switch (i) { case 1:posunx = -1; posuny = -1; break; case 2:posunx = 1; posuny = -1; break; case 3:posunx = -1; posuny = 0; break; case 4:posunx = 1; posuny = 0; break; case 5:posunx = -1; posuny = 1; break; case 6:posunx = 1; posuny = -1; break; } if (panacek[i].x == 0) {continue;} DrawCircle(g, panacek[i].x + posunx*3, panacek[i].y + posuny*3, 6, Color.MidnightBlue); DrawCircle(g, panacek[i].x + posunx*3, panacek[i].y + posuny*3, 5, panacek[i].barva); } for (int i = 0; i < 22; i++) { //sazky if (hazardicek[i].x == 0) {continue;} //nevsazeno Rectangle okolo = new Rectangle(hazardicek[i].x, hazardicek[i].y, 20, 20); PointF[] bdy = StarPoints(5, okolo); pen = new Pen(Color.FromArgb(255, 0, 255, 0), 3); g.DrawPolygon(pen, bdy); pen = new Pen(Color.MidnightBlue, 1); g.DrawPolygon(pen, bdy); } //nakresli staje, preprava, trener1 2 3 4 for (int i = 0; i < 6; i++) { if (sluzbicka[i].x == 0 && sluzbicka[i].barva == Color.Pink) {continue;} DrawCircle(g, sluzbicka[i].x, sluzbicka[i].y-3, 8, Color.White); DrawCircle(g, sluzbicka[i].x, sluzbicka[i].y-3, 7, Color.MidnightBlue); DrawCircle(g, sluzbicka[i].x, sluzbicka[i].y-3, 6, sluzbicka[i].barva); } //nakresli kone for (int i = 0; i < 22; i++) { if (konicek[i].x > 0 && konicek[i].barva != Color.Empty) { DrawCircle(g, konicek[i].x, konicek[i].y, 8, Color.Turquoise); DrawCircle(g, konicek[i].x, konicek[i].y, 7, Color.MidnightBlue); DrawCircle(g, konicek[i].x, konicek[i].y, 6, konicek[i].barva); } if (popisecka[i].hodnota > 0) { if (popisecka[i].hodnota < 5) { hodnotabrush = new SolidBrush(Color.Yellow); } else { hodnotabrush = new SolidBrush(Color.Red); } //popisky dostihy gp.AddString( (popisecka[i].hodnota).ToString(), new FontFamily("Verdana"), (int)FontStyle.Bold, 20, new Point(konicek[i].x, konicek[i].y), StringFormat.GenericTypographic ); g.FillPath(hodnotabrush, gp); g.DrawPath(Pens.Black, gp); hodnotabrush.Dispose(); } } //nakresli do okna g = Graphics.FromHwnd(this.Handle); g.DrawImage(bm, 1, 1); g.Dispose(); gp.Dispose(); } protected override void OnPaint(PaintEventArgs e) { SketchDBuf(); } } public class herni_formular : Form { //atributy private TabControl tabControl1; private static TextBox newText; private static ListBox chat; private static Label label_jmeno; private static Label label_penize; private static Label label_kone_prodej; private static Label label_sluzby_prodej; private static Label label2; private static Socket client; public static Button hazej; public static Button pokracuj; private static Label vysledek_hodu; private static byte[] data = new byte[1024]; Button kup; RichTextBox richTextBox1; Label label_distanc; PictureBox img_distanc; string nadpis = "DAS\n---\n"; GroupBox infogroupbox = new System.Windows.Forms.GroupBox(); Label klabel1 = new System.Windows.Forms.Label(); Label klabel2 = new System.Windows.Forms.Label(); Label klabel3 = new System.Windows.Forms.Label(); Label klabel4 = new System.Windows.Forms.Label(); Label klabel5 = new System.Windows.Forms.Label(); Label klabel6 = new System.Windows.Forms.Label(); Label klabel7 = new System.Windows.Forms.Label(); Label klabel8 = new System.Windows.Forms.Label(); Button[] kbutton = new System.Windows.Forms.Button[8]; ComboBox[] kcombo = new System.Windows.Forms.ComboBox[8]; TextBox[] kcena = new System.Windows.Forms.TextBox[8]; ListBox[] listBox = new ListBox[8]; Label[] infohraci = new Label[6]; CheckBox checkbox_trener1; CheckBox checkbox_trener2; CheckBox checkbox_trener3; CheckBox checkbox_trener4; CheckBox checkbox_staje; CheckBox checkbox_preprava; Button[] sbutton = new System.Windows.Forms.Button[6]; ComboBox[] scombo = new System.Windows.Forms.ComboBox[6]; TextBox[] scena = new System.Windows.Forms.TextBox[6]; Button button_pujcit; Button button_vratit; TextBox textBox_castka; bool server; string pokracuj_string; string kup_string; bod[] panacek = new bod[6]; bod[] konicek = new bod[22]; popiska[] popisecka = new popiska[22]; bod[] sluzbicka = new bod[6]; bod[] hazardicek = new bod[22]; string[] jmena_hracu = new string[6]; int pocet_sazek = 0; // Pen p; // SolidBrush b = new SolidBrush(Color.MidnightBlue); Image im = null; // Font f; string path = "plocha.jpg"; das.hra.trida_manazer manazer; int clovek = 0; int pocitac = 0; string ip; private string jmeno_hrace; private int cislo_hrace; private System.Windows.Forms.GroupBox groupBox_sazky; private System.Windows.Forms.Label label_kone; private System.Windows.Forms.Label label_castka; private System.Windows.Forms.Button button_vsad; private System.Windows.Forms.TextBox textBox_sazka; private System.Windows.Forms.ListBox listBox_kone; Button button_osvobozeni; Button button_konec_hry; Button button_uloz; Button button_nacti; Button button_vzdat_se; bool vzdalse = false; TabPage2 tab_hra; TabPage tab_kone; TabPage tab_karty; int label_koni_zacatek; int label_koni_pozice; //metody public static int pocet_znaku(string s, char c) { int navrat = 0; for (int i = 0; i < s.Length; i ++) { if (s[i] == c) { navrat++; } } return navrat; } //koduj kone public string k_k(string k) { return zpravy.base64Encode(k); } //dekoduj kone public string d_k(string k) { return zpravy.base64Decode(k); } public void vytvor_sazeci_koutek() { groupBox_sazky = new System.Windows.Forms.GroupBox(); label_castka = new System.Windows.Forms.Label(); label_kone = new System.Windows.Forms.Label(); button_vsad = new System.Windows.Forms.Button(); textBox_sazka = new System.Windows.Forms.TextBox(); listBox_kone = new System.Windows.Forms.ListBox(); // // groupBox_sazky // groupBox_sazky.Controls.Add(label_castka); groupBox_sazky.Controls.Add(label_kone); groupBox_sazky.Controls.Add(button_vsad); groupBox_sazky.Controls.Add(textBox_sazka); groupBox_sazky.Controls.Add(listBox_kone); groupBox_sazky.Location = new System.Drawing.Point(30, 180); groupBox_sazky.Name = "groupBox_sazky"; groupBox_sazky.Size = new System.Drawing.Size(189, 256); groupBox_sazky.TabIndex = 0; groupBox_sazky.TabStop = false; groupBox_sazky.Text = "Sázky"; // // label2 // label_castka.AutoSize = true; label_castka.Location = new System.Drawing.Point(12, 161); label_castka.Name = "castka"; label_castka.Size = new System.Drawing.Size(40, 13); label_castka.TabIndex = 4; label_castka.Text = "Částka"; // // label1 // label_kone.AutoSize = true; label_kone.Location = new System.Drawing.Point(12, 25); label_kone.Name = "kone"; label_kone.Size = new System.Drawing.Size(70, 13); label_kone.TabIndex = 3; label_kone.Text = "Seznam koní"; // // button_vsad // button_vsad.Location = new System.Drawing.Point(15, 203); button_vsad.Name = "button_vsad"; button_vsad.Size = new System.Drawing.Size(161, 38); button_vsad.TabIndex = 2; button_vsad.Text = "&Vsaď si"; button_vsad.UseVisualStyleBackColor = true; button_vsad.Click += new System.EventHandler(button_vsad_Click); // // textBox_sazka // textBox_sazka.Location = new System.Drawing.Point(15, 177); textBox_sazka.Name = "textBox_castka"; textBox_sazka.Size = new System.Drawing.Size(161, 20); textBox_sazka.TabIndex = 1; textBox_sazka.Text = "100"; // // listBox_kone // listBox_kone.FormattingEnabled = true; listBox_kone.Location = new System.Drawing.Point(15, 41); listBox_kone.Name = "listBox_kone"; listBox_kone.Size = new System.Drawing.Size(161, 95); listBox_kone.TabIndex = 0; groupBox_sazky.Parent = tab_karty; } public bod vrat_souradnice_vnejsipole(int pole) { bod b = new bod(0,0); switch (pole) { case 1: b.x = 506; b.y = 505 ; break; case 2: b.x = 466; b.y = 526 ; break; case 3: b.x = 421; b.y = 539 ; break; case 4: b.x = 379; b.y = 546 ; break; case 5: b.x = 339; b.y = 546 ; break; case 6: b.x = 303; b.y = 546 ; break; case 7: b.x = 262; b.y = 550 ; break; case 8: b.x = 220; b.y = 551 ; break; case 9: b.x = 176; b.y = 537 ; break; case 10: b.x = 135; b.y = 531 ; break; case 11: b.x = 94; b.y = 503 ; break; case 12: b.x = 69; b.y = 464 ; break; case 13: b.x = 54; b.y = 419 ; break; case 14: b.x = 54; b.y = 376 ; break; case 15: b.x = 54; b.y = 336 ; break; case 16: b.x = 54; b.y = 299 ; break; case 17: b.x = 50; b.y = 262 ; break; case 18: b.x = 50; b.y = 220 ; break; case 19: b.x = 56; b.y = 177 ; break; case 20: b.x = 78; b.y = 135 ; break; case 21: b.x = 100; b.y = 103 ; break; case 22: b.x = 137; b.y = 69 ; break; case 23: b.x = 175; b.y = 52 ; break; case 24: b.x = 217; b.y = 56 ; break; case 25: b.x = 260; b.y = 52 ; break; case 26: b.x = 298; b.y = 57 ; break; case 27: b.x = 341; b.y = 60 ; break; case 28: b.x = 376; b.y = 56 ; break; case 29: b.x = 423; b.y = 62 ; break; case 30: b.x = 471; b.y = 72 ; break; case 31: b.x = 505; b.y = 94 ; break; case 32: b.x = 531; b.y = 132 ; break; case 33: b.x = 545; b.y = 173 ; break; case 34: b.x = 545; b.y = 217 ; break; case 35: b.x = 545; b.y = 261 ; break; case 36: b.x = 545; b.y = 298 ; break; case 37: b.x = 545; b.y = 337 ; break; case 38: b.x = 545; b.y = 380 ; break; case 39: b.x = 545; b.y = 422 ; break; case 40: b.x = 527; b.y = 468 ; break; } return b; } public bod vrat_souradnice_pole(int pole) { bod b = new bod(0,0); switch (pole) { case 1: b.x = 431; b.y = 431; break; case 2: b.x = 405; b.y = 451; break; case 3: b.x = 383; b.y = 461; break; case 4: b.x = 351; b.y = 461; break; case 5: b.x = 324; b.y = 461; break; case 6: b.x = 300; b.y = 461; break; case 7: b.x = 274; b.y = 461; break; case 8: b.x = 247; b.y = 461; break; case 9: b.x = 216; b.y = 461; break; case 10: b.x = 191; b.y = 455; break; case 11: b.x = 167; b.y = 430; break; case 12: b.x = 152; b.y = 405; break; case 13: b.x = 142; b.y = 379; break; case 14: b.x = 142; b.y = 352; break; case 15: b.x = 142; b.y = 326; break; case 16: b.x = 142; b.y = 301; break; case 17: b.x = 142; b.y = 273; break; case 18: b.x = 142; b.y = 244; break; case 19: b.x = 142; b.y = 218; break; case 20: b.x = 150; b.y = 190; break; case 21: b.x = 168; b.y = 165; break; case 22: b.x = 190; b.y = 150; break; case 23: b.x = 217; b.y = 147; break; case 24: b.x = 248; b.y = 139; break; case 25: b.x = 274; b.y = 139; break; case 26: b.x = 300; b.y = 139; break; case 27: b.x = 326; b.y = 139; break; case 28: b.x = 352; b.y = 139; break; case 29: b.x = 381; b.y = 141; break; case 30: b.x = 406; b.y = 150; break; case 31: b.x = 434; b.y = 165; break; case 32: b.x = 453; b.y = 189; break; case 33: b.x = 457; b.y = 218; break; case 34: b.x = 460; b.y = 248; break; case 35: b.x = 460; b.y = 275; break; case 36: b.x = 460; b.y = 298; break; case 37: b.x = 460; b.y = 324; break; case 38: b.x = 460; b.y = 352; break; case 39: b.x = 460; b.y = 380; break; case 40: b.x = 448; b.y = 407; break; } return b; } private int vrat_pole_kone(string kun) { switch (kun) { case "Fantome": return 1; case "Gavora": return 3; case "LadyAnne": return 6; case "Pasek": return 8; case "Koran": return 9; case "Neklan": return 11; case "Portlancl": return 13; case "Japan": return 14; case "Kostrava": return 16; case "Lukava": return 18; case "Melák": return 19; case "Grifel": return 21; case "Mohyla": return 23; case "Metál": return 24; case "Tara": return 26; case "Furioso": return 27; case "Genius": return 29; case "Shagga": return 31; case "Dahoman": return 32; case "Gira": return 34; case "Narcius": return 37; case "Napoli": return 39; } return 0; } private void inicializace() { // Color cP = Color.Gray; // Color cB = Color.LightGray; // p = new Pen(cP, 6); // b = new SolidBrush(cB); try { im = Image.FromFile(path); } catch { Console.WriteLine("nemam "+path); Environment.Exit(1); } // f = new Font(new FontFamily("Times New Roman"), 10); vysledek_hodu.Font = new Font("Verdana", 20); label_penize.Font = new Font("Verdana", 20); nastav_velikost_tabu(); this.SizeChanged += new EventHandler(herni_formular_zmena_velikosti); } void herni_formular_zmena_velikosti(object sender, EventArgs e) { nastav_velikost_tabu(); } void nastav_velikost_tabu() { tabControl1.Width = this.Width; tabControl1.Height = this.Height; } public void DrawCircle(Graphics g, int x, int y, int r, Color color) { int start = x - r; int end = y - r; int d = r + r; SolidBrush redBrush = new SolidBrush(color); g.FillEllipse(redBrush, start, end, d, d); } private void vytvor_server_formular() { this.Width = 300; this.Height = 200; this.Text = "Das Server"; label_jmeno = new Label(); label_jmeno.Parent = this; label_jmeno.Text = "DAS Server"; label_jmeno.AutoSize = true; label_jmeno.Location = new Point(10, 10); //zrecyklujeme nejake labely z klienta //seznam hracu a ip label_kone = new Label(); label_kone.Parent = this; label_kone.Text = "lidi:\n"; label_kone.AutoSize = true; label_kone.Location = new Point(100, 10); //zrecyklujeme nejake labely z klienta klabel1 = new Label(); klabel1.Parent = this; klabel1.Text = "clovek:"+clovek.ToString(); klabel1.AutoSize = true; klabel1.Location = new Point(10, 30); klabel2 = new Label(); klabel2.Parent = this; klabel2.Text = "pocitac:"+pocitac.ToString(); klabel2.AutoSize = true; klabel2.Location = new Point(10, 50); } public void zobraz_ip() { label_kone.Text = "Seznam hracu:\n"; for (int i = 0; i < clovek; i++) { label_kone.Text += i + ":" + net.ip_pole[i] + "\n"; } } private void vzdat_se() { if (hazej.Enabled) { posli_zpravu("uz_nehazim"); hazej.Enabled = false; } string s = "vzdat_se hned"; posli_zpravu(s); vzdalse = true; Thread.Sleep(2000); Environment.Exit(0); } private void zavreni_formulare(object sender, System.ComponentModel.CancelEventArgs e) { if(MessageBox.Show(this,t._("chces skoncit"), "DAS", MessageBoxButtons.YesNo) == DialogResult.Yes) { vzdat_se(); Thread.Sleep(2000); e.Cancel = false; } else { e.Cancel = true; } } private void zabiti_serveru(object sender, System.ComponentModel.CancelEventArgs e) { zpravy.log("server konec"); if(MessageBox.Show(this,t._("chces skoncit server"), "DAS", MessageBoxButtons.YesNo) == DialogResult.Yes) { net.posli_vsem("konec_hry"); Thread.Sleep(2000); Environment.Exit(0); e.Cancel = false; } else { e.Cancel = true; } } private void zobraz_kone(string radek) { if (radek.IndexOf(";") == -1) {return;} string[] parametry = radek.Split(';'); string kun = d_k(parametry[0]); switch (parametry[2]) { case "oranzova": listBox[0].Items.Add(kun); break; case "hneda": listBox[1].Items.Add(kun); break; case "modra": listBox[2].Items.Add(kun); break; case "svetlezelena": listBox[3].Items.Add(kun); break; case "cervena": listBox[4].Items.Add(kun); break; case "zluta": listBox[5].Items.Add(kun); break; case "zelena": listBox[6].Items.Add(kun); break; case "fialova": listBox[7].Items.Add(kun); break; } } private void vytvor_tlacitko(Button b, string jmeno, int x, int y) { b.Location = new System.Drawing.Point(x, y); b.Name = jmeno; b.Size = new System.Drawing.Size(80, 20); b.Text = "Prodat"; b.UseVisualStyleBackColor = true; b.Parent = tab_kone; } private void vytvor_cenatextbox(TextBox t, int hodnota, int x, int y) { t.Location = new System.Drawing.Point(x, y); t.Name = "cenazakone"; t.Size = new System.Drawing.Size(80, 30); t.Text = hodnota.ToString(); t.Parent = tab_kone; } private void vytvor_kombo(ComboBox c, string jmeno, int x, int y) { c.Location = new System.Drawing.Point(x, y); c.Name = jmeno; c.Size = new System.Drawing.Size(95, 30); c.Text = "Vyber komu"; c.Parent = tab_kone; } void napln_komba() { for (int i = 0; i < 8; i++) { kcombo[i].Items.Add("banka"); for (int j = 0; j < 6; j++) { kcombo[i].Items.Add(jmena_hracu[j]); } } for (int i = 0; i < 6; i++) { scombo[i].Items.Add("banka"); for (int j = 0; j < 6; j++) { scombo[i].Items.Add(jmena_hracu[j]); } } } void vytvor_seznam_vlastnenych_koni() { label_koni_pozice = 0; int listbox_kone_y = 86; int kombo_prodej_koni_y = listbox_kone_y + 100; int cena_prodej_koni_y = listbox_kone_y + 150; int tlacitko_prodej_koni_y = listbox_kone_y + 200; label_kone_prodej = new Label(); label_kone_prodej.Parent = tab_kone; label_kone_prodej.Text = t._("prodej koni"); label_kone_prodej.AutoSize = true; label_kone_prodej.Location = new Point(label_koni_zacatek, listbox_kone_y - 70); for (int ix = 0; ix < 8; ix++) { listBox[ix] = new ListBox(); kbutton[ix] = new Button(); kcombo[ix] = new ComboBox(); kcena[ix] = new TextBox(); listBox[ix].Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice * 121, listbox_kone_y); vytvor_kombo(kcombo[ix], "k1", label_koni_zacatek + label_koni_pozice * 121, kombo_prodej_koni_y); vytvor_cenatextbox(kcena[ix], 1000, label_koni_zacatek + label_koni_pozice * 121, cena_prodej_koni_y); vytvor_tlacitko(kbutton[ix], "k1", label_koni_zacatek + label_koni_pozice * 121, tlacitko_prodej_koni_y); listBox[ix].ItemHeight = 16; listBox[ix].Parent = tab_kone; //dalsi sloupec label_koni_pozice++; } kbutton[0].Click += new EventHandler(prodej1_Click); kbutton[1].Click += new EventHandler(prodej2_Click); kbutton[2].Click += new EventHandler(prodej3_Click); kbutton[3].Click += new EventHandler(prodej4_Click); kbutton[4].Click += new EventHandler(prodej5_Click); kbutton[5].Click += new EventHandler(prodej6_Click); kbutton[6].Click += new EventHandler(prodej7_Click); kbutton[7].Click += new EventHandler(prodej8_Click); } void pridej_prodat_sluzbu(int radek, int x, int y) { sbutton[radek] = new Button(); scombo[radek] = new ComboBox(); scena[radek] = new TextBox(); vytvor_kombo(scombo[radek], "k1", x + 120, y); vytvor_cenatextbox(scena[radek], 1000, x + 220, y); vytvor_tlacitko(sbutton[radek], "s1", x + 320, y); } public void vytvor_info_o_hracich() { for (int i = 0; i < 6; i++) { infohraci[i] = new Label(); infohraci[i].Text = i+" hrac: ---"; infohraci[i].AutoSize = true; infohraci[i].Location = new System.Drawing.Point(5, 220+i*20); infohraci[i].Name = "infohraci"+i; infohraci[i].Size = new System.Drawing.Size(100, 20); infogroupbox.Controls.Add(infohraci[i]); } } public void nastav_info_o_hraci(int hrac, string text, string parametr) { string s = ""; // s += hrac + " " + jmena_hracu[hrac] + ":(" + text+")"+t._(text); s += hrac + " " + jmena_hracu[hrac] + ":" +t._(text); if (parametr != "nic") { s += " " + parametr; } s += "."; infohraci[hrac].Text = s; } public void vytvor_infobox() { int igx = 646; int igy = 6; int velikost_tlacitka_x = 148; int velikost_tlacitka_y = 41; infogroupbox.SuspendLayout(); label2 = new Label(); label2.Text = t._("Vita"); label2.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); label2.AutoSize = false; label2.Location = new Point(6, 19); label2.Size = new System.Drawing.Size(336, 200); kup = new Button(); kup.Text = "???"; kup.Location = new Point(183, 344); kup.Size = new Size(velikost_tlacitka_x, velikost_tlacitka_y); kup.Click += new EventHandler(ButtonKupOnClick); pokracuj = new Button(); pokracuj.Text = "???"; pokracuj.Location = new Point(17, 344); pokracuj.Size = new Size(velikost_tlacitka_x, velikost_tlacitka_y); pokracuj.Click += new EventHandler(ButtonPokracujOnClick); pokracuj_string = "pokracuj"; infogroupbox.Location = new System.Drawing.Point(igx, igy); infogroupbox.Size = new System.Drawing.Size(348, 391); infogroupbox.Name = "Info Panel"; infogroupbox.Controls.Add(label2); infogroupbox.Controls.AddRange( new System.Windows.Forms.Control[] { kup, pokracuj } ); } private void vytvor_herni_formular() { tabControl1 = new TabControl(); tab_hra = new TabPage2(t._("Hra"), panacek, konicek, popisecka, sluzbicka, hazardicek); tab_kone = new TabPage(t._("Kone")); tab_karty = new TabPage(t._("Ostatni")); tabControl1.Controls.Add(tab_hra ); tabControl1.Controls.Add(tab_kone ); tabControl1.Controls.Add(tab_karty); this.Controls.Add(tabControl1); vytvor_infobox(); vytvor_info_o_hracich(); infogroupbox.Parent = tab_hra; infogroupbox.ResumeLayout(); label_koni_zacatek = 20; label_koni_pozice = 0; klabel1.AutoSize = true; klabel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); klabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel1.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel1.Name = "label1"; klabel1.Size = new System.Drawing.Size(51, 20); klabel1.TabIndex = 0; klabel1.Text = "Stáj"; klabel1.Parent = tab_kone; klabel2.AutoSize = true; klabel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(64)))), ((int)(((byte)(0))))); klabel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel2.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel2.Name = "label2"; klabel2.Size = new System.Drawing.Size(51, 20); klabel2.TabIndex = 1; klabel2.Text = "Stáj"; klabel2.Parent = tab_kone; klabel3.AutoSize = true; klabel3.BackColor = System.Drawing.Color.Cyan; klabel3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel3.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel3.Name = "label3"; klabel3.Size = new System.Drawing.Size(51, 20); klabel3.TabIndex = 2; klabel3.Text = "Stáj"; klabel3.Parent = tab_kone; klabel4.AutoSize = true; klabel4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); klabel4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel4.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel4.Name = "label4"; klabel4.Size = new System.Drawing.Size(51, 20); klabel4.TabIndex = 3; klabel4.Text = "Stáj"; klabel4.Parent = tab_kone; klabel5.AutoSize = true; klabel5.BackColor = System.Drawing.Color.Red; klabel5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel5.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel5.Name = "label5"; klabel5.Size = new System.Drawing.Size(51, 20); klabel5.TabIndex = 4; klabel5.Text = "Stáj"; klabel5.Parent = tab_kone; klabel6.AutoSize = true; klabel6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); klabel6.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel6.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel6.Name = "label6"; klabel6.Size = new System.Drawing.Size(51, 20); klabel6.TabIndex = 5; klabel6.Text = "Stáj"; klabel6.Parent = tab_kone; klabel7.AutoSize = true; klabel7.BackColor = System.Drawing.Color.Green; klabel7.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel7.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel7.Name = "label7"; klabel7.Size = new System.Drawing.Size(51, 20); klabel7.TabIndex = 6; klabel7.Text = "Stáj"; klabel7.Parent = tab_kone; klabel8.AutoSize = true; klabel8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))); klabel8.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); klabel8.Location = new System.Drawing.Point(label_koni_zacatek + label_koni_pozice++ * 121, 36); klabel8.Name = "label8"; klabel8.Size = new System.Drawing.Size(51, 20); klabel8.TabIndex = 7; klabel8.Text = "Stáj"; klabel8.Parent = tab_kone; vytvor_seznam_vlastnenych_koni(); label_jmeno = new Label(); label_jmeno.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); label_jmeno.Parent = tab_hra; label_jmeno.Text = t._("cekejte"); label_jmeno.AutoSize = true; label_jmeno.Location = new Point(29, 628); label_jmeno.Size = new System.Drawing.Size(95, 31); label_penize = new Label(); label_penize.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); label_penize.Parent = tab_hra; label_penize.Text = "$30000"; label_penize.AutoSize = true; label_penize.Location = new Point(255, 628); label_penize.Size = new System.Drawing.Size(97, 31); vysledek_hodu = new Label(); vysledek_hodu.Parent = tab_hra; vysledek_hodu.AutoSize = true; vysledek_hodu.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); vysledek_hodu.Location = new System.Drawing.Point(483, 628); vysledek_hodu.Name = "kostka"; vysledek_hodu.Size = new System.Drawing.Size(90, 31); vysledek_hodu.TabIndex = 8; vysledek_hodu.Text = "---"; richTextBox1 = new RichTextBox(); richTextBox1.Dock = DockStyle.None; richTextBox1.Size = new Size(400, 600); richTextBox1.Location = new Point(500, 20); richTextBox1.Parent = tab_karty; richTextBox1.SelectionFont = new Font("Verdana", 12, FontStyle.Bold); richTextBox1.SelectionColor = Color.Red; richTextBox1.Text = "x"; try { richTextBox1.LoadFile("pravidla.rtf", RichTextBoxStreamType.RichText); } catch { MessageBox.Show(this,"nemam pravidla.rtf", "DAS", MessageBoxButtons.OK); } newText = new TextBox(); newText.Multiline = false; newText.Parent = tab_hra; newText.Size = new Size(348-80, 20); newText.Location = new Point(643, 628); chat = new ListBox(); chat.Parent = tab_hra; chat.Location = new Point(643, 487); chat.Size = new Size(348, 134); Button sendit = new Button(); sendit.Parent = tab_hra; sendit.Text = "Mluv"; sendit.Location = new Point(643+348-80, 628); sendit.Size = new Size(5 * Font.Height, 2 * Font.Height); sendit.Click += new EventHandler(ButtonSendOnClick); hazej = new Button(); try { hazej.Image = new Bitmap("kostka.png"); } catch { MessageBox.Show(this,"nemam kostka.png", "DAS", MessageBoxButtons.YesNo); Environment.Exit(0); } hazej.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; hazej.Parent = tab_hra; hazej.Text = (string)t._("Hazej"); hazej.TextAlign = System.Drawing.ContentAlignment.MiddleRight; hazej.Location = new Point(719, 403); hazej.Size = new Size(197, 78); hazej.Click += new EventHandler(ButtonHrajOnClick); hazej.Enabled = false; label_distanc = new Label(); label_distanc.Location = new Point(640, 410); label_distanc.Text="ok";//zmeni se na mas distanc label_distanc.Size = new System.Drawing.Size(69, 20); label_distanc.Parent = tab_hra; img_distanc = new PictureBox(); img_distanc.Parent = tab_hra; img_distanc.BorderStyle = System.Windows.Forms.BorderStyle.None; img_distanc.Width = 32; img_distanc.Height = 32; img_distanc.Left = 640; img_distanc.Top = 432; try { img_distanc.Image = new Bitmap("nohand.png"); } catch { MessageBox.Show(this, "nemam nohand.png", "DAS", MessageBoxButtons.YesNo); Environment.Exit(0); } checkbox_trener1 = new CheckBox(); checkbox_trener2 = new CheckBox(); checkbox_trener3 = new CheckBox(); checkbox_trener4 = new CheckBox(); checkbox_staje = new CheckBox(); checkbox_preprava = new CheckBox(); int sluzba_x = 20; int sluzba_y = 350; label_sluzby_prodej = new Label(); label_sluzby_prodej.Parent = tab_kone; label_sluzby_prodej.Text = t._("prodej sluzeb"); label_sluzby_prodej.AutoSize = true; label_sluzby_prodej.Location = new Point(sluzba_x, sluzba_y - 20); pridej_sluzbu(checkbox_trener1 , sluzba_x, sluzba_y + 0, "Trener #1"); pridej_sluzbu(checkbox_trener2 , sluzba_x, sluzba_y + 20, "Trener #2"); pridej_sluzbu(checkbox_trener3 , sluzba_x, sluzba_y + 40, "Trener #3"); pridej_sluzbu(checkbox_trener4 , sluzba_x, sluzba_y + 60, "Trener #4"); pridej_sluzbu(checkbox_staje , sluzba_x, sluzba_y + 80, "Staje "); pridej_sluzbu(checkbox_preprava, sluzba_x, sluzba_y + 100, "Preprava "); for (int radek = 0; radek < 6; radek++) { pridej_prodat_sluzbu(radek, sluzba_x, sluzba_y + radek * 20); } sbutton[0].Click += new EventHandler(prodejsluzby1_Click); sbutton[1].Click += new EventHandler(prodejsluzby2_Click); sbutton[2].Click += new EventHandler(prodejsluzby3_Click); sbutton[3].Click += new EventHandler(prodejsluzby4_Click); sbutton[4].Click += new EventHandler(prodejsluzby5_Click); sbutton[5].Click += new EventHandler(prodejsluzby6_Click); button_pujcit = new System.Windows.Forms.Button(); button_vratit = new System.Windows.Forms.Button(); textBox_castka = new System.Windows.Forms.TextBox(); button_pujcit.Location = new System.Drawing.Point(64, 69); button_pujcit.Name = "button_pujcit"; button_pujcit.Size = new System.Drawing.Size(75, 23); button_pujcit.TabIndex = 0; button_pujcit.Text = "Půjčit"; button_pujcit.UseVisualStyleBackColor = true; button_pujcit.Click += new System.EventHandler(this.button_pujcit_Click); button_pujcit.Parent = tab_karty; button_vratit.Location = new System.Drawing.Point(162, 69); button_vratit.Name = "button_vratit"; button_vratit.Size = new System.Drawing.Size(75, 23); button_vratit.TabIndex = 1; button_vratit.Text = "Vrátit"; button_vratit.UseVisualStyleBackColor = true; button_vratit.Click += new System.EventHandler(this.button_vratit_Click); button_vratit.Parent = tab_karty; textBox_castka.Location = new System.Drawing.Point(64, 43); textBox_castka.Name = "textBox_castka"; textBox_castka.Size = new System.Drawing.Size(173, 20); textBox_castka.TabIndex = 2; textBox_castka.Text = "1000"; textBox_castka.Parent = tab_karty; ukoncovaci_tlacitka(); vytvor_sazeci_koutek(); } void ukoncovaci_tlacitka() { int x = 30; int y = 140; button_vzdat_se = new System.Windows.Forms.Button(); button_vzdat_se.Location = new System.Drawing.Point(x, y); button_vzdat_se.Name = "button_vzdat_se"; button_vzdat_se.Size = new System.Drawing.Size(75, 23); button_vzdat_se.TabIndex = 1; button_vzdat_se.Text = "Vzdát se"; button_vzdat_se.UseVisualStyleBackColor = true; button_vzdat_se.Click += new System.EventHandler(this.button_vzdat_se_Click); button_vzdat_se.Parent = tab_karty; button_konec_hry = new System.Windows.Forms.Button(); button_konec_hry.Location = new System.Drawing.Point(x + 80, y); button_konec_hry.Name = "button_konec_hry"; button_konec_hry.Size = new System.Drawing.Size(75, 23); button_konec_hry.TabIndex = 1; button_konec_hry.Text = "Konec Hry"; button_konec_hry.UseVisualStyleBackColor = true; button_konec_hry.Click += new System.EventHandler(this.button_konec_hry_Click); button_konec_hry.Parent = tab_karty; button_uloz = new System.Windows.Forms.Button(); button_uloz.Location = new System.Drawing.Point(x + 2 * 80, y); button_uloz.Name = "button_uloz"; button_uloz.Size = new System.Drawing.Size(75, 23); button_uloz.TabIndex = 1; button_uloz.Text = t._("uloz"); button_uloz.UseVisualStyleBackColor = true; button_uloz.Click += new System.EventHandler(this.button_uloz_Click); button_uloz.Parent = tab_karty; button_nacti = new System.Windows.Forms.Button(); button_nacti.Location = new System.Drawing.Point(x + 3 * 80, y); button_nacti.Name = "button_nacti"; button_nacti.Size = new System.Drawing.Size(75, 23); button_nacti.TabIndex = 1; button_nacti.Text = t._("nacti"); button_nacti.UseVisualStyleBackColor = true; button_nacti.Click += new System.EventHandler(this.button_nacti_Click); button_nacti.Parent = tab_karty; button_osvobozeni = new System.Windows.Forms.Button(); button_osvobozeni.Location = new System.Drawing.Point(x + 4 * 80, y); button_osvobozeni.Name = "button_osvobodit_se"; button_osvobozeni.Size = new System.Drawing.Size(80, 23); button_osvobozeni.TabIndex = 1; button_osvobozeni.Text = "Osvobodit se"; button_osvobozeni.UseVisualStyleBackColor = true; button_osvobozeni.Click += new System.EventHandler(this.button_osvobodit_se_Click); button_osvobozeni.Parent = tab_karty; } void prodej_kone(string kun, string jmeno_hrace, int cena) { string s = "prodej_kone " + kun + " " + jmeno_hrace + " " + cena; zpravy.log(s); posli_zpravu(s); } void prodej_sluzbu(string sluzba, string jmeno_hrace, int cena) { string s = "prodej_sluzbu " + sluzba + " " + jmeno_hrace + " " + cena; zpravy.log(s); posli_zpravu(s); } void zpracuj_tlacitko_prodej(int sloupec) { int ic = kcombo[sloupec].SelectedIndex; int il = listBox[sloupec].SelectedIndex; if (ic < 0 || il < 0) {return;} string hrac = kcombo[sloupec].SelectedItem.ToString(); string kun = listBox[sloupec].SelectedItems[0].ToString(); int cena = int.Parse(kcena[sloupec].Text); prodej_kone(kun, hrac, cena); } void zpracuj_tlacitko_prodej_sluzby(int radek) { int ic = scombo[radek].SelectedIndex; string sluzba = ""; if (ic < 0 || radek < 0) {return;} switch(radek) { case 0:sluzba = "trener1";break; case 1:sluzba = "trener2";break; case 2:sluzba = "trener3";break; case 3:sluzba = "trener4";break; case 4:sluzba = "staje";break; case 5:sluzba = "preprava";break; } string hrac = scombo[radek].SelectedItem.ToString(); int cena = int.Parse(scena[radek].Text); prodej_sluzbu(sluzba, hrac, cena); } private void prodej1_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(0); } private void prodej2_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(1); } private void prodej3_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(2); } private void prodej4_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(3); } private void prodej5_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(4); } private void prodej6_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(5); } private void prodej7_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(6); } private void prodej8_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej(7); } private void prodejsluzby1_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej_sluzby(0); } private void prodejsluzby2_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej_sluzby(1); } private void prodejsluzby3_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej_sluzby(2); } private void prodejsluzby4_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej_sluzby(3); } private void prodejsluzby5_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej_sluzby(4); } private void prodejsluzby6_Click(object sender, EventArgs e) { zpracuj_tlacitko_prodej_sluzby(5); } private void button_vzdat_se_Click(object sender, EventArgs e) { vzdat_se(); } private void button_osvobodit_se_Click(object sender, EventArgs e) { string s = "osvobodit_se hned"; posli_zpravu(s); } private void button_konec_hry_Click(object sender, EventArgs e) { string s = "konec_hry"; posli_zpravu(s); } private void button_uloz_Click(object sender, EventArgs e) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "soubory *.das|*.das|All Files (*.*)|*.*" ; dlg.InitialDirectory = Application.StartupPath; dlg.FilterIndex = 1; if(dlg.ShowDialog(this) == DialogResult.OK) { string s = "uloz_hru "+k_k(dlg.FileName); posli_zpravu(s); } } private void button_nacti_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = Application.StartupPath; dlg.Filter = "soubory *.das|*.das|All Files (*.*)|*.*" ; dlg.FilterIndex = 1; if (dlg.ShowDialog(this) == DialogResult.OK) { string s = "nacti_hru "+k_k(dlg.FileName); posli_zpravu(s); } } private void button_pujcit_Click(object sender, EventArgs e) { string s = "pujcit_z_banky " + textBox_castka.Text; posli_zpravu(s); } private void button_vratit_Click(object sender, EventArgs e) { string s = "vratit_do_banky " + textBox_castka.Text; posli_zpravu(s); } public void pridej_sluzbu(CheckBox checkbox, int x, int y, string s) { checkbox.Location = new Point(x, y); checkbox.AutoCheck = true; checkbox.Text = s; checkbox.Checked = false; checkbox.Parent = tab_kone; } public void manazer_hraj() { manazer = new trida_manazer(clovek, pocitac); manazer.inicializuj_sit(clovek); zobraz_ip(); Invalidate(); manazer.hraj(); } private void OnTimedEvent(object source, ElapsedEventArgs e) { label_kone.Text = "Seznam hracu:\n"+prenos.data; } public herni_formular() { Text = "DAS"; Size = new Size(1024, 768); for (int i = 0; i < 6; i++) { panacek[i] = new bod(0,0); panacek[i].barva = Color.Pink; jmena_hracu[i] = "---"; sluzbicka[i] = new bod(0,0); sluzbicka[i].barva = Color.Pink; } for (int i = 0; i < 22; i++) { konicek[i] = new bod(0,0); konicek[i].barva = Color.Pink; hazardicek[i] = new bod(0,0); hazardicek[i].barva = Color.Pink; bod b = new bod(0,0); popisecka[i] = new popiska(b, Color.Pink, 0); } zvol_klient_server(); if (server) { System.Timers.Timer aTimer = new System.Timers.Timer(); aTimer.Elapsed+=new ElapsedEventHandler(OnTimedEvent); aTimer.Interval=5000; aTimer.Enabled=true; Thread thread1 = new Thread(new ThreadStart(manazer_hraj)); vytvor_server_formular(); this.Closing += new System.ComponentModel.CancelEventHandler(this.zabiti_serveru); zpravy.log("Bezim jako server pro "+clovek+" lidi a "+pocitac+" pocitacu."); thread1.Start(); Console.WriteLine(prenos.data); } else { vytvor_herni_formular(); this.Closing += new System.ComponentModel.CancelEventHandler(this.zavreni_formulare); inicializace(); try { client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint iep = new IPEndPoint(IPAddress.Parse(ip), 9050); client.BeginConnect(iep, new AsyncCallback(Connected), client); } catch { DialogResult odpoved = MessageBox.Show(this,"Spatna ip adresa", "", MessageBoxButtons.OK, MessageBoxIcon.Question); if (odpoved == DialogResult.OK) { Environment.Exit(1); } } Thread.Sleep(5000); posli_zpravu("ahoj " + jmeno_hrace); } } void zvol_klient_server() { login_dialog ldg = new login_dialog(); ldg.ShowDialog(); login_dialog.BoxResults result = ldg.ButtonClicked; switch (result) { case login_dialog.BoxResults.Konec: Environment.Exit(0); break; case login_dialog.BoxResults.Server: zpravy.server = true; try { clovek = int.Parse(ldg.pocet_lidi()); } catch { clovek = 1; zpravy.log("Nepodarilo se zjistit pocet lidi"); } try { pocitac = int.Parse(ldg.pocet_pocitacu()); } catch { pocitac = 1; zpravy.log("Nepodarilo se zjistit pocet pocitacu"); } ldg.Hide(); ldg.Dispose(); server = true; break; case login_dialog.BoxResults.Klient: ip = ldg.get_ip(); jmeno_hrace = ldg.get_jmeno(); server = false; zpravy.server = false; zpravy.log("Bezim jako klient pripojeno k "+ip+" pod jmenem "+jmeno_hrace); ldg.Dispose(); break; } } private void button_vsad_Click(object sender, EventArgs e) { string s; int castka = 0; string jmeno = ""; jmeno = listBox_kone.SelectedItems[0].ToString(); castka = int.Parse(textBox_sazka.Text); if (jmeno.Length == 0 || jmeno == "" || jmeno == string.Empty ) {return;} s = "sazim_na_kone " + jmeno + " " + castka; int pole_kone = vrat_pole_kone(jmeno); //zjistit zda je vsazeno a nepustit to if (pocet_sazek < 22) { hazardicek[pocet_sazek++] = vrat_souradnice_vnejsipole(pole_kone+1); } posli_zpravu(s); } void ButtonConnectOnClick(object obj, EventArgs ea) { zvol_klient_server(); } void posli_zpravu(string zprava) { try { byte[] message = Encoding.ASCII.GetBytes(zprava);//+"\n"); Console.WriteLine(">>> posilam:"+zprava+"\n"); client.BeginSend(message , 0, message.Length, 0, new AsyncCallback(SendData), client); } catch { Console.WriteLine("Neposlano:"+zprava); } } void ButtonSendOnClick(object obj, EventArgs ea) { posli_zpravu("chat "+label_jmeno.Text+">"+newText.Text); newText.Clear(); } void ButtonHrajOnClick(object obj, EventArgs ea) { posli_zpravu("hazim_kostkou"); hazej.Enabled = false; } void ButtonPokracujOnClick(object obj, EventArgs ea) { posli_zpravu(pokracuj_string); label2.Text = nadpis+"\n"+t._("pokracujes"); deaktivuj_pokracovaci_tlacitka(); } void ButtonKupOnClick(object obj, EventArgs ea) { posli_zpravu(kup_string); label2.Text = nadpis + "\n" + t._("pokracujes"); deaktivuj_pokracovaci_tlacitka(); } void Connected(IAsyncResult iar) { try { client.EndConnect(iar); zpravy.log("Connected to: " + client.RemoteEndPoint.ToString()); Thread receiver = new Thread(new ThreadStart(ReceiveData)); receiver.IsBackground = true; receiver.Start(); } catch (SocketException) { DialogResult odpoved = MessageBox.Show(this,"nepripojeno", "", MessageBoxButtons.OK, MessageBoxIcon.Question); if (odpoved == DialogResult.OK) { Environment.Exit(1); } } } void SendData(IAsyncResult iar) { Socket remote = (Socket)iar.AsyncState; int sent = remote.EndSend(iar); zpravy.log("klient poslano: "+sent); } void priprav_tlacitko_pokracuj(string s1, string s2) { pokracuj.Text = s1; pokracuj_string = s2; pokracuj.Enabled = true; } void priprav_tlacitko_kup(string s1, string s2) { kup.Text = s1; kup_string = s2; kup.Enabled = true; } void deaktivuj_pokracovaci_tlacitka() { kup.Text="???"; kup.Enabled = false; pokracuj.Text = "???"; pokracuj.Enabled = false; } void ReceiveData() { int recv = 0; string stringData; while (true) { try { recv = client.Receive(data); } catch { //fixme neco sem napsat Console.WriteLine("konec sveta"); Environment.Exit(1); } if (recv == 0) { Console.WriteLine("server se odpojil"); Environment.Exit(1); } stringData = Encoding.ASCII.GetString(data, 0, recv); if (vzdalse) { return; } string[] prikazy = stringData.Split('\n'); Console.WriteLine("========================================>"); foreach (string prikaz in prikazy) { if (prikaz == "") {continue;} Console.WriteLine("==>"); Console.WriteLine(prikaz); Console.WriteLine("<=="); if (prikaz.IndexOf(":") > -1) { string[] slova = prikaz.Split(':'); foreach (string word in slova) { Console.Write("* "); Console.WriteLine(word); } string zprava = slova[1]; string[] parametry = zprava.Split(' '); foreach (string parametr in parametry) { Console.Write("** "); Console.WriteLine(parametr); } if (zprava == "bye") break; if (zprava.IndexOf("tahni") == 0) { deaktivuj_pokracovaci_tlacitka(); hazej.Enabled = true; pocet_sazek = 0; for (int i = 0; i < 22; i++) { hazardicek[i].x = 0; hazardicek[i].y = 0; } } if (zprava.IndexOf("volny_kun") == 0) { string jmeno = d_k(parametry[1]); int cena = int.Parse(parametry[2]); string staj = parametry[3]; label2.Text = t._("Stoupl jsi na volneho kone")+"\n" +t._("jmeno") +": "+jmeno+"\n" +t._("cena") +": "+cena+"\n" +t._("staj") +": "+t._(staj)+"\n"; priprav_tlacitko_kup(t._("Kup kone"),"kupuji_kone"); priprav_tlacitko_pokracuj(t._("Nekupuj a pokracuj"), "pokracuj"); } if (zprava.IndexOf("pokracujes") == 0) { label2.Text = t._("Pokracujes")+"\n"; } if (zprava.IndexOf("koupils_kone") == 0) { string jmeno; jmeno = d_k(parametry[1]); label2.Text = t._("Koupils kone")+"\n" +t._("jmeno") +": "+jmeno+"\n"; } if (parametry[0] == "pozice_hrace") { int hrac = int.Parse(parametry[1]); int poz = int.Parse(parametry[2]); Console.WriteLine("hrac poz:"+hrac+" "+poz); bod bb = vrat_souradnice_pole(poz+1); panacek[hrac].x = bb.x; panacek[hrac].y = bb.y; tab_hra.Invalidate(); Console.WriteLine("invalidate\n"); } if (zprava.IndexOf("hodils") == 0) { vysledek_hodu.Text = t._("Hozeno")+" "+parametry[2]; label2.Text = "DAS"; } if (zprava.IndexOf("konec_tahu") == 0) { hazej.Text = t._("Hazej"); } if (zprava.IndexOf("cizi_kun") == 0) { string jmeno = d_k(parametry[1]); string majitel = parametry[2]; string poplatek = parametry[3]; string staj = parametry[4]; label2.Text = t._("stoupls na ciziho kone")+"\n" +t._("jmeno") +": "+jmeno+"\n" +t._("majitel") +": "+majitel+"\n" +t._("poplatek")+": "+poplatek+"\n" +t._("staj") +": "+t._(staj)+"\n"; priprav_tlacitko_pokracuj(t._("zaplatim"), "zaplacena_prohlidka"); } if (zprava.IndexOf("tvuj_kun") == 0) { string jmeno = d_k(parametry[1]); string poplatek_dostih = parametry[2]; string poplatek_dostih_hlavni = parametry[3]; string staj = parametry[4]; string ma_celou_staj = parametry[5]; label2.Text = t._("stoupls na sveho kone")+"\n" +t._("jmeno") +": "+jmeno+"\n" +t._("staj") +": "+t._(staj)+"\n" +t._("poplatek dostih") +": "+poplatek_dostih+"\n" +t._("poplatek dostih hlavni") +": "+poplatek_dostih_hlavni+"\n" +t._("ma celou staj") +": "+t._(ma_celou_staj.ToString())+"\n"; if (ma_celou_staj == "1") { priprav_tlacitko_kup(t._("koupim dostih"), "kupuji_dostih"); priprav_tlacitko_pokracuj(t._("nechci"), "pokracuj"); } else { priprav_tlacitko_pokracuj(t._("Nemas celou staj"), "pokracuj"); } } if (zprava.IndexOf("finance") == 0) { string kodovany_text = parametry[1]; string text = zpravy.base64Decode(kodovany_text); string suma = parametry[2]; label2.Text = "Finance\n"+text+"\n"+suma+"\n"; priprav_tlacitko_pokracuj(t._("Akceptuji"), "akceptuji_finance"); } if (zprava.IndexOf("koupit_trenera") == 0) { int trener_id = int.Parse(parametry[1]); int cena = int.Parse(parametry[2]); string s = t._("koupit trenera")+Environment.NewLine +t._("trener cislo") +": "+trener_id+"\n" +t._("cena")+": "+cena+"\n"; label2.Text = s; priprav_tlacitko_kup(t._("kupuji trenera"), "kupuji_trenera"); priprav_tlacitko_pokracuj(t._("Nekupuji"), "pokracuj"); } if (zprava.IndexOf("zaplat_za_trenera") == 0) { label2.Text = t._("zaplatim za trenera"); priprav_tlacitko_pokracuj(t._("platim trenink"), "platim_za_trenera"); } if (zprava.IndexOf("zaplat_za_prepravu") == 0) { label2.Text = "zaplatim za prepravu"; priprav_tlacitko_pokracuj(t._("platim za prepravu"), "platim_za_prepravu"); } if (zprava.IndexOf("zaplat_za_staje") == 0) { label2.Text = "zaplatim za staje"; priprav_tlacitko_pokracuj(t._("platim staje"), "platim_za_staje"); } if (zprava.IndexOf("koupit_prepravu") == 0) { int cena = int.Parse(parametry[1]); label2.Text = t._("Koupit prepravu ") + t._("cena") + ": " +cena + "\n"; priprav_tlacitko_kup(t._("kupuji prepravu"), "kupuji_prepravu"); priprav_tlacitko_pokracuj(t._("Nekupuji"), "pokracuj"); } if (zprava.IndexOf("koupit_staje") == 0) { int cena = int.Parse(parametry[1]); label2.Text = t._("Koupit staje ") +t._("cena") +": "+cena+"\n"; priprav_tlacitko_kup(t._("kupuji staje"), "kupuji_staje"); priprav_tlacitko_pokracuj(t._("Nekupuji"), "pokracuj"); } if (zprava.IndexOf("identifikator_hrace") == 0) { int hrac = int.Parse(parametry[1]); string jmeno_hrace = parametry[2]; cislo_hrace = hrac; label_jmeno.Text = jmeno_hrace; } if (zprava.IndexOf("nahoda") == 0) { string kodovany_text = parametry[1]; string text = zpravy.base64Decode(kodovany_text); label2.Text = t._("Nahoda")+"\n"+text+"\n"; priprav_tlacitko_pokracuj(t._("Akceptuji"), "akceptuji_nahodu"); } if (zprava.IndexOf("mas_distanc") == 0) { label2.Text = t._("Mas distanc\n pokracujes pote co hodis 6\n"); priprav_tlacitko_pokracuj(t._("Budiz"), "akceptuji_distanc"); } if (zprava.IndexOf("stop") == 0) { label2.Text = t._("Stop na 1 kolo"); priprav_tlacitko_pokracuj(t._("Budiz"), "akceptuji_stop"); } if (zprava.IndexOf("zprava_o_stavu") == 0) { int hrac = int.Parse(parametry[1]); string zpozice = parametry[2]; string zhod = parametry[3]; string penize = parametry[4]; label_penize.Text = "$"+penize; zpravy.log("udalost zprava_o_stavu:"+hrac+zpozice+zhod+penize); } if (zprava.IndexOf("info_o_vsech") == 0) { int hrac = int.Parse(parametry[1]); string dalsi = d_k(parametry[2]); string textik = ""; for (int texti = 3; texti < parametry.Length; texti++) { textik = textik + " " + parametry[texti]; } Console.WriteLine("xxxx"+textik); nastav_info_o_hraci(hrac, textik, dalsi); } if (zprava.IndexOf("prichozi_chat") == 0) { string textik = ""; for (int chati = 2; chati < parametry.Length; chati++) { textik = textik + " " + parametry[chati]; } chat.Items.Add(textik); } if (zprava.IndexOf("zaplat_penize") == 0) { string kolik = parametry[1]; label2.Text = t._("ZAPLAT!!!")+kolik+"\n"; priprav_tlacitko_pokracuj(t._("zaplatim"), "zaplaceno_penize"); } if (zprava.IndexOf("potvrzeni_o_zaplaceni") == 0) { string suma = parametry[1]; label_penize.Text = "$"+suma; } if (zprava.IndexOf("trener_info") == 0) { int id_trenera = int.Parse(parametry[1]); int hrac = int.Parse(parametry[2]); if (hrac >= 0) { switch (id_trenera) { case 1:sluzbicka[2] = vrat_souradnice_vnejsipole(5+1); sluzbicka[2].barva = panacek[hrac].barva;break; case 2:sluzbicka[3] = vrat_souradnice_vnejsipole(15+1); sluzbicka[3].barva = panacek[hrac].barva;break; case 3:sluzbicka[4] = vrat_souradnice_vnejsipole(25+1); sluzbicka[4].barva = panacek[hrac].barva;break; case 4:sluzbicka[5] = vrat_souradnice_vnejsipole(35+1); sluzbicka[5].barva = panacek[hrac].barva;break; } } if (hrac == cislo_hrace) { if (id_trenera == 1) { //trener je muj checkbox_trener1.Checked = true; } else if (id_trenera == 2) { checkbox_trener2.Checked = true; } else if (id_trenera == 3) { checkbox_trener3.Checked = true; } else if (id_trenera == 4) { checkbox_trener4.Checked = true; } } else { //trener je cizi if (id_trenera == 1) { checkbox_trener1.Checked = false; } else if (id_trenera == 2) { checkbox_trener2.Checked = false; } else if (id_trenera == 3) { checkbox_trener3.Checked = false; } else if (id_trenera == 4) { checkbox_trener4.Checked = false; } } } if (zprava.IndexOf("staje_info") == 0) { int hrac = int.Parse(parametry[1]); if (hrac >= 0) { sluzbicka[0] = vrat_souradnice_vnejsipole(28+1); sluzbicka[0].barva = panacek[hrac].barva; } if (hrac == cislo_hrace) { checkbox_staje.Checked = true; } else { checkbox_staje.Checked = false; } } if (zprava.IndexOf("distanc_info") == 0) { int distanc = int.Parse(parametry[1]); if (distanc > 0) { label_distanc.Text = t._("mas distanc"); img_distanc.Visible=true; } else { img_distanc.Visible = false; label_distanc.Text = t._("ok"); } } if (zprava.IndexOf("preprava_info") == 0) { int hrac = int.Parse(parametry[1]); if (hrac >= 0) { sluzbicka[1] = vrat_souradnice_vnejsipole(12+1); sluzbicka[1].barva = panacek[hrac].barva; } if (hrac == cislo_hrace) { checkbox_preprava.Checked = true; } else { checkbox_preprava.Checked = false; } } if (zprava.IndexOf("konec_hry") == 0) { zpravy.log("prisel konec hry koncim"); MessageBox.Show(this, t._("server zabit"),"DAS", MessageBoxButtons.OK, MessageBoxIcon.Information); Environment.Exit(0); } if (zprava.IndexOf("vzdal_se") == 0) { int hrac = int.Parse(parametry[1]); zpravy.log("prisla zprava ze hrac "+hrac+" se vzdal"); MessageBox.Show(this, t._("vzdal se")+hrac,"DAS", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (zprava.IndexOf("info_o_hraci") == 0) { int hrac = int.Parse(parametry[1]); string barva = parametry[2]; string jmeno = parametry[3]; switch (barva) { case "cervena": panacek[hrac].barva = Color.Red; break; case "zelena": panacek[hrac].barva = Color.Green; break; case "zluta": panacek[hrac].barva = Color.Yellow; break; case "modra": panacek[hrac].barva = Color.Blue; break; case "bila": panacek[hrac].barva = Color.White; break; case "cerna": panacek[hrac].barva = Color.Black; break; } jmena_hracu[hrac] = jmeno; } if (zprava.IndexOf("tvoje_kone") == 0) { for (int i = 0; i< 8; i++) { listBox[i].Items.Clear(); } foreach (string parametr in parametry) { zobraz_kone(parametr); } } if (zprava.IndexOf("vsechny_kone") == 0) { listBox_kone.Items.Clear(); foreach (string parametr in parametry) { if (parametr == "vsechny_kone") {continue;} listBox_kone.Items.Add(d_k(parametr)); } } if (zprava.IndexOf("vlastnici_koni") == 0) { int ik = 0; int pole_kone; foreach (string parametr in parametry) { zpravy.log("udalost vlastnici_koni: "+ik+" parametr ("+parametr+")"); if (parametr == "vlastnici_koni" || parametr=="") {continue;} if (pocet_znaku(parametr,'>') != 2) {continue;} //spatne dosla zprava string[] par = parametr.Split('>'); zpravy.log("udalost vlastnici_koni: "+ik+" dekodovano"+d_k(par[0])+" "+par[1]+" "+par[2]); pole_kone = vrat_pole_kone(d_k(par[0])); Console.WriteLine(pole_kone); try { konicek[ik] = vrat_souradnice_vnejsipole(pole_kone+1); popisecka[ik].b = vrat_souradnice_vnejsipole(pole_kone+1); popisecka[ik].hodnota = int.Parse(par[2]); } catch { } zpravy.log("udalost vlastnici_koni: "+ik+" pozice"+konicek[ik].x+","+konicek[ik].y); int hrac = int.Parse(par[1]); if (hrac > -1) { konicek[ik].barva = panacek[hrac].barva; } ik++; } } if (zprava.IndexOf("pujcka_ok") == 0) { MessageBox.Show(this, t._("pujceno"), t._("zprava od banky"), MessageBoxButtons.OK, MessageBoxIcon.Question); } if (zprava.IndexOf("nejsou_penize") == 0) { MessageBox.Show(this, t._("dosli penize"), t._("zprava od banky"), MessageBoxButtons.OK, MessageBoxIcon.Question); } if (zprava.IndexOf("koupis_kone_od_jineho") == 0) { string jmeno_kone = parametry[1]; int cena = int.Parse(parametry[2]); DialogResult dlgResult = MessageBox.Show(this, t._("nabidka kone")+jmeno_kone+cena, t._("chces koupit kone?"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgResult == DialogResult.Yes) { //preved_kone string s = "preved_kone " + jmeno_kone + " " + jmeno_hrace + " " + cena;// + "\n"; Console.WriteLine(s); posli_zpravu(s); } else if (dlgResult == DialogResult.No) { // No, stop } } if (zprava.IndexOf("koupis_sluzbu_od_jineho") == 0) { string nazev_sluzby = parametry[1]; int cena = int.Parse(parametry[2]); DialogResult dlgResult = MessageBox.Show(this, t._("nabidka sluzby")+nazev_sluzby+cena, t._("chces koupit sluzbu?"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgResult == DialogResult.Yes) { //preved_kone string s = "preved_sluzbu " + nazev_sluzby + " " + jmeno_hrace + " " + cena;// + "\n"; Console.WriteLine(s); posli_zpravu(s); } else if (dlgResult == DialogResult.No) { // No, stop } } if (zprava.IndexOf("zahajena_hra") == 0) { napln_komba(); MessageBox.Show(this, t._("zahajena hra"),"DAS", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } Console.WriteLine("<========================================"); } } } }