コード例 #1
0
        public void TestNoLimitRaising()
        {
            double[] blinds = new double[] { 2, 4 };
            betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            Action[] actions = new Action[] {
                new Action("Player0", Action.ActionTypes.PostSmallBlind, 2),
                new Action("Player1", Action.ActionTypes.PostBigBlind, 4),
                new Action("Player2", Action.ActionTypes.Bet, 6),  //should be corrected to Raise 8
                new Action("Player3", Action.ActionTypes.Raise, 20),
                new Action("Player4", Action.ActionTypes.Raise, 0) //should be corrected to 32
            };

            betMan.Commit(actions[0]);
            betMan.Commit(actions[1]);

            Action action = betMan.GetValidatedAction(actions[2]);

            Assert.AreEqual(8, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[3]);
            Assert.AreEqual(20, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[4]);
            Assert.AreEqual(32, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);
        }
コード例 #2
0
    // Start is called before the first frame update
    private void Start()
    {
        playerController = GameObject.FindGameObjectWithTag("Player").AddComponent <PlayerController>();

        alerter = GameObject.FindGameObjectWithTag("Alerter").GetComponent <Text>();
        playerController.InitPlayerController("Player", GetComponent <GameManager>());

        cardManager = this.gameObject.GetComponent <CardManager>();
        betManager  = this.gameObject.GetComponent <BetManager>();
        uiManager   = GameObject.FindGameObjectWithTag("UIManager").GetComponent <UIManager>();

        asource = gameObject.AddComponent <AudioSource>();

        soundManager = new SoundManager();
        soundManager.InitSoundManager();
        soundManager.StartBGMusic(asource);
        cardManager.initCardManager(this);
        betManager.InitBetManager(this);

        gameStarted  = false;
        lockedBetsIn = false;

        BetTurn    = 1;
        playerTurn = 1;
        numPlayers = 5;

        uiManager.enableBetSliderUI();

        //CreateNewGame();
    }
コード例 #3
0
        public void TestBlinds()
        {
            double[] blinds = new double[] { 1, 2 };
            betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            FastPokerAction[] actions = new FastPokerAction[] {
                new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 25),
                new FastPokerAction("Player4", FastPokerAction.ActionTypes.PostBigBlind, 100),
                new FastPokerAction("Player0", FastPokerAction.ActionTypes.Raise, 1),
            };

            FastPokerAction action = betMan.GetValidatedAction(actions[0]);

            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[1]);
            Assert.AreEqual(2, action.Amount);
            Assert.AreEqual(FastPokerAction.ActionTypes.PostBigBlind, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[2]);
            Assert.AreEqual(4, action.Amount);
            Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);
        }
コード例 #4
0
        public void TestAntes()
        {
            double[] blinds = new double[] { 2, 4 };
            betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 1);

            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostAnte, 25),  //should be 1
                new Action("Player4", Action.ActionTypes.PostAnte, 0.5), // should be 1
                new Action("Player0", Action.ActionTypes.PostAnte, 2),   //should be PostAnte and 1
            };

            Action action = betMan.GetValidatedAction(actions[0]);

            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[1]);
            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[2]);
            Assert.AreEqual(1, action.Amount);
            Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType);

            betMan.Commit(action);
            Assert.IsFalse(betMan.RoundOver);
        }
コード例 #5
0
 void Start()
 {
     rb         = GetComponent <Rigidbody2D>();
     animator   = GetComponent <Animator>();
     betManager = FindObjectOfType <BetManager>();
     health     = maxHealth;
 }
コード例 #6
0
    //when message is recieved from IRC-server or our own message.
    void OnChatMsgRecieved(string msg)
    {
        //parse from buffer.
        int    msgIndex  = msg.IndexOf("PRIVMSG #");
        string msgString = msg.Substring(msgIndex + IRC.channelName.Length + 11);
        string user      = msg.Substring(1, msg.IndexOf('!') - 1);

        GuestManager.CheckOrRegisterGuest(user);

        BetManager.GetABet(msgString, user, this.gameObject);
        Debug.Log("<color=purple> msg = " + msg + "</color><color=blue> msgString = " + msgString + "</color><color=purple>user = "******"</color>");


        if (msgString == "Enter")
        {
            Debug.Log("Spawn a spectator!");              //Possible future feature to spawn audience avatar
        }

        //remove old messages for performance reasons.
        if (messages.Count > maxMessages)
        {
            Destroy(messages.First.Value);
            messages.RemoveFirst();
        }

        //add new message.
        //CreateUIMessage(user, msgString);
    }
コード例 #7
0
    private void PlaceBet()
    {
        if (BetManager.IsMoneyEnough())
        {
            betAnimationController.PlaceChipInButton(transform.position.x, transform.position.y);

            BetManager.totalBet   += BetManager.betValue;
            BetManager.totalMoney -= BetManager.betValue;
            totalBetOnThisButton  += BetManager.betValue;

            //buttonText.text = BetManager.totalBet.ToString();

            UpdateTextDisplayers();

            Debug.Log("Total money bet on this spin: " + BetManager.totalBet);


            foreach (numberButton button in groupButtons)
            {
                if (BetManager.betData.Contains(button))
                {
                }
                else
                {
                    BetManager.betData.Add(button);
                }
            }
        }
        else
        {
            Debug.Log("Not enough money to place current chip");
        }
    }
コード例 #8
0
        public void Should_Add_Big_Blind()
        {
            // namesToChips["Player0"] = 200;
            // namesToChips["Player1"] = 200;
            // namesToChips["Player2"] = 200;
            // namesToChips["Player3"] = 200;
            // namesToChips["Player4"] = 200;

            UInt64[]   blinds = new UInt64[] { 1, 2 };
            BetManager betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            FastPokerAction action = betMan.GetValidatedAction(new FastPokerAction("Player0", FastPokerAction.ActionTypes.PostSmallBlind, 1));

            Assert.True(1 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);

            Assert.False(betMan.RoundOver);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(new FastPokerAction("Player1", FastPokerAction.ActionTypes.PostSmallBlind, 1));
            Assert.True(2 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostBigBlind, action.ActionType);
        }
コード例 #9
0
ファイル: BetMore.cs プロジェクト: apekshadarbari/PokerFace
    /// <summary>
    /// onclick function for each of the buttons that have to do with betting
    /// </summary>
    public void EndTurn()
    {
        // TODO : do enable instead of deactivate as it cuts off the sound of the click
        audioSrc.clip = buttonPressed;
        audioSrc.Play();

        //Debug.Log(RoundManager.Instance.PlayerTurn);
        //if (this.photonView.ownerId == 1)
        //{
        //    var btns = GameObject.FindGameObjectWithTag("Player1BetController");

        //    //betMan = GameObject.FindGameObjectWithTag("Player1BetController").GetComponent<BetManager>();
        //}
        //if (this.photonView.ownerId == 2)
        //{
        //    betMan = GameObject.FindGameObjectWithTag("Player2BetController").GetComponent<BetManager>();
        //}

        //TODO: move all of these into another script called betcontroller
        //Debug.Log("this button belongs to player: " + this.photonView.ownerId);s
        if (PhotonNetwork.player.ID == this.photonView.ownerId && RoundManager.Instance.PlayerTurn == PhotonNetwork.player.ID)
        {
            betMan = BetManager.Instance;
            switch (action)
            {
                case BetAction.IncreaseBet:
                    //Adding chips to raise
                    betMan.IncreaseBet();
                    break;

                case BetAction.DecreaseBet:
                    //Reducing chips to raises
                    betMan.DecreaseBet();
                    break;

                case BetAction.CommitBet:
                    //accepting the bet size and commiting it
                    //betMan.Bet();
                    break;

                case BetAction.CallOrCheck:
                    //Calling the last value
                    //Debug.Log("hej");
                    /*  betMan.SetBetToCallValue();*///setss the bet to what it needs to be to call;
                    betMan.Bet();
                    break;

                case BetAction.Fold:
                    //Folding cards
                    betMan.Fold();
                    break;
            }
            OnExitHover();
        }
        //else if (!this.photonView.isMine)
        //{
        //    throw new NotImplementedException("not yours");
        //}
    }
コード例 #10
0
        /// <summary>Creates a new Primedice client instance.</summary>
        /// <param name="authToken">Access token used for creating an authenticated instance.</param>
        public PrimediceClient(string authToken = null)
        {
            WebClient = new RestWebClient(authToken);

            Users  = new UserManager(WebClient);
            Bets   = new BetManager(WebClient);
            Wallet = new WalletManager(WebClient);
        }
コード例 #11
0
 void Start()
 {
     Invoke("FindFighters", 0.1f);
     betManager           = FindObjectOfType <BetManager>();
     canvas               = FindObjectOfType <Canvas>();
     healthBar1           = canvas.transform.Find("Fighter1Health").transform.Find("Bar").gameObject;
     healthBarBackground1 = canvas.transform.Find("Fighter1Health").transform.Find("Background").gameObject;
     healthBar2           = canvas.transform.Find("Fighter2Health").transform.Find("Bar").gameObject;
     healthBarBackground2 = canvas.transform.Find("Fighter2Health").transform.Find("Background").gameObject;
 }
コード例 #12
0
ファイル: BetEditor.cs プロジェクト: mattsparks77/Black-Jack
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        BetManager myScript = (BetManager)target;

        if (GUILayout.Button("Add 50"))
        {
            myScript.myWallet.AddMoney(50);
        }
    }
コード例 #13
0
ファイル: BetManager.cs プロジェクト: Francois992/CloudJam
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #14
0
        public Game(ElementManager elmManager, BetManager betManager, CardEngine cardEngine, ResizingHandler resizer)
        {
            this.handManager = new HandManager();
            this.betManager  = betManager;
            this.elmManager  = elmManager;
            this.cardEngine  = cardEngine;
            this.resizer     = resizer;

            this.roundIsOver = false;
            this.issplit     = false;
            this.start       = true;

            //Kinda starts the program u know?
            reset();
        }
コード例 #15
0
        public void Should_Add_Big_Blind()
        {
            namesToChips            = new Dictionary <string, UInt64>();
            namesToChips["Player0"] = 200;
            namesToChips["Player1"] = 200;
            namesToChips["Player2"] = 200;
            namesToChips["Player3"] = 200;
            namesToChips["Player4"] = 200;

            UInt64[]   blinds = new UInt64[] { 1, 2 };
            BetManager betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            FastPokerAction action = betMan.GetValidatedAction(new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 1));

            Assert.True(1 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);
        }
コード例 #16
0
    //when message is recieved from IRC-server or our own message.
    void OnChatMsgRecieved(string msg)
    {
        //parse from buffer.
        int    msgIndex  = msg.IndexOf("PRIVMSG #");
        string msgString = msg.Substring(msgIndex + IRC.channelName.Length + 11);
        string user      = msg.Substring(1, msg.IndexOf('!') - 1);

        GuestManager.CheckOrRegisterGuest(user);

        BetManager.GetABet(msgString, user, this.gameObject);
        //Debug.Log("<color=purple> msg = " + msg + "</color><color=blue> msgString = " + msgString + "</color><color=purple>user = "******"</color>");


        if (msgString == "Enter")
        {
            Debug.Log("Spawn a spectator!");              //Possible future feature to spawn audience avatar
            foreach (GuestData possibleGuest in GuestManager.AllGuests)
            {
                if (possibleGuest.guestName == user)
                {
                    if (possibleGuest.ownedTurtles.Count > 0)
                    {
                        string numbersInMessage      = Regex.Match(msgString, @"\d+").Value;
                        int    numbersInMessageAsInt = int.Parse(numbersInMessage);
                        //BonusRoundManager.TurtlesToEnterNextRace.SetValue(possibleGuest.ownedTurtles[numbersInMessageAsInt-1], BonusRoundManager.TurtlesToEnterNextRace.Length); //doing this elsewhere now
                    }
                }
            }
        }
        if (msgString.CaseInsensitiveContains("balance"))
        {
            //send a PM with their balance
        }

        //remove old messages for performance reasons.
        if (messages.Count > maxMessages)
        {
            Destroy(messages.First.Value);
            messages.RemoveFirst();
        }

        //add new message.
        //CreateUIMessage(user, msgString);
    }
コード例 #17
0
        public dynamic AddUserBet(RequestData data)
        {
            var userToken = RequestContextHelper.SessionToken; //data.token;
            var betType   = (int)Enum.Parse(typeof(BetType), data.betsType);

            BetManager mgr = new BetManager();

            List <Tuple <int, decimal, string> > bets = new List <Tuple <int, decimal, string> >();

            foreach (var uibet in data.uibets)
            {
                Tuple <int, decimal, string> bet = new Tuple <int, decimal, string>(uibet.ID, uibet.Amount, uibet.BetType);
                bets.Add(bet);
            }

            var success = mgr.AddUserBet(userToken, (int)betType, bets);

            return(this.GetUserBet(RequestContextHelper.SessionToken));
        }
コード例 #18
0
        public void Should_Add_Valid_Blinds()
        {
            namesToChips            = new Dictionary <string, UInt64>();
            namesToChips["Player0"] = 200;
            namesToChips["Player1"] = 200;
            namesToChips["Player2"] = 200;
            namesToChips["Player3"] = 200;
            namesToChips["Player4"] = 200;

            UInt64[]   blinds = new UInt64[] { 1, 2 };
            BetManager betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            FastPokerAction[] actions = new FastPokerAction[]
            {
                new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 25),
                new FastPokerAction("Player4", FastPokerAction.ActionTypes.PostBigBlind, 50),
                new FastPokerAction("Player0", FastPokerAction.ActionTypes.Raise, 1),
            };

            FastPokerAction action = betMan.GetValidatedAction(new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 1));

            Assert.True(1 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[1]);
            Assert.True(2 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostBigBlind, action.ActionType);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[2]);
            Assert.True(4 == action.Amount);
            Assert.Equal(Engine.Action.ActionTypes.Raise, action.ActionType);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);
        }
コード例 #19
0
        public void Should_Be_Able_To_Raise()
        {
            UInt64[]   blinds = new UInt64[] { 2, 4 };
            BetManager betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            Action[] actions = new Action[]
            {
                new Action("Player0", Action.ActionTypes.PostSmallBlind, 2),
                new Action("Player1", Action.ActionTypes.PostBigBlind, 4),
                new Action("Player2", Action.ActionTypes.Bet, 6),  //should be corrected to Raise 8
                new Action("Player3", Action.ActionTypes.Raise, 20),
                new Action("Player4", Action.ActionTypes.Raise, 0) //should be corrected to 32
            };

            betMan.Commit(actions[0]);
            betMan.Commit(actions[1]);

            Action action = betMan.GetValidatedAction(actions[2]);

            Assert.True(8 == action.Amount);
            Assert.Equal(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[3]);
            Assert.True(20 == action.Amount);
            Assert.Equal(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[4]);
            Assert.True(32 == action.Amount);
            Assert.Equal(Action.ActionTypes.Raise, action.ActionType);
            betMan.Commit(action);
            Assert.False(betMan.RoundOver);
        }
コード例 #20
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeSinceLevelLoad > 1 && !hasPlacedAIBets)
        {
            TwitchChatExample ChatLink = gameObject.GetComponent <TwitchChatExample>();
            for (int i = 0; i <= 128; i++)
            {
                ChatLink.fakeMessage(TurtlesInTheRace[Random.Range(0, 10)].name);
                if (i > 122)
                {
                    ChatLink.fakeMessage("bid A " + CurrentTurtlesForSale[0].GetComponent <TurtleForSale>().myName + " " + Random.Range(1, 10));
                }
            }
            hasPlacedAIBets = true;
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            if (BonusRoundManager.IsMusicEnabled)
            {
                BonusRoundManager.IsMusicEnabled = false;
                Debug.Log("Disabling Music");
            }
            else
            {
                BonusRoundManager.IsMusicEnabled = true;
                Debug.Log("Enabling Music");
            }
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            foreach (GameObject eachTurtle in TurtlesInTheRace)
            {
                TurtleAI ti = eachTurtle.GetComponent <TurtleAI>();
                ti.BaseSpeed = 50;
            }
            TimeBetweenRaces = 2;
        }
        if (Input.GetKeyDown(KeyCode.S))
        { //start the race shortcut
            TimeBetweenRaces = 2;
        }

        if (TimeBetweenRaces - 9 < Time.timeSinceLevelLoad && BettingOpenDialog.activeInHierarchy == true)
        {
            AudioSource.PlayClipAtPoint(bellSound, Camera.main.transform.position);
            BettingClosedDialog.SetActive(true);
            BettingOpenDialog.SetActive(false);
            raceInfoDialog.SetActive(false);
            RaceDetailsGridObject.SetActive(false);
        }
        if (TimeBetweenRaces - Time.timeSinceLevelLoad < 40 && !startedMusic)
        {
            print("time race ended " + timeRaceEnded + " time between races " + TimeBetweenRaces);

            MainCameraHelper.StartTheRaceMusic();
            startedMusic = true;
        }
        if (TimeBetweenRaces - 6 < Time.timeSinceLevelLoad && isBettingOpen)
        {
            isBettingOpen = false;
        }

        if (TimeBetweenRaces * 0.9f < Time.timeSinceLevelLoad && !hasAucionCompleted)
        {
            Auctioneer.FinalizeAuction(this.gameObject);
            hasAucionCompleted = true;
            AuctionTimerObject.SetActive(false);
            WholeAuctionObject.SetActive(false);
        }
        else
        {
            AuctionTimer.text = Mathf.RoundToInt((TimeBetweenRaces * 0.9f) - Time.timeSinceLevelLoad) + " Seconds";
        }

        if (TimeBetweenRaces < Time.timeSinceLevelLoad && !hasRaceStarted)
        {
            hasRaceStarted = true;
            RaceStartingTimerObject.SetActive(false);
            BettingClosedDialog.SetActive(false);
            RaceCam1.m_Speed = 1;
            //TimeBetweenRaces += Time.time; //this was causing extra delays
            BetManager.FinalizeOdds(this.gameObject);
        }
        else
        {
            RaceStartingTimer.text = Mathf.RoundToInt(TimeBetweenRaces - Time.timeSinceLevelLoad) + " Seconds";
        }
        if (hasRaceStarted && FinishLineCam.Priority != 16)
        {
            foreach (GameObject turtleRef in TurtlesInTheRace)
            {
                TurtleAI turlteScriptRef = turtleRef.GetComponent <TurtleAI>();

                /*if(BackHalfCam.Priority!=15 && turlteScriptRef.percentFinished > 0.5f){
                 *                      BackHalfCam.Priority = 15;
                 *              }*/
                if (turlteScriptRef.percentFinished > 0.9f)
                {
                    FinishLineCam.Priority = 16;
                }
            }
        }

        //If a single turtle finshed, open the in-race results gui.
        if (TurtleAI.HowManyTurtlesFinished > 0 && !hasRaceEnded)
        {
            if (!InRaceresultsScreen.activeInHierarchy)
            {
                InRaceresultsScreen.SetActive(true);
            }
        }

        if (TurtleAI.HowManyTurtlesFinished == 10 && !hasRaceEnded)
        {
            hasRaceEnded = true;
            PayOutWinners();
            InRaceresultsScreen.SetActive(false);
            RaceResultsScreen.SetActive(true);
            RaceStartingTitle.text = "Bonus Round in";
            BettingClosedDialog.SetActive(true);
            raceInfoDialog.SetActive(true);
            RaceResultsGUITextA.text = TurtleAI.RaceResultsColumn1 + "<nobr>";
            RaceResultsGUITextB.text = TurtleAI.RaceResultsColumn2 + "<nobr>";
            RaceResultsGuiTextC.text = TurtleAI.RaceResultsColumn3 + "<nobr>";
            RaceResultsGiuTextD.text = TurtleAI.RaceResultsColumn4 + "<nobr>";

            timeRaceEnded = Time.timeSinceLevelLoad;
            int   totalTrueBets = 0;
            float totalPaidOut  = 0;
            foreach (BetData eachBet in CurrentRaceBets)
            {
                //Check for winning bets
                if (eachBet.BetType == "win")
                {
                    foreach (RaceResultData contestant in GuestManager.CurrentRaceresults)
                    {
                        if (contestant.FinishingPlace == 1 && contestant.TurtleName == eachBet.TurtlesName)
                        {
                            //They predicted this win!
                            eachBet.didBetComeTrue = true;
                            totalTrueBets++;
                        }
                    }
                }
                if (eachBet.BetType == "place")
                {
                    foreach (RaceResultData contestant in GuestManager.CurrentRaceresults)
                    {
                        if (contestant.TurtleName == eachBet.TurtlesName)
                        {
                            if (contestant.FinishingPlace == 1 || contestant.FinishingPlace == 2)
                            {
                                eachBet.didBetComeTrue = true;
                                totalTrueBets++;
                            }
                        }
                    }
                }
                if (eachBet.BetType == "show")
                {
                    foreach (RaceResultData contestant in GuestManager.CurrentRaceresults)
                    {
                        if (contestant.TurtleName == eachBet.TurtlesName)
                        {
                            if (contestant.FinishingPlace <= 3)
                            {
                                eachBet.didBetComeTrue = true;
                                totalTrueBets++;
                            }
                        }
                    }
                }

                foreach (GuestData eachGuest in GuestManager.AllGuests)
                {
                    if (eachGuest.guestName == eachBet.BettersName)
                    {
                        if (eachBet.didBetComeTrue)
                        {
                            //Pay them if the bet won.
                            float     amountToPay = eachBet.BetAmount * eachBet.BetOdds;
                            TwitchIRC tIRC        = GetComponent <TwitchIRC>();
                            if (eachBet.BetType == "place")
                            {
                                amountToPay = eachBet.BetAmount + OddsDisplay.CurrentTotalPlacePool * (eachBet.BetAmount / (OddsDisplay.CurrentTotalPlacePool / 2));
                                //Debug.Log("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " to place of a pool of " + OddsDisplay.CurrentTotalPlacePool);
                                if (!eachGuest.guestName.Contains("turtlebot"))
                                {
                                    //tIRC.SendMsg("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + "to place of a pool of " + OddsDisplay.CurrentTotalPlacePool);
                                }
                            }
                            if (eachBet.BetType == "win")
                            {
                                //Debug.Log("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " at odds of " + eachBet.BetOdds);
                                if (!eachGuest.guestName.Contains("turtlebot"))
                                {
                                    //tIRC.SendMsg("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " at odds of " + eachBet.BetOdds);
                                }
                            }
                            if (eachBet.BetType == "show")
                            {
                                amountToPay = eachBet.BetAmount + OddsDisplay.CurrentTotalShowPool * (eachBet.BetAmount / (OddsDisplay.CurrentTotalShowPool / 3));
                                //Debug.Log("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " to show of a pool of " + OddsDisplay.CurrentTotalShowPool);
                                if (!eachGuest.guestName.Contains("turtlebot"))
                                {
                                    //tIRC.SendMsg("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " to show of a pool of " + OddsDisplay.CurrentTotalShowPool);
                                }
                            }
                            eachGuest.guestCash += amountToPay;
                            totalPaidOut        += amountToPay;
                            float totalPaidIn = OddsDisplay.CurrentTotalPlacePool + OddsDisplay.CurrentTotalPot + OddsDisplay.CurrentTotalShowPool;
                            //print("Total paid out = " + totalPaidOut + " Total paid in = " + totalPaidIn);
                        }
                    }
                }
            }
        }
        if (timeRaceEnded > 1)
        {
            if (RaceStartingTimerObject.activeInHierarchy != true)
            {
                RaceStartingTimerObject.SetActive(true);
            }
            RaceStartingTimer.text = Mathf.RoundToInt((timeRaceEnded + (TimeBetweenRaces / 5)) - Time.timeSinceLevelLoad) + " Seconds";
            RaceStartingTitle.text = "Bonus Round in...";
            //Debug.Log("Time race ended " + timeRaceEnded + "  Time between races " + TimeBetweenRaces + "  current time " + Time.time);
            if (Time.timeSinceLevelLoad > timeRaceEnded + (TimeBetweenRaces / 5))
            {
                GuestManager.SaveGuestData();
                GuestManager.ClearNextRaceTurtles();
                SceneManager.LoadScene("Pachinko");
            }
        }
    }
コード例 #21
0
        public ActionResult dodaj(BetSetGetView itm1)
        {
            BetSetGetView mod = new BetSetGetView();

            if (ModelState.IsValid)
            {
                using (var db = new ProjektEntities())
                {
                    var season = db.SEASONS.OrderByDescending(m => m.Year).Select(r => r.Season_ID).First();

                    var driver = from b in db.DRIVERS
                                 join p in db.PARTICIPANTS
                                 on b.Driver_ID equals p.Driver_ID
                                 where p.Season_ID == season
                                 select new { b.Driver_Name };

                    var x = driver.ToList().Select(c => new SelectListItem
                    {
                        Text  = c.Driver_Name,
                        Value = c.Driver_Name
                    }).ToList();

                    ViewBag.KategoriaList = x;

                    var selectYear = from b in db.BETS
                                     join xa in db.RACES
                                     on b.Race_ID equals xa.Race_ID
                                     join da in db.SEASONS
                                     on xa.Season_ID equals da.Season_ID
                                     where b.User_ID == User.Identity.Name && b.ScorePos1 != null
                                     group da by da.Year into avc
                                     select avc.FirstOrDefault();



                    mod.MenuLevel1 = selectYear.ToList().Select(m => new SelectListItem
                    {
                        Value = m.Season_ID.ToString(),
                        Text  = m.Year
                    }).ToList();


                    mod.MenuLevel1.Insert(0, new SelectListItem
                    {
                        Value = "-1",
                        Text  = "Rok"
                    });

                    mod.MenuLevel2 = new List <SelectListItem>();

                    string login = User.Identity.Name;

                    mod.betRaces = new List <RacesView>();

                    var allRace = from r in db.RACES
                                  select new { r.Track, r.Date };
                    foreach (var item in allRace)
                    {
                        mod.betRaces.Add(new RacesView {
                            raceTrack = item.Track, raceDate = item.Date
                        });
                    }

                    int    raceID = 1;
                    string date   = Request.Form["date_picker"];
                    date = date.Replace("/", "-");
                    var searchRaceID = from r in db.RACES
                                       where r.Date.Contains(date)
                                       select new { r.Race_ID, };
                    foreach (var item in searchRaceID)
                    {
                        raceID = item.Race_ID;
                    }

                    BetManager betManager = new BetManager();
                    if (betManager.IsBetExists(User.Identity.Name, raceID))
                    {
                        ModelState.AddModelError("", "Nie można zrobić dwa razy zakładu na ten sam wyścig.");
                    }
                    else
                    if (itm1.betSetView.Driver_Name1 != itm1.betSetView.Driver_Name2 && itm1.betSetView.Driver_Name2 != itm1.betSetView.Driver_Name3 && itm1.betSetView.Driver_Name1 != itm1.betSetView.Driver_Name3)
                    {
                        betManager.SetBet(User.Identity.Name, raceID, itm1.betSetView.Driver_Name1, itm1.betSetView.Driver_Name2, itm1.betSetView.Driver_Name3, itm1.betSetView.Driver_Time1);
                        ViewBag.Status = "Zakład został dodany.";
                    }
                    else
                    {
                        ModelState.AddModelError("", "Dane się nie zgadzają, proszę wybrać zawodników jeszcze raz.");
                    }
                }
            }
            return(View(mod));
        }
コード例 #22
0
        public dynamic GetUserBet(string id)
        {
            BetManager    mgr      = new BetManager();
            EventsManager mgrEvent = new EventsManager();
            //var bets = mgr.GetUserBets(id);
            var bets = mgr.GetUserBets(RequestContextHelper.SessionToken);

            if (bets.Status.Equals(ResponseStatus.OK))
            {
                List <UserBetDTO> betList = new List <UserBetDTO>();

                string lastProcessedLinkedCode = null;

                foreach (var bet in bets.GetData().OrderBy(b => b.LinkedCode))
                {
                    if (string.IsNullOrWhiteSpace(bet.LinkedCode) || (bet.LinkedCode != lastProcessedLinkedCode))
                    {
                        UserBetDTO viewBet = new UserBetDTO();
                        viewBet.ID       = bet.ID;
                        viewBet.Amount   = bet.Amount;
                        viewBet.Simple   = string.IsNullOrWhiteSpace(bet.LinkedCode);
                        viewBet.Composed = !viewBet.Simple;
                        if (viewBet.Simple)
                        {
                            viewBet.OddType = bet.SportBet.Code;
                            viewBet.OddCode = bet.BetType;
                            viewBet.Price   = bet.BetPrice;

                            var      match     = mgrEvent.GetSportEvent(bet.MatchCode);
                            MatchDTO thisEvent = new MatchDTO();
                            thisEvent.ID        = match.ID;
                            thisEvent.Code      = match.Code;
                            thisEvent.Name      = match.Name;
                            thisEvent.Local     = match.Home;
                            thisEvent.Visitante = match.Away;
                            thisEvent.Date      = match.Init.ToString("dd MMM");
                            thisEvent.Time      = match.Init.ToString("hh:mm");
                            viewBet.Match       = thisEvent;
                        }
                        else
                        {
                            viewBet.Price           = 1;
                            lastProcessedLinkedCode = bet.LinkedCode;
                            viewBet.BetInfo         = new List <BetInfoItemDTO>();
                            foreach (var linkedBet in bets.GetData().Where(b => b.LinkedCode == bet.LinkedCode))
                            {
                                viewBet.Price = viewBet.Price * linkedBet.BetPrice;
                                var          match     = mgrEvent.GetSportEvent(linkedBet.MatchCode);
                                BetDetailDTO betDetail = new BetDetailDTO();
                                betDetail.OddType = linkedBet.SportBet.Code;
                                betDetail.OddCode = linkedBet.BetType;

                                MatchDTO matchDetail = new MatchDTO();
                                matchDetail.ID        = match.ID;
                                matchDetail.Code      = match.Code;
                                matchDetail.Name      = match.Name;
                                matchDetail.Local     = match.Home;
                                matchDetail.Visitante = match.Away;
                                matchDetail.Date      = match.Init.ToString("dd MMM");
                                matchDetail.Time      = match.Init.ToString("hh:mm");

                                BetInfoItemDTO betInfoItem = new BetInfoItemDTO();
                                betInfoItem.BetDetail = betDetail;
                                betInfoItem.Match     = matchDetail;

                                viewBet.BetInfo.Add(betInfoItem);
                            }
                        }
                        betList.Add(viewBet);
                    }
                }

                return(this.GetView(betList));
            }

            return(this.GetView("OperationFails"));
        }
コード例 #23
0
 private void Awake()
 {
     _instance    = this;
     MyCurrentBet = 0;
 }
コード例 #24
0
 private void Awake()
 {
     Instance = this;
 }
コード例 #25
0
 public RequestLogController()
 {
     _IBetManager         = new BetManager();
     _HttpResponseMessage = new HttpResponseMessage();
 }
コード例 #26
0
 private void StartBetCalculationTask()
 {
     Debug.Log("Boton presionado");
     GameManagerFactory.gameManager.ReturnNumber().AwaitInCoroutine(number => BetManager.CheckNumberOnList(number));
 }