Esempio n. 1
0
        /// <summary>
        /// Adds a new character to TCTData.Data.CharList and invokes CharacterAddedEvent
        /// </summary>
        /// <param name="character">Character to be added (if not existing)</param>
        public static void AddCharacter(Character character)
        {
            bool found = false;

            foreach (var cl in CharList)
            {
                if (cl.Name == character.Name)
                {
                    found         = true;
                    cl.Laurel     = character.Laurel;
                    cl.Level      = character.Level;
                    cl.CharClass  = character.CharClass;
                    cl.GuildId    = character.GuildId;
                    cl.LocationId = character.LocationId;
                    cl.LastOnline = character.LastOnline;
                    cl.AccountId  = character.AccountId;
                    cl.Position   = character.Position;

                    break;
                }
            }

            if (!found)
            {
                // add char to chList
                CharList.Add(character);

                // check for TC
                int tc = 1;
                if (AccountList.Find(a => a.Id == character.AccountId).TeraClub)
                {
                    tc = 2;
                }

                // initialize dungeons
                for (int j = 0; j < DungList.Count; j++)
                {
                    if (DungList[j].ShortName == "AH" || DungList[j].ShortName == "EA" || DungList[j].ShortName == "GL" || DungList[j].ShortName == "CA")
                    {
                        CharList.Last().Dungeons.Add(new CharDungeon(DungList[j].ShortName, DungList[j].MaxBaseRuns, 0));
                    }
                    else
                    {
                        CharList.Last().Dungeons.Add(new CharDungeon(DungList[j].ShortName, DungList[j].MaxBaseRuns * tc, 0));
                    }
                }

                // create and add strip to list

                CharacterAddedEvent.Invoke(CharList.Count - 1);

                //UI.MainWin.CreateStrip(CharList.Count - 1);
            }
        }