Esempio n. 1
0
        private static void ConsoleOnTournamentMatchStart(object sender, EventArgs eventArgs)
        {
            var matchStartArgs = (MatchStartEventArgs)eventArgs;

            //Don't try to bet on matches already in progress
            if (matchStartArgs.RedPlayer == "null" ||
                matchStartArgs.BluePlayer == "null")
            {
                Log.Information("Match already in progress.");
                return;
            }

            //Store some session information
            if (_sessionResults.StartingSalt == 0)
            {
                _sessionResults.StartingSalt = matchStartArgs.Salt;
            }

            if (_tournamentResults.StartingSalt == 0)
            {
                _tournamentResults.StartingSalt = matchStartArgs.Salt;
            }

            //For Tournaments
            BettingPlan betPlan;

            try
            {
                betPlan = _tournamentBettingEngine.PlaceBet(matchStartArgs);
            }
            catch
            {
                Log.Debug("Could not create tournament bet due to EF Exception, defaulting to random");
                betPlan = new BettingPlan
                {
                    Character = SaltyConsole.Players.Unknown,
                    Salt      = 0,
                    Symbol    = "",
                };
            }

            //In case no bet was placed, fallback to random
            if (betPlan.Character == SaltyConsole.Players.Unknown)
            {
                betPlan = _bettingEngineBackup.PlaceBet(matchStartArgs);
            }

            //Place and report bet.
            _saltyBetConsole.PlaceBet(betPlan.Character, betPlan.Salt);

            var betCharacterName = betPlan.Character == SaltyConsole.Players.BluePlayer ? matchStartArgs.BluePlayer : matchStartArgs.RedPlayer;

            Log.Information("Tournament Match Start: [{BetSymbol}] {RedPlayer} vs {BluePlayer}. Betting {SaltAmount:N0}$ on {BetPlayer}.",
                            betPlan.Symbol,
                            matchStartArgs.RedPlayer,
                            matchStartArgs.BluePlayer,
                            betPlan.Salt,
                            betCharacterName);
        }
Esempio n. 2
0
        private static void SaltyBetConsoleOnExhibitionMatchStart(object sender, EventArgs eventArgs)
        {
            var matchStartArgs = (MatchStartEventArgs)eventArgs;

            //Don't try to bet on matches already in progress
            if (matchStartArgs.RedPlayer == "null" ||
                matchStartArgs.BluePlayer == "null")
            {
                Log.Information("Exhibition match already in progress.");
                return;
            }

            //Store some session information
            if (_sessionResults.StartingSalt == 0)
            {
                _sessionResults.StartingSalt = matchStartArgs.Salt;
            }

            BettingPlan betPlan;

            try
            {
                betPlan = _exibhitionBettingEngine.PlaceBet(matchStartArgs);
            }
            catch
            {
                Log.Debug("Could not create exhibition bet due to EF Exception, defaulting to random");
                betPlan = new BettingPlan
                {
                    Character = SaltyConsole.Players.Unknown,
                    Salt      = 0,
                    Symbol    = "",
                };
            }

            //In case no bet was placed, fallback to random
            if (betPlan.Character == SaltyConsole.Players.Unknown)
            {
                betPlan = _bettingEngineBackup.PlaceBet(matchStartArgs);
            }

            //Exhibitions are garbage, only bet half of adviced
            betPlan.Salt = (int)(betPlan.Salt * 0.5);

            _saltyBetConsole.PlaceBet(betPlan.Character, betPlan.Salt);

            var betCharacterName = betPlan.Character == SaltyConsole.Players.BluePlayer ? matchStartArgs.BluePlayer : matchStartArgs.RedPlayer;

            Log.Information("Exhibition Match Start: [{BetSymbol}] {RedPlayer} vs {BluePlayer}. Betting {SaltAmount:N0}$ on {BetPlayer}.",
                            betPlan.Symbol,
                            matchStartArgs.RedPlayer,
                            matchStartArgs.BluePlayer,
                            betPlan.Salt,
                            betCharacterName);
        }