Ejemplo n.º 1
0
        public static void UpdateLadderBasedOnGame(Game game, int DefaultLadderPosition)
        {
            foreach (GamePlayer gameplayer in game.GamePlayers)
            {
                if (game.finished == 1)
                {
                    // add new people to ladder. No longer worrying about people who drop in their first game - just add them to the ladder anyway
                    if (!Ladder.Exists(x => x.PlayerName == gameplayer.playername))
                    {
                        Ladder.Add(new LadderPlayer(gameplayer.playername, DefaultLadderPosition));
                        gameplayer.currentposition = DefaultLadderPosition;
                    }
                    else
                    {
                        gameplayer.currentposition = Ladder.Find(x => x.PlayerName == gameplayer.playername).Position;
                    }

                    AddPositionalScores(game, false);


                    // Add the game info to the ladder player and set their temporary "position" ready for ordering
                    PlayerGameInfo Info = new PlayerGameInfo();
                    Info.GameNumber = game.GameNumber;
                    Info.WeekNumber = game.WeekNumber;
                    Info.Finished   = true;
                    Info.Dropped    = false;
                    Info.Faction    = gameplayer.faction;
                    Info.Rank       = gameplayer.rank;
                    LadderPlayer LP = Ladder.Find(x => x.PlayerName == gameplayer.playername);
                    LP.AddGameInfo(Info);
                    LP.Playing = true;
                    LP.TemporaryPositionDouble = LP.Position - gameplayer.score;
                    LP.AddTogmgMarathonScore(game.GameNumber, (int)gameplayer.rank);
                }
                else
                {
                    LadderPlayer LP = Ladder.Find(x => x.PlayerName == gameplayer.playername);
                    if (LP != null)
                    {
                        LP.Playing = true;
                        LP.TemporaryPositionDouble = (double)(LP.Position);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public PlayerDetailGump(PlayerMobile from, PlayerMobile mobile)
        {
            _from   = from;
            _mobile = mobile;

            Width = 320;

            int n = Notoriety.Compute(from, mobile);

            int notoColor = _notorietyColors[n];

            AddBorderedText(20, 18, Width - 40, 20, Center(mobile.Name ?? "Unknown"), notoColor, BlackColor32);

            AddSeperator(30, 40, Width - 60);

            const int LabelOffset = 20;
            const int LabelWidth  = 55;

            const int ValueOffset = 25 + LabelWidth;
            int       ValueWidth  = Width - (20 + ValueOffset);

            int y = 44;

            PlayerMobile pm = mobile as PlayerMobile;

            Guild guild = mobile.Guild as Guild;

            if (guild != null)
            {
                AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Guild:"), LabelColor32, BlackColor32);

                AddBorderedText(ValueOffset, y, ValueWidth, 20, guild.Name ?? "Unknown", WhiteColor32, BlackColor32);
                y += 20;
            }

            if (mobile.PublicMyRunUO && mobile.Kills >= 5)
            {
                AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Kills:"), LabelColor32, BlackColor32);
                AddBorderedText(ValueOffset, y, ValueWidth, 20, mobile.Kills.ToString("N0"), WhiteColor32, BlackColor32);

                y += 20;
            }

            Account acct = mobile.Account as Account;

            if (acct != null)
            {
                TimeSpan age = DateTime.UtcNow - acct.Created;

                int ageInDays = ( int )age.TotalDays;

                int ageInYears  = ((ageInDays + 162) / 365);
                int ageInMonths = ((ageInDays + 15) / 30);
                int ageInWeeks  = ((ageInDays + 3) / 7);

                string ageString;

                if (ageInYears > 0)
                {
                    ageString = String.Format("{0:N0} year{1}", ageInYears, ageInYears == 1?"":"s");
                }
                else if (ageInMonths > 1)
                {
                    ageString = String.Format("{0:N0} month{1}", ageInMonths, ageInMonths == 1?"":"s");
                }
                else if (ageInWeeks > 1)
                {
                    ageString = String.Format("{0:N0} week{1}", ageInWeeks, ageInWeeks == 1?"":"s");
                }
                else
                {
                    ageString = String.Format("Newbie", ageInDays, ageInDays == 1?"":"s");
                }



                AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Age:"), LabelColor32, BlackColor32);
                AddBorderedText(ValueOffset, y, ValueWidth, 20, ageString, WhiteColor32, BlackColor32);

                y += 20;
            }

            PlayerState ps = PlayerState.Find(mobile);

            if (ps != null)
            {
                Faction fac = ps.Faction;

                //AddItem( Width - 51, 7, 5535, (fac.Definition.HueSecondary ^ 0x0000) - 1 );
                AddItem(7, 7, 5534, (fac.Definition.HuePrimary ^ 0x0000) - 1);

                y += 8;

                AddBorderedText(LabelOffset, y, LabelWidth + ValueWidth, 20, fac.Definition.FriendlyName, WhiteColor32, BlackColor32);

                y += 21;
                AddSeperator(30, y, Width - 60);
                y += 3;

                string rank = String.Format(
                    "Level {0} {1}",
                    ps.Rank.Rank,
                    ps.Rank.Title.String
                    );

                AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Rank:"), LabelColor32, BlackColor32);
                AddBorderedText(ValueOffset, y, ValueWidth, 20, rank, WhiteColor32, BlackColor32);
                y += 20;

                AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Points:"), LabelColor32, BlackColor32);
                AddBorderedText(ValueOffset, y, ValueWidth, 20, String.Format("{0:N0}", ps.KillPoints), WhiteColor32, BlackColor32);
                y += 20;
            }

            Ladder instance = Ladder.Instance;

            if (instance != null)
            {
                LadderEntry entry = instance.Find(mobile);

                if (entry != null && (entry.Wins + entry.Losses) > 0)
                {
                    y += 8;

                    AddBorderedText(LabelOffset, y, LabelWidth + ValueWidth, 20, "Duelist", WhiteColor32, BlackColor32);

                    y += 21;
                    AddSeperator(30, y, Width - 60);
                    y += 3;

                    string rank = LadderGump.Rank(entry.Index + 1);

                    AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Rank:"), LabelColor32, BlackColor32);
                    AddBorderedText(ValueOffset, y, ValueWidth, 20, rank, WhiteColor32, BlackColor32);
                    y += 20;

                    AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Level:"), LabelColor32, BlackColor32);
                    AddBorderedText(ValueOffset, y, ValueWidth, 20, Ladder.GetLevel(entry.Experience).ToString("N0"), WhiteColor32, BlackColor32);
                    y += 20;

                    AddBorderedText(LabelOffset, y, LabelWidth, 20, Right("Matches:"), LabelColor32, BlackColor32);
                    AddBorderedText(ValueOffset, y, ValueWidth, 20, String.Format("{0:N0}", (entry.Wins + entry.Losses)), WhiteColor32, BlackColor32);
                    y += 20;
                }
            }

            Height = y + 12;

            Ethic ethic = Ethic.Find(mobile);

            if (ethic == Ethic.Hero)
            {
                AddItem(Width - 36, Height - 26, 7188);
            }
            else if (ethic == Ethic.Evil)
            {
                AddItem(Width - 35, Height - 36, 6232);
            }
        }