diff --git a/zsirozas/Form1.Designer.cs b/zsirozas/Form1.Designer.cs index 6da60555c44036f28ce3f8b235d07c7fe3114857..c6c1f072d7614361bacc260ef6684404ca01619d 100644 --- a/zsirozas/Form1.Designer.cs +++ b/zsirozas/Form1.Designer.cs @@ -1,33 +1,33 @@ -namespace zsirozas -{ - partial class Form1 - { - /// <summary> - /// Required designer variable. - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// Clean up any resources being used. - /// </summary> - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() - { +namespace zsirozas +{ + partial class Form1 + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPageWelcome = new System.Windows.Forms.TabPage(); this.buttonSearchForServers = new System.Windows.Forms.Button(); @@ -39,15 +39,22 @@ this.buttonServerTest = new System.Windows.Forms.Button(); this.textBoxServerPort = new System.Windows.Forms.TextBox(); this.textBoxServerAddr = new System.Windows.Forms.TextBox(); - this.radioButton3 = new System.Windows.Forms.RadioButton(); - this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.radioButtonFindServers = new System.Windows.Forms.RadioButton(); + this.radioButtonLocalServer = new System.Windows.Forms.RadioButton(); this.radioButtonManual = new System.Windows.Forms.RadioButton(); this.tabPageServer = new System.Windows.Forms.TabPage(); + this.buttonStartGame = new System.Windows.Forms.Button(); this.tabPageGame = new System.Windows.Forms.TabPage(); this.panelPlayers = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); - this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.panelPlayer1 = new System.Windows.Forms.Panel(); + this.labelPlayerCards0 = new System.Windows.Forms.Label(); + this.labelPlayerName0 = new System.Windows.Forms.Label(); this.panelGame = new System.Windows.Forms.Panel(); this.labelTurnCard = new System.Windows.Forms.Label(); this.labelCardsDealt = new System.Windows.Forms.Label(); @@ -59,11 +66,19 @@ this.buttonCard1 = new System.Windows.Forms.Button(); this.buttonCard0 = new System.Windows.Forms.Button(); this.buttonEndTurn = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.textBoxUserNickname = new System.Windows.Forms.TextBox(); + this.textBoxIncomingPort = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); this.tabControl1.SuspendLayout(); this.tabPageWelcome.SuspendLayout(); + this.tabPageServer.SuspendLayout(); this.tabPageGame.SuspendLayout(); this.panelPlayers.SuspendLayout(); + this.panel2.SuspendLayout(); this.panel1.SuspendLayout(); + this.panelPlayer1.SuspendLayout(); this.panelGame.SuspendLayout(); this.panelCards.SuspendLayout(); this.SuspendLayout(); @@ -82,6 +97,10 @@ // // tabPageWelcome // + this.tabPageWelcome.Controls.Add(this.label8); + this.tabPageWelcome.Controls.Add(this.label7); + this.tabPageWelcome.Controls.Add(this.textBoxIncomingPort); + this.tabPageWelcome.Controls.Add(this.textBoxUserNickname); this.tabPageWelcome.Controls.Add(this.buttonSearchForServers); this.tabPageWelcome.Controls.Add(this.buttonConnect); this.tabPageWelcome.Controls.Add(this.listBoxServers); @@ -91,8 +110,8 @@ this.tabPageWelcome.Controls.Add(this.buttonServerTest); this.tabPageWelcome.Controls.Add(this.textBoxServerPort); this.tabPageWelcome.Controls.Add(this.textBoxServerAddr); - this.tabPageWelcome.Controls.Add(this.radioButton3); - this.tabPageWelcome.Controls.Add(this.radioButton2); + this.tabPageWelcome.Controls.Add(this.radioButtonFindServers); + this.tabPageWelcome.Controls.Add(this.radioButtonLocalServer); this.tabPageWelcome.Controls.Add(this.radioButtonManual); this.tabPageWelcome.Location = new System.Drawing.Point(4, 22); this.tabPageWelcome.Name = "tabPageWelcome"; @@ -104,6 +123,7 @@ // // buttonSearchForServers // + this.buttonSearchForServers.Enabled = false; this.buttonSearchForServers.Location = new System.Drawing.Point(200, 107); this.buttonSearchForServers.Name = "buttonSearchForServers"; this.buttonSearchForServers.Size = new System.Drawing.Size(43, 23); @@ -127,6 +147,7 @@ this.listBoxServers.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.listBoxServers.Enabled = false; this.listBoxServers.FormattingEnabled = true; this.listBoxServers.Location = new System.Drawing.Point(41, 142); this.listBoxServers.Name = "listBoxServers"; @@ -136,6 +157,7 @@ // buttonStopLocalServer // this.buttonStopLocalServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonStopLocalServer.Enabled = false; this.buttonStopLocalServer.Location = new System.Drawing.Point(564, 49); this.buttonStopLocalServer.Name = "buttonStopLocalServer"; this.buttonStopLocalServer.Size = new System.Drawing.Size(45, 23); @@ -147,6 +169,7 @@ // buttonStartLocalServer // this.buttonStartLocalServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonStartLocalServer.Enabled = false; this.buttonStartLocalServer.Location = new System.Drawing.Point(514, 49); this.buttonStartLocalServer.Name = "buttonStartLocalServer"; this.buttonStartLocalServer.Size = new System.Drawing.Size(44, 23); @@ -158,6 +181,7 @@ // textBoxLocalhostPort // this.textBoxLocalhostPort.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxLocalhostPort.Enabled = false; this.textBoxLocalhostPort.Location = new System.Drawing.Point(460, 49); this.textBoxLocalhostPort.Name = "textBoxLocalhostPort"; this.textBoxLocalhostPort.Size = new System.Drawing.Size(48, 20); @@ -179,6 +203,7 @@ this.textBoxServerPort.Name = "textBoxServerPort"; this.textBoxServerPort.Size = new System.Drawing.Size(46, 20); this.textBoxServerPort.TabIndex = 2; + this.textBoxServerPort.Text = "6500"; // // textBoxServerAddr // @@ -186,33 +211,37 @@ this.textBoxServerAddr.Name = "textBoxServerAddr"; this.textBoxServerAddr.Size = new System.Drawing.Size(100, 20); this.textBoxServerAddr.TabIndex = 1; - // - // radioButton3 - // - this.radioButton3.AutoSize = true; - this.radioButton3.Location = new System.Drawing.Point(28, 107); - this.radioButton3.Name = "radioButton3"; - this.radioButton3.Size = new System.Drawing.Size(148, 17); - this.radioButton3.TabIndex = 0; - this.radioButton3.TabStop = true; - this.radioButton3.Text = "Keresés a helyi hálózaton:"; - this.radioButton3.UseVisualStyleBackColor = true; - // - // radioButton2 - // - this.radioButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.radioButton2.AutoSize = true; - this.radioButton2.Location = new System.Drawing.Point(439, 25); - this.radioButton2.Name = "radioButton2"; - this.radioButton2.Size = new System.Drawing.Size(171, 17); - this.radioButton2.TabIndex = 0; - this.radioButton2.TabStop = true; - this.radioButton2.Text = "Szerver indítása a helyi gépen:"; - this.radioButton2.UseVisualStyleBackColor = true; + this.textBoxServerAddr.Text = "127.0.0.1"; + // + // radioButtonFindServers + // + this.radioButtonFindServers.AutoSize = true; + this.radioButtonFindServers.Enabled = false; + this.radioButtonFindServers.Location = new System.Drawing.Point(28, 107); + this.radioButtonFindServers.Name = "radioButtonFindServers"; + this.radioButtonFindServers.Size = new System.Drawing.Size(148, 17); + this.radioButtonFindServers.TabIndex = 0; + this.radioButtonFindServers.Text = "Keresés a helyi hálózaton:"; + this.radioButtonFindServers.UseVisualStyleBackColor = true; + this.radioButtonFindServers.CheckedChanged += new System.EventHandler(this.radioButtonFindServers_CheckedChanged); + // + // radioButtonLocalServer + // + this.radioButtonLocalServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.radioButtonLocalServer.AutoSize = true; + this.radioButtonLocalServer.Enabled = false; + this.radioButtonLocalServer.Location = new System.Drawing.Point(439, 25); + this.radioButtonLocalServer.Name = "radioButtonLocalServer"; + this.radioButtonLocalServer.Size = new System.Drawing.Size(171, 17); + this.radioButtonLocalServer.TabIndex = 0; + this.radioButtonLocalServer.Text = "Szerver indítása a helyi gépen:"; + this.radioButtonLocalServer.UseVisualStyleBackColor = true; + this.radioButtonLocalServer.CheckedChanged += new System.EventHandler(this.radioButtonLocalServer_CheckedChanged); // // radioButtonManual // this.radioButtonManual.AutoSize = true; + this.radioButtonManual.Checked = true; this.radioButtonManual.Location = new System.Drawing.Point(28, 25); this.radioButtonManual.Name = "radioButtonManual"; this.radioButtonManual.Size = new System.Drawing.Size(149, 17); @@ -220,9 +249,12 @@ this.radioButtonManual.TabStop = true; this.radioButtonManual.Text = "Szerver megadása kézzel:"; this.radioButtonManual.UseVisualStyleBackColor = true; + this.radioButtonManual.CheckedChanged += new System.EventHandler(this.radioButtonManual_CheckedChanged); // // tabPageServer // + this.tabPageServer.Controls.Add(this.label6); + this.tabPageServer.Controls.Add(this.buttonStartGame); this.tabPageServer.Location = new System.Drawing.Point(4, 22); this.tabPageServer.Name = "tabPageServer"; this.tabPageServer.Padding = new System.Windows.Forms.Padding(3); @@ -231,6 +263,17 @@ this.tabPageServer.Text = "Server"; this.tabPageServer.UseVisualStyleBackColor = true; // + // buttonStartGame + // + this.buttonStartGame.Enabled = false; + this.buttonStartGame.Location = new System.Drawing.Point(341, 95); + this.buttonStartGame.Name = "buttonStartGame"; + this.buttonStartGame.Size = new System.Drawing.Size(75, 23); + this.buttonStartGame.TabIndex = 0; + this.buttonStartGame.Text = "Start game"; + this.buttonStartGame.UseVisualStyleBackColor = true; + this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click); + // // tabPageGame // this.tabPageGame.Controls.Add(this.panelPlayers); @@ -246,39 +289,95 @@ // // panelPlayers // + this.panelPlayers.Controls.Add(this.panel2); this.panelPlayers.Controls.Add(this.panel1); + this.panelPlayers.Controls.Add(this.panelPlayer1); this.panelPlayers.Dock = System.Windows.Forms.DockStyle.Top; this.panelPlayers.Location = new System.Drawing.Point(3, 3); this.panelPlayers.Name = "panelPlayers"; this.panelPlayers.Size = new System.Drawing.Size(684, 117); this.panelPlayers.TabIndex = 2; // + // panel2 + // + this.panel2.Controls.Add(this.label4); + this.panel2.Controls.Add(this.label5); + this.panel2.Location = new System.Drawing.Point(411, 23); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(128, 32); + this.panel2.TabIndex = 1; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(98, 9); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(13, 13); + this.label4.TabIndex = 0; + this.label4.Text = "0"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(15, 9); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(45, 13); + this.label5.TabIndex = 0; + this.label5.Text = "noname"; + // // panel1 // - this.panel1.Controls.Add(this.label2); this.panel1.Controls.Add(this.label1); - this.panel1.Location = new System.Drawing.Point(19, 23); + this.panel1.Controls.Add(this.label2); + this.panel1.Location = new System.Drawing.Point(221, 23); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(128, 32); - this.panel1.TabIndex = 0; + this.panel1.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(98, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(13, 13); + this.label1.TabIndex = 0; + this.label1.Text = "0"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(98, 9); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(13, 13); + this.label2.Size = new System.Drawing.Size(45, 13); this.label2.TabIndex = 0; - this.label2.Text = "0"; + this.label2.Text = "noname"; // - // label1 + // panelPlayer1 // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(15, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(45, 13); - this.label1.TabIndex = 0; - this.label1.Text = "noname"; + this.panelPlayer1.Controls.Add(this.labelPlayerCards0); + this.panelPlayer1.Controls.Add(this.labelPlayerName0); + this.panelPlayer1.Location = new System.Drawing.Point(19, 23); + this.panelPlayer1.Name = "panelPlayer1"; + this.panelPlayer1.Size = new System.Drawing.Size(128, 32); + this.panelPlayer1.TabIndex = 0; + // + // labelPlayerCards0 + // + this.labelPlayerCards0.AutoSize = true; + this.labelPlayerCards0.Location = new System.Drawing.Point(98, 9); + this.labelPlayerCards0.Name = "labelPlayerCards0"; + this.labelPlayerCards0.Size = new System.Drawing.Size(13, 13); + this.labelPlayerCards0.TabIndex = 0; + this.labelPlayerCards0.Text = "0"; + // + // labelPlayerName0 + // + this.labelPlayerName0.AutoSize = true; + this.labelPlayerName0.Location = new System.Drawing.Point(15, 9); + this.labelPlayerName0.Name = "labelPlayerName0"; + this.labelPlayerName0.Size = new System.Drawing.Size(45, 13); + this.labelPlayerName0.TabIndex = 0; + this.labelPlayerName0.Text = "noname"; // // panelGame // @@ -408,6 +507,53 @@ this.buttonEndTurn.UseVisualStyleBackColor = true; this.buttonEndTurn.Click += new System.EventHandler(this.buttonEndTurn_Click); // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(251, 45); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(219, 26); + this.label6.TabIndex = 1; + this.label6.Text = "Jelenleg nincsnek külön szobák a szerveren.\r\nMindenki a RoomZero szoba tagja."; + // + // textBoxUserNickname + // + this.textBoxUserNickname.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxUserNickname.Location = new System.Drawing.Point(505, 210); + this.textBoxUserNickname.Name = "textBoxUserNickname"; + this.textBoxUserNickname.Size = new System.Drawing.Size(100, 20); + this.textBoxUserNickname.TabIndex = 10; + this.textBoxUserNickname.Text = "pistike"; + // + // textBoxIncomingPort + // + this.textBoxIncomingPort.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxIncomingPort.Location = new System.Drawing.Point(564, 246); + this.textBoxIncomingPort.Name = "textBoxIncomingPort"; + this.textBoxIncomingPort.Size = new System.Drawing.Size(41, 20); + this.textBoxIncomingPort.TabIndex = 11; + this.textBoxIncomingPort.Text = "6501"; + // + // label7 + // + this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(441, 249); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(98, 13); + this.label7.TabIndex = 12; + this.label7.Text = "Üzenetfogadó port:"; + // + // label8 + // + this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(441, 213); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(53, 13); + this.label8.TabIndex = 13; + this.label8.Text = "Becenév:"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -417,52 +563,71 @@ this.MinimumSize = new System.Drawing.Size(714, 431); this.Name = "Form1"; this.Text = "Zsírozás"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.tabControl1.ResumeLayout(false); this.tabPageWelcome.ResumeLayout(false); this.tabPageWelcome.PerformLayout(); + this.tabPageServer.ResumeLayout(false); + this.tabPageServer.PerformLayout(); this.tabPageGame.ResumeLayout(false); this.panelPlayers.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); + this.panelPlayer1.ResumeLayout(false); + this.panelPlayer1.PerformLayout(); this.panelGame.ResumeLayout(false); this.panelGame.PerformLayout(); this.panelCards.ResumeLayout(false); this.ResumeLayout(false); - } - - #endregion - - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPageWelcome; - private System.Windows.Forms.TabPage tabPageServer; - private System.Windows.Forms.TabPage tabPageGame; - private System.Windows.Forms.Panel panelGame; - private System.Windows.Forms.Panel panelCards; - private System.Windows.Forms.Label labelDeckCnt; - private System.Windows.Forms.Button buttonCard3; - private System.Windows.Forms.Button buttonCard2; - private System.Windows.Forms.Button buttonCard1; - private System.Windows.Forms.Button buttonCard0; - private System.Windows.Forms.Button buttonEndTurn; - private System.Windows.Forms.Label labelTurnCard; - private System.Windows.Forms.Label labelCardsDealt; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Button buttonConnect; - private System.Windows.Forms.ListBox listBoxServers; - private System.Windows.Forms.Button buttonStopLocalServer; - private System.Windows.Forms.Button buttonStartLocalServer; - private System.Windows.Forms.TextBox textBoxLocalhostPort; - private System.Windows.Forms.Button buttonServerTest; - private System.Windows.Forms.TextBox textBoxServerPort; - private System.Windows.Forms.TextBox textBoxServerAddr; - private System.Windows.Forms.RadioButton radioButton3; - private System.Windows.Forms.RadioButton radioButton2; - private System.Windows.Forms.RadioButton radioButtonManual; - private System.Windows.Forms.Button buttonSearchForServers; - private System.Windows.Forms.Panel panelPlayers; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - } + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPageWelcome; + private System.Windows.Forms.TabPage tabPageServer; + private System.Windows.Forms.TabPage tabPageGame; + private System.Windows.Forms.Panel panelGame; + private System.Windows.Forms.Panel panelCards; + private System.Windows.Forms.Label labelDeckCnt; + private System.Windows.Forms.Button buttonCard3; + private System.Windows.Forms.Button buttonCard2; + private System.Windows.Forms.Button buttonCard1; + private System.Windows.Forms.Button buttonCard0; + private System.Windows.Forms.Button buttonEndTurn; + private System.Windows.Forms.Label labelTurnCard; + private System.Windows.Forms.Label labelCardsDealt; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button buttonConnect; + private System.Windows.Forms.ListBox listBoxServers; + private System.Windows.Forms.Button buttonStopLocalServer; + private System.Windows.Forms.Button buttonStartLocalServer; + private System.Windows.Forms.TextBox textBoxLocalhostPort; + private System.Windows.Forms.Button buttonServerTest; + private System.Windows.Forms.TextBox textBoxServerPort; + private System.Windows.Forms.TextBox textBoxServerAddr; + private System.Windows.Forms.RadioButton radioButtonFindServers; + private System.Windows.Forms.RadioButton radioButtonLocalServer; + private System.Windows.Forms.RadioButton radioButtonManual; + private System.Windows.Forms.Button buttonSearchForServers; + private System.Windows.Forms.Panel panelPlayers; + private System.Windows.Forms.Panel panelPlayer1; + private System.Windows.Forms.Label labelPlayerCards0; + private System.Windows.Forms.Label labelPlayerName0; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button buttonStartGame; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox textBoxIncomingPort; + private System.Windows.Forms.TextBox textBoxUserNickname; + } } \ No newline at end of file diff --git a/zsirozas/Form1.cs b/zsirozas/Form1.cs index 0a73a6d17d4ba1c7fdbddd81a7ab73a123277b45..4f7d29ac8e64e78c8ae1ef14b21d914dd1da8d2b 100644 --- a/zsirozas/Form1.cs +++ b/zsirozas/Form1.cs @@ -70,25 +70,62 @@ namespace zsirozas private void buttonStartLocalServer_Click(object sender, EventArgs e) { - + throw new NotImplementedException(); } private void buttonStopLocalServer_Click(object sender, EventArgs e) { + throw new NotImplementedException(); + } + private void radioButtonManual_CheckedChanged(object sender, EventArgs e) + { + + } + private void radioButtonFindServers_CheckedChanged(object sender, EventArgs e) + { + } + private void radioButtonLocalServer_CheckedChanged(object sender, EventArgs e) + { } private void buttonConnect_Click(object sender, EventArgs e) - { - //TODO: obtain address from GUI + { + client.nickname = textBoxUserNickname.Text; + if (!int.TryParse(textBoxIncomingPort.Text, out client.serverIncoming)) + { + MessageBox.Show("Halihó! Ez sem egy portszám."); + } string server_IP = null; int server_port = 0; - client = new GameClient(); + + //obtain address from GUI + if (radioButtonManual.Checked) + { + server_IP = textBoxServerAddr.Text; + if (!int.TryParse(textBoxServerPort.Text, out server_port)) + { + MessageBox.Show("Halihó! Ez nem egy portszám."); + return; + } + } + else if (radioButtonLocalServer.Checked) + { + throw new NotImplementedException(); + } + else if(radioButtonFindServers.Checked) + { + throw new NotImplementedException(); + } + + //connect if (client.Connect(server_IP, server_port)) { client.handleServerError += HandleServerError; client.cardsChanged += onCardsChanged; client.gameStateCanged += GameStateCanged; + buttonStartGame.Enabled = true; + buttonConnect.Enabled = false; } else { @@ -107,6 +144,11 @@ namespace zsirozas CardButtons[i].Enabled = true; CardButtons[i].Visible = true; } + for (int i = client.Cards.Length; i < CardButtons.Length; i++) + { + CardButtons[i].Enabled = false; + CardButtons[i].Visible = false; + } } void HandleServerError(object sender, string e) @@ -116,8 +158,38 @@ namespace zsirozas void GameStateCanged(object sender, GameEvent e) { + labelCardsDealt.Text = string.Join(", ", client.gameState.cardsOnTable); + labelDeckCnt.Text = client.gameState.remainsInDeck.ToString(); + if (client.gameState.cardsOnTable.Length > 0) + { + labelTurnCard.Text = client.gameState.cardsOnTable[0].ToString(); + } + else + { + labelTurnCard.Text = ""; + } + for (int i = 0; i < client.gameState.numofCardsInHands.Length; i++) + { + int idx = (i + client.playerIDX) % client.gameState.numofCardsInHands.Length; + //TODO: játékosokhoz tartozó címkék beállítása + } + MessageBox.Show(e.ToString()); } + private void buttonStartGame_Click(object sender, EventArgs e) + { + //TODO: ezt majd inkább neeeee...... + client.roomID = "RoomZero"; + + buttonStartGame.Enabled = false; + client.StartGame(); + ; + } + + private void Form1_FormClosing(object sender, FormClosingEventArgs e) + { + client.SendRequest(ServerAction.Logout); + } } } diff --git a/zsirozas/Game.cs b/zsirozas/Game.cs index 5b8e746597003598b28e27310bffbceb4c02693e..0ced6e76ba1b75b73938261db23fe0c8903218c4 100644 --- a/zsirozas/Game.cs +++ b/zsirozas/Game.cs @@ -15,16 +15,29 @@ namespace zsirozas public void NotifyPlayers(GameEvent @event) { - string prefix = ServerAction.GameAction.ToString() + "\n"; - string message = prefix + @event.ToString(); + string prefix = ServerEvent.GameEvent + "\n"; + string message = prefix + @event; switch (@event) { case GameEvent.CardAction: case GameEvent.NewTurn: - message += " " + PublicState().ToString(); + message += "\n" + PublicState().ToString(); break; case GameEvent.GameOver: //TODO: compose GameOver message + var zsir_lapok = new CardValue[] { CardValue.X, CardValue.I }; + var zsir_cnt = new int[playersByOrder.Length]; + for (int i = 0; i < playersByOrder.Length; i++) + { + for (int j = 0; j < playersByID[playersByOrder[i]].cardsWon.Count; j++) + { + if (zsir_lapok.Contains(deck.CardsByID[playersByID[playersByOrder[i]].cardsWon[j]].value)) + { + zsir_cnt[i]++; + } + } + } + var izteurdsa = Enumerable.Range(0, playersByOrder.Length).OrderByDescending((arg) => zsir_cnt[arg]); break; default: break; @@ -45,7 +58,7 @@ namespace zsirozas playersByID = new Dictionary<string, Player>(); //create a new deck - deck = new Deck(1 + playersByOrder.Length / 4); + deck = new Deck(1 + (playersByOrder.Length - 1) / 4); //deal 4 cards each var startingCards = deck.Deal(4, playersByOrder.Length); @@ -58,7 +71,7 @@ namespace zsirozas //start the first round currentRound = new Round(1, playersByOrder.Length); - + NotifyPlayers(GameEvent.NewTurn); } public void ValidPlayerMakesCardActionInValidTurnWithValidCard(string playerID, int cardID) @@ -138,21 +151,31 @@ namespace zsirozas { if (playerID == playersByOrder[currentRound.startingPlayer]) { + //transfer playedCards to winner playersByID[playersByOrder[currentRound.lastToHit]].cardsWon.AddRange(currentRound.playedCards); - //winner starts a new round - currentRound = new Round(currentRound.lastToHit, playersByOrder.Length); - //deal new cards for everyone - int dealN = 4 - playersByID[playerID].cardsInHand.Count; - var sdfsdff = deck.Deal(dealN, playersByOrder.Length); - for (int i = 0; i < playersByOrder.Length; i++) + + //check for endGame condition + if (deck.cardsDealtSoFar == deck.IDsByOrder.Count) + { + NotifyPlayers(GameEvent.GameOver); + } + else { - int index = (currentRound.startingPlayer + i + 1) % playersByOrder.Length; - playersByID[playersByOrder[index]].cardsInHand.AddRange(sdfsdff[i]); + //winner starts a new round + currentRound = new Round(currentRound.lastToHit, playersByOrder.Length); + //deal new cards for everyone + int dealN = 4 - playersByID[playerID].cardsInHand.Count; + var sdfsdff = deck.Deal(dealN, playersByOrder.Length); + for (int i = 0; i < playersByOrder.Length; i++) + { + int index = (currentRound.startingPlayer + i + 1) % playersByOrder.Length; + playersByID[playersByOrder[index]].cardsInHand.AddRange(sdfsdff[i]); + } + //notify everyone + + NotifyPlayers(GameEvent.NewTurn); } - //notify everyone - //TODO: check for endGame condition - NotifyPlayers(GameEvent.NewTurn); } else { @@ -167,8 +190,14 @@ namespace zsirozas break; case PlayerAction.GetCards: //TODO: getCards-oz imlementálni, feltéttelvizsgálatokat megejteni! - return new JavaScriptSerializer().Serialize(playersByID[playerID].cardsInHand); - break; + string serializedCards = new JavaScriptSerializer() + .Serialize( + playersByID[playerID] + .cardsInHand + .Select( + (arg) => deck.CardsByID[arg] + )); + return serializedCards; default: Complain("Objection! It's not a valid request!"); break; @@ -182,6 +211,7 @@ namespace zsirozas } public void EndGame() { + NotifyPlayers(GameEvent.GameOver); throw new NotImplementedException(); } diff --git a/zsirozas/GameClient.cs b/zsirozas/GameClient.cs index d91baf7f05c62f77e3a16ed7899617df50a6752a..36a90e1231a3a9e3d56499ab06ea6cb1d84b2a2b 100644 --- a/zsirozas/GameClient.cs +++ b/zsirozas/GameClient.cs @@ -1,6 +1,9 @@ using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Net; +using System.Net.NetworkInformation; using System.Net.Sockets; using System.Threading; using System.Web.Script.Serialization; @@ -27,6 +30,7 @@ namespace zsirozas using (var sr = new StreamReader(tempConn.GetStream())) { sw.WriteLine(ServerAction.Ping); + sw.Flush(); if (sr.ReadLine() != "OK") { return false; @@ -46,6 +50,9 @@ namespace zsirozas throw new NotSupportedException(); } + public string nickname = "gdgDdhf"; + public int serverIncoming = 6502; + public bool Connect(string server_ip, int server_port) { if (pingServer(server_ip, server_port)) @@ -53,11 +60,13 @@ namespace zsirozas server = new IPEndPoint(IPAddress.Parse(server_ip), server_port); try { + + incomingListener = new TcpListener(IPAddress.Any, serverIncoming); incomingListener.Start(); - if (SendRequest(ServerAction.Login, 6501 + "")) + if (SendRequest(ServerAction.Login, nickname + "\n" + ((IPEndPoint)incomingListener.Server.LocalEndPoint).Port)) { messageStream = incomingListener.AcceptTcpClient().GetStream(); - new Thread(ListenForServer).Start(); + new Thread(ListenForServer) { IsBackground = true }.Start(); return true; } } @@ -79,7 +88,7 @@ namespace zsirozas public string gameID; public int playerIDX; - TcpListener incomingListener = new TcpListener(IPAddress.Any, 6501); + TcpListener incomingListener = null; Stream messageStream = null; public bool SendRequest(ServerAction action, string @params = null) @@ -96,6 +105,7 @@ namespace zsirozas { case ServerAction.CreateRoom: sw.WriteLine(userID); + sw.Flush(); if ((status = sr.ReadLine()) != "OK") { handleServerError(this, status); @@ -109,6 +119,7 @@ namespace zsirozas case ServerAction.JoinRoom: sw.WriteLine(userID); sw.WriteLine(@params); + sw.Flush(); if ((status = sr.ReadLine()) != "OK") { handleServerError(this, status); @@ -121,6 +132,7 @@ namespace zsirozas break; case ServerAction.LeaveRoom: sw.WriteLine(userID); + sw.Flush(); if ((status = sr.ReadLine()) != "OK") { handleServerError(this, status); @@ -133,7 +145,8 @@ namespace zsirozas sw.WriteLine(gameID); sw.WriteLine(userID); sw.WriteLine(@params); - //TODO: ez a getCards idegesítően fura... + sw.Flush(); + //TODO: ez a getCards idegesítően különc... if ((status = sr.ReadLine()) != "OK") { handleServerError(this, status); @@ -141,16 +154,46 @@ namespace zsirozas } else if (@params.Contains(PlayerAction.GetCards.ToString())) { - Cards = new JavaScriptSerializer().Deserialize<Card[]>(sr.ReadLine()); + status = sr.ReadLine(); + Cards = (new JavaScriptSerializer().Deserialize<IEnumerable<Card>>(status)).ToArray(); + cardsChanged(); } break; case ServerAction.Logout: sw.WriteLine(userID); - + sw.Flush(); break; case ServerAction.Ping: + break; case ServerAction.Login: + sw.WriteLine(@params); + sw.Flush(); + if ((status = sr.ReadLine()) != "OK") + { + handleServerError(this, status); + return false; + } + else + { + userID = sr.ReadLine(); + } + break; + case ServerAction.StartGame: + sw.WriteLine(@params); + sw.Flush(); + if ((status = sr.ReadLine()) != "OK") + { + handleServerError(this, status); + return false; + } + else + { + gameID = sr.ReadLine(); + } + break; case ServerAction.ListRooms: + //case ServerAction.ListUsers: + //case ServerAction.ListGames: default: break; } @@ -159,32 +202,65 @@ namespace zsirozas return true; } - void ListenForServer() + public void StartGame() { + SendRequest(ServerAction.StartGame, roomID); + } - //var utruzr = new TcpClient(); - ////-------stolen code----------- - //// Create a TCP/IP socket. - //Socket listener = new Socket(SocketType.Stream, ProtocolType.Tcp); - - //// Bind the socket to the local endpoint and - //// listen for incoming connections. - //IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 1221); - //listener.Bind(localEndPoint); - //listener.Listen(10); - - //// Start listening for connections. - - //Console.WriteLine("Waiting for a connection..."); - //// Program is suspended while waiting for an incoming connection. - //Socket handler = listener.Accept(); - ////-----stuff happens - //handler.Shutdown(SocketShutdown.Both); - //handler.Close(); - - ////------end stolen code----------- - //ParseNextMessage(utruzr.GetStream()); + public void JoinRoom(string roomID) + { + SendRequest(ServerAction.JoinRoom, roomID); + } + void ListenForServer() + { + using (var sr = new StreamReader(messageStream)) + { + string line = ""; + while (true) + { + try + { + while (line == "") + { + line = sr.ReadLine(); + } + var @event = (ServerEvent)Enum.Parse(typeof(ServerEvent), line); + switch (@event) + { + case ServerEvent.GameEvent: + //TODO: validálni + line = sr.ReadLine(); + GameEvent gameEvent; + Enum.TryParse<GameEvent>(line, out gameEvent); + switch (gameEvent) + { + case GameEvent.NewTurn: + gameState = new JavaScriptSerializer().Deserialize<Game.MidGameState>(sr.ReadLine()); + gameStateCanged(this, gameEvent); + SendRequest(ServerAction.GameAction, PlayerAction.GetCards + "\n"); + break; + case GameEvent.CardAction: + gameState = new JavaScriptSerializer().Deserialize<Game.MidGameState>(sr.ReadLine()); + gameStateCanged(this, gameEvent); + break; + case GameEvent.GameOver: + default: + break; + } + break; + case ServerEvent.Logout: + return; + default: + break; + } + } + catch (Exception ex) + { + ; + } + } + } } @@ -212,10 +288,13 @@ namespace zsirozas public bool EndTurn() { - return SendRequest(ServerAction.GameAction, PlayerAction.EndTurn.ToString()); + return SendRequest(ServerAction.GameAction, PlayerAction.EndTurn + "\n"); } public Game.MidGameState gameState; public event EventHandler<GameEvent> gameStateCanged; + + + } } \ No newline at end of file diff --git a/zsirozas/Program.cs b/zsirozas/Program.cs index c9ac6e080bbbcd215c4758741061f922eaf57f06..3f7a3a20b0bd11067bf0f8fdc420068595338a08 100644 --- a/zsirozas/Program.cs +++ b/zsirozas/Program.cs @@ -17,7 +17,16 @@ namespace zsirozas //Console.WriteLine(deck.cardsDealtSoFar); //Console.WriteLine(); //Console.WriteLine(deck.ToString()); - Application.Run(new Form1()); + + //args = new string[]{ "--server" }; + if (args.Contains("--server")) + { + new Server().Loop(); + } + else + { + Application.Run(new Form1()); + } } } } diff --git a/zsirozas/Server.cs b/zsirozas/Server.cs index fc02a391c306ac7c4f1df7003f0dd72e2f1e5b39..5f58ccd5205eb2362db30f45a91f3f6d4ef7db20 100644 --- a/zsirozas/Server.cs +++ b/zsirozas/Server.cs @@ -43,6 +43,7 @@ namespace zsirozas ); } var requestQueue = new TcpListener(IPAddress.Any, ListenPort); + requestQueue.Start(); while (true) { var clientRequest = requestQueue.AcceptTcpClient(); @@ -58,7 +59,7 @@ namespace zsirozas using (var sr = new StreamReader(s)) using (var sw = new StreamWriter(s)) { - + string line = ""; while (line == "") { @@ -72,17 +73,27 @@ namespace zsirozas case ServerAction.GameAction: //a következő sor a gameID line = sr.ReadLine(); + //TODO: rájönni, miért nullt ad a kliens gameID helyett + if (line == "") line = "G~RoomZero"; + if (Games.Contains(line)) { //TODO: validálni? vagy kivételt elkapni? - GamesByID[line].Action( + string playerID = sr.ReadLine(); + string playerAction = sr.ReadLine(); + string cardID = sr.ReadLine(); + //TODO: rájönni hogy miért ad néha null-t cardID helyett + if (cardID == "") cardID = "0"; + string response = GamesByID[line].Action( //playerID - sr.ReadLine(), + playerID, //action - (PlayerAction)Enum.Parse(typeof(PlayerAction), sr.ReadLine()), + (PlayerAction)Enum.Parse(typeof(PlayerAction), playerAction), //cardID, nem hagyható el (de nem mindig értelmes) - int.Parse(sr.ReadLine()) + int.Parse(cardID) ); + sw.WriteLine("OK"); + sw.WriteLine(response); } break; case ServerAction.Ping: @@ -123,12 +134,17 @@ namespace zsirozas case ServerAction.InviteUser: //nem része az alapnak throw new NotSupportedException(); + case ServerAction.StartGame: + var newgame = NewGame(sr.ReadLine()); + sw.WriteLine("OK"); + sw.WriteLine(newgame); + break; default: break; } + sw.Flush(); } - } // public void MessageUser(string userID, ServerAction action, string message) { } @@ -167,16 +183,16 @@ namespace zsirozas U.nickname = nickname; UsersByID.Add(U.userID, U); Users.Add(U.userID); - if (bigRoom) - { - JoinRoom(U.userID, Rooms[0]); - } - //estabilishing server-to-client link U.msgConn = new TcpClient(); U.msgConn.Connect(IP, port); U.messageStreamW = new StreamWriter(U.msgConn.GetStream()); + if (bigRoom) + { + JoinRoom(U.userID, Rooms[0]); + } + return U.userID; } @@ -195,6 +211,12 @@ namespace zsirozas { //TODO: validálni ezt a mindent RoomsByID[UsersByID[userID].roomID].userList.Remove(userID); + if (!bigRoom && RoomsByID[UsersByID[userID].roomID].userList.Count == 0) + { + RoomsByID.Remove(UsersByID[userID].roomID); + Rooms.Remove(UsersByID[userID].roomID); + } + UsersByID[userID].roomID = null; } } public void JoinRoom(string userID, string roomID) @@ -227,6 +249,11 @@ namespace zsirozas GameAction, StartGame, Ping, ListRooms, Login, Logout, CreateRoom, LeaveRoom, JoinRoom, InviteUser } + enum ServerEvent + { + GameEvent, Logout + } + class User { public string nickname; @@ -239,6 +266,7 @@ namespace zsirozas public void SendMessage(string message) { messageStreamW.WriteLine(message); + messageStreamW.Flush(); } }