/// <summary> /// Makes the tests. /// </summary> /// <returns> /// The tests. /// </returns> /// <exception cref='Exception'> /// Represents errors that occur during application execution. /// </exception> public bool MakeTests() { /* CONSTRUCTORS */ Console.Out.Write("Vytvářím slovník (bezparametrický konstruktor):\t"); dic1 = new Scrabble.Lexicon.GADDAG(); Console.Out.WriteLine("OK"); string s1 = "dům"; string s2 = "dort"; Console.Out.Write("Vytvářím slovník (\"dům\",\"dort\"):\t"); dic2 = new Scrabble.Lexicon.GADDAG(new string [] { s1, s2 }); if (dic2.Content(s1)) { //ok } else { throw new Exception("FAIL GADDAG constructor with parametr string[]"); } Console.Out.WriteLine("OK"); /* ADD */ Console.Out.Write("Přidávám do slovníku:\t"); string s3 = "důl"; string s4 = "kůl"; dic1.Add(s3); dic1.Add(s4); if (dic1.Content(s3)) { //ok } else { throw new Exception("FAIL add to dictionary"); } Console.Out.WriteLine("OK"); /* REMOVE */ return(true); }
/// <summary> /// Loads the dictionary (take lot of time - use own thread). /// </summary> protected void LoadDictionary() { lock ( dicLoc ) { this.dic = new Scrabble.Lexicon.GADDAG(); if (!File.Exists(Scrabble.Game.InitialConfig.dicPath)) { DicPathError(); } else { StreamReader sr = new StreamReader(Scrabble.Game.InitialConfig.dicPath); this.dic = new Scrabble.Lexicon.GADDAG(sr); } } if (Scrabble.Game.InitialConfig.log) { Console.Out.WriteLine("[INFO]\tSlovník obsahuje {0} slov.", dic.WordCount); } statusb.Push(statusb.GetContextId("Slovník"), "Slovník načten"); }
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 ); } }
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); } }