Esempio n. 1
0
        private Ranking[] GetMatchResult(User current, User user, BattleResult result)
        {
            Ranking one = new Ranking();

            one.EloRanking = current.EloRanking;
            Ranking two = new Ranking();

            two.EloRanking = user.EloRanking;

            Ranking.Update(one, two, result);

            return(new Ranking[] { one, two });
        }
Esempio n. 2
0
        protected void Calculate(object sender, EventArgs args)
        {
            try{
                BattleResult result = GetResult();

                Ranking one = new Ranking();
                one.EloRanking = int.Parse(rank1.Text);

                Ranking two = new Ranking();
                two.EloRanking = int.Parse(rank2.Text);

                Ranking.Update(one, two, result);

                rank1Label.Text = one.EloRanking.ToString();
                rank2Label.Text = two.EloRanking.ToString();
            } catch (Exception ex)  {
                userRank.Text = "Error <!-- " + ex.ToString() + "-->";
            }
        }
Esempio n. 3
0
        public static void RankingBattleEndend(Ruler one, Ruler two, BattleResult result)
        {
            try {
                User uone = UserUtility.bd.getUser(one.ForeignId);
                User utwo = UserUtility.bd.getUser(two.ForeignId);

                Ranking.Update(uone, utwo, result);

                if (result == BattleResult.NumberOneVictory)
                {
                    ++uone.Wins;
                    ++utwo.Losses;
                }
                else
                {
                    ++utwo.Wins;
                    ++uone.Losses;
                }

                UserUtility.bd.saveUser(uone, string.Empty);
                UserUtility.bd.saveUser(utwo, string.Empty);

                if (uone.AllianceId > 0 && utwo.AllianceId > 0 && uone.AllianceId != utwo.AllianceId)
                {
                    AllianceInfo aone = AllianceUtility.Persistance.Get(uone.AllianceId);
                    AllianceInfo atwo = AllianceUtility.Persistance.Get(utwo.AllianceId);

                    Ranking.Update(aone, atwo, result);

                    ++aone.RankingBattles;
                    ++atwo.RankingBattles;

                    AllianceUtility.Persistance.Save(aone);
                    AllianceUtility.Persistance.Save(atwo);
                }
            } catch (Exception ex) {
                ExceptionLog.log(ex);
            }
        }