static void SlaveStartSpring(AutoHost ah, List <UserBattleStatus> team)
        {
            var serv = GlobalConst.GetSpringieService();

            var context = ah.tas.MyBattle.GetContext();

            context.Players = team.Select(x => new PlayerTeam()
            {
                AllyID = x.AllyNumber, Name = x.Name, LobbyID = x.LobbyUser.AccountID, TeamID = x.TeamNumber, IsSpectator = false
            }).ToList();

            var balance = serv.BalanceTeams(context, true, null, null);

            ah.ApplyBalanceResults(balance);
            context.Players = balance.Players;
            context.Bots    = balance.Bots;

            ah.SayBattle("please wait, game is about to start");
            ah.StopVote();
            ah.slaveContextOverride = context;
            ah.tas.StartGame();
        }
Esempio n. 2
0
        protected bool CheckEnd(out int winVote)
        {
            int[] sums = new int[options];
            foreach (int val in votes)
            {
                if (val > 0 && val <= options)
                {
                    sums[val - 1]++;
                }
            }

            int votesLeft = votes.FindAll(delegate(int t) { return(t == 0); }).Count;
            bool canDecide = false;
            int  winLimit  = (int)(initialUserCount * ratio);

            int max      = 0;
            int maxCount = 0;

            for (int i = 0; i < sums.Length; ++i)
            {
                if (sums[i] > max)
                {
                    max = sums[i];
                }
            }
            for (int i = 0; i < sums.Length; ++i)
            {
                if (sums[i] == max)
                {
                    maxCount++;
                }
            }

            for (int i = 0; i < sums.Length; ++i)
            {
                string text = string.Format("option {0} has {1} of {2} votes", i + 1, sums[i], winLimit + 1);

                if (!hackEndTimeVote && i + 1 == lastVote)
                {
                    ah.SayBattle(text);
                }

                if (sums[i] > winLimit)
                {
                    winVote = i + 1;
                    return(true);
                }
                if (hackEndTimeVote && sums[i] >= 2 && sums[i] == max && maxCount == 1)
                {
                    winVote = i + 1;
                    return(true);
                }

                if (sums[i] + votesLeft > winLimit)
                {
                    canDecide = true;
                }
            }
            winVote = 0;
            if (!canDecide)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
 public virtual void TimeEnd()
 {
     ah.SayBattle("not enough votes");
 }
        static void SlaveStartSpring(AutoHost ah, List<UserBattleStatus> team)
        {
            var serv = GlobalConst.GetSpringieService();

            var context = ah.tas.MyBattle.GetContext();
            context.Players = team.Select(x => new PlayerTeam() { AllyID = x.AllyNumber, Name = x.Name, LobbyID = x.LobbyUser.AccountID, TeamID = x.TeamNumber, IsSpectator = false }).ToList();

            var balance = serv.BalanceTeams(context, true, null, null);
            ah.ApplyBalanceResults(balance);
            context.Players = balance.Players;
            context.Bots = balance.Bots;

            ah.SayBattle("please wait, game is about to start");
            ah.StopVote();
            ah.slaveContextOverride = context;
            ah.tas.StartGame();
        }