Beispiel #1
0
    private void HandleMatchStart(MatchStartEventArgs args)
    {
        m_CurrentMatch.TurnState = new TurnState
                                       (m_CurrentMatch, args.PlayerIdOfFirstToMove);

        EventSink.InvokeMatchChatMessageEvent
            (new MatchChatMessageEventArgs("System", DateTime.Now.ToShortTimeString(),
                                           string.Format("{0} Has been randomly selected to move first.",
                                                         m_CurrentMatch.GetPlayerStateById(m_CurrentMatch.TurnState.CurrentPlayerId).Username)));
    }
        private void InterEventDispatcher_MatchStartEvent(MatchStartEventArgs args)
        {
            string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}",
                                       (int)ReadProtocol.GetVersion(),
                                       m_SegmentTerminator,
                                       NetworkCommand.GetCommand(NetworkCommandType.StartMatch),
                                       args.MatchId,
                                       args.PlayerIdOfFirstToMove);

            MatchHandler.SendMessageToUsersInMatch(args.MatchId, cmd);
        }
        private void Refresh()
        {
            saltyStateMachine.RefreshState();
            MatchInformation.UpdateFighterData();

            if (!MatchInformation.HasOfferedBet)
            {
                MatchInformation.UpdateData();
                MatchInformation.MatchStart = DateTime.Now;


                var matchStartEventArgs = new MatchStartEventArgs
                {
                    Salt       = DataExtractor.GetSaltBalanceNum(),
                    BluePlayer = MatchInformation.currentBluePlayer,
                    RedPlayer  = MatchInformation.currentRedPlayer,

                    Tournament = _lastMatchType == MatchType.Tournament,
                    TournamentPlayersRemaining = _bracketCount,
                };

                if (_lastMatchType == MatchType.Tournament && _nextMatchType != MatchType.Tournament)
                {
                    OnTournamentEnded(new EventArgs());
                }

                switch (_nextMatchType)
                {
                case MatchType.Tournament:
                    OnTournamentMatchStart(matchStartEventArgs);
                    break;

                case MatchType.Exhibition:
                    OnExhibitionMatchStart(matchStartEventArgs);
                    break;

                case MatchType.Matchmaking:
                    OnMatchStart(matchStartEventArgs);
                    break;
                }

                MatchInformation.HasOfferedBet = true;
            }
        }
Beispiel #4
0
        public BettingPlan PlaceBet(MatchStartEventArgs matchArgs)
        {
            var betAmount = BaseBetAmount(matchArgs.Salt);
            var player    = SaltyConsole.Players.RedPlayer;

            if (IsHeads())
            {
                player = SaltyConsole.Players.BluePlayer;
            }

            Log.Verbose("Better - Random: Randomly picked {player}.",
                        player.ToString());

            return(new BettingPlan
            {
                Symbol = "~",
                Character = player,
                Salt = betAmount
            });
        }
Beispiel #5
0
        public BettingPlan PlaceBet(MatchStartEventArgs matchArgs)
        {
            var betSymbol = " ";

            var betSalt      = BaseBetAmount(matchArgs.Salt);
            var betCharacter = SaltyConsole.Players.Unknown;

            var bluePlayer = _forbiddingManse.GetOrCreateCharacter(matchArgs.BluePlayer);
            var redPlayer  = _forbiddingManse.GetOrCreateCharacter(matchArgs.RedPlayer);

            if (redPlayer.IsReliableData && bluePlayer.IsReliableData)
            {
                //Ideal case, we have reliable information on both characters
                if (redPlayer.WinPercent > bluePlayer.WinPercent)
                {
                    betCharacter = SaltyConsole.Players.RedPlayer;
                    betSalt     += AdditionalBetAmount(redPlayer, betSalt);
                }
                else
                {
                    betCharacter = SaltyConsole.Players.BluePlayer;
                    betSalt     += AdditionalBetAmount(bluePlayer, betSalt);
                }

                betSymbol = "=";

                Log.Verbose("Better - Winrate: {RedPlayer} Winrate {RedWinrate}%. {BluePlayer} Winrate {BlueWinrate}%.",
                            redPlayer.Name,
                            redPlayer.WinPercent,
                            bluePlayer.Name,
                            bluePlayer.WinPercent);
            }
            else if (redPlayer.IsReliableData)
            {
                if (redPlayer.WinPercent > 50)
                {
                    betCharacter = SaltyConsole.Players.RedPlayer;
                    betSalt     += AdditionalBetAmount(redPlayer, betSalt);
                }
                else
                {
                    betCharacter = SaltyConsole.Players.BluePlayer;
                }

                betSymbol = "-";

                Log.Verbose("Better - Winrate: {RedPlayer} Winrate {RedWinrate}. {BluePlayer} Winrate is unreliable.",
                            redPlayer.Name,
                            redPlayer.WinPercent,
                            bluePlayer.Name);
            }
            else if (bluePlayer.IsReliableData)
            {
                if (bluePlayer.WinPercent > 50)
                {
                    betCharacter = SaltyConsole.Players.BluePlayer;
                    betSalt     += AdditionalBetAmount(bluePlayer, betSalt);
                }
                else
                {
                    betCharacter = SaltyConsole.Players.RedPlayer;
                }

                betSymbol = "-";

                Log.Verbose("Better - Winrate: {RedPlayer} Winrate is unreliable. {Blueplayer} Winrate is {BlueWinrate}.",
                            redPlayer.Name,
                            bluePlayer.Name,
                            bluePlayer.WinPercent);
            }

            return(new BettingPlan
            {
                Symbol = betSymbol,
                Character = betCharacter,
                Salt = betSalt
            });
        }
Beispiel #6
0
 private void InterEventDispatcher_MatchStartEvent(MatchStartEventArgs args)
 {
     ClientManager.Post(() => HandleMatchStart(args));
 }
        public BettingPlan PlaceBet(MatchStartEventArgs matchArgs)
        {
            string betSymbol;

            var betSalt      = BaseBetAmount(matchArgs.Salt, matchArgs.TournamentPlayersRemaining);
            var betCharacter = SaltyConsole.Players.Unknown;

            var bluePlayer = _forbiddingManse.GetOrCreateCharacter(matchArgs.BluePlayer);
            var redPlayer  = _forbiddingManse.GetOrCreateCharacter(matchArgs.RedPlayer);

            if (redPlayer.IsReliableData && bluePlayer.IsReliableData)
            {
                //Ideal case, we have reliable information on both characters
                if (redPlayer.WinPercent > bluePlayer.WinPercent)
                {
                    betCharacter = SaltyConsole.Players.RedPlayer;
                }
                else
                {
                    betCharacter = SaltyConsole.Players.BluePlayer;
                }

                betSymbol = "=";

                Log.Verbose("Better - Winrate Tournament: {RedPlayer} Winrate {RedWinrate}%. {BluePlayer} Winrate {BlueWinrate}%.",
                            redPlayer.Name,
                            redPlayer.WinPercent,
                            bluePlayer.Name,
                            bluePlayer.WinPercent);
            }
            else if (redPlayer.IsReliableData)
            {
                if (redPlayer.WinPercent > 50)
                {
                    betCharacter = SaltyConsole.Players.RedPlayer;
                }
                else
                {
                    betCharacter = SaltyConsole.Players.BluePlayer;
                }

                betSymbol = "-";

                Log.Verbose("Better - Winrate Tournament: {RedPlayer} Winrate {RedWinrate}. {BluePlayer} Winrate is unreliable.",
                            redPlayer.Name,
                            redPlayer.WinPercent,
                            bluePlayer.Name);
            }
            else if (bluePlayer.IsReliableData)
            {
                if (bluePlayer.WinPercent > 50)
                {
                    betCharacter = SaltyConsole.Players.BluePlayer;
                }
                else
                {
                    betCharacter = SaltyConsole.Players.RedPlayer;
                }

                betSymbol = "-";

                Log.Verbose("Better - Winrate Tournament: {RedPlayer} Winrate is unreliable. {Blueplayer} Winrate is {BlueWinrate}.",
                            redPlayer.Name,
                            bluePlayer.Name,
                            bluePlayer.WinPercent);
            }
            else
            {
                betSymbol    = "~";
                betCharacter = SaltyConsole.Players.RedPlayer;
                if (IsHeads())
                {
                    betCharacter = SaltyConsole.Players.BluePlayer;
                }

                Log.Verbose("Better - Winrate Tournament: No reliable stats on either character. Randomly picked {player}.",
                            betCharacter.ToString());
            }

            return(new BettingPlan
            {
                Symbol = betSymbol,
                Character = betCharacter,
                Salt = betSalt
            });
        }
        public BettingPlan PlaceBet(MatchStartEventArgs matchArgs)
        {
            var betSymbol = " ";

            var betSalt      = 10;
            var betCharacter = SaltyConsole.Players.Unknown;

            var bluePlayer = _forbiddingManse.GetOrCreateCharacter(matchArgs.BluePlayer);
            var redPlayer  = _forbiddingManse.GetOrCreateCharacter(matchArgs.RedPlayer);

            var(bluePlayerProfit, bluePlayerMatchcount) = GetProfitAndMatchcount(bluePlayer);
            var(redPlayerProfit, redPlayerMatchcount)   = GetProfitAndMatchcount(redPlayer);

            if (redPlayerProfit.Equals(bluePlayerProfit))
            {
                //Either identical profit expectations or more likely two characters without recorded matches
                return(new BettingPlan
                {
                    Symbol = betSymbol,
                    Character = SaltyConsole.Players.Unknown,
                    Salt = betSalt
                });
            }

            if (bluePlayerProfit != 0 && redPlayerProfit != 0)
            {
                betSymbol = "=";
            }
            else if (bluePlayerProfit != 0 || redPlayerProfit != 0)
            {
                betSymbol = "-";
            }

            if (redPlayerProfit > bluePlayerProfit)
            {
                betCharacter = SaltyConsole.Players.RedPlayer;
                betSalt      = BaseBetAmount(redPlayerProfit, matchArgs.Salt);

                if (redPlayerMatchcount > _reliableMatchCount && bluePlayerMatchcount > _reliableMatchCount)
                {
                    betSalt += AdditionalBetAmount(redPlayerProfit, betSalt);
                }

                Log.Verbose("Better - Profit: {RedPlayer} odds {RedPlayerCertainty}{RedPlayerProfit:N4} >>> {Blueplayer} odds {BluePlayerCertainty}{BluePlayerProfit:N4}.",
                            redPlayer.Name,
                            redPlayerMatchcount <= _reliableMatchCount ? "~" : "",
                            redPlayerProfit,
                            bluePlayer.Name,
                            bluePlayerMatchcount <= _reliableMatchCount ? "~" : "",
                            bluePlayerProfit);
            }
            else
            {
                betCharacter = SaltyConsole.Players.BluePlayer;
                betSalt      = BaseBetAmount(bluePlayerProfit, matchArgs.Salt);

                if (redPlayerMatchcount > _reliableMatchCount && bluePlayerMatchcount > _reliableMatchCount)
                {
                    betSalt += AdditionalBetAmount(bluePlayerProfit, betSalt);
                }

                Log.Verbose("Better - Profit: {RedPlayer} odds {RedPlayerCertainty}{RedPlayerProfit:N4} <<< {Blueplayer} odds {BluePlayerCertainty}{BluePlayerProfit:N4}.",
                            redPlayer.Name,
                            redPlayerMatchcount <= _reliableMatchCount ? "~" : "",
                            redPlayerProfit,
                            bluePlayer.Name,
                            bluePlayerMatchcount <= _reliableMatchCount ? "~" : "",
                            bluePlayerProfit);
            }

            return(new BettingPlan
            {
                Symbol = betSymbol,
                Character = betCharacter,
                Salt = betSalt
            });
        }