Beispiel #1
0
    private void ResetMatch()
    {
        if (isServer && gameState == GameStates.POST_LOBBY)
        {
            gameState = GameStates.PRE_LOBBY;
            RpcTransmitGameState(gameState);
            winner = Winners.UNDETERMINED;

            // Disable Post-Lobby UI
            menuController.WinScreenHide();
            // Enable Pre-Lobby UI
            menuController.LobbyActive(true);

            RpcResetMatch();

            for (int i = 0; i < 32; i++)
            {
                if (activePlayers[i] && playerIsInMatch[i])
                {
                    players[i].GetComponent <ClientMaster>().TriggerResetMatch();
                }
            }

            if (players[localPlayer].GetComponent <ClientMaster>().GetIcebergMaster())
            {
                players[localPlayer].GetComponent <ClientMaster>().GetIcebergMaster().GetComponent <IcebergMaster>().ResetMatch();
            }
        }
    }
Beispiel #2
0
 public virtual object ToStats()
 {
     return(new {
         isEnded = IsEnded,
         winnerNames = Winners.Select(p => p.Name)
     });
 }
Beispiel #3
0
        public void SelectWinners_ListOfTravelers_ListOfWinners()
        {
            Traveler traveler1 = new Traveler();
            Traveler traveler2 = new Traveler();
            Traveler traveler3 = new Traveler();

            traveler1.AddScore(40);
            traveler2.AddScore(20);
            traveler3.AddScore(40);

            List <Traveler> travelers = new List <Traveler>();

            travelers.Add(traveler1);
            travelers.Add(traveler2);
            travelers.Add(traveler3);

            Winners winners = new Winners(travelers);

            List <Traveler> correctResult = new List <Traveler>();

            correctResult.Add(traveler1);
            correctResult.Add(traveler3);

            Assert.AreEqual(winners.ListOfWinners, correctResult);
        }
Beispiel #4
0
        // Method to determine winner of Round.
        // Compares Weapon Types to determine winner.
        // Uses the CanBeat List fields of the Weapon Type to determine if opponent has a weapon that you can beat.
        private string BattleOutcome()
        {
            WeaponsUsed.Add(PlayerOne.CurrentWeapon.WeaponName);
            WeaponsUsed.Add(PlayerTwo.CurrentWeapon.WeaponName);

            var p1Weapon = PlayerOne.CurrentWeapon.GetType();
            var p2Weapon = PlayerTwo.CurrentWeapon.GetType();

            var message = String.Format("\n{0} chose {1}, {2} chose {3}. ",
                                        PlayerOne.Name,
                                        PlayerOne.CurrentWeapon.WeaponName,
                                        PlayerTwo.Name,
                                        PlayerTwo.CurrentWeapon.WeaponName);

            // Determines winner and adds names to Winners List for sorting after the battle
            // Both names are added if a draw.  Only winners name is added for a win.
            if (p1Weapon == p2Weapon)
            {
                Winners.Add(PlayerOne.Name);
                Winners.Add(PlayerTwo.Name);
                return(message + "It's A Draw");
            }
            else if (PlayerOne.CurrentWeapon.CanBeat.Contains(p2Weapon))
            {
                Winners.Add(PlayerOne.Name);
                return(message + PlayerOne.Name + " is the WINNER");
            }
            else
            {
                Winners.Add(PlayerTwo.Name);
                return(message + PlayerTwo.Name + " is the WINNER");
            }
        }
Beispiel #5
0
        public void AddFighters(bool firstRound)
        {
            if (firstRound)
            {
                m_Participants = Contestants.Count;
                Contestants    = new List <Mobile>(RandomizeGenericList(Contestants)); //Randomize
            }

            if (Contestants.Count > 1)
            {
                if (!firstRound && Fighting.Count <= 0)
                {
                    for (int i = 0; i < Winners.Count; ++i)
                    {
                        Winners[i].MoveToWorld(JoinLocation, JoinMap);
                    }

                    TournamentCore.SendMessage(Contestants, "Next round will start in 60 seconds!");
                    Contestants = new List <Mobile>(RandomizeGenericList(Contestants)); //Randomize
                    Winners.Clear();
                    Timer.DelayCall(TimeSpan.FromSeconds(60), new TimerCallback(SpawnContestants));
                }
                else
                {
                    SpawnContestants();
                }
            }
            else
            {
                EndTournament(true);
            }
        }
Beispiel #6
0
        private void CalcularGanador(DA.Motor motor)
        {
            if (Querys.Count() == 0)
            {
                return;
            }

            long mayor = 0;

            DA.Winner mayorQuery = new DA.Winner();
            mayorQuery.Motor = motor;
            long total = 0;
            List <DA.Resultado> resxquery = new List <DA.Resultado>();

            foreach (DA.Query q in Querys)
            {
                resxquery = q.Resultados;
                foreach (DA.Resultado r in resxquery)
                {
                    if (motor.Nombre == r.MotorBusqueda.Nombre)
                    {
                        total = r.Total;
                    }
                }
                if (total > mayor)
                {
                    mayor            = total;
                    mayorQuery.Query = q;
                }
            }

            Winners.Add(mayorQuery);
        }
Beispiel #7
0
        public void ResetsFieldsWithThirdPlayer()
        {
            _state.Invoke(new BidMade
            {
                Id  = TestTableId,
                Bid = new BidInfo
                {
                    UserId       = _state.Players[2].UserId,
                    Position     = _state.Players[2].Position,
                    Bid          = 60,
                    Amount       = 60,
                    NewCashValue = 900,
                    BidType      = BidTypeEnum.Raise,
                }
            });

            _state.Invoke(new GameFinished
            {
                Id      = TestTableId,
                GameId  = "game_2",
                Winners = Winners.Me1(50)
            });

            Assert.IsNull(_state.GameId);
            Assert.IsNull(_state.CurrentBidding);
            Assert.AreEqual(0, _state.MaxBid);
        }
Beispiel #8
0
 public void FishCaught(PlayerID id)
 {
     fishCaught[((int)id) - 1]++;
     if (fishCaught[((int)id) - 1] >= targetFish)
     {
         finished = true;
         Destroy(spawnTimer);
         Fish[] allFish = FindObjectsOfType <Fish>();
         for (int i = 0; i < allFish.Length; i++)
         {
             Destroy(allFish[i].transform.root.gameObject);
         }
         Winners.Add(id);
         if (EndGame != null)
         {
             EndGame();
         }
         for (int i = 0; i < inGameBaskets.Count; i++)
         {
             GameManager.instance.AllPlayers.Find(x => x.Character.Equals(inGameBaskets[i].Character)).ThrowObject();
             inGameBaskets[i].transform.parent = null;
             Destroy(inGameBaskets[i].gameObject);
         }
     }
 }
Beispiel #9
0
        private void CheckAloneFighter()
        {
            for (int i = 0; i < m_Areas.Count; ++i)
            {
                IPooledEnumerable eable   = JoinMap.GetMobilesInBounds(m_Areas[i]);
                List <Mobile>     players = new List <Mobile>();

                foreach (Mobile mob in eable)
                {
                    if (Contestants.Contains(mob))
                    {
                        players.Add(mob);
                    }
                }

                eable.Free();

                if (players.Count == 1) //Alone
                {
                    Mobile m = players[0];
                    m.MoveToWorld(WinLocation, WinMap);
                    m.PublicOverheadMessage(MessageType.Regular, 38, true, "Skipping to next round...");
                    m.Blessed = true;
                    Fighting.Remove(m);
                    Winners.Add(m);
                    UpdateScores(null, m);
                    AddFighters(false);
                }
            }
        }
Beispiel #10
0
 internal bool AddWinners(int clubID, string year, int wonMatches, int lostMatches, int goalsScored, int goalsLost)
 {
     try
     {
         using (dbEntities1 context = new dbEntities1())
         {
             Winners winners = new Winners
             {
                 clubID      = clubID,
                 year        = year,
                 wonMatches  = wonMatches,
                 lostMatches = lostMatches,
                 goalsScored = goalsScored,
                 goalsLost   = goalsLost
             };
             context.Winners.Add(winners);
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #11
0
        public short CalculateEarnedHonor(CharacterFighter character)
        {
            if (Draw)
            {
                return(0);
            }

            if (character.OpposedTeam.AlignmentSide == AlignmentSideEnum.ALIGNMENT_NEUTRAL)
            {
                return(0);
            }

            var winnersLevel   = (double)Winners.GetAllFightersWithLeavers <CharacterFighter>().Sum(entry => entry.Level);
            var losersLevel    = (double)Losers.GetAllFightersWithLeavers <CharacterFighter>().Sum(entry => entry.Level);
            var maxLosersLevel = winnersLevel + 15;

            var delta = Math.Floor(Math.Sqrt(character.Level) * 10 * ((losersLevel > maxLosersLevel ? maxLosersLevel : losersLevel) / winnersLevel));

            if (Losers == character.Team)
            {
                delta = -delta;
            }

            return((short)delta);
        }
        public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        {
            if (AlexaUtils.IsRequestInvalid(session))
            {
                return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
            }

            var intent     = intentRequest.Intent;
            var intentName = intent?.Name;

            switch (intentName.ToUpper())
            {
            case "BALANCE":
                return(await GetBalance.GetResults(session));

            case "TRANSACTIONS":
                return(await GetTransactions.GetResults(session, intentRequest.Intent.Slots["date"].Value));

            case "PAYMENT":
                return(await MakePayment.GetResults(session, decimal.Parse(intentRequest.Intent.Slots["amount"].Value), intentRequest.Intent.Slots["account"].Value));

            case "WINNERS":
                return(await Winners.GetResults());

            case "MORTGAGE":
                return(await Mortgage.GetResults(session));

            case "SAVINGS":
                return(await Insights.GetResults(session));

            default:
                return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session)));
            }
        }
Beispiel #13
0
        public Victory(IList <IPlayer> winners, Notification popup)
        {
            Winners = winners.ToImmutableList();
            Popup   = popup;
            var winnerNames = string.Join(", ", Winners.Select(winner => winner.Name));

            WinnersList = Notification.Popup(DayKey.Congratulations, winnerNames);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="el"></param>
 public void SetWinner(XElement el)
 {
     Winners.Clear();
     foreach (var elc in el.Descendants("Candidat"))
     {
         Winners.Add(new CandidatViewModel(elc));
     }
     RaisePropertyChanged("Tooltip");
 }
Beispiel #15
0
 public virtual object ToClient()
 {
     return(new {
         table = new {
             activePlayerName = Table.ActivePlayer?.Name,
         },
         isEnded = IsEnded,
         winnerNames = Winners.Select(p => p.Name)
     });
 }
Beispiel #16
0
 protected override void CreateSummary()
 {
     if (Winners == null || !Winners.Any() || Losers == null || !Losers.Any())
     {
         Summary = "Game Ended.";
     }
     else
     {
         Summary = String.Format("Game ended: {0} wins against {1}.", Winners.First(), Losers.First());
     }
 }
        public void ResetsFields()
        {
            _state.Invoke(new GameFinished
            {
                Id      = TestTableId,
                Winners = Winners.Me1(50)
            });

            Assert.IsNull(_state.GameId);
            Assert.IsNull(_state.CurrentBidding);
            Assert.AreEqual(0, _state.MaxBid);
        }
        public void GivesBankToWinner()
        {
            var cash = _state.JoinedPlayers["me1"].Cash;

            _state.Invoke(new GameFinished
            {
                Id      = TestTableId,
                Winners = Winners.Me1(50)
            });

            Assert.AreEqual(cash + 50, _state.JoinedPlayers["me1"].Cash);
        }
 private void CheckWinners(TwitchChat.User user, string argument)
 {
     if (user.Badges.HasFlag(TwitchChat.ChatBadges.Broadcaster) || (Settings.AllowMods && user.Badges.HasFlag(TwitchChat.ChatBadges.Moderator)))
     {
         List <KeyValuePair <string, Tuple <int, string> > > list;
         list = Winners.OrderByDescending(kvp => kvp.Value.Item1).ToList();
         SendMessage("Top 5 Winners!");
         for (int i = 0; i < 5; i++)
         {
             SendMessage(list[i].Key + ": " + list[i].Value.Item1 + " - " + list[i].Value.Item2);
         }
     }
 }
Beispiel #20
0
 public object ToClient()
 {
     return(new {
         gameName = GameName,
         instanceGameName = InstanceGameName,
         token = Token,
         status = Status.ToString(),
         playerNames = Players.Select(p => p.Name),
         game = Game?.ToClient(),
         stats = GetStats(),
         winnerNames = Winners.Select(p => p.Name)
     });
 }
        public override string ToString()
        {
            int i  = 0;
            var sb = new StringBuilder();

            sb.AppendLine("Round Results:");
            Winners.ForEach(winner =>
            {
                i++;
                sb.AppendLine("Game " + i + " - winner: " + winner.ToString());
            });
            return(sb.ToString());
        }
        private void ProcessResult(SpinResult result)
        {
            foreach (var bet in Bets)
            {
                bet.WinAmount = 0;
                if (bet.Color.HasValue)
                {
                    if (bet.Color == result.RouletteNumber.Color)
                    {
                        bet.WinAmount += bet.BetAmount * 2;
                    }
                }

                if (bet.OutsideDozens.HasValue)
                {
                    if (bet.OutsideDozens == result.RouletteNumber.IsInOutsizeDozen)
                    {
                        bet.WinAmount += bet.BetAmount * 3;
                    }
                }

                foreach (var r in bet.RouletteNumbers)
                {
                    if (r.Number == "0" || r.Number == "00")
                    {
                        bet.WinAmount += bet.BetAmount * 17;
                    }
                    else
                    if (r.Number == result.RouletteNumber.Number)
                    {
                        if (bet.RouletteNumbers.Count == 4)
                        {
                            bet.WinAmount += bet.BetAmount * 8;
                        }
                        if (bet.RouletteNumbers.Count == 1)
                        {
                            bet.WinAmount += bet.BetAmount * 35;
                        }
                        if (bet.RouletteNumbers.Count == 2)
                        {
                            bet.WinAmount += bet.BetAmount * 16;
                        }
                    }
                }

                if (bet.WinAmount > 0)
                {
                    Winners.Add(bet);
                }
            }
        }
Beispiel #23
0
        private void WinnerFound(object sender, Aiva.Models.Giveaway.Users e)
        {
            Winners.Add(e);
            JoinedUsers.Remove(e);

            if (!string.IsNullOrEmpty(WinnersSeperated))
            {
                WinnersSeperated += $" | {e.Username}";
            }
            else
            {
                WinnersSeperated += e.Username;
            }
        }
Beispiel #24
0
        private void SpawnContestants()
        {
            for (int i = 0; i < Contestants.Count; ++i)
            {
                if (Fighting.Contains(Contestants[i]) || Winners.Contains(Contestants[i]))
                {
                    continue;
                }

                SpawnMobile(Contestants[i]);
            }

            Timer.DelayCall(TimeSpan.FromSeconds(3), new TimerCallback(CheckAloneFighter));
        }
Beispiel #25
0
        private void GenerateStageDecoration()
        {
            if (Winners != null)
            {
                Winners.Clear();
            }

            if (PointTable != null)
            {
                PointTable.Clear();
            }

            if (RewardBag != null)
            {
                RewardBag.Delete();
                RewardBag = null;
            }

            var map      = Siege.SiegeShard ? Map.Felucca : Map.Trammel;
            int treeType = 1;

            switch (CurrentCity)
            {
            case City.Trinsic: treeType = 2; break;

            case City.Britain:
            case City.NewMagincia: treeType = 3; break;

            case City.Minoc: treeType = 4; break;
            }

            if (TownTree != null)
            {
                TownTree.Delete();
            }

            TownTree = new TownTree(treeType);
            TownTree.MoveToWorld(_CityLocations[Stage], map);

            if (Elf == null)
            {
                Elf = new FestivalElf();
            }

            var p = new Point3D(TownTree.X + Utility.RandomMinMax(-1, 1), TownTree.Y + Utility.RandomMinMax(-1, 1), TownTree.Z);

            Elf.MoveToWorld(p, map);
            Elf.Home      = p;
            Elf.RangeHome = 5;
        }
        public SpinResult Spin()
        {
            Winners.Clear();
            var rouletteNumber = RandomizeResult();
            var spinResult     = new SpinResult(rouletteNumber);

            spinResult.RouletteNumber = rouletteNumber;
            LastSpinResult            = spinResult;

            ProcessResult(spinResult);

            SpinHistory.Add(spinResult);

            return(spinResult);
        }
        public override void Run()
        {
            int       numDead  = 0;
            Fireplace survivor = null;

            foreach (Fireplace f in inGameFirePlaces)
            {
                if (f.Dead)
                {
                    numDead++;
                }
                else
                {
                    survivor = f;
                }
            }

            if (numDead >= GameManager.instance.AllPlayers.Count - 1)
            {
                winnerFound -= Data.GameManager.instance.DeltaTime;
                if (winnerFound < 0)
                {
                    for (int i = 0; i < GameManager.instance.AllPlayers.Count; i++)
                    {
                        GameManager.instance.AllPlayers[i].ThrowObject();
                    }

                    for (int i = 0; i < inGameLogs.Count; i++)
                    {
                        Destroy(inGameLogs[i].gameObject);
                    }
                    for (int i = 0; i < inGameFirePlaces.Count; i++)
                    {
                        if (inGameFirePlaces[i] != null)
                        {
                            Destroy(inGameFirePlaces[i].gameObject);
                        }
                    }
                    if (survivor)
                    {
                        Winners.Add(GameManager.instance.CharacterToPlayer[survivor.linkedCharacter]);
                    }
                    finished    = true;
                    winnerFound = 2f;
                }
            }
        }
Beispiel #28
0
        public static void MostWinningCoach(List <SuperBowlWinner> SuperBowlWinners, StreamWriter Writer)
        {
            // using linq to get the Coach who won the most games.
            var MostWins = (
                from i in SuperBowlWinners
                group i by i.CoachWinner into Winners
                where Winners.Count() > 2
                orderby Winners.Count() descending
                select Winners).Take(1);

            foreach (var e in MostWins)
            {
                Writer.WriteLine("The Coach who Won the most super bowls is {0}.", e.Key);

                Writer.WriteLine();
            }
        }
Beispiel #29
0
        public override void Stop()
        {
            Program.MainForm.LogDebug("Stopping." + Environment.StackTrace);
            End?.Stop();
            End = null;

            List <Character> Winners;
            List <Character> Losers;

            if (SnowballMap.GetWinner() == SnowballEventState.MAPLE_WIN)
            {
                Winners = MapleTeam.ToList();
                Losers  = StoryTeam.ToList();
            }
            else
            {
                Winners = StoryTeam.ToList();
                Losers  = MapleTeam.ToList();
            }

            _log.Info("Total players: " + (Winners.Count + Losers.Count));
            _log.Info("Winners: " + string.Join(", ", Winners.Select(x => x.Name)));
            _log.Info("Losers: " + string.Join(", ", Losers.Select(x => x.Name)));

            Winners.ForEach(c =>
            {
                MapPacket.MapEffect(c, 4, "Coconut/Victory", true);
                MapPacket.MapEffect(c, 3, "event/coconut/victory", true);
            });
            Losers.ForEach(c =>
            {
                MapPacket.MapEffect(c, 4, "Coconut/Failed", true);
                MapPacket.MapEffect(c, 3, "event/coconut/lose", true);
            });

            RepeatingAction.Start("snowball warper", e =>
            {
                Winners.ForEach(c => c.ChangeMap(WinMapId));
                Losers.ForEach(c => c.ChangeMap(LoseMapId));
                SnowballMap.TimerEndTime = MasterThread.CurrentTime;
                MapleTeam.Clear();
                StoryTeam.Clear();
                SnowballMap.Reset();
                base.Stop();
            }, 10 * 1000, 0);
        }
Beispiel #30
0
        public GameChangeResult End(GameAction endAction)
        {
            IsEnded   = true;
            EndAction = endAction;

            // transition lock status
            if (HasLock)
            {
                PlayerCups.First(pc => pc.LockStatus == LockStatus.Locking).LockStatus = LockStatus.Unavailable;
            }

            // highlight matching dices
            foreach (var matchingDice in PlayerCups.SelectMany(pc => pc.Dices).Where(d => d.Value == Dice.Value || d.Value == 1))
            {
                matchingDice.IsHighlighted = true;
            }

            // check if table ends
            var playersWithDices = PlayerCups.Where(pc => pc.DicesQuantity > 0).Select(pc => pc.Player);

            if (playersWithDices.Count() == 1)
            {
                Table.End(playersWithDices);
            }

            var gameEndResult = new GameChangeResult(new {
                actualQuantity = ActualQuantity,
                playerCups     = PlayerCups.Select(pc => pc.ToClient()),
                table          = new {
                    status           = Table.Status.ToString(),
                    activePlayerName = Table.ActivePlayer?.Name,
                    stats            = Table.GetStats(),
                    winnerNames      = Table.Winners.Select(p => p.Name)
                },
                isEnded        = IsEnded,
                winnerNames    = Winners.Select(p => p.Name),
                endActionName  = EndAction?.Name,
                diceLoserName  = DiceLoser?.Name,
                diceWinnerName = DiceWinner?.Name
            });

            return(gameEndResult);
        }