コード例 #1
0
            public void OnGameAdvertisementAddEvent(object o,
								 GameAdvertisement
								 ad)
            {
                if (!categories.
                    ContainsKey (ad.category.ToLower ()))
                    return;
                graph.AddGameInfo (new
                           GameAdvertisementInfo
                           (ad));
            }
コード例 #2
0
            private void AddGameAdvertisement(GameAdvertisement
							   ad)
            {
                ads.Add (ad);
                map[ad.gameHandle] = ad;
                if (GameAdvertisementAddEvent != null)
                    GameAdvertisementAddEvent (this, ad);
            }
コード例 #3
0
            // <s> 9 w=samochess ti=00 rt=1362  t=5 i=7 r=r tp=blitz c=? rr=0-9999 a=t f=t
            public static GameAdvertisement FromBuffer(byte[]buffer, int start, int end)
            {
                ParserUtils.SkipWhitespace (buffer, ref start,
                                end);
                GameAdvertisement ad =
                    new GameAdvertisement ();
                string str;
                ParserUtils.ReadWord (buffer, ' ', ref start,
                              end, out str);
                ad.gameHandle = Int32.Parse (str);
                while (start < end)
                  {
                      ParserUtils.SkipWhitespace (buffer,
                                      ref
                                      start,
                                      end);
                      if (start >= end)
                          break;

                      string paramname, paramvalue;
                      ParserUtils.ReadNameValue (buffer,
                                     ref
                                     start,
                                     end,
                                     out
                                     paramname,
                                     out
                                     paramvalue);
                      if (paramname.Equals ("w"))
                          ad.username = paramvalue;
                      else if (paramname.Equals ("rt"))
                        {
                            if (!System.Char.
                            IsDigit (paramvalue
                                 [paramvalue.
                                  Length -
                                  1]))
                              {
                                  ad.rating_char =
                                      paramvalue
                                      [paramvalue.
                                       Length
                                       - 1];
                                  paramvalue =
                                      paramvalue.
                                      Substring
                                      (0,
                                       paramvalue.
                                       Length
                                       - 1);
                              }
                            ad.rating =
                                paramvalue[0] ==
                                '+' ? -1 : Int32.
                                Parse
                                (paramvalue);
                        }
                      else if (paramname.Equals ("t"))
                          ad.time_limit =
                              Int32.
                              Parse (paramvalue);
                      else if (paramname.Equals ("i"))
                          ad.time_increment =
                              Int32.
                              Parse (paramvalue);
                      else if (paramname.Equals ("tp"))
                          ad.category = paramvalue;
                      else if (paramname.Equals ("r"))
                          ad.rated =
                              paramvalue[0] ==
                              'r';
                      else if (paramname.Equals ("c"))
                          ad.color = paramvalue[0];
                      else if (paramname.Equals ("a"))
                          ad.automatic =
                              paramvalue[0] ==
                              't';
                      else if (paramname.Equals ("f"))
                          ad.formula =
                              paramvalue[0] ==
                              't';
                      else if (paramname.Equals ("ti"))
                          ad.ti = Int32.
                              Parse (paramvalue);
                      else if (paramname.Equals ("rr"))
                        {
                            string[]toks =
                                paramvalue.
                                Split ('-');
                            ad.rating_range =
                                new int[2];
                            ad.rating_range[0] =
                                Int32.
                                Parse (toks[0]);
                            ad.rating_range[1] =
                                Int32.
                                Parse (toks[1]);
                        }
                  }

                return ad;
            }
コード例 #4
0
            public void OnGameAdvertisementRemoveEvent(object o,
								    GameAdvertisement
								    ad)
            {
                graph.RemoveGame (ad.gameHandle);
            }
コード例 #5
0
 public GameAdvertisementInfo(GameAdvertisement a)
 {
     ad = a;
 }