示例#1
0
        public Desk(Game.Game g) : base(sizeX, sizeY, true)
        {
            this.fields = new Stone[sizeX + 1, sizeY + 1];
            this.game   = g;
            this.Pdesk  = ((Game.Game)game).desk;

            // inicialization of labels
            this.fields[0, 0]           = new Stone();
            this.fields[0, 0].Sensitive = false;
            for (uint i = 1; i < fields.GetLength(0); i++)
            {
                this.fields[i, 0] = new Stone();
                this.Attach(fields[i, 0], i, i + 1, 0, 1);
                this.fields[i, 0].Sensitive = false;
                this.fields[i, 0].Show();
                this.fields[i, 0].setChar(i.ToString());

                this.fields[0, i] = new Stone();
                this.Attach(fields[0, i], 0, 1, i, i + 1);
                this.fields[0, i].Sensitive = false;
                this.fields[0, i].Show();
                this.fields[0, i].setChar(i.ToString());
            }

            for (uint j = 1; j < fields.GetLength(1); j++)
            {
                for (uint i = 1; i < fields.GetLength(0); i++)
                {
                    fields[i, j] = new Stone();
                    this.Attach(fields[i, j], i, i + 1, j, j + 1);
                }
            }

            this.Restart();
        }
示例#2
0
 public void networkUpdate(NetworkCarrierFull c)
 {
     lock (this.gameLock) {
         this.newData = true;
         this.players = c.players;
         foreach (Scrabble.Player.Player p in this.players)
         {
             p.SetGame(this);
         }
         this.desk = c.playDesk;
         this.desk.setGame(this);
     }
 }
示例#3
0
        public void newGame()
        {
            this.window.Hide();
            this.round = 1;
            this.desk  = new Scrabble.Lexicon.PlayDesk(this);
            foreach (Scrabble.Player.Player p in this.players)
            {
                p.Restart();
                Scrabble.Game.StonesBag.CompleteRack(p.Rack);
            }
            OnTurn = 0;

            this.bestMove = new Scrabble.Lexicon.Move("");

            this.window.Update();
            this.window.ShowAll();
        }
示例#4
0
 public NetworkCarrierFull(Scrabble.Player.Player[] p, Scrabble.Lexicon.PlayDesk d)
 {
     this.players  = p;
     this.playDesk = d;
 }
示例#5
0
        public Game(bool isClient = false )
        {
            if( Scrabble.Game.InitialConfig.dictionary == null )
                throw new NullReferenceException("During game initialization is Scrabble.Game.InitialConfig.dictionary == null");
            else
                this.dictionary	= Scrabble.Game.InitialConfig.dictionary;

            this.client = isClient;
            this.round = 1;
            this.historyM = new Stack<Scrabble.Lexicon.Move>(20);
            this.futureM = new Stack<Scrabble.Lexicon.Move>(6);

            // Initialization of play desk (logic component, not gtk)
            this.desk = new Scrabble.Lexicon.PlayDesk ( this );

            global::Scrabble.Lexicon.SearchAlgorithm.Init( desk.Desk, this.dictionary );

            this.players = Scrabble.Game.InitialConfig.players;

            if( isClient ) {
                this.morePeople = true;
            } else {
                sserver = new scrabbleServer( this );
                int k =0;
                int l =0;
                foreach( Scrabble.Player.Player p in players ) {
                    if( p.GetType() == typeof( Scrabble.Player.Player ) ) k++;
                    if( p.GetType() == typeof( Scrabble.Player.NetworkPlayer ) ) l++;
                    p.SetGame( this );
                    p.ReloadRack();
                }
                if( k > 1 ) this.morePeople = true;
                if( l > 0 ) this.networkPlayers = true;
            }

            // Inicialize dialogs from menu (like checkword, about etc.)
            Scrabble.GUI.StaticWindows.Init( this );

            if( this.client ) {
                this.sclient = new scrabbleClient( this );
                this.clientThread = new Thread( this.mainClientLoop );
                this.clientThread.Start();
            } else {
                this.sendUpdatViaNetwork( true );
            }
        }
示例#6
0
        public void newGame()
        {
            this.window.Hide();
            this.round = 1;
            this.desk = new Scrabble.Lexicon.PlayDesk(this);
            foreach( Scrabble.Player.Player p in this.players ) {
                p.Restart();
                Scrabble.Game.StonesBag.CompleteRack( p.Rack );
            }
            OnTurn = 0;

            this.bestMove = new Scrabble.Lexicon.Move("");

            this.window.Update();
            this.window.ShowAll();
        }
示例#7
0
 public void networkUpdate( NetworkCarrierFull c )
 {
     lock( this.gameLock ) {
         this.newData = true;
         this.players = c.players;
         foreach( Scrabble.Player.Player p in this.players )
             p.SetGame( this );
         this.desk = c.playDesk;
         this.desk.setGame( this );
     }
 }
示例#8
0
        public Game(bool isClient = false)
        {
            if (Scrabble.Game.InitialConfig.dictionary == null)
            {
                throw new NullReferenceException("During game initialization is Scrabble.Game.InitialConfig.dictionary == null");
            }
            else
            {
                this.dictionary = Scrabble.Game.InitialConfig.dictionary;
            }

            this.client   = isClient;
            this.round    = 1;
            this.historyM = new Stack <Scrabble.Lexicon.Move>(20);
            this.futureM  = new Stack <Scrabble.Lexicon.Move>(6);

            // Initialization of play desk (logic component, not gtk)
            this.desk = new Scrabble.Lexicon.PlayDesk(this);

            global::Scrabble.Lexicon.SearchAlgorithm.Init(desk.Desk, this.dictionary);

            this.players = Scrabble.Game.InitialConfig.players;

            if (isClient)
            {
                this.morePeople = true;
            }
            else
            {
                sserver = new scrabbleServer(this);
                int k = 0;
                int l = 0;
                foreach (Scrabble.Player.Player p in players)
                {
                    if (p.GetType() == typeof(Scrabble.Player.Player))
                    {
                        k++;
                    }
                    if (p.GetType() == typeof(Scrabble.Player.NetworkPlayer))
                    {
                        l++;
                    }
                    p.SetGame(this);
                    p.ReloadRack();
                }
                if (k > 1)
                {
                    this.morePeople = true;
                }
                if (l > 0)
                {
                    this.networkPlayers = true;
                }
            }

            // Inicialize dialogs from menu (like checkword, about etc.)
            Scrabble.GUI.StaticWindows.Init(this);

            if (this.client)
            {
                this.sclient      = new scrabbleClient(this);
                this.clientThread = new Thread(this.mainClientLoop);
                this.clientThread.Start();
            }
            else
            {
                this.sendUpdatViaNetwork(true);
            }
        }