Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Scrabble.Lexicon.PlayDesk"/> class.
        /// Layout is classic Scrabble desk 15*15 + classic bonuses.
        /// </summary>/
        public PlayDesk(Game.Game g)
        {
            this.game      = g;
            this.desk      = new char[15, 15];
            this.wordBonus = new byte[15, 15];
            this.charBonus = new byte[15, 15];

            for (int j = 0; j < desk.GetLength(1); j++)
            {
                for (int i = 0; i < desk.GetLength(1); i++)
                {
                    desk[i, j]      = '_';
                    wordBonus[i, j] = 1;
                    charBonus[i, j] = 1;
                }
            }

            byte[,] tripleW  = { { 0, 0 }, { 7, 0 }, { 14, 0 }, { 0, 7 }, { 7, 14 }, { 0, 14 }, { 14, 0 }, { 14, 7 }, { 14, 14 } };
            byte[,] doubleW  = { { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 4 }, { 7, 7 }, { 13, 1 }, { 12, 2 }, { 11, 3 }, { 10, 4 }, { 4, 10 }, { 3, 11 }, { 2, 12 }, { 1, 13 }, { 10, 10 }, { 11, 11 }, { 12, 12 }, { 13, 13 } };
            byte[,] tripleCh = { { 5, 1 }, { 9, 1 }, { 5, 5 }, { 9, 5 }, { 1, 5 }, { 13, 5 }, { 5, 9 }, { 9, 9 }, { 5, 13 }, { 9, 13 }, { 1, 9 }, { 13, 9 } };
            byte[,] doubleCh = { { 3, 0 }, { 11, 0 }, { 6, 6 }, { 8, 6 }, { 6, 8 }, { 8, 8 }, { 3, 14 }, { 11, 14 }, { 2, 6 }, { 3, 7 }, { 2, 8 }, { 6, 2 }, { 7, 3 }, { 8, 2 }, { 11, 7 }, { 12, 6 }, { 12, 8 }, { 6, 12 }, { 7, 11 }, { 8, 12 } };

            LoadFromMemory(wordBonus, tripleW, 3);
            LoadFromMemory(wordBonus, doubleW, 2);
            LoadFromMemory(charBonus, tripleCh, 3);
            LoadFromMemory(charBonus, doubleCh, 2);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Scrabble.GUI.Rack"/> class.
        /// </summary>
        /// <param name='g'>
        /// G.
        /// </param>
        public Rack(Scrabble.Game.Game g) : base("Zásobník")
        {
            this.HeightRequest = 60;
            this.WidthRequest  = 350;

            this.labels      = new Gtk.Label[Scrabble.Game.InitialConfig.sizeOfRack];
            this.labelsHover = new Gtk.Table(1, (uint)Game.InitialConfig.sizeOfRack, true);
            for (uint i = 0; i < Game.InitialConfig.sizeOfRack; i++)
            {
                this.labels[i] = new Label();
                this.labelsHover.Attach(labels[i], i, i + 1, 0, 1);
            }

            this.labelsHover.ColumnSpacing = 6;
            this.labelsHover.BorderWidth   = 3;
            this.BorderWidth = 5;

            this.Add(this.labelsHover);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Scrabble.GUI.Control"/> class.
        /// </summary>
        /// <param name='g'>
        /// G.
        /// </param>
        public Control(Scrabble.Game.Game g) : base("Tah")
        {
            this.HeightRequest = 60;
            this.WidthRequest  = 350;


            this.game        = g;
            this.BorderWidth = 5;

            reload          = new Gtk.Button("Reload");
            reload.Clicked += ReloadRack;
            pass            = new Gtk.Button("Vzdát se tahu");
            pass.Clicked   += delegate {
                this.game.changePlayer();
            };

            mainVbox = new Gtk.VBox();
            mainVbox.PackStart(reload);
            mainVbox.PackEnd(pass);

            this.Add(mainVbox);
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Scrabble.Lexicon.PlayDesk"/> class. 
        /// Layout is classic Scrabble desk 15*15 + classic bonuses.
        /// </summary>/
        public PlayDesk(Game.Game g)
        {
            this.game = g;
            this.desk = 	new char[15,15];
            this.wordBonus = new byte[15,15];
            this.charBonus = new byte[15,15];

            for(int j=0; j<desk.GetLength(1); j++)
                for(int i=0; i<desk.GetLength(1); i++) {
                    desk[i,j] = '_';
                    wordBonus[i,j] = 1;
                    charBonus[i,j] = 1;
            }

            byte[,] tripleW = {{0,0},{7,0},{14,0},{0,7},{7,14},{0,14},{14,0},{14,7},{14,14}};
            byte[,] doubleW = {{1,1},{2,2},{3,3},{4,4},{7,7},{13,1},{12,2},{11,3},{10,4},{4,10},{3,11},{2,12},{1,13},{10,10},{11,11},{12,12},{13,13} };
            byte[,] tripleCh = {{5,1},{9,1},{5,5},{9,5},{1,5},{13,5},{5,9},{9,9},{5,13},{9,13},{1,9},{13,9} };
            byte[,] doubleCh = {{3,0},{11,0},{6,6},{8,6},{6,8},{8,8},{3,14},{11,14},{2,6},{3,7},{2,8},{6,2},{7,3},{8,2},{11,7},{12,6},{12,8},{6,12},{7,11},{8,12} };

            LoadFromMemory(wordBonus,tripleW,3);
            LoadFromMemory(wordBonus,doubleW,2);
            LoadFromMemory(charBonus,tripleCh,3);
            LoadFromMemory(charBonus,doubleCh,2);
        }
Пример #5
0
 public scrabbleClient(Scrabble.Game.Game g)
 {
     this.game     = g;
     this.listener = new TcpListener(IPAddress.Any, Scrabble.Game.InitialConfig.port);
 }
Пример #6
0
 public scrabbleServer(Scrabble.Game.Game g)
 {
     this.game = g;
 }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Scrabble.GUI.ScrabbleWindow"/> class.
        /// </summary>
        /// <param name='isClient'>
        /// Is client.
        /// </param>
        /// <exception cref='System.NullReferenceException'>
        /// Is thrown when there is an attempt to dereference a null object reference.
        /// </exception>
        public ScrabbleWindow(bool isClient = false) : base(Gtk.WindowType.Toplevel)
        {
            #region Basic window properties
            // Basic window properties
            this.Title          = "Scrabble - Hrací deska" + (isClient ? " (klient)" : "");
            this.Name           = "MainWindow";
            this.DoubleBuffered = true;
            this.SetPosition(WindowPosition.Center);
            this.Icon = Scrabble.Game.InitialConfig.icon;

            this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);

            this.DefaultWidth  = 550;
            this.DefaultHeight = 700;
            #endregion

            this.client = isClient;
            if (Scrabble.Game.InitialConfig.game == null)
            {
                throw new System.NullReferenceException("During Scrabble main widow initialization is Scrabble.Game.InitialConfig.game == null");
            }
            this.game = Scrabble.Game.InitialConfig.game;

            // General GUI classes
            this.menu    = new MenuHover(this);
            this.desk    = new Desk(this.game);
            this.rack    = new Rack(this.game);
            this.control = new Control(this.game);
            this.info    = new Info(this.game);

            this.bottomVbox = new VBox(true, 4);
            this.bottomVbox.PackStart(rack);
            this.bottomVbox.PackEnd(control);
            this.bottomVbox.ShowAll();

            this.vertical = new HPaned();
            this.vertical.HeightRequest = 100;

            // Use only CLIENT
            clientNotice             = new Label();
            clientNotice.Markup      = "<b>Čekám</b> na aktualizaci dat o hře.";
            clientNotice.TooltipText = "Na portu " + Scrabble.Game.InitialConfig.port.ToString();

            // STATUSBAR
            statusbar = new Statusbar();
            statusbar.HeightRequest = 20;
            statusbar.Homogeneous   = true;
            StatusLabelLast         = new Label("Poslední tah:");
            StatusLabelBest         = new Label("Nejlepší tah:");
            OnTurnLabel             = new Label("Na tahu:");
            statusbar.PackStart(OnTurnLabel, false, false, 0);
            statusbar.Add(StatusLabelLast);
            statusbar.PackEnd(StatusLabelBest, false, false, 0);

            // Vertical divide at bottom
            this.vertical = new HPaned();
            this.vertical.HeightRequest = 100;
            this.vertical.Add1(bottomVbox);
            this.vertical.Add2(info);


            this.mainVbox = new VBox(false, 5);
            if (isClient)
            {
                this.mainVbox.PackStart(clientNotice, false, false, 5);
            }
            else
            {
                this.mainVbox.PackStart(menu.menuBar, false, false, 0);
            }
            this.mainVbox.Add(desk);
            this.mainVbox.Add(vertical);
            this.mainVbox.PackEnd(statusbar, false, false, 0);

            this.Add(mainVbox);
            this.changePlayer(game.GetActualPlayer());

            if (isClient)
            {
                DisableButtons();
            }
        }
Пример #8
0
 public static void Init( Scrabble.Game.Game g )
 {
     game = g;
 }
Пример #9
0
 /// <summary>
 /// Sets the game.
 /// </summary>
 /// <param name='g'>
 /// G.
 /// </param>
 public void setGame(Scrabble.Game.Game g)
 {
     this.game = g;
 }
Пример #10
0
 /// <summary>
 /// Sets the game.
 /// </summary>
 /// <param name='g'>
 /// G.
 /// </param>
 public void setGame( Scrabble.Game.Game g )
 {
     this.game = g;
 }
Пример #11
0
 public static void Init(Scrabble.Game.Game g)
 {
     game = g;
 }