Exemple #1
0
        private void SetImageMethod(Place place)
        {
            var pl = Places.Single(z => z.Id == place.Id);

            pl.IsEmpty = false;
            pl.Type    = IsPlayer1Turn ? IconType.Cross : IconType.Circle;

            var winner = CheckWinner();

            if (winner != -1 || Places.Where(z => !z.IsEmpty).Count() == Math.Pow(gameSize, 2))
            {
                if (winner == 1)
                {
                    Player1Score++;
                }
                else if (winner == 2)
                {
                    Player2Score++;
                }

                Places.ForEach(z => { z.IsEmpty = true; z.Type = null; });
            }

            Places = new List <Place>(Places);
            ChangeTurn();
        }
Exemple #2
0
 /// <summary>
 /// All the geocoding data can be gotten from: http://download.geonames.org/export/dump/
 /// </summary>
 /// <param name="input"></param>
 public void SetCountryInfos(Stream input)
 {
     CountryInfos.Clear();
     using (StreamReader db = new StreamReader(input))
     {
         string line;
         while (!db.EndOfStream && (line = db.ReadLine()) != null)
         {
             if (line.StartsWith("#"))
             {
                 continue;
             }
             var countryInfo = new CountryInfo(line);
             CountryInfos.Add(countryInfo);
         }
     }
     if (Places.Any())
     {
         Places.ForEach(p => p.Country = CountryInfos.Find(c => c.ISO == p.CountryCode));
     }
 }
 /// <summary>
 /// Resets all tokens to zero and puts one token on all source places
 /// </summary>
 public void ResetTokens()
 {
     Places.ForEach(place => place.Token       = 0);
     SourcePlaces.ForEach(place => place.Token = 1);
 }