Пример #1
0
 /// <summary>
 /// Retreive the network config from the DOTA 2 CDN
 /// </summary>
 /// <returns>Network config on success, null otherwise.</returns>
 public static NetworkConfig GetNetworkConfig(CDNType type = CDNType.STANDARD, Games game = Games.DOTA2)
 {
     using (var wc = new WebClient())
     {
         var str = wc.DownloadString(DatagramNetworkConfig(type, game));
         JObject obj = JObject.Parse(str);
         return obj.ToObject<NetworkConfig>();
     }
 }
Пример #2
0
 /// <summary>
 /// Build the URL to something static in the CDN
 /// </summary>
 /// <returns></returns>
 public static string StaticDataPath(CDNData target, Games game = Games.DOTA2)
 {
     switch (target)
     {
         case CDNData.DATAGRAM_NETWORK_CONFIG:
             return "/apps/sdr/network_config.json";
         default:
             return null;
     }
 }
Пример #3
0
        public List<Games> Get(Games request)
        {
            var games = GetGames();

            var t = request.HomeTeam;
            if (!string.IsNullOrWhiteSpace(t))
                return games.Where(x => x.HomeTeam == t || x.AwayTeam == t).ToList();

            return games;
        }
        public VictoryConditionResult Evaluate(Player player, Games.Map map)
        {
            if (!player.Countries.Any())
            {
                return VictoryConditionResult.Defeat;
            }

            if (player.Countries.Count() == map.Countries.Count())
            {
                return VictoryConditionResult.Victory;
            }

            return VictoryConditionResult.Inconclusive;
        }
Пример #5
0
 protected void AddGameBtn_Click(object sender, EventArgs e)
 {
     TestGameRepository testGame = new TestGameRepository();
     gameRating = DropDownList1.SelectedValue.ToString();
     gameName = TextBox1.Text;
     Games newGame = new Games();
     newGame.GameName = gameName;
     newGame.GameRating = gameRating;
     newGame.IsCheckedOut = false;
     newGame.CheckedOutTo = string.Empty;
     testGame.Add(newGame);
     GridView1.DataSource = testGame.GetItems();
     GridView1.DataBind();
 }
Пример #6
0
 /// <summary>
 /// Internally create an instance of the GC handler.
 /// </summary>
 /// <param name="client"></param>
 /// <param name="appId"></param>
 /// <param name="_engine"></param>
 internal DotaGCHandler(SteamClient client, Games appId, ESourceEngine _engine)
 {
     gameId = appId;
     engine = _engine;
     SteamClient = client;
     gcConnectTimer = new Timer(5000);
     gcConnectTimer.Elapsed += (sender, args) =>
     {
         if (!running)
         {
             gcConnectTimer.Stop();
             return;
         }
         SayHello();
     };
 }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Games checkOutGame = new Games();
        TestGameRepository testGame = new TestGameRepository();
        GameGridView.DataSource = testGame.GetItems();
        GameGridView.DataBind();

        var nonCheckedOutGame = from g in testGame.GetItems()
                                where g.IsCheckedOut == false
                                select g.GameName;
        DropDownList1.DataSource = nonCheckedOutGame.ToList();
        DropDownList1.DataBind();

        var toBeCheckedOuts = from g in testGame.GetItems()
                             where g.GameName == DropDownList1.SelectedItem.ToString()
                             select g;
        checkOutGame = toBeCheckedOuts.FirstOrDefault();
        checkOutGame.IsCheckedOut = true;
    }
Пример #8
0
    public Games GetLatestMove(string sName, string sGame)
    {
        Games Game = new Games(sGame);
           // List<Plays> Plays = new List<Plays>();

            if ( StoredGames != null)
            {
               // List<Games> StoredGames = (List<Games>)HttpContext.Current.Session["GamesPlayed"];
                int index = 0;
                foreach (Games item in StoredGames)
                {
                    if (item.NameOfGame != null)
                    {
                        if (item.NameOfGame.Trim().ToLower() == sGame.Trim().ToLower())
                        {
                            // Plays Play = new Plays();

                            Game.PlayerName1 = item.PlayerName1;
                            Game.PlayerName2 = item.PlayerName2;
                            if (Game.PlayerName1.ToLower() != sName.ToLower())
                            {
                                if (Game.PlayerName2 == "")
                                {
                                    Game.PlayerName2 = sName;
                                }
                            }

                            Game.PlayerTurn = item.PlayerTurn;
                            Game.LastPlayed = item.LastPlayed;
                            Game.Plays = item.Plays;

                            StoredGames[index] = Game;
                            break;
                        }
                    }
                    index++;
                }

            }

            return Game;
    }
Пример #9
0
        public override void Update(Games.GameInfo gameInfo, Input input)
        {
            base.Update(gameInfo, input);

            //--- 自分のプレイヤー情報を更新 ---//
            foreach (PlayerInfo player in gameInfo.PlayerInfos)
            {
                if (PlayerIndex == player.Index)
                {
                    me = player;
                    break;
                }
            }

            //--- ルールベースで命令を記述 ---//
            foreach (PlayerInfo player in gameInfo.PlayerInfos)
            {
                // 自分の情報はスキップ
                if (player.Equals(me)) continue;
                // 敵の進行方向に自分がいるか
                if (isLookingThisWay(player))
                {
                    runAwayFrom(player);
                    break;
                }
                else
                {
                    // 自分の進行方向に敵がいるか
                    if (isInADirection(player))
                    {
                        Attack();
                        break;
                    }
                    else
                    {
                        idle(gameInfo);
                    }
                }
            }
        }
Пример #10
0
 public GameSelector(Games games)
 {
     InitializeComponent();
     this.Games.DataSource = this._gameText;
     this.Games.SelectedIndex = 0;
     switch((int)games) {
         case 7: // cs & cz & css
             break;
         case 6: // cz & css
             _gameIcons.Images.RemoveAt(0);
             _gameText = new string[]{"Condition Zero","Counter-Strike Source"};
             break;
         case 5: // cs & css
             _gameIcons.Images.RemoveAt(1);
             _gameText = new string[]{"Counter-Strike","Counter-Strike Source"};
             break;
         case 4: // css
             _gameIcons.Images.RemoveAt(0);
             _gameIcons.Images.RemoveAt(1);
             _gameText = new string[]{"Counter-Strike Source"};
             break;
         case 3: // cs & cz
             _gameIcons.Images.RemoveAt(2);
             _gameText = new string[]{"Counter-Strike","Condition Zero"};
             break;
         case 2: // cz
             _gameIcons.Images.RemoveAt(0);
             _gameIcons.Images.RemoveAt(2);
             _gameText = new string[]{"Condition Zero"};
             break;
         case 1: // cs
             _gameIcons.Images.RemoveAt(1);
             _gameIcons.Images.RemoveAt(2);
             _gameText = new string[]{"Counter-Strike"};
             break;
     }
 }
Пример #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Whist game players!");

            using (var context = new MyDBContext())
            {
                Console.WriteLine("Keep track of your games by using the WhistApp!");
                Console.WriteLine("Usage:");
                Console.WriteLine("If this is your first time using the WhistApp, please follow these steps:");
                Console.WriteLine("Step 1: Add Players (type p)");
                Console.WriteLine("Step 2: Add Game (type g)");
                Console.WriteLine("Step 3: Connect Players to Game (type c)");
                Console.WriteLine("Step 4: Add Game Rounds (type r)");
                Console.WriteLine("---------------------------------------------------------------");
                Console.WriteLine("See lists of already played games:");
                Console.WriteLine("Option 1: See list of Games (type gl)");
                Console.WriteLine("Option 2: See list of Games with players (type gp)");
                Console.WriteLine("Option 3: See list of Games round players and points (type gr)");
                Console.WriteLine("Option 4: See list of player ids (type pl)");

                while (true)
                {
                    Console.WriteLine("Type command");
                    string line = Console.ReadLine();

                    switch (line)
                    {
                    case "p":
                        Players players = InputPlayer();
                        context.Players.Add(players);
                        context.SaveChanges();
                        break;

                    case "g":
                        Games games = InputGames(context);
                        context.Games.Add(games);
                        context.SaveChanges();
                        break;

                    case "r":
                        if (context.Games.Count() == 0)
                        {
                            Console.WriteLine("No games exist!");
                            break;
                        }
                        else
                        {
                            GameRounds gameRounds = InputGameRounds(context);
                            context.GameRounds.Add(gameRounds);
                            context.SaveChanges();
                        }
                        break;

                    case "c":
                        if (context.Games.Count() == 0)
                        {
                            Console.WriteLine("No games exist!");
                            break;
                        }
                        else if (context.Players.Count() == 0)
                        {
                            Console.WriteLine("No players exist!");
                            break;
                        }
                        else
                        {
                            GamePlayers gamePlayers = InputGamePlayers(context);
                            context.GamePlayers.Add(gamePlayers);
                            context.SaveChanges();
                        }
                        break;

                    case "gp":
                        ListGamePlayers(context);
                        break;

                    case "gl":
                        ListGames(context);
                        break;

                    case "gr":
                        ListGameRoundPlayers(context);
                        break;

                    case "pl":
                        ListPlayers(context);
                        break;

                        //Mangler lister
                    }
                }
            }
        }
Пример #12
0
 private static void CMLoad()
 {
     Games.Import();
 }
Пример #13
0
        public override bool LoadAllGames()
        {
            List <BethNetGame> possibleGames = new List <BethNetGame>();

            // games folder

            if (!GamesFolder.Exists)
            {
                Utils.Error(new StoreException($"The GamesFolder for BethNet at {GamesFolder} does not exist!"));
                return(false);
            }

            if (GamesFolder.Exists && GamesFolder.IsDirectory)
            {
                GamesFolder.EnumerateDirectories(false).Do(d =>
                {
                    var files = d.EnumerateFiles();
                    var game  = GameRegistry.Games.Values
                                .FirstOrDefault(g => g.RequiredFiles?.All(f =>
                    {
                        var absPath = new RelativePath(f).RelativeTo(d);
                        return(files.Contains(absPath));
                    }) ?? true);

                    if (game != null)
                    {
                        possibleGames.Add(new BethNetGame
                        {
                            Game = game.Game,
                            ID   = game.BethNetID,
                            Name = game.Game.ToString(),
                            Path = d,
                            Type = StoreType.BethNet
                        });
                    }
                    else
                    {
                        Utils.Log($"BethNet Game at {d} is not supported!");
                    }
                });
            }

            possibleGames.Do(g =>
            {
                try
                {
                    var regString = g.Game.MetaData().RegString;
                    var regKey    = Registry.LocalMachine.OpenSubKey(regString);
                    regString     = @"HKEY_LOCAL_MACHINE\" + regString;
                    if (regKey == null)
                    {
                        Utils.Error(new StoreException($@"Could not open registry key at {regString}"));
                        return;
                    }

                    var pathValue            = regKey.GetValue("Path");
                    var uninstallStringValue = regKey.GetValue("UninstallString");

                    if (pathValue == null || uninstallStringValue == null)
                    {
                        Utils.Error(new StoreException($@"Could not get Value from either {regString}\Path or UninstallString"));
                        return;
                    }

                    var path            = pathValue.ToString() ?? string.Empty;
                    var uninstallString = uninstallStringValue.ToString() ?? string.Empty;

                    if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(uninstallString))
                    {
                        Utils.Error(new StoreException($@"Path or UninstallString is null or empty for {regString}!"));
                        return;
                    }

                    path = FixRegistryValue(path);

                    if ((AbsolutePath)path != g.Path)
                    {
                        Utils.Error(new StoreException($"Path from registry does not equal game path: {path} != {g.Path} at {regString}"));
                        return;
                    }

                    var split = uninstallString.Split("\"");
                    if (split.Length != 3)
                    {
                        Utils.Error(new StoreException($"UninstallString at {regString} can not be split into 3 parts!"));
                        return;
                    }

                    var updaterPath = (AbsolutePath)split[1];
                    var args        = split[2].Trim();

                    if (!updaterPath.Exists)
                    {
                        Utils.Error(new StoreException($"UpdaterPath from {regString} does not exist at {updaterPath}"));
                        return;
                    }

                    if (updaterPath.Parent != BethPath)
                    {
                        Utils.Error(new StoreException($"Parent of UpdatePath from {regString} is not BethPath: {updaterPath.Parent} != {BethPath}"));
                        return;
                    }

                    if (!args.Equals($"bethesdanet://uninstall/{g.ID}", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Utils.Error(new StoreException($"Uninstall arguments from {regString} is not valid: {args}"));
                        return;
                    }

                    Utils.Log($"Found BethNet game \"{g.Game}\" ({g.ID}) at {g.Path}");

                    Games.Add(g);
                }
                catch (SecurityException se)
                {
                    Utils.Error(se, "BethNetHandler could not read from registry!");
                }
                catch (UnauthorizedAccessException uae)
                {
                    Utils.Error(uae, "BethNetHandler could not read from registry!");
                }
            });

            Utils.Log($"Total number of BethNet Games found: {Games.Count}");

            return(Games.Count != 0);
        }
Пример #14
0
        // GET: Game

        public ActionResult Shop(string t, string m)
        {
            string search = "";

            if (Session["search"] != null)
            {
                search            = Session["search"].ToString();
                Session["search"] = null;
            }
            Session["c"] = "Game";
            List <ProductV1> lst = null;

            if (t == null)
            {
                lst = new Games().GetProductList()
                      .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "New").ToList();
                Session["t"] = "n";
                Session["m"] = "ps";
            }
            else
            {
                Session["t"] = t;
                Session["m"] = m;
            }
            if (t == "n" && m == "ps")
            {
                if (search != "")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "New" &&
                                 (g.Title.Contains(search) || g.Platform.Contains(search))).ToList();
                }
                else
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "New").ToList();
                }
            }
            if (t == "u" && m == "ps")
            {
                if (search != "")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "Used" &&
                                 (g.Title.Contains(search) || g.Platform.Contains(search))).ToList();
                }
                else
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "Used").ToList();
                }
            }
            if (t == "n" && m == "xbox")
            {
                if (search != "")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("XBox") && g.Condition == "New" &&
                                 (g.Title.Contains(search) || g.Platform.Contains(search))).ToList();
                }
                else
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("XBox") && g.Condition == "New").ToList();
                }
            }
            if (t == "u" && m == "xbox")
            {
                if (search != "")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("XBox") && g.Condition == "Used" &&
                                 (g.Title.Contains(search) || g.Platform.Contains(search))).ToList();
                }
                else
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("XBox") && g.Condition == "Used").ToList();
                }
            }
            if (t == "n" && m == "nintendo")
            {
                if (search != "")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Nintendo") && g.Condition == "New" &&
                                 (g.Title.Contains(search) || g.Platform.Contains(search))).ToList();
                }
                else
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Nintendo") && g.Condition == "New").ToList();
                }
            }
            if (t == "u" && m == "nintendo")
            {
                if (search != "")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Nintendo") && g.Condition == "Used" &&
                                 (g.Title.Contains(search) || g.Platform.Contains(search))).ToList();
                }
                else
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Nintendo") && g.Condition == "Used").ToList();
                }
            }


            return(View(lst));
        }
Пример #15
0
 public IEnumerator <Game> GetEnumerator()
 => Games.GetEnumerator();
Пример #16
0
 internal string GetConfigPath(Games game, ConfigType type)
 {
     return this.GamePaths.GetConfigPath(game, type);
 }
Пример #17
0
 /// <summary>
 /// There are no comments for Games in the schema.
 /// </summary>
 public void AddToGames(Games games)
 {
     base.AddObject("Games", games);
 }
Пример #18
0
 protected override TGame Game(CommandContext ctx)
 {
     return(Games.GetForChannel <TGame>(ctx.Channel.Id));
 }
Пример #19
0
 /// <summary>
 /// Builds the URL to the Steam Datagram network config file.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="game"></param>
 /// <returns></returns>
 public static Uri DatagramNetworkConfig(CDNType type = CDNType.STANDARD, Games game = Games.DOTA2)
 {
     UriBuilder builder = new UriBuilder("http", GetHostname(type), 80,
         StaticDataPath(CDNData.DATAGRAM_NETWORK_CONFIG, game));
     return builder.Uri;
 }
 internal void AddPath(string accountName, Games game, string pathToConfig)
 {
     if(_accounts.ContainsKey(accountName)) {
         ((Account)_accounts[accountName]).AddPath(game, pathToConfig);
     }
 }
 /// <summary>
 /// gets a game path for a specific account name & game
 /// </summary>
 internal string this[string accountName, Games game]
 {
     get{
         if(game == Games.CS) {
             if(_accounts.ContainsKey(accountName)) {
                 return ((Account)_accounts[accountName]).GamePaths.CsPath;
             }else
                 throw new IndexOutOfRangeException();
         }else if(game == Games.CZ) {
             if(_accounts.ContainsKey(accountName)) {
                 return ((Account)_accounts[accountName]).GamePaths.CzPath;
             }else
                 throw new IndexOutOfRangeException();
         }else if(game == Games.CSS) {
             if(_accounts.ContainsKey(accountName)) {
                 return ((Account)_accounts[accountName]).GamePaths.CssPath;
             }else
                 throw new IndexOutOfRangeException();
         }else
             throw new IndexOutOfRangeException();
     }
 }
Пример #22
0
 /// <summary>
 /// Create a new Games object.
 /// </summary>
 /// <param name="gameId">Initial value of GameId.</param>
 public static Games CreateGames(int gameId)
 {
     Games games = new Games();
     games.GameId = gameId;
     return games;
 }
Пример #23
0
 internal void AddPath(Games game, string path)
 {
     this._paths.AddPath(game, path);
 }
 public GamesItem(Games game)
 {
     Game        = game;
     DisplayName = game.GetGameInfo().DisplayName;
 }
Пример #25
0
 public void Update(Games games)
 {
     Console.WriteLine(games.GameName + " oyun güncellendi !");
 }
Пример #26
0
        public Games GetGames(DateTime scheduleDate)
        {
            var url = string.Format(scheduleUrlFormat, scheduleDate.Year, scheduleDate.Month, scheduleDate.Day);

            var games = new Games();

            var contents = GetContents(url);

            if (string.IsNullOrEmpty(contents))
            {
                Debug.WriteLine("No data found for " + url); // not necessarily an error, could be no games
                return games;
            }

            dynamic schedule = JsonConvert.DeserializeObject(contents);

            foreach (dynamic game in schedule.games)
            {
                var gameId = game.gameId;
                var startTimeEastern = DateTime.Parse(game.startTime.ToString());
                // will either have a preview or a recap
                var summary = game.gamePreview != null ? game.gamePreview : game.gameRecap;

                var home = new Team
                {
                    Abbreviation = game.h.ab,
                    Record = game.h.record,
                };

                var away = new Team
                {
                    Abbreviation = game.a.ab,
                    Record = game.a.record,
                };

                // fix the game time
                var startTimeLocal = startTimeEastern.AddHours(offsetFromEasternTime);

                games.Add(new Game { Away = away, Home = home, GameID = gameId, UtcStart = startTimeLocal.ToUniversalTime(), Summary = summary });
            }

            return games;
        }
Пример #27
0
 public Config_RaymanRavingRabbids_ViewModel(Games game)
 {
     Game = game;
 }
Пример #28
0
 private Game GetGame(Games game)
 {
     switch (game)
     {
         case Games.HotAndCold:
             return new HotAndCold(this);
         default:
             return null;
     }
 }
Пример #29
0
        public Pather(Games.Game game)
        {

            this.game = game;
        }
Пример #30
0
 internal void LoadGames(Games games)
 {
     _games = games;
 }
Пример #31
0
 public LoadResults SwitchToGame( Games.GameInformation game )
 {
     Debug.WriteLine( "Instance: switching to game " + game.Parameters.Title );
     _bios.Game = game;
     return _bios.Load();
 }
Пример #32
0
        /// <summary>
        /// Loads our favorites from favorites.ini
        /// </summary>
        /// <returns>How many favorites have been added already to our internal list.</returns>
        private int LoadFavorites()
        {
            _gamesFavorites = new Games();
            _countFavorites = 0;
            if (File.Exists(Settings.Default.favorites_ini))
            {
                string[] favs = File.ReadAllLines(Settings.Default.favorites_ini);
                foreach (string s in favs) //Some of the lines are not favorites, just ignores them.
                {
                    try
                    {
                        Game game = XmlParser.Games.FindGame(s);
                        if (game != null)
                        {
                            Game g = game.Copy();
                            g.Name = "fav_" + g.Name;
                            g.IsFavorite = true;
                            _gamesFavorites.Add(g.Name, g);
                        }
                    }
                    catch (Exception)
                    {
                        //Not a game, do nothing.
                    }
                }

                //Sorts out the list by description alphabetically and filters it according to what the user set.
                var sortedDict = (from entry in _gamesFavorites
                                  where
                                      entry.Value.Name.Contains(_filter, StringComparison.InvariantCultureIgnoreCase) ||
                                      entry.Value.Manufacturer.Contains(_filter,
                                                                        StringComparison.InvariantCultureIgnoreCase) ||
                                      entry.Value.Year.Contains(_filter,
                                                                StringComparison.InvariantCultureIgnoreCase) ||
                                      entry.Value.SourceFile.Contains(_filter,
                                                                      StringComparison.InvariantCultureIgnoreCase) ||
                                      entry.Value.Description.Contains(_filter,
                                                                       StringComparison.InvariantCultureIgnoreCase)
                                  orderby entry.Value.Description.ToLower() ascending
                                  select entry);

                //Add the filtered favorites to our game list.
                Game prevGame = null;
                int i = 0;
                foreach (var fGame in sortedDict)
                {
                    fGame.Value.Index = i++;
                    Games.Add(fGame.Key, fGame.Value);
                    _countFavorites++;
                    if (prevGame != null)
                    {
                        prevGame.NextGame = fGame.Value;
                    }
                    fGame.Value.PreviousGame = prevGame;
                    prevGame = fGame.Value;
                }
                return i;
            }
            return 0;
        }
Пример #33
0
 public void Update(Games game)
 {
 }
Пример #34
0
 public void Add(Games games)
 {
     Console.WriteLine(games.Name + " has added to your basket.");
 }
Пример #35
0
        public PartialViewResult RelatedProducts()
        {
            string t    = "";
            string m    = "";
            string type = "";

            if (Session["t"] != null)
            {
                t = Session["t"].ToString();
            }
            if (Session["m"] != null)
            {
                m = Session["m"].ToString();
            }
            List <ProductV1> lst = null;

            if (Session["c"] != null)
            {
                type = Session["c"].ToString();
            }
            else
            {
                type = "Game";
            }
            if (t != "" && m == "")
            {
                type = "Acc";
            }
            if (type == "Game")
            {
                if (t == "")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "New").Take(3).ToList();
                }
                if (t == "n" && m == "ps")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "New").Take(3).ToList();
                }
                if (t == "u" && m == "ps")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Ps") && g.Condition == "Used").Take(3).ToList();
                }
                if (t == "n" && m == "xbox")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("XBox") && g.Condition == "New").Take(3).ToList();
                }
                if (t == "u" && m == "xbox")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("XBox") && g.Condition == "Used").Take(3).ToList();
                }
                if (t == "n" && m == "nintendo")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Nintendo") && g.Condition == "New").Take(3).ToList();
                }
                if (t == "u" && m == "nintendo")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Game" && g.Platform.Contains("Nintendo") && g.Condition == "Used").Take(3).ToList();
                }
            }
            if (type == "Acc")
            {
                if (t == "vr")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("VR")).ToList();
                }
                if (t == "tv")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("TV")).ToList();
                }
                if (t == "hs")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("Headsets")).ToList();
                }
                if (t == "ms")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("Mouse")).ToList();
                }
                if (t == "js")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("Joysticks")).ToList();
                }
                if (t == "kb")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("Keyboards")).ToList();
                }
                if (t == "cm")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("Cameras")).ToList();
                }
                if (t == "sp")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Acc" && g.Category.Contains("Speakers")).ToList();
                }
            }

            if (type == "Console")
            {
                if (t == "n" && m == "ps")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Console" && g.Category.Contains("PlayStation") && g.Condition == "New").ToList();
                }
                if (t == "u" && m == "ps")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Console" && g.Category.Contains("PlayStation") && g.Condition == "Used").ToList();
                }
                if (t == "n" && m == "xbox")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Console" && g.Category.Contains("XBOX") && g.Condition == "New").ToList();
                }
                if (t == "u" && m == "xbox")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Console" && g.Category.Contains("XBOX") && g.Condition == "Used").ToList();
                }
                if (t == "n" && m == "nintendo")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Console" && g.Category.Contains("Nintendo") && g.Condition == "New").ToList();
                }
                if (t == "u" && m == "nintendo")
                {
                    lst = new Games().GetProductList()
                          .Where(g => g.Type == "Console" && g.Category.Contains("Nintendo") && g.Condition == "Used").ToList();
                }
            }
            return(PartialView("_RelatedProducts", lst));
        }
Пример #36
0
        private bool ScanMarket(Games game, int startIndex = 0)
        {
            try
            {
                RootObject ro = null;
                do
                {
                    int    timeout = (int)TimeSpan.FromMinutes(3).TotalMilliseconds;
                    string target  = "http://arkarrsourceservers.ddns.net:27019/steammarketitems?apikey=" + APIkey + "&appid=" + (int)game + "&version=2";
                    string json    = fetcher.Fetch(target, "GET", null, true, "", true, timeout);
                    ro = JsonConvert.DeserializeObject <RootObject>(json);

                    if (ro == null)
                    {
                        Console.WriteLine("Error fetching : " + target + " !");
                        Console.WriteLine("Trying again.");
                    }
                }while (ro == null && !stop);

                if (stop)
                {
                    return(false);
                }

                List <Item> items = ro.items;
                if (ro.success && stop == false)
                {
                    List <Item> itemToAdd = new List <Item>();
                    foreach (Item item in items)
                    {
                        Item i = null;
                        if (game == Games.TF2)
                        {
                            i = steamMarketItemsTF2.FirstOrDefault(x => x.Name == item.Name);
                        }
                        else if (game == Games.CSGO)
                        {
                            i = steamMarketItemsCSGO.FirstOrDefault(x => x.Name == item.Name);
                        }
                        else if (game == Games.Dota2)
                        {
                            i = steamMarketItemsDOTA2.FirstOrDefault(x => x.Name == item.Name);
                        }

                        if (i != null && i.Value != item.Value)
                        {
                            i.Value       = item.Value;
                            i.LastUpdated = item.LastUpdated;
                        }
                        else if (i == null)
                        {
                            itemToAdd.Add(item);
                        }
                    }

                    if (itemToAdd.Count != 0)
                    {
                        if (game == Games.TF2)
                        {
                            steamMarketItemsTF2.AddRange(itemToAdd);
                        }
                        else if (game == Games.CSGO)
                        {
                            steamMarketItemsCSGO.AddRange(itemToAdd);
                        }
                        else if (game == Games.Dota2)
                        {
                            steamMarketItemsDOTA2.AddRange(itemToAdd);
                        }

                        itemToAdd.Clear();
                    }

                    return(true);
                }
                else
                {
                    Console.WriteLine("Error while fetching " + game.ToString() + "'s market : ");
                    Console.WriteLine(ro.message);

                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while fetching " + game.ToString() + "'s market : ");
                Console.WriteLine(e.Message);

                return(false);
            }
        }
Пример #37
0
 private static void CMSave()
 {
     Games.Export();
 }
Пример #38
0
        public void GoToGame(Object sender, GestureEventArgs gestureEventArgs)
        {
            var game = Games.First(g => g.Id == (string)(((Button)sender).Tag));

            OpenGame(game);
        }
Пример #39
0
 static public Games InsertGame(int userId, Games newGame)
 {
     return(Dbconnection.InsertGame(userId, newGame));
 }
Пример #40
0
 public void Add(Games games)
 {
     Console.WriteLine(games.GameName + " oyun eklendi !");
 }
Пример #41
0
        private static GameRounds InputGameRounds(MyDBContext context)
        {
            GameRounds gameRounds;

            Games games = findGame(context);

            Console.Write("What round number are you at?: ");
            int roundNum = Convert.ToInt32(Console.ReadLine());

            Console.Write("What type of round are you playing (sole/normal): ");
            string round = Console.ReadLine();

            Console.Write("Is the round started (yes/no): ");
            string yesNo   = Console.ReadLine();
            bool   started = YesNo(yesNo);

            Console.Write("Is the round ended (yes/no): ");
            string E_yesNo = Console.ReadLine();
            bool   ended   = YesNo(E_yesNo);


            if (round == "sole")
            {
                //Add Type: SoleRound
                Console.Write("What solo type is this?: ");
                string    soloType  = Console.ReadLine();
                SoleRound soleRound = new SoleRound()
                {
                    SoloType = soloType
                };
                context.SoleRound.Add(soleRound);
                gameRounds = new GameRounds()
                {
                    Types    = soleRound,
                    RoundNum = roundNum,
                    Started  = started,
                    Ended    = ended,
                    Games    = games,
                };
                //Add SoleRoundWinner
                Console.WriteLine("How many sole round winners are there?");
                int number = Convert.ToInt32(Console.ReadLine());

                gameRounds.SoleRoundWinnerList = new List <SoleRoundWinner>();
                for (int i = 0; i < number; i++)
                {
                    Console.Write($"What is the trick for winner {i + 1}?: ");
                    int             trick           = Convert.ToInt32(Console.ReadLine());
                    SoleRoundWinner soleRoundWinner = new SoleRoundWinner()
                    {
                        GameRound = gameRounds,
                        Tricks    = trick
                    };
                    context.SoleRoundWinner.Add(soleRoundWinner);
                }
            }
            else
            {
                //Add Type: NormalRound
                Console.Write("What is the trick?: ");
                int trick = Convert.ToInt32(Console.ReadLine());

                Console.Write("What is the bid attachment?:");
                int bidAttachment = Convert.ToInt32(Console.ReadLine());

                Console.Write("What is the bid tricks?:");
                int bidTricks = Convert.ToInt32(Console.ReadLine());

                NormalRound normalRound = new NormalRound()
                {
                    Tricks        = trick,
                    BidAttachment = bidAttachment,
                    BitTricks     = bidTricks
                };
                context.NormalRound.Add(normalRound);

                gameRounds = new GameRounds()
                {
                    Types    = normalRound,
                    RoundNum = roundNum,
                    Started  = started,
                    Ended    = ended,
                    Games    = games,
                };
            }
            //Add GameRoundPlayers
            Console.WriteLine("Add points your game round players: ");
            gameRounds.GameRoundPlayersList = new List <GameRoundPlayers>();
            for (int i = 0; i < 4; i++)
            {
                Console.Write($"Player {i + 1}'s points: ");
                int points = Convert.ToInt32(Console.ReadLine());
                GameRoundPlayers gameRoundPlayers = new GameRoundPlayers()
                {
                    Points     = points,
                    GameRounds = gameRounds
                };
                context.GameRoundPlayers.Add(gameRoundPlayers);
            }

            return(gameRounds);
        }
 public DummyVirtualModActivator(Games.IGameMode gameMode, IEnvironmentInfo environment)
 {
     GameMode = gameMode;
     EnvironmentInfo = environment;
 }
Пример #43
0
 public void Delete(Games games)
 {
     Console.WriteLine(games.Name + " has removed from your basket.");
 }
 internal void AddPath(Games game, string path)
 {
     this._games |= game;
     this._gamePaths.Add(game, path);
 }
Пример #45
0
        private void RefreshMarket(Games game = Games.None)
        {
            if (game == Games.None)
            {
                Console.WriteLine("Fetching market's prices...");

                if (TF2marketScanner == null || !TF2marketScanner.IsAlive)
                {
                    TF2marketScanner = new Thread(() =>
                    {
                        DateTime dt         = DateTime.Now;
                        TF2OK               = ScanMarket(Games.TF2);
                        DateTime now        = DateTime.Now;
                        TimeSpan difference = now.Subtract(dt);
                        Console.WriteLine("market scan for tf2 in : " + difference.Hours.ToString("00") + "h:" + difference.Minutes.ToString("00") + "m:" + difference.Seconds.ToString("00") + "s");
                    });
                }

                if (CSGOmarketScanner == null || !CSGOmarketScanner.IsAlive)
                {
                    CSGOmarketScanner = new Thread(() =>
                    {
                        DateTime dt         = DateTime.Now;
                        CSGOOK              = ScanMarket(Games.CSGO);
                        DateTime now        = DateTime.Now;
                        TimeSpan difference = now.Subtract(dt);
                        Console.WriteLine("market scan for CS:GO in : " + difference.Hours.ToString("00") + "h:" + difference.Minutes.ToString("00") + "m:" + difference.Seconds.ToString("00") + "s");
                    });
                }


                if (DOTA2marketScanner == null || !DOTA2marketScanner.IsAlive)
                {
                    DOTA2marketScanner = new Thread(() =>
                    {
                        DateTime dt         = DateTime.Now;
                        DOTA2OK             = ScanMarket(Games.Dota2);
                        DateTime now        = DateTime.Now;
                        TimeSpan difference = now.Subtract(dt);
                        Console.WriteLine("market scan for DOTA 2 in : " + difference.Hours.ToString("00") + "h:" + difference.Minutes.ToString("00") + "m:" + difference.Seconds.ToString("00") + "s");
                    });
                }

                TF2marketScanner.Start();
                CSGOmarketScanner.Start();
                DOTA2marketScanner.Start();
            }
            else
            {
                if (!stop)
                {
                    if (marketScanner == null || !marketScanner.IsAlive)
                    {
                        Console.WriteLine("Fetching " + game + " prices...");
                        marketScanner = new Thread(() =>
                        {
                            switch (game)
                            {
                            case Games.CSGO: CSGOOK = ScanMarket(game); break;

                            case Games.TF2: TF2OK = ScanMarket(game); break;

                            case Games.Dota2: DOTA2OK = ScanMarket(game); break;
                            }
                        });
                        marketScanner.Start();
                    }
                }
            }
        }
 internal string GetConfigPath(Games game, ConfigType type)
 {
     switch((int)type) {
         case 0:
             if(game == Games.CS) {
                 return Path.Combine(this.CsPath, "autoexec.cfg");
             }else if(game == Games.CSS) {
                 return Path.Combine(this.CssPath, "autoexec.cfg");
             }else {
                 return Path.Combine(this.CzPath, "autoexec.cfg");
             }
         case 1:
             if(game == Games.CS) {
                 return Path.Combine(this.CsPath, "config.cfg");
             }else if(game == Games.CSS) {
                 return Path.Combine(this.CssPath, "config.cfg");
             }else {
                 return Path.Combine(this.CzPath, "config.cfg");
             }
         case 2:
             if(game == Games.CS) {
                 return Path.Combine(this.CsPath, "czbind.cfg");
             }else if(game == Games.CSS) {
                 return Path.Combine(this.CssPath, "czbind.cfg");
             }else {
                 return Path.Combine(this.CzPath, "czbind.cfg");
             }
         case 3:
             if(game == Games.CS) {
                 return Path.Combine(this.CsPath, "userconfig.cfg");
             }else if(game == Games.CSS) {
                 return Path.Combine(this.CssPath, "userconfig.cfg");
             }else {
                 return Path.Combine(this.CzPath, "userconfig.cfg");
             }
         case 4:
             if(game == Games.CSS) {
                 return Path.Combine(this.CssPath, "compatibility.cfg");
             }
             break;
         case 5:
             if(game == Games.CS) {
                 return Path.Combine(this.CsPath, "clips.cfg");
             }else if(game == Games.CSS) {
                 return Path.Combine(this.CssPath, "clips.cfg");
             }else {
                 return Path.Combine(this.CzPath, "clips.cfg");
             }
     }
     return "";
 }
Пример #47
0
        string Sign;                                                        //定义验证参数

        /// <summary>
        /// 实例化接口参数
        /// </summary>
        public Game_Ftz()
        {
            game = games.GetGame("ftz");                                   //获取游戏
            gc   = gcs.GetGameConfig(game.Id);                             //获取游戏参数
        }
 internal void AddPath(string path)
 {
     if(Regex.Match(path, @"counter-strike", RegexOptions.IgnoreCase|RegexOptions.ExplicitCapture).Success) {
         _games |= Games.CS;
         this._gamePaths.Add(Games.CS, path);
     }
     if(Regex.Match(path, @"condition zero", RegexOptions.IgnoreCase|RegexOptions.ExplicitCapture).Success) {
         _games |= Games.CZ;
         this._gamePaths.Add(Games.CZ, path);
     }
     if(Regex.Match(path, @"counter-strike\ssource", RegexOptions.IgnoreCase|RegexOptions.ExplicitCapture).Success) {
         _games |= Games.CSS;
         this._gamePaths.Add(Games.CSS, Path.Combine(path, "cfg"));
     }
 }
Пример #49
0
 public void Delete(Games games)
 {
     Console.WriteLine(games.GameName + " oyun silindi !");
 }
Пример #50
0
 /// <summary>
 /// Internally create an instance of the GC handler.
 /// </summary>
 /// <param name="client"></param>
 /// <param name="appId"></param>
 /// <param name="_engine"></param>
 internal DotaGCHandler(SteamClient client, Games appId, ESourceEngine _engine)
 {
     GameID = appId;
     engine = _engine;
     SteamClient = client;
     // Usually we'd have around 200-600 items.
     EconItems = new Dictionary<ulong, CSOEconItem>(300);
     // Reasonably a bot wouldn't have very many of these.
     LeagueViewPasses = new Dictionary<ulong, CSOEconItemLeagueViewPass>(5);
     // Generally this seems to be 2
     MapLocationStates = new Dictionary<int, CSODOTAMapLocationState>(2);
     gcConnectTimer = new Timer(5000);
     gcConnectTimer.Elapsed += (sender, args) =>
     {
         if (!running)
         {
             gcConnectTimer.Stop();
             return;
         }
         SayHello();
     };
 }
Пример #51
0
        void BackupProgramHandler_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Core.settings.IsBackupPathSet || archive_name_override != null)
            {
                if (archive_name_override != null)
                {
                    output_path = Path.GetDirectoryName(archive_name_override);
                }
                else
                {
                    output_path = Core.settings.backup_path;
                }


                IList <GameEntry> games;

                if (back_these_up != null && back_these_up.Count > 0)
                {
                    games = back_these_up;
                }
                else
                {
                    if (Games.detected_games_count == 0)
                    {
                        Games.detectGames();
                    }
                    games = Games.DetectedGames.Items;
                }

                if (games.Count > 0)
                {
                    ProgressHandler.value = 1;
                    ProgressHandler.max   = games.Count;
                    TranslatingProgressHandler.setTranslatedMessage("GamesToBeBackedUpCount", games.Count.ToString());


                    foreach (GameEntry game in games)
                    {
                        if (CancellationPending)
                        {
                            return;
                        }

                        //if(archive_name_override!=null)
                        //all_users_archive = new ArchiveHandler(new FileInfo(archive_name_override),game.id);

                        if (games.Count == 1)
                        {
                            TranslatingProgressHandler.setTranslatedMessage("BackingUpSingleGame", game.Title);
                        }
                        else
                        {
                            TranslatingProgressHandler.setTranslatedMessage("BackingUpMultipleGames", game.Title, ProgressHandler.value.ToString(), games.Count.ToString());
                        }

                        List <DetectedFile> files;
                        if (only_these_files != null && only_these_files.Count > 0)
                        {
                            files = only_these_files;
                        }
                        else
                        {
                            files = game.Saves.Flatten();
                            ;
                        }


                        Archive override_archive = null;

                        try {
                            DictionaryList <Archive, DetectedFile> backup_files = new DictionaryList <Archive, DetectedFile>();
                            foreach (DetectedFile file in files)
                            {
                                ArchiveID archive_id;
                                Archive   archive;
                                if (CancellationPending)
                                {
                                    return;
                                }

                                archive_id = new ArchiveID(game.id, file);

                                if (archive_name_override != null)
                                {
                                    if (override_archive == null)
                                    {
                                        file.Type = null;
                                    }
                                    override_archive = new Archive(new FileInfo(archive_name_override), new ArchiveID(game.id, file));
                                    archive          = override_archive;
                                }
                                else
                                {
                                    if (Archives.Get(archive_id) == null)
                                    {
                                        Archives.Add(new Archive(output_path, new ArchiveID(game.id, file)));
                                    }
                                    archive = Archives.Get(archive_id);
                                }

                                backup_files.Add(archive, file);
                            }
                            if (CancellationPending)
                            {
                                return;
                            }

                            foreach (KeyValuePair <Archive, List <DetectedFile> > backup_file in backup_files)
                            {
                                if (override_archive == null)
                                {
                                    backup_file.Key.backup(backup_file.Value, false, false);
                                }
                                else
                                {
                                    backup_file.Key.backup(backup_file.Value, true, false);
                                }
                            }
                        } catch (Exception ex) {
                            TranslatingMessageHandler.SendException(ex);
                        } finally {
                            ProgressHandler.value++;
                        }
                    }
                }
                else
                {
                    TranslatingMessageHandler.SendError("NothingToBackup");
                }
            }
            else
            {
                TranslatingMessageHandler.SendError("BackupPathNotSet");
            }
        }
Пример #52
0
 /// <summary>
 /// Setup the DOTA 2 GC handler on an existing client.
 /// </summary>
 /// <param name="client"></param>
 /// <param name="appId">Optional, specify the GC to communicate with.</param>
 /// <param name="engine">Optional, engine to connect to. Default source2.</param>
 public static void Bootstrap(SteamClient client, Games appId = Games.DOTA2,
     ESourceEngine engine = ESourceEngine.k_ESE_Source2)
 {
     client.AddHandler(new DotaGCHandler(client, appId, engine));
 }
Пример #53
0
        private string AddInventoryItems(Bot bot, Games game, SteamID steamID, bool img)
        {
            string items = "";

            long[] contextID = new long[1];
            contextID[0] = 2;

            bot.OtherGenericInventory.load((int)game, contextID, steamID);

            if (bot.OtherGenericInventory.errors.Count > 0)
            {
                Program.PrintErrorMessage("Error while inventory scan :");
                foreach (string error in bot.OtherGenericInventory.errors)
                {
                    Program.PrintErrorMessage(error);
                }
                items = "EMPTY";
            }
            else
            {
                if (bot.OtherGenericInventory.items.Count == 0) //time out
                {
                    items = "TIME_OUT";
                }
                else
                {
                    bool allItemsFound = false;
                    while (!allItemsFound)
                    {
                        allItemsFound = true;

                        foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                        {
                            ItemDescription description = (ItemDescription)bot.OtherGenericInventory.getDescription(item.assetid);

                            SteamMarketUtility.Item i = bot.ArkarrSteamMarket.GetItemByName(description.market_hash_name, item.appid);
                            if (description.tradable)
                            {
                                if (i != null)// && i.Value != 0)
                                {
                                    items += item.assetid + "=" + description.market_hash_name.Replace("|", " - ") + "=" + (i.Value.ToString().Replace(',', '.')) + (img ? "=" + i.Image : "") + ",";
                                }
                                else
                                {
                                    items += item.assetid + "=" + description.market_hash_name.Replace("|", " - ") + "=" + "0" + (img ? "=" + "NOT_FOUND" : "") + ",";
                                }
                            }
                        }
                    }

                    if (items.Length != 0)
                    {
                        items = items.Remove(items.Length - 1);
                    }
                    else
                    {
                        items = "EMPTY";
                    }
                }
            }

            return(items);
        }
Пример #54
0
 public static void Save(Game game)
 {
     Games.Add(game);
 }
Пример #55
0
 //Used for the detailed outputs; can be copied and pasted into Excel
 public override string ToString() => $"{WonSetString}\t{NumberOfGames}\t{String.Join(string.Empty, Games.Select(g => g.ToString()))}";
        /// <summary>
        /// Called when [activated].
        /// </summary>
        /// <param name="disposables">The disposables.</param>
        protected override void OnActivated(CompositeDisposable disposables)
        {
            Games = gameService.Get();

            previousGame = SelectedGame = Games.FirstOrDefault(s => s.IsSelected);

            var changed = this.WhenAnyValue(s => s.SelectedGame).Where(s => s != null && Games?.Count() > 0).Subscribe(s =>
            {
                if (gameService.SetSelected(Games, s) && previousGame != s)
                {
                    var args = new SelectedGameChangedEventArgs()
                    {
                        Game = gameService.GetSelected()
                    };
                    ReactiveUI.MessageBus.Current.SendMessage(args);
                    previousGame = s;
                }
            }).DisposeWith(disposables);

            activeGameRequestHandler.Message.Subscribe(m =>
            {
                if (m.Game != null)
                {
                    SelectedGame = Games.FirstOrDefault(p => p.Type.Equals(m.Game.Type, StringComparison.OrdinalIgnoreCase));
                }
            }).DisposeWith(disposables);

            base.OnActivated(disposables);
        }
Пример #57
0
 public Game_Jhwj()
 {
     game = games.GetGame("jhwj");                                   //获取游戏
     gc   = gcs.GetGameConfig(game.Id);                              //获取游戏参数
 }
 public void Export(Games game)
 {
     WriteToXML($"AppData/xml-{game.GameId}.xml", game);
 }
Пример #59
0
 public void SwitchToGame( Games.GameInformation game )
 {
     Log.WriteLine( Verbosity.Critical, Feature.General, "Instance: switching to game " + game.Parameters.Title );
     #if XMB
     _xmb.Disable();
     #else
     #endif
     _bios.Game = game;
     LoadResults results = _bios.Load();
 }
Пример #60
0
        private async Task HandleCommandAsync(SocketMessage arg)
        {
            try
            {
                if (!(arg is SocketUserMessage msg))
                {
                    return;
                }

                if (msg.Author.Id == Client.CurrentUser.Id || msg.Author.IsBot)
                {
                    return;
                }

                string prefix = "&";
                int    pos    = prefix.Length - 1;

                UserInfo info = new UserInfo(arg.Author.Id);
                info.AddMessage();

                var          context = new ShardedCommandContext(Client, msg);
                GuildChannel guild   = new GuildChannel(context.Guild);
                if (msg.HasStringPrefix(prefix, ref pos) || msg.HasMentionPrefix(Client.CurrentUser, ref pos))
                {
                    if (!guild.CommandsOn || guild.DisChannelsList.Contains(arg.Channel.Id) == false || msg.Content == $"{prefix}disable")
                    {
                        var result = await Commands.ExecuteAsync(context, pos, Services);

                        if (!result.IsSuccess)
                        {
                            var cmdresult = await CustomCommands.ExecuteCommands(context, pos);

                            if (!cmdresult)
                            {
                                Utils.CustomErrors(msg, result, context);
                            }
                        }
                        else if (result.IsSuccess)
                        {
                            info.AddCommand();
                            CommandUsed.CommandAdd();
                        }
                    }
                    else
                    {
                        var message = await context.Channel.GetMessageAsync(msg.Id);

                        await message.DeleteAsync();

                        CommandUsed.ClearAdd(1);
                    }
                }

                if (arg.Author.IsBot && arg.Author.Id != 372615866652557312 || !guild.GainXp)
                {
                    return;
                }
                else
                {
                    try
                    {
                        LevelUser user = new LevelUser();
                        CommandUsed.GainedMessagesAdd();
                        user.Load(arg.Author.Id);
                        int xp = new Random().Next(1, 5);
                        CommandUsed.TotalXpAdd(xp);
                        user.GainXpUser(arg, guild, xp);
                        if (File.Exists($"./userimg.png"))
                        {
                            File.Delete($"./userimg.png");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"User:{arg.Author.Id}" + ex.ToString());
                    }
                }

                try
                {
                    Games.GetInput(msg.Content.ToLower(), context);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"User:{arg.Author.Id}: = " + ex.ToString());
                }
            }
            catch (Exception)
            {
            }
        }