Example #1
0
 private void fillControls(Game g)
 {
     pnlBasicA.Controls.Clear();
     this.Width = (g.GetFieldSize() - 1) * 70 + 221 + 221 + 4;
     for (int i = 0; i < g.GetFieldSize(); i++)
     {
         if (g.Field.Houses[i] is SideHouse)
         {
             lblSideA.Text = g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount;
         }
         else
         {
             Label lblBasicHouse = new Label();
             lblBasicHouse.Font = fntBasic;
             lblBasicHouse.ForeColor = clrBasic;
             lblBasicHouse.Dock = System.Windows.Forms.DockStyle.Left;
             lblBasicHouse.Location = new System.Drawing.Point(0, 0);
             lblBasicHouse.Name = "lblBasicA_" + i.ToString();
             lblBasicHouse.Text = g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount;
             lblBasicHouse.TextAlign = System.Drawing.ContentAlignment.TopCenter;
             lblBasicHouse.BorderStyle = BorderStyle.FixedSingle;
             lblBasicHouse.Size = new System.Drawing.Size(
                 /*(pnlBasicA.ClientSize.Width-pnlSideB.Width)/(g.GetFieldSize()-1)*/ 70
                 ,
                 pnlBasicA.ClientSize.Height
                 );
             lblBasicHouse.ImageIndex = 1;
             lblBasicHouse.ImageList = this.imlImagesBasic;
             lblBasicHouse.Tag = i;
             lblBasicHouse.Click += lblBasicHouse_Click;
             lblBasicHouse.MouseEnter += lblBasicHouse_MouseEnter;
             lblBasicHouse.MouseLeave += new EventHandler(lblBasicHouse_MouseLeave);
             pnlBasicA.Controls.Add(lblBasicHouse);
         }
         //Console.Write("|" + (((g.FieldA.Houses[i] is SideHouse) ? "+" : " ") + g.FieldA.Houses[i].Idx + ": " + g.FieldA.Houses[i].TokenAmount).PadLeft(8, ' '));
     }
     pnlBasicB.Controls.Clear();
     //  pnlBasicB.Controls.Add(lblPlayerBInfo);
     for (int i = g.GetFieldSize(); i < g.GetFieldSize() * 2; i++)
     {
         if (g.Field.Houses[i] is SideHouse)
         {
             lblSideB.Text = g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount;
         }
         else
         {
             Label lblBasicHouse = new Label();
             lblBasicHouse.Font = fntBasic;
             lblBasicHouse.ForeColor = clrBasic;
             lblBasicHouse.Dock = System.Windows.Forms.DockStyle.Right;
             lblBasicHouse.Location = new System.Drawing.Point(0, 0);
             lblBasicHouse.Name = "lblBasicB_" + i.ToString();
             lblBasicHouse.Text = g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount;
             lblBasicHouse.TextAlign = System.Drawing.ContentAlignment.TopCenter;
             lblBasicHouse.BorderStyle = BorderStyle.FixedSingle;
             lblBasicHouse.Size = new System.Drawing.Size(
                 /* (pnlBasicB.ClientSize.Width - pnlSideA.Width) / (g.GetFieldSize() - 1) */
                70
                 ,
                 pnlBasicB.ClientSize.Height
                 );
             lblBasicHouse.ImageIndex = 1;
             lblBasicHouse.ImageList = this.imlImagesBasic;
             lblBasicHouse.Tag = i;
             lblBasicHouse.Click += lblBasicHouse_Click;
             lblBasicHouse.MouseEnter += lblBasicHouse_MouseEnter;
             lblBasicHouse.MouseLeave += new EventHandler(lblBasicHouse_MouseLeave);
             pnlBasicB.Controls.Add(lblBasicHouse);
         }
         //   Console.Write("|" + (((g.FieldA.Houses[i] is SideHouse) ? "+" : " ") + g.FieldA.Houses[i].Idx + ": " + g.FieldA.Houses[i].TokenAmount).PadLeft(8, ' '));
     }
     lblSideA.Font = fntSide;
     lblSideA.ForeColor = clrBasic;
     lblSideB.Font = fntSide;
     lblSideB.ForeColor = clrBasic;
     //pnlBasicA.Enabled = true;
     if (game.ActivePlayer == game.PlayerA) { setPanelControlsState(pnlBasicA, true); }
     else
     {
         setPanelControlsState(pnlBasicB, true);
     }
 }
Example #2
0
 private void drawGame(Game g, GameState gs)
 {
     lblGameCaption.Text = g.PlayerA.Name + " vs " + g.PlayerB.Name;
     Label lbl = null;
     for (int i = 0; i < g.GetFieldSize(); i++)
     {
         if (g.Field.Houses[i] is SideHouse)
         {
             lblSideA.Text = /*"\n"*/ +g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount;
             switch (g.Field.Houses[i].TokenAmount)
             {
                 case 0:
                     lblSideA.ImageIndex = 0;
                     break;
                 case 1:
                     lblSideA.ImageIndex = 1;
                     break;
                 case 2:
                     lblSideA.ImageIndex = 2;
                     break;
                 case 3:
                     lblSideA.ImageIndex = 3;
                     break;
                 case 4:
                     lblSideA.ImageIndex = 3;
                     break;
                 case 5:
                     lblSideA.ImageIndex = 3;
                     break;
                 default:
                     lblSideA.ImageIndex = 3;
                     break;
             }
         }
         else
         {
             lbl = (Label)(pnlBasicA.Controls.Find("lblBasicA_" + i.ToString(), false))[0];
             lbl.Text = /*"\n" + *//*g.FieldA.Houses[i].Idx + ": " +*/ "" + g.Field.Houses[i].TokenAmount;
             lbl.ImageIndex = (g.Field.Houses[i].TokenAmount == 0) ? 1 : 2;
         }
     }
     for (int i = g.GetFieldSize(); i < g.GetFieldSize() * 2; i++)
     {
         if (g.Field.Houses[i] is SideHouse)
         {
             lblSideB.Text =/* "\n"+*/g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount;
             switch (g.Field.Houses[i].TokenAmount)
             {
                 case 0:
                     lblSideB.ImageIndex = 6;
                     break;
                 case 1:
                     lblSideB.ImageIndex = 7;
                     break;
                 case 2:
                     lblSideB.ImageIndex = 8;
                     break;
                 case 3:
                     lblSideB.ImageIndex = 9;
                     break;
                 case 4:
                     lblSideB.ImageIndex = 9;
                     break;
                 case 5:
                     lblSideB.ImageIndex = 9;
                     break;
                 default:
                     lblSideB.ImageIndex = 9;
                     break;
             }
             /*using (Graphics  graphics =  pbxSideB.CreateGraphics()){
                 graphics.DrawString("++", fntBasic, new SolidBrush(clrBasic), 0, 0);
             }*/
         }
         else
         {
             lbl = (Label)(pnlBasicB.Controls.Find("lblBasicB_" + i.ToString(), false))[0];
             lbl.Text = /*"\n" +*//* g.FieldA.Houses[i].Idx + ": " +*/ "" + g.Field.Houses[i].TokenAmount;
             lbl.ImageIndex = (g.Field.Houses[i].TokenAmount == 0) ? 3 : 4;
         }
     }
     switch (g.LastTurnResult)
     {
         case TurnResult.NOTHING:
             break;
         case TurnResult.CELL_BELONGS_OTHER_PLAYER:
             addToLog("This cell belongs to other player, you can't make turn here.");
             break;
         case TurnResult.SIDEHOUSE_SELECTED:
             addToLog("This cell is a sidehouse, you can't make turn here.");
             break;
         case TurnResult.EMPTY_HOUSE:
             addToLog("This cell is empty, you can't make turn here.");
             break;
         case TurnResult.ADDITIONAL_TURN:
             addToLog("You finished in sidehouse, additional turn!");
             break;
         case TurnResult.SUCCESSFUL:
             break;
         case TurnResult.GAME_FINISHED:
             addToLog("Game finished! ");
             if (gs.CurrentPlayer != null)
             {
                 addToLog("Player " + gs.CurrentPlayer.Name + " wins!");
             }
             else
             {
                 addToLog("Nobody wins.");
             }
             break;
         default:
             break;
     }
     lblSideA.Text =/*+= "\n" +*/ g.PlayerA.Name /*+ "\nfield: " + gs.ABasicSum */+ "\nRedeemed: " + gs.ASideNum;
     lblSideB.Text =/*+= "\n" +*/ g.PlayerB.Name /*+ "\nfield: " + gs.BBasicSum */+ "\nEnthralled: " + gs.BSideNum;
     //   lblPlayerAInfo.Text= g.PlayerA.Name + "\nfield: " + gs.ABasicSum + "\nside: " + gs.ASideNum;
     //      lblPlayerBInfo.Text= g.PlayerB.Name + "\nfield: " + gs.BBasicSum + "\nside: " + gs.BSideNum;
     if (!gs.GameFinished)
     {
         addToLog("It is your turn, " + gs.CurrentPlayer.Name);
         //  pnlBasicA.Enabled = (gs.CurrentPlayer == g.PlayerA);
         setPanelControlsState(pnlBasicA, gs.CurrentPlayer == g.PlayerA);
         setPanelControlsState(pnlBasicB, gs.CurrentPlayer != g.PlayerA);
         //pnlBasicB.Enabled = !pnlBasicA.Enabled;
     }
     else
     {
         //pnlBasicB.Enabled = pnlBasicA.Enabled = false;
         setPanelControlsState(pnlBasicA, false);
         setPanelControlsState(pnlBasicB, false);
     }
 }
Example #3
0
        static void drawGame(Game g, GameState gs)
        {
            Console.WriteLine();
            Console.WriteLine(g.PlayerA.Name + " vs " + g.PlayerB.Name);

            Console.WriteLine("---------------------------------------------------------------");
            Console.Write("".PadLeft(9,' '));
            for (int i = 0; i < g.GetFieldSize(); i++)
            {
                Console.Write("|" +( ((g.Field.Houses[i] is SideHouse) ? "+" : " ") + g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount).PadLeft(8,' '));
            }

            Console.WriteLine();
            Console.WriteLine("---------------------------------------------------------------");
            for (int i = g.GetFieldSize()*2-1; i >= g.GetFieldSize(); i--)
            {
                Console.Write("|" +( ((g.Field.Houses[i] is SideHouse) ? "+" : " ") + g.Field.Houses[i].Idx + ": " + g.Field.Houses[i].TokenAmount).PadLeft(8, ' '));
            }
            Console.WriteLine();

            switch (g.LastTurnResult)
            {
                case TurnResult.NOTHING:
                    break;
                case TurnResult.CELL_BELONGS_OTHER_PLAYER:
                    Console.WriteLine("This cell belongs to other player, you can't make turn here.");
                    break;
                case TurnResult.SIDEHOUSE_SELECTED:
                    Console.WriteLine("This cell is a sidehouse, you can't make turn here.");
                    break;
                case TurnResult.EMPTY_HOUSE:
                    Console.WriteLine("This cell is empty, you can't make turn here.");
                    break;
                case TurnResult.ADDITIONAL_TURN:
                    Console.WriteLine("You finished in sidehouse, additional turn!");
                    break;
                case TurnResult.SUCCESSFUL:

                    break;
                case TurnResult.GAME_FINISHED:
                    Console.WriteLine("Game finished! ");
                    if (gs.CurrentPlayer != null)
                    {
                        Console.WriteLine("Player " + gs.CurrentPlayer.Name + " wins!");
                    }
                    else {
                        Console.WriteLine("Nobody wins.");
                    }
                    break;
                default:
                    break;
            }

            Console.WriteLine(g.PlayerA.Name+": field: " +gs.ABasicSum+", side: "+gs.ASideNum);
            Console.WriteLine(g.PlayerB.Name + ": field: " + gs.BBasicSum + ", side: " + gs.BSideNum);

            if (!gs.GameFinished) { Console.WriteLine("It is your turn, " + g.ActivePlayer.Name); }

              /*
            Console.Write("      ");
            for (int i = 0; i < g.GetFieldSize(); i++)
            {
                Console.Write("|" + ((g.FieldB.Houses[i] is SideHouse) ? "+" : " ") + g.FieldB.Houses[i].Idx+": "+ g.FieldB.Houses[i].TokenAmount);
            }
            Console.WriteLine();
            Console.WriteLine("It is your turn, "+g.ActivePlayer.Name);
            */
        }