Esempio n. 1
0
        public async Task ChooseCard()
        {
            var newUser = new User {
                Name = "CommonUser"
            };
            await db.Users.AddAsync(newUser);

            var newUser2 = new User {
                Name = "CommonUser2"
            };
            await db.Users.AddAsync(newUser);

            var newRoom = new Room {
                Name = "TestRoom", OwnerID = 1
            };
            await db.Rooms.AddAsync(newRoom);

            var newRound = new Round {
                Room = newRoom, Subject = "Some text", Timer = 2
            };
            await db.Rounds.AddAsync(newRound);

            await db.SaveChangesAsync();

            var cards = new Card[]
            {
                new Card {
                    Value = 0, Description = "zero"
                }, new Card {
                    Value = 1, Description = "one"
                }, new Card {
                    Value = 2, Description = "two"
                }, new Card {
                    Value = 4, Description = "four"
                }
            };
            var newDeck = new Deck {
                Name = "testDeck"
            };

            foreach (Card card in cards)
            {
                db.Cards.Add(card);
                newDeck.Cards.Add(card);
            }
            var newRoundCard = new RoundResults {
                Round = newRound, UserID = 1, CardValue = 3
            };
            var newRoundCard2 = new RoundResults {
                Round = newRound, UserID = 2, CardValue = 1
            };
            await roundCard.UserChoose(newRoundCard);

            await roundCard.UserChoose(newRoundCard2);

            var length = newRound.Cards.Count;

            Assert.That(2, Is.EqualTo(length));
            Assert.That(2, Is.EqualTo(newRound.Result));
        }
Esempio n. 2
0
    public void Show(RoundResults results)
    {
        pointsEarnedText.text     = "Points earned: " + results.pointsEarned;
        distanceTraveledText.text = "Distance traveled: " + results.distance;
        causeOfDeathText.text     = "Cause of death: " + results.causeOfDeath;
        UpdateUpgradeButton();

        gameObject.SetActive(true);
    }
Esempio n. 3
0
        // Token: 0x06000180 RID: 384 RVA: 0x0000A334 File Offset: 0x00008534
        public bool Update(GameProcess gameProcess)
        {
            this.AddressBase    = this.ReadAddressBase(gameProcess);
            this.GameRulesProxy = this.ReadGameRulesProxy(gameProcess);
            this.GlobalVars     = this.ReadGlobalVars(gameProcess);
            this.isFreezeTime   = this.checkFreezetime(gameProcess);
            this.isWarmup       = this.checkWarmup(gameProcess);
            this.IsMatchmaking  = this.checkGameType(gameProcess);
            this.isBombPlanted  = this.checkBombPlanted(gameProcess);
            this.RoundNumber    = this.GetCurrentMatchRound(gameProcess);
            this.RoundTime      = this.GetCurrentRoundTime(gameProcess);
            this.RoundResults   = this.GetRoundResults(gameProcess);
            int num  = 0;
            int num2 = 0;

            FieldInfo[] fields = typeof(RoundResults).GetFields();
            for (int i = 0; i < fields.Length; i++)
            {
                int num3 = (int)fields[i].GetValue(this.RoundResults);
                if (num3 != 0)
                {
                    if (num3 > 4)
                    {
                        num++;
                    }
                    else
                    {
                        num2++;
                    }
                }
            }
            this.T_Score  = num;
            this.CT_Score = num2;
            if (this.T_Score == 15 || this.CT_Score == 15)
            {
                this.isMatchPoint = true;
            }
            else
            {
                this.isMatchPoint = false;
            }
            if (this.RoundNumber != this.LastFreezeTimeRound && this.isFreezeTime)
            {
                this.LastFreezeTimeRound = this.RoundNumber;
                Task.Run(delegate()
                {
                    EventHandler onMatchNewRound = this.OnMatchNewRound;
                    if (onMatchNewRound == null)
                    {
                        return;
                    }
                    onMatchNewRound(this, null);
                });
            }
            return(true);
        }
        public object GenerateBracketObject()
        {
            List <dynamic> Rounds       = new List <dynamic>();
            List <dynamic> PlayedGames  = new List <dynamic>();
            List <dynamic> RoundResults = new List <dynamic>();


            int currentRound = 0;

            foreach (var item in _gameFixture)
            {
                if (currentRound != item.RoundNumber || currentRound == 0) // new Round
                {
                    /*PlayedGames = new List<dynamic>();*/
                    RoundResults = new List <dynamic>();
                }

                List <dynamic> Game = new List <dynamic>();
                if (item.HomeTeam != null)
                {
                    Game.Add(item.HomeTeam.Tag);
                }

                if (item.AwayTeam != null)
                {
                    Game.Add(item.AwayTeam?.Tag);
                }

                if ((item.HomeTeam == null && item.AwayTeam != null) || (item.HomeTeam != null && item.AwayTeam == null))
                {
                    Game.Add(null);
                }

                if ((item.HomeTeam != null || item.AwayTeam != null) && item.RoundNumber == 1)
                {
                    PlayedGames.Add(Game);
                }


                List <dynamic> Scores = new List <dynamic>();
                Scores.Add(item != null && item.IsFinished  ?  item.HomeTeamScore : null);
                Scores.Add(item != null && item.IsFinished  ?  item.AwayTeamScore : null);
                RoundResults.Add(Scores);

                if (currentRound != item.RoundNumber)
                {
                    Rounds.Add(RoundResults);
                    currentRound = item.RoundNumber;
                }
            }


            var result = new { teams = PlayedGames.ToArray(), results = Rounds.ToArray() };

            return(result);
        }
Esempio n. 5
0
    /// <summary>
    /// Invoked when a round ends during the Action phase.
    /// Creates the Round data and switches to the Strategy portion of the game.
    /// </summary>
    /// <param name="rr">The round results from the Action phase</param>
    private void OnRoundEnded(RoundResults rr)
    {
        // TODO: Finish implementation when round results are expanded
        Round = new RoundData(rr.WinningTeam);

        // Begin switch to Strategy portion


        SwitchToStrategy();
    }
Esempio n. 6
0
        public RoundResults GetRoundResults(GameProcess gameProcess)
        {
            if (GameRulesProxy != IntPtr.Zero)
            {
                RoundResults m_iMatchStats_RoundResults = gameProcess.Process.Read <RoundResults>(GameRulesProxy + 2480);

                return(m_iMatchStats_RoundResults);
            }

            return(default);
Esempio n. 7
0
        public void RecordRoundsResult()
        {
            string        round   = string.Format("Results after round {0} ballot count", Round.ToWords());
            List <string> results = new List <string>();

            CompetingKingdom.ForEach(Kingdom =>
            {
                results.Add(string.Format("Allies for {0} : {1}", Kingdom.Name, Kingdom.GetAlliesCount()));
            });
            RoundResults.Add(round, results);
        }
Esempio n. 8
0
    private void ResetMatch()
    {
        CurrentRound = -1;

        RoundResults.Clear();
        for (int i = 0; i < TotalRound; i++)
        {
            RoundResults.Add(new RoundResultData());
        }

        CurrentMatchState = MatchState.Null;
    }
Esempio n. 9
0
    public void ProcessResults(string causeOfEnd)
    {
        //Turn players points into cash

        roundInProgress = false;

        AddCash(roundPoints);

        RoundResults roundResults = new RoundResults();

        roundResults.pointsEarned = roundPoints;
        roundResults.distance     = currentPlane.transform.position.z - startPoint.transform.position.z;
        roundResults.causeOfDeath = causeOfEnd;
        playerFinishedRoundEvent.Invoke(roundResults);
    }
        /// <summary>
        /// Выбор карты.
        /// </summary>>
        /// <param name="card">инстанс класса карты.</param>
        /// <returns>ничего не возвращает.</returns>
        public async Task UserChoose(RoundResults card)
        {
            if (await this.RoundCardExist(card.UserID, card.Round.ID))
            {
                var currentCard = await this.db.RoundCards.FindAsync(card.ID);

                currentCard.CardValue = card.CardValue;
            }
            else
            {
                this.db.RoundCards.Add(card);
            }

            await this.db.SaveChangesAsync();
        }
Esempio n. 11
0
        //private Random _rnd = new Random();
        //public string drawNumbers(int numLimit, int numAmount)
        //{

        //    return string.Join(",",
        //        Enumerable
        //            .Range(1, numLimit)
        //            .OrderBy(x => _rnd.Next())
        //            .Take(numAmount));
        //}
        public RoundViewModel ActivateRound()
        {
            var round = new RoundViewModel()
            {
                WinningCombination = _helper.GenerateNumbers(37, 7)
            };

            var createdRound = new RoundResults()
            {
                WinningCombination = round.WinningCombination
            };

            _roundRepository.CreateRound(createdRound);

            return(round);
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            //RPSChoice choice = RPSChoice.Rock;

            IChoiceGetter p1 = new HumanPlayer(); //could use var, but having the left side be an interface makes things more explicit
            IChoiceGetter p2 = new RandomPlayer();

            var engine = new GameEngine(p1, p2);

            int p1Wins     = 0;
            int p2Wins     = 0;
            int draws      = 0;
            int gameNumber = 1;

            for (int i = 0; i < 100; i++)
            {
                RoundResults result = engine.PlayerRound();

                Console.WriteLine($"Player 1 played {result.P1Choice} and Player 2 played {result.P2Choice}. Game number: {gameNumber}");

                if (result.Result < 0)
                {
                    p1Wins++;
                    Console.WriteLine("Player 1 wins!");
                }
                else if (result.Result > 0)
                {
                    p2Wins++;
                    Console.WriteLine("Player 2 wins!");
                }
                else
                {
                    draws++;
                    Console.WriteLine("Draw!");
                }

                gameNumber++;
            }

            Console.WriteLine("After 100 games: ");
            Console.WriteLine("Player 1 wins: " + p1Wins);
            Console.WriteLine("Player 2 wins: " + p2Wins);
            Console.WriteLine("Draws: " + draws);

            Console.ReadLine();
        }
        private RoundResults CalculateCardInteractionsOneVsOne(PlayerSide attackerSide, int cardAttackerNumber, int cardDefenderNumber, int attackerUsedPillz, bool attackerUsedFury)
        {
            PlayerStatus attacker     = (attackerSide == PlayerSide.Left) ? Combat.LeftPlayerStatus : Combat.RightPlayerStatus;
            PlayerStatus defender     = (attackerSide == PlayerSide.Left) ? Combat.RightPlayerStatus : Combat.LeftPlayerStatus;
            RoundResults roundResults = null;

            for (int usedPillzByDefender = 0; usedPillzByDefender <= defender.Pillz; usedPillzByDefender++)
            {
                roundResults = (attackerSide == PlayerSide.Left)
                    ? Combat.PreviewRound(cardAttackerNumber, cardDefenderNumber, attackerUsedFury, false, attackerUsedPillz, usedPillzByDefender)
                    : Combat.PreviewRound(cardDefenderNumber, cardAttackerNumber, false, attackerUsedFury, usedPillzByDefender, attackerUsedPillz);

                if (roundResults.RoundWinner != attackerSide)
                {
                    break;
                }
            }

            return(roundResults);
        }
    public void SetBonusRounds(int IdEnemy)
    {
        if (IdEnemy >= 10 && IdEnemy <= 12)
        {
            TableT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, TableT.rect.height + 100f);

            BonusRound4.SetActive(true);
            BonusRound5.SetActive(true);

            for (int i = 3; i < listResultsUI.Count; i++)
            {
                RoundResults RR = listResultsUI[i];
                for (int j = 0; j < RR.ResultJudges.Count; j++)
                {
                    RR.ResultJudges[j].gameObject.SetActive(true);
                }
            }

            NumersOfRounds = 4;
        }
    }
Esempio n. 15
0
 public void CreateRound(RoundResults entity)
 {
     _dbContext.RoundResults.Add(entity);
     _dbContext.SaveChanges();
 }
 private void SetInteractionResults(RoundResults results)
 {
     ResetInteractionResults();
     InteractionResults.Add(results);
 }
Esempio n. 17
0
 public static void CheckResults()
 {
     RoundResultsPage     = new RoundResults();
     App.Current.MainPage = RoundResultsPage;
     App.Current.Game.OnResultsPage(RoundResultsPage);
 }
Esempio n. 18
0
        /// <summary>
        /// Метод заполнения бд значениями.
        /// </summary>
        /// <param name="context">контекст бд.</param>
        public static void Initialize(ModelContext context)
        {
            context.Database.EnsureCreated();
            if (context.Decks.Any())
            {
                return;
            }

            var users = new User[]
            {
                new User {
                    Name = "Alex"
                }, new User {
                    Name = "Dima"
                }, new User {
                    Name = "Andrey"
                }, new User {
                    Name = "Ilia"
                }
            };

            foreach (User user in users)
            {
                context.Users.Add(user);
            }

            context.SaveChanges();

            var rooms = new Room[]
            {
                new Room {
                    Name = "Room1", OwnerID = 1
                }, new Room {
                    Name = "Room2", OwnerID = 2
                }, new Room {
                    Name = "Room3", OwnerID = 3
                }, new Room {
                    Name = "Room4", OwnerID = 4
                }
            };

            foreach (Room room in rooms)
            {
                context.Rooms.Add(room);
            }

            context.SaveChanges();
            var cards = new Card[]
            {
                new Card {
                    Value = 0, Description = "zero"
                }, new Card {
                    Value = 1, Description = "one"
                }, new Card {
                    Value = 2, Description = "two"
                }, new Card {
                    Value = 4, Description = "four"
                }
            };
            var deck = new Deck {
                Name = "1st deck", Description = "this is 1st deck"
            };

            foreach (Card card in cards)
            {
                context.Cards.Add(card);
                deck.Cards.Add(card);
            }

            context.Decks.Add(deck);
            context.SaveChanges();
            var round = new Round {
                Subject = "test round 2", RoomID = 2, DeckID = 1
            };

            context.Rounds.Add(round);
            context.SaveChanges();

            var roundCards = new RoundResults[]
            {
                new RoundResults {
                    CardValue = cards[1].Value, UserID = 1, RoundID = 1
                }, new RoundResults {
                    CardValue = cards[2].Value, UserID = 2, RoundID = 1
                }
            };

            foreach (RoundResults card  in roundCards)
            {
                context.RoundCards.Add(card);
            }
            context.SaveChanges();
        }