Exemple #1
0
 // Use this for initialization
 void Start()
 {
     if (!current)
     {
         current = this;
     }
 }
Exemple #2
0
 // Use this for initialization
 void Start()
 {
     if (!current)
     {
         current = this;
     }
 }
        public void Go()
        {
            var user  = this.CreateUser();
            var stake = this.SetStake(user);

            var bookie = new Bookie(user, stake);

            this.Loop(bookie);
        }
        private double GetWinAmount(Bookie bookie)
        {
            bookie.User.Amount     -= bookie.SpinStake;
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("---------- User Amount: " + bookie.User.Amount);
            Console.ResetColor();

            var winCoef   = this._engine.Spin();
            var winAmount = string.Format("{0:0.00}", winCoef * bookie.SpinStake);

            return(double.Parse(winAmount));
        }
Exemple #5
0
        public CommandManager(PerfStatsCollector perfStatsCollector)
        {
            _perfStatsCollector = perfStatsCollector;
            bookie = new RequestLogging.Bookie(perfStatsCollector);
            CommandLogManager.InitializeLogger(perfStatsCollector.InstanceName);

            CompactFormatterServices.RegisterCompactType(typeof(Web.Synchronization.SyncCache), 124);

            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.StateTransferInfo), 130);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.ReplicatorStatusInfo), 131);

            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.OperationContext), 153);

            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.EnumerationPointer), 161);

            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.EnumerationDataChunk), 162);
        }
Exemple #6
0
        public IGameUI NewGameUI()
        {
            IRandom random                        = new InjectableRandom();
            IPlayer player                        = new Player();
            SnailNameGenerator snailNameGenerator = new SnailNameGenerator(random);
            IBookie bookie                        = new Bookie();
            IGame game                            = new Game
            (
                player,
                CreateRaceLineup.DelegateCreateRaceLineup
                (
                    random,
                    40,
                    CreateRace.DelegateCreateRace()
                ),
                AggregateSnails.DelegateAggregateSnails
                (
                    CreateSnail.DelegateCreateSnail(),
                    snailNameGenerator
                ),
                bookie
            );
            DelegateCreateOutputMethod standardOutput = CreateConsoleOutput.DelegateCreateConsoleOutput();
            DelegateCreateOutputMethod bufferedOutput = CreateBufferedConsoleOutput.DelegateCreateBufferedConsoleOutput();

            ISplashScreen splashScreen   = new SplashScreen(standardOutput);
            IRaceViewer raceViewer       = new RaceViewer(100, bufferedOutput);
            IBookieInput bookieInput     = new BookieInput(CreateBet.DelegateCreateBet(), standardOutput);
            IPayoutDisplay payoutDisplay = new PayoutDisplay(standardOutput);

            return new GameUI(
                game,
                splashScreen,
                raceViewer,
                bookieInput,
                payoutDisplay
            );
        }
        private void Loop(Bookie bookie)
        {
            while (bookie.User.CoverStake(bookie.SpinStake))
            {
                var winAmount = this.GetWinAmount(bookie);
                if (winAmount > 0)
                {
                    bookie.User.Amount += winAmount;
                }

                this.PrintStats(winAmount, bookie.User.Amount);

                if (bookie.User.Amount == 0)
                {
                    break;
                }

                Console.WriteLine($"---------------------------");
                bookie.SpinStake = this.SetStake(bookie.User);
            }

            Console.WriteLine("**-----GAME OVER-----**");
        }
 /// <summary>
 /// Gets a list of all open matches from the bookie
 /// </summary>
 /// <param name="requestingB">The bookie to request the matches from</param>
 /// <returns>A list of open matches</returns>
 public List<Match> showMatches(Bookie requestingB)
 {
     object[] parameter = new object[] {
         _gambler.ID
     };
     JsonResponse response = handleJsonRpcRequest("showMatches", parameter, this._gambler.getNextMessageID());
     if (response != null)
     {
         string[] array = responseToStringArray(response);
         List<Match> listOfMatches = new List<Match>();
         foreach (string str in array)
         {
             if (str.Contains(","))
             {
                 string bookieID = string.Empty;
                 int id = int.MinValue;
                 string teamA = string.Empty;
                 string teamB = string.Empty;
                 float oddsA = float.MinValue;
                 float oddsB = float.MinValue;
                 float oddsDraw = float.MinValue;
                 float limit = float.MinValue;
                 string[] matchData = str.Split(',');
                 Controller.FunctionController f = Controller.FunctionController.getInstance();
                 foreach (string m in matchData)
                 {
                     if (m.StartsWith("bookieID"))
                         bookieID = m.Split(':')[1];
                     else if (m.StartsWith("id") && !f.isInt(m.Split(':')[1], out id))
                         throw new Exception("Match ID is not in an integer format");
                     else if (m.StartsWith("teamA"))
                         teamA = m.Split(':')[1];
                     else if (m.StartsWith("teamB"))
                         teamB = m.Split(':')[1];
                     else if (m.StartsWith("oddsA") && !f.isFloat(m.Split(':')[1], out oddsA))
                         throw new Exception("Odds A was not a valid float value");
                     else if (m.StartsWith("oddsB") && !f.isFloat(m.Split(':')[1], out oddsB))
                         throw new Exception("Odds B was not a valid float value");
                     else if (m.StartsWith("limit") && !f.isFloat(m.Split(':')[1], out limit))
                         throw new Exception("Stake was not a valid float value");
                     else if (m.StartsWith("oddsDraw") && !f.isFloat(m.Split(':')[1], out oddsDraw))
                         throw new Exception("Odds draw was not a valid float value");
                 }
                 if (teamA != string.Empty && teamB != string.Empty && bookieID != string.Empty && bookieID == requestingB.ID)
                     listOfMatches.Add(new Match(id, teamA, oddsA, teamB, oddsB, oddsDraw, limit, requestingB));
             }
         }
         return listOfMatches;
     }
     return new List<Match>();
 }
 public InquiryRequestCommand(Bookie bookie)
 {
     _bookie = bookie;
 }