Exemplo n.º 1
0
        public PersonView[] AncestrySearch(string name, Gender gender, Ancestry anchestry)
        {
            Data data = dataStore.Get();

            Person current =
                data.people.FirstOrDefault(
                    p => p.name.Equals(name?.Trim(), StringComparison.CurrentCultureIgnoreCase));
            var ancestryList = current != null
                ? FindAncestry(GetPeopleByIdDictionary(data.people), GetPeopleByParentIdDictionary(data.people),
                               current, gender, anchestry, 0)
                : new List <Person>();

            var query = (from person in ancestryList.ToArray()
                         join place in data.places
                         on person.place_id equals place.id
                         orderby person.level, person.id
                         select new PersonView
            {
                Id = person.id,
                Name = person.name,
                Gender = person.gender.Equals('M') ? Gender.Male : Gender.Female,
                BirthPlace = place.name
            })
                        .Take(10);

            return(query.ToArray());
        }
Exemplo n.º 2
0
        public void Insert(Ancestry ancestry)
        {
            string           sqlite     = @"insert into Ancestry (Identifier) values (@ancestryIdentifier);";
            SQLiteConnection connection = new SQLiteConnection(connectionString);

            connection.Execute(sqlite, new { ancestryIdentifier = ancestry.Identifier });
        }
Exemplo n.º 3
0
        public Ancestry GetById(int id)
        {
            string           sqlite     = @"select * from ancestry where ancestry.Id = " + id + ";";
            SQLiteConnection connection = new SQLiteConnection(connectionString);
            Ancestry         ancestry   = connection.Query <Ancestry>(sqlite).FirstOrDefault();

            return(ancestry);
        }
Exemplo n.º 4
0
        private Character CreateCharacter(string characterName, Ancestry ancestry, int genderID, PyDictionary appearance, long currentTime, CallInformation call)
        {
            // load the item into memory
            ItemEntity owner = this.ItemManager.LocationSystem;

            int stationID, solarSystemID, constellationID, regionID, corporationID, careerID, schoolID, careerSpecialityID;

            this.GetRandomCareerForRace(ancestry.Bloodline.RaceID, out careerID, out schoolID, out careerSpecialityID, out corporationID);
            this.GetLocationForCorporation(corporationID, out stationID, out solarSystemID, out constellationID, out regionID);

            int itemID = this.DB.CreateCharacter(
                ancestry.Bloodline.ItemType, characterName, owner, call.Client.AccountID, this.mConfiguration.Balance,
                0.0, corporationID, 0, 0, 0, 0, 0,
                currentTime, currentTime, currentTime, ancestry.ID,
                careerID, schoolID, careerSpecialityID, genderID,
                appearance.ContainsKey("accessoryID") ? appearance["accessoryID"] as PyInteger : null,
                appearance.ContainsKey("beardID") ? appearance["beardID"] as PyInteger : null,
                appearance["costumeID"] as PyInteger,
                appearance.ContainsKey("decoID") ? appearance["decoID"] as PyInteger : null,
                appearance["eyebrowsID"] as PyInteger,
                appearance["eyesID"] as PyInteger,
                appearance["hairID"] as PyInteger,
                appearance.ContainsKey("lipstickID") ? appearance["lipstickID"] as PyInteger : null,
                appearance.ContainsKey("makeupID") ? appearance["makeupID"] as PyInteger : null,
                appearance["skinID"] as PyInteger,
                appearance["backgroundID"] as PyInteger,
                appearance["lightID"] as PyInteger,
                appearance["headRotation1"] as PyDecimal,
                appearance["headRotation2"] as PyDecimal,
                appearance["headRotation3"] as PyDecimal,
                appearance["eyeRotation1"] as PyDecimal,
                appearance["eyeRotation2"] as PyDecimal,
                appearance["eyeRotation3"] as PyDecimal,
                appearance["camPos1"] as PyDecimal,
                appearance["camPos2"] as PyDecimal,
                appearance["camPos3"] as PyDecimal,
                appearance.ContainsKey("morph1e") ? appearance["morph1e"] as PyDecimal : null,
                appearance.ContainsKey("morph1n") ? appearance["morph1n"] as PyDecimal : null,
                appearance.ContainsKey("morph1s") ? appearance["morph1s"] as PyDecimal : null,
                appearance.ContainsKey("morph1w") ? appearance["morph1w"] as PyDecimal : null,
                appearance.ContainsKey("morph2e") ? appearance["morph2e"] as PyDecimal : null,
                appearance.ContainsKey("morph2n") ? appearance["morph2n"] as PyDecimal : null,
                appearance.ContainsKey("morph2s") ? appearance["morph2s"] as PyDecimal : null,
                appearance.ContainsKey("morph2w") ? appearance["morph2w"] as PyDecimal : null,
                appearance.ContainsKey("morph3e") ? appearance["morph3e"] as PyDecimal : null,
                appearance.ContainsKey("morph3n") ? appearance["morph3n"] as PyDecimal : null,
                appearance.ContainsKey("morph3s") ? appearance["morph3s"] as PyDecimal : null,
                appearance.ContainsKey("morph3w") ? appearance["morph3w"] as PyDecimal : null,
                appearance.ContainsKey("morph4e") ? appearance["morph4e"] as PyDecimal : null,
                appearance.ContainsKey("morph4n") ? appearance["morph4n"] as PyDecimal : null,
                appearance.ContainsKey("morph4s") ? appearance["morph4s"] as PyDecimal : null,
                appearance.ContainsKey("morph4w") ? appearance["morph4w"] as PyDecimal : null,
                stationID, solarSystemID, constellationID, regionID);

            return(this.ItemManager.LoadItem(itemID) as Character);
        }
Exemplo n.º 5
0
        private void populateAncestryUserControl()
        {
            this.UserControlPanel.Controls.Clear();
            F25090FieldSummaryData.ParcelAncestryDataDataTable ds = new F25090FieldSummaryData.ParcelAncestryDataDataTable();
            Ancestry ancestryUserControl = new Ancestry();

            ancestryUserControl.AncestryDataSet = this.FieldData.ParcelAncestryData;
            this.UserControlPanel.Controls.Add(ancestryUserControl);
            this.F25090Panel.Controls.Clear();
            this.F25090Panel.Controls.Add(this.UserControlPanel);
            this.F25090Panel.Controls.Add(this.BottomPanel);
            this.F25090PictureBox.SendToBack();
            ancestryUserControl.Location = new System.Drawing.Point(0, 0);
        }
Exemplo n.º 6
0
        public bool Update(Ancestry ancestry)
        {
            string           sqlite     = @"update Ancestry set Identifier = @ancestryIdentifier where Ancestry.Id = @ancestryId";
            SQLiteConnection connection = new SQLiteConnection(connectionString);

            try
            {
                connection.ExecuteScalar(sqlite, new { ancestryIdentifier = ancestry.Identifier, ancestryId = ancestry.Id });
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public bool Post(AncestryModel ancestryModel)
        {
            AncestryRepository ancestryRepository = new AncestryRepository();

            try
            {
                Ancestry ancestry = new Ancestry();
                ancestry.Identifier = ancestryModel.Identifier;
                ancestryRepository.Insert(ancestry);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        public AncestryModel GetById(int id)
        {
            AncestryRepository ancestryRepository = new AncestryRepository();

            try
            {
                Ancestry      ancestry      = ancestryRepository.GetById(id);
                AncestryModel ancestryModel = new AncestryModel();
                ancestryModel.Id         = ancestry.Id;
                ancestryModel.Identifier = ancestry.Identifier;

                return(ancestryModel);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public bool Update(AncestryModel ancestryModel)
        {
            AncestryRepository ancestryRepository = new AncestryRepository();
            Ancestry           ancestry           = new Ancestry();

            try
            {
                ancestry.Id         = ancestryModel.Id;
                ancestry.Identifier = ancestryModel.Identifier;
                ancestryRepository.Update(ancestry);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 10
0
        public void RelationshipCheck()
        {
            var trios = new List <(uint, uint, uint)>()
            {
                (1, 2, 3),
                (3, 4, 6),
                (5, 4, 0),
                (15, 5, 0),
                (7, 9, 8),
                (8, 10, 0)
            };

            var ancesTree = new Ancestry(trios);

            Assert.True(ancesTree.HasCommonAncestry(1, 3));   // parent
            Assert.True(ancesTree.HasCommonAncestry(1, 6));   // grandparent
            Assert.True(ancesTree.HasCommonAncestry(1, 5));   // uncle
            Assert.True(ancesTree.HasCommonAncestry(1, 15));  // cousin
            Assert.False(ancesTree.HasCommonAncestry(1, 10)); // no relationship
        }
Exemplo n.º 11
0
        public ActionResult Ancestry(Ancestry ancestry)
        {
            var pet = db.Pets.Where(x => x.AncestryId == ancestry.Id).Select(x => x).FirstOrDefault();

            if (pet == null)
            {
                pet = db.Pets.Where(x => x.Id == UserHelper.CurrentPetID).Select(x => x).FirstOrDefault();
            }
            var res = db.Ancestries.SingleOrDefault(p => p.Id == ancestry.Id);

            string filePath = null;

            foreach (string file in Request.Files)
            {
                var postedFile = Request.Files[file];

                filePath = Server.MapPath("~/UploadedFiles/") + Path.GetFileName(postedFile.FileName);

                postedFile.SaveAs(filePath);

                ancestry.DocumentPath = filePath ?? "";
            }

            if (res != null)
            {
                res.MotherId     = ancestry.MotherId;
                res.FatherId     = ancestry.FatherId;
                res.DocumentPath = ancestry.DocumentPath;

                db.SaveChanges();
            }
            else
            {
                db.Ancestries.Add(ancestry);
                pet.AncestryId = ancestry.Id;
                db.SaveChanges();
            }
            return(RedirectToAction("Pets", "Home", new { userId = pet.UserId }));
        }
Exemplo n.º 12
0
        public ActionResult Ancestry(int petId)
        {
            var pet      = db.Pets.Where(x => x.Id == petId).Select(x => x).FirstOrDefault();
            var ancestry = db.Ancestries.Where(x => x.Id == pet.AncestryId).FirstOrDefault();

            ViewBag.males   = GetPetMaleList(petId);
            ViewBag.females = GetPetFemaleList(petId);
            ViewBag.UserId  = pet.UserId;

            UserHelper.CurrentPetID = pet.Id;
            if (ancestry == null)
            {
                var list = db.Ancestries.Select(x => x.Id).ToList();
                list.Sort();
                ancestry = new Ancestry()
                {
                    Id = 1 + list.LastOrDefault()
                };
            }

            return(View(ancestry));
        }
Exemplo n.º 13
0
        public bool Update <T2>(T2 model) where T2 : GenericModel
        {
            Ancestry ancestry = new Ancestry();

            try
            {
                dynamic entity = new
                {
                    Id         = model.Id,
                    Identifier = model.Identifier
                };

                T obj = Mapper.Map <T>(entity);

                _genericRepository.Update(obj);

                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Exemplo n.º 14
0
        public Dictionary <int, Ancestry> GetAncestryInformation(Dictionary <int, Bloodline> bloodlines)
        {
            Dictionary <int, Ancestry> result     = new Dictionary <int, Ancestry>();
            MySqlConnection            connection = null;
            MySqlDataReader            reader     = Database.Query(
                ref connection,
                "SELECT " +
                " ancestryID, ancestryName, bloodlineID, description, perception, willpower, charisma," +
                " memory, intelligence, graphicID, shortDescription " +
                " FROM chrAncestries "
                );

            using (connection)
                using (reader)
                {
                    while (reader.Read() == true)
                    {
                        Ancestry ancestry = new Ancestry(
                            reader.GetInt32(0),
                            reader.GetString(1),
                            bloodlines [reader.GetInt32(2)],
                            reader.GetString(3),
                            reader.GetInt32(4),
                            reader.GetInt32(5),
                            reader.GetInt32(6),
                            reader.GetInt32(7),
                            reader.GetInt32(8),
                            reader.GetInt32OrDefault(9),
                            reader.GetString(10)
                            );

                        result[ancestry.ID] = ancestry;
                    }
                }

            return(result);
        }
Exemplo n.º 15
0
        public void WhenSearchingAncestry(string name, Gender?gender, Ancestry ancestry, int resultCount,
                                          int[] expectedIds)
        {
            // Arrange
            Mock <IDataStore <Data> > dataStore = new Mock <IDataStore <Data> >();

            dataStore.Setup(ds => ds.Get())
            .Returns(new Data
            {
                places = TestPlaces.GetPlaces(),
                people = TestPeople.GetPeople()
            });
            PersonSearchService classUnderTest = new PersonSearchService(dataStore.Object);

            PersonView[] result = null;

            // Act
            result = classUnderTest.AncestrySearch(name, gender.HasValue ? gender.Value : Gender.Male | Gender.Female,
                                                   ancestry);
            Assert.IsNotNull(result);
            Assert.AreEqual(resultCount, result.Length);
            Assert.IsTrue(Enumerable.SequenceEqual(expectedIds, result.Select(p => p.Id)));
            // Assert
        }
Exemplo n.º 16
0
        private Character CreateCharacter(string characterName, Ancestry ancestry, int genderID, PyDictionary appearance, long currentTime, CallInformation call)
        {
            // load the item into memory
            ItemEntity owner = this.ItemFactory.LocationSystem;

            this.GetRandomCareerForRace(ancestry.Bloodline.RaceID, out int careerID, out int schoolID, out int careerSpecialityID, out int corporationID);
            this.GetLocationForCorporation(corporationID, out int stationID, out int solarSystemID, out int constellationID, out int regionID);
            this.ExtractCharacterAppearance(appearance, out PyInteger costumeID, out PyInteger eyebrowsID,
                                            out PyInteger eyesID, out PyInteger hairID, out PyInteger skinID, out PyInteger backgroundID,
                                            out PyInteger lightID, out PyDecimal headRotation1, out PyDecimal headRotation2,
                                            out PyDecimal headRotation3, out PyDecimal eyeRotation1, out PyDecimal eyeRotation2,
                                            out PyDecimal eyeRotation3, out PyDecimal camPos1, out PyDecimal camPos2, out PyDecimal camPos3
                                            );
            this.ExtractExtraCharacterAppearance(appearance, out PyInteger accessoryID, out PyInteger beardID,
                                                 out PyInteger decoID, out PyInteger lipstickID, out PyInteger makeupID, out PyDecimal morph1e,
                                                 out PyDecimal morph1n, out PyDecimal morph1s, out PyDecimal morph1w, out PyDecimal morph2e,
                                                 out PyDecimal morph2n, out PyDecimal morph2s, out PyDecimal morph2w, out PyDecimal morph3e,
                                                 out PyDecimal morph3n, out PyDecimal morph3s, out PyDecimal morph3w, out PyDecimal morph4e,
                                                 out PyDecimal morph4n, out PyDecimal morph4s, out PyDecimal morph4w
                                                 );

            int itemID = this.DB.CreateCharacter(
                ancestry.Bloodline.CharacterType, characterName, owner, call.Client.AccountID, this.mConfiguration.Balance,
                0.0, corporationID, 0, 0, 0, 0, 0,
                currentTime, currentTime, currentTime, ancestry.ID,
                careerID, schoolID, careerSpecialityID, genderID,
                accessoryID, beardID, costumeID, decoID, eyebrowsID, eyesID, hairID, lipstickID,
                makeupID, skinID, backgroundID, lightID, headRotation1, headRotation2, headRotation3,
                eyeRotation1, eyeRotation2, eyeRotation3, camPos1, camPos2, camPos3,
                morph1e, morph1n, morph1s, morph1w, morph2e, morph2n, morph2s, morph2w,
                morph3e, morph3n, morph3s, morph3w, morph4e, morph4n, morph4s, morph4w,
                stationID, solarSystemID, constellationID, regionID
                );

            return(this.ItemFactory.LoadItem(itemID) as Character);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Updates the ancestry controls.
        /// </summary>
        private void UpdateAncestryControl()
        {
            int index = 0;

            switch (BlankCharacterUIHelper.Bloodline)
            {
            case Bloodline.Unknown:
            case Bloodline.Amarr:
                break;

            case Bloodline.Ni_Kunni:
                index = 3;
                break;

            case Bloodline.Khanid:
                index = 6;
                break;

            case Bloodline.Deteis:
                index = 9;
                break;

            case Bloodline.Civire:
                index = 12;
                break;

            case Bloodline.Achura:
                index = 15;
                break;

            case Bloodline.Gallente:
                index = 18;
                break;

            case Bloodline.Intaki:
                index = 21;
                break;

            case Bloodline.Jin_Mei:
                index = 24;
                break;

            case Bloodline.Sebiestor:
                index = 27;
                break;

            case Bloodline.Brutor:
                index = 30;
                break;

            case Bloodline.Vherokior:
                index = 33;
                break;

            default:
                throw new NotImplementedException();
            }

            // Calculate bloodlines based on image position (they used to match up in code,
            // but the codes were remapped to match the SDE)
            Ancestry ancestry1 = ANCESTRIES_BY_INDEX[index], ancestry2 = ANCESTRIES_BY_INDEX[
                index + 1], ancestry3 = ANCESTRIES_BY_INDEX[index + 2];

            pbAncestry1.Image = ilAncestry.Images[index];
            pbAncestry2.Image = ilAncestry.Images[index + 1];
            pbAncestry3.Image = ilAncestry.Images[index + 2];
            lblAncestry1.Text = ancestry1.ToString().ToUpper(CultureConstants.DefaultCulture).
                                UnderscoresToSpaces();
            lblAncestry2.Text = ancestry2.ToString().ToUpper(CultureConstants.DefaultCulture).
                                UnderscoresToSpaces();
            lblAncestry3.Text = ancestry3.ToString().ToUpper(CultureConstants.DefaultCulture).
                                UnderscoresToSpaces();
            lblAncestry1.Tag = ancestry1;
            lblAncestry2.Tag = ancestry2;
            lblAncestry3.Tag = ancestry3;

            if (rbAncestry1.Checked)
            {
                BlankCharacterUIHelper.Ancestry = ancestry1;
            }
            if (rbAncestry2.Checked)
            {
                BlankCharacterUIHelper.Ancestry = ancestry2;
            }
            if (rbAncestry3.Checked)
            {
                BlankCharacterUIHelper.Ancestry = ancestry3;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Updates the ancestry controls.
        /// </summary>
        private void UpdateAncestryControl()
        {
            int index = 0;

            switch (m_bloodline)
            {
            default:
            case Bloodline.Amarr:
                break;

            case Bloodline.Ni_Kunni:
                index = 3;
                break;

            case Bloodline.Khanid:
                index = 6;
                break;

            case Bloodline.Deteis:
                index = 9;
                break;

            case Bloodline.Civire:
                index = 12;
                break;

            case Bloodline.Achura:
                index = 15;
                break;

            case Bloodline.Gallente:
                index = 18;
                break;

            case Bloodline.Intaki:
                index = 21;
                break;

            case Bloodline.Jin_Mei:
                index = 24;
                break;

            case Bloodline.Sebiestor:
                index = 27;
                break;

            case Bloodline.Brutor:
                index = 30;
                break;

            case Bloodline.Vherokior:
                index = 33;
                break;
            }

            pbAncestry1.Image = ilAncestry.Images[index];
            pbAncestry2.Image = ilAncestry.Images[index + 1];
            pbAncestry3.Image = ilAncestry.Images[index + 2];
            lblAncestry1.Text = ((Ancestry)Enum.ToObject(typeof(Ancestry), index)).ToString().ToUpper().Replace("_", " ");
            lblAncestry2.Text = ((Ancestry)Enum.ToObject(typeof(Ancestry), index + 1)).ToString().ToUpper().Replace("_", " ");
            lblAncestry3.Text = ((Ancestry)Enum.ToObject(typeof(Ancestry), index + 2)).ToString().ToUpper().Replace("_", " ");
            lblAncestry1.Tag  = (Ancestry)Enum.ToObject(typeof(Ancestry), index);
            lblAncestry2.Tag  = (Ancestry)Enum.ToObject(typeof(Ancestry), index + 1);
            lblAncestry3.Tag  = (Ancestry)Enum.ToObject(typeof(Ancestry), index + 2);

            if (rbAncestry1.Checked)
            {
                m_ancestry = (Ancestry)lblAncestry1.Tag;
            }
            if (rbAncestry2.Checked)
            {
                m_ancestry = (Ancestry)lblAncestry2.Tag;
            }
            if (rbAncestry3.Checked)
            {
                m_ancestry = (Ancestry)lblAncestry3.Tag;
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Handles the Click event of the rbAncestry3 control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void rbAncestry3_Click(object sender, EventArgs e)
 {
     m_ancestry = (Ancestry)lblAncestry3.Tag;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Handles the Click event of the rbAncestry3 control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void rbAncestry3_Click(object sender, EventArgs e)
 {
     m_ancestry = (Ancestry)lblAncestry3.Tag;
 }
Exemplo n.º 21
0
        private List <Person> FindAncestry(Dictionary <int, Person> people, Dictionary <int, Person[]> descendants,
                                           Person current, Gender gender,
                                           Ancestry ancestry, int count)
        {
            List <Person> ancestryList = new List <Person>();

            switch (ancestry)
            {
            case Ancestry.Ancestors:
                if (current.father_id.HasValue)
                {
                    if (people.TryGetValue(current.father_id.Value, out var father))
                    {
                        if (CheckPersonGender(father.gender, gender))
                        {
                            ancestryList.Add(father);
                            count++;
                        }
                        if (count < 10)
                        {
                            ancestryList.AddRange(
                                FindAncestry(people, descendants, father, gender, ancestry, count));
                        }
                    }
                }
                if (current.mother_id.HasValue)
                {
                    if (people.TryGetValue(current.mother_id.Value, out var mother))
                    {
                        if (CheckPersonGender(mother.gender, gender))
                        {
                            ancestryList.Add(mother);
                            count++;
                        }
                        if (count < 10)
                        {
                            ancestryList.AddRange(
                                FindAncestry(people, descendants, mother, gender, ancestry, count));
                        }
                    }
                }
                break;

            case Ancestry.Descendants:
                if (descendants.TryGetValue(current.id, out var children))
                {
                    foreach (var child in children)
                    {
                        if (CheckPersonGender(child.gender, gender))
                        {
                            ancestryList.Add(child);
                            count++;
                        }
                        if (count < 10)
                        {
                            ancestryList.AddRange(FindAncestry(people, descendants, child, gender, ancestry,
                                                               count));
                        }
                    }
                }
                break;
            }

            return(ancestryList);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Updates the ancestry controls.
        /// </summary>
        private void UpdateAncestryControl()
        {
            int index = 0;

            switch (m_bloodline)
            {
                default:
                case Bloodline.Amarr:
                    break;
                case Bloodline.Ni_Kunni:
                    index = 3;
                    break;
                case Bloodline.Khanid:
                    index = 6;
                    break;
                case Bloodline.Deteis:
                    index = 9;
                    break;
                case Bloodline.Civire:
                    index = 12;
                    break;
                case Bloodline.Achura:
                    index = 15;
                    break;
                case Bloodline.Gallente:
                    index = 18;
                    break;
                case Bloodline.Intaki:
                    index = 21;
                    break;
                case Bloodline.Jin_Mei:
                    index = 24;
                    break;
                case Bloodline.Sebiestor:
                    index = 27;
                    break;
                case Bloodline.Brutor:
                    index = 30;
                    break;
                case Bloodline.Vherokior:
                    index = 33;
                    break;
            }

            pbAncestry1.Image = ilAncestry.Images[index];
            pbAncestry2.Image = ilAncestry.Images[index + 1];
            pbAncestry3.Image = ilAncestry.Images[index + 2];
            lblAncestry1.Text = ((Ancestry)Enum.ToObject(typeof(Ancestry), index)).ToString().ToUpper().Replace("_", " ");
            lblAncestry2.Text = ((Ancestry)Enum.ToObject(typeof(Ancestry), index + 1)).ToString().ToUpper().Replace("_", " ");
            lblAncestry3.Text = ((Ancestry)Enum.ToObject(typeof(Ancestry), index + 2)).ToString().ToUpper().Replace("_", " ");
            lblAncestry1.Tag = (Ancestry)Enum.ToObject(typeof(Ancestry), index);
            lblAncestry2.Tag = (Ancestry)Enum.ToObject(typeof(Ancestry), index + 1);
            lblAncestry3.Tag = (Ancestry)Enum.ToObject(typeof(Ancestry), index + 2);

            if (rbAncestry1.Checked)
                m_ancestry = (Ancestry)lblAncestry1.Tag;
            if (rbAncestry2.Checked)
                m_ancestry = (Ancestry)lblAncestry2.Tag;
            if (rbAncestry3.Checked)
                m_ancestry = (Ancestry)lblAncestry3.Tag;
        }
Exemplo n.º 23
0
 public BannedBloodline(Ancestry ancestry, Bloodline bloodline) : base("BannedBloodline",
                                                                       new PyDictionary {
     ["name"] = ancestry.Name, ["bloodlineName"] = bloodline.Name
 })
 {
 }
Exemplo n.º 24
0
        public List <Wizzard> Get()
        {
            string sqLite = @"SELECT * FROM Wizzard
                           LEFT JOIN Species on wizzard.SpeciesId = Species.Id
                           LEFT JOIN Gender on wizzard.GenderId = Gender.Id
                           LEFT JOIN House on wizzard.HouseId = House.Id
                           LEFT JOIN Ancestry on wizzard.AncestryId = Ancestry.Id
                           LEFT JOIN Colour c on wizzard.EyeColourId = c.Id
                           LEFT JOIN Colour c2 on wizzard.HairColourId = c2.Id
                           LEFT JOIN Wand on wizzard.WandId = Wand.Id
                           LEFT JOIN Material m1 on Wand.WoodMaterialId = M1.Id
                           LEFT JOIN MaterialType mt1 on m1.MaterialTypeId = mt1.Id
                           LEFT JOIN Material m2 on Wand.CoreMaterialId = M2.Id
                           LEFT JOIN MaterialType mt2 on m2.MaterialTypeId = mt2.Id
                           LEFT JOIN patronus on wizzard.PatronusId = Patronus.Id";

            SQLiteConnection connection = new SQLiteConnection(connectionString);
            List <Wizzard>   wizzards   = connection.Query <Wizzard>
                                              (sqLite,
                                              new[]
            {
                typeof(Wizzard),
                typeof(Species),
                typeof(Gender),
                typeof(House),
                typeof(Ancestry),
                typeof(Colour),
                typeof(Colour),
                typeof(Wand),
                typeof(Material),
                typeof(MaterialType),
                typeof(Material),
                typeof(MaterialType),
                typeof(Patronus)
            }
                                              , objects =>
            {
                Wizzard wizzard       = objects[0] as Wizzard;
                Species species       = objects[1] as Species;
                Gender gender         = objects[2] as Gender;
                House house           = objects[3] as House;
                Ancestry ancestry     = objects[4] as Ancestry;
                Colour eyeColour      = objects[5] as Colour;
                Colour hairColour     = objects[6] as Colour;
                Wand wand             = objects[7] as Wand;
                Material woodMaterial = objects[8] as Material;
                MaterialType mt1      = objects[9] as MaterialType;
                Material coreMaterial = objects[10] as Material;
                MaterialType mt2      = objects[11] as MaterialType;
                Patronus patronus     = objects[12] as Patronus;

                wizzard.Species    = species;
                wizzard.Gender     = gender;
                wizzard.House      = house;
                wizzard.Ancestry   = ancestry;
                wizzard.EyeColour  = eyeColour;
                wizzard.HairColour = hairColour;
                wizzard.Wand       = wand;
                if (wand != null)
                {
                    wand.WoodMaterial = woodMaterial;
                    if (woodMaterial != null)
                    {
                        wand.WoodMaterial.MaterialType = mt1;
                    }

                    wand.CoreMaterial = coreMaterial;
                    if (coreMaterial != null)
                    {
                        wand.CoreMaterial.MaterialType = mt2;
                    }
                }
                wizzard.Patronus = patronus;

                return(wizzard);
            },
                                              splitOn: "Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id").ToList();

            return(wizzards);
        }
Exemplo n.º 25
0
        public Wizzard GetById(int id)
        {
            string           sqLite     = @"select * from Wizzard 
                            left join Species on Wizzard.SpeciesId = Species.Id
                            left join Gender on Wizzard.GenderId = Gender.Id
                            left join House on Wizzard.HouseId = House.Id
                            left join Ancestry on Wizzard.AncestryId = Ancestry.Id
                            left join Colour eye on Wizzard.EyeColourId = eye.Id
                            left join Colour hair on Wizzard.HairColourId = hair.Id
                            left join Wand on Wizzard.WandId = Wand.Id
                            left join Material mWood on Wand.WoodMaterialId = mWood.Id
                            left join MaterialType mtWood on mWood.MaterialTypeId = mtWood.Id
                            left join Material mCore on Wand.CoreMaterialId = mCore.Id
                            left join MaterialType mtCore on mCore.MaterialTypeId = mtCore.Id
                            left join Patronus on Wizzard.PatronusId = Patronus.Id
                            where Wizzard.Id = " + id + ";";
            SQLiteConnection connection = new SQLiteConnection(connectionString);
            Wizzard          wizzard    = connection.Query <Wizzard>
                                              (sqLite,
                                              new[]
            {
                typeof(Wizzard),
                typeof(Species),
                typeof(Gender),
                typeof(House),
                typeof(Ancestry),
                typeof(Colour),
                typeof(Colour),
                typeof(Wand),
                typeof(Material),
                typeof(MaterialType),
                typeof(Material),
                typeof(MaterialType),
                typeof(Patronus)
            }
                                              , objects =>
            {
                Wizzard _wizzard      = objects[0] as Wizzard;
                Species species       = objects[1] as Species;
                Gender gender         = objects[2] as Gender;
                House house           = objects[3] as House;
                Ancestry ancestry     = objects[4] as Ancestry;
                Colour eyeColour      = objects[5] as Colour;
                Colour hairColour     = objects[6] as Colour;
                Wand wand             = objects[7] as Wand;
                Material woodMaterial = objects[8] as Material;
                MaterialType mt1      = objects[9] as MaterialType;
                Material coreMaterial = objects[10] as Material;
                MaterialType mt2      = objects[11] as MaterialType;
                Patronus patronus     = objects[12] as Patronus;

                _wizzard.Species    = species;
                _wizzard.Gender     = gender;
                _wizzard.House      = house;
                _wizzard.Ancestry   = ancestry;
                _wizzard.EyeColour  = eyeColour;
                _wizzard.HairColour = hairColour;
                _wizzard.Wand       = wand;
                if (wand != null)
                {
                    wand.WoodMaterial = woodMaterial;
                    if (woodMaterial != null)
                    {
                        wand.WoodMaterial.MaterialType = mt1;
                    }

                    wand.CoreMaterial = coreMaterial;
                    if (coreMaterial != null)
                    {
                        wand.CoreMaterial.MaterialType = mt2;
                    }
                }
                _wizzard.Patronus = patronus;

                return(_wizzard);
            },
                                              splitOn: "Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id,Id").FirstOrDefault();

            return(wizzard);
        }
Exemplo n.º 26
0
        public void Post(Ancestry ancestry)
        {
            var db = LiteDBClient.Database;

            db.GetCollection <Model.Ancestry>(LiteDBClient.Ancestries).Upsert(ancestry);
        }
Exemplo n.º 27
0
        public PyDataType CreateCharacter2(
            PyString characterName, PyInteger bloodlineID, PyInteger genderID, PyInteger ancestryID,
            PyDictionary appearance, CallInformation call)
        {
            int validationError = this.ValidateNameEx(characterName, call);

            // ensure the name is valid
            switch (validationError)
            {
            case (int)NameValidationResults.TooLong: throw new CharNameInvalidMaxLength();

            case (int)NameValidationResults.Taken: throw new CharNameInvalidTaken();

            case (int)NameValidationResults.IllegalCharacters: throw new CharNameInvalidSomeChar();

            case (int)NameValidationResults.TooShort: throw new CharNameInvalidMinLength();

            case (int)NameValidationResults.MoreThanOneSpace: throw new CharNameInvalidMaxSpaces();

            case (int)NameValidationResults.Banned: throw new CharNameInvalidBannedWord();

            case (int)NameValidationResults.Valid: break;

            // unknown actual error, return generic error
            default: throw new CharNameInvalid();
            }

            // load bloodline and ancestry info for the requested character
            Bloodline bloodline   = this.mBloodlineCache[bloodlineID];
            Ancestry  ancestry    = this.mAncestriesCache[ancestryID];
            long      currentTime = DateTime.UtcNow.ToFileTimeUtc();

            if (ancestry.Bloodline != bloodline)
            {
                Log.Error($"The ancestry {ancestryID} doesn't belong to the given bloodline {bloodlineID}");

                throw new BannedBloodline(ancestry, bloodline);
            }

            Character character =
                this.CreateCharacter(characterName, ancestry, genderID, appearance, currentTime, call);
            Station station = this.ItemManager.GetStation(character.StationID);

            // change character attributes based on the picked ancestry
            character.Charisma     = bloodline.Charisma + ancestry.Charisma;
            character.Intelligence = bloodline.Intelligence + ancestry.Intelligence;
            character.Memory       = bloodline.Memory + ancestry.Memory;
            character.Willpower    = bloodline.Willpower + ancestry.Willpower;
            character.Perception   = bloodline.Perception + ancestry.Perception;

            // get skills by race and create them
            Dictionary <int, int> skills = this.DB.GetBasicSkillsByRace(bloodline.RaceID);

            foreach (KeyValuePair <int, int> pair in skills)
            {
                ItemType skillType = this.TypeManager[pair.Key];

                // create the skill at the required level
                this.ItemManager.CreateSkill(skillType, character, pair.Value);
            }

            // create the ship for the character
            Ship ship = this.ItemManager.CreateShip(bloodline.ShipType, station,
                                                    character);

            // add one unit of Tritanium to the station's hangar for the player
            ItemType tritaniumType = this.TypeManager[ItemTypes.Tritanium];

            ItemEntity tritanium =
                this.ItemManager.CreateSimpleItem(tritaniumType, character,
                                                  station, ItemFlags.Hangar);

            // add one unit of Damage Control I to the station's hangar for the player
            ItemType damageControlType = this.TypeManager[ItemTypes.DamageControlI];

            ItemEntity damageControl =
                this.ItemManager.CreateSimpleItem(damageControlType, character,
                                                  station, ItemFlags.Hangar);

            // create an alpha clone
            ItemType cloneType = this.TypeManager[ItemTypes.CloneGradeAlpha];

            Clone clone = this.ItemManager.CreateClone(cloneType, station, character);

            character.LocationID  = ship.ID;
            character.ActiveClone = clone;

            // character is 100% created and the base items are too
            // persist objects to database and unload them as they do not really belong to us
            clone.Persist();
            damageControl.Persist();
            tritanium.Persist();
            ship.Persist();
            character.Persist();

            // join the character to all the general channels
            this.ChatDB.GrantAccessToStandardChannels(character.ID);
            // create required mailing list channel
            this.ChatDB.CreateChannel(character, character, characterName, true);
            // and subscribe the character to some channels
            this.ChatDB.JoinEntityMailingList(character.ID, character.ID);
            this.ChatDB.JoinEntityChannel(character.SolarSystemID, character.ID);
            this.ChatDB.JoinEntityChannel(character.ConstellationID, character.ID);
            this.ChatDB.JoinEntityChannel(character.RegionID, character.ID);
            this.ChatDB.JoinEntityChannel(character.CorporationID, character.ID);
            this.ChatDB.JoinEntityMailingList(character.CorporationID, character.ID);

            // unload items from list
            this.ItemManager.UnloadItem(clone);
            this.ItemManager.UnloadItem(damageControl);
            this.ItemManager.UnloadItem(tritanium);
            this.ItemManager.UnloadItem(ship);
            this.ItemManager.UnloadItem(character);

            // finally return the new character's ID and wait for the subsequent calls from the EVE client :)

            return(character.ID);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Updates the ancestry controls.
        /// </summary>
        private void UpdateAncestryControl()
        {
            int index = 0;

            Ancestry[] tags;

            switch (BlankCharacterUIHelper.Bloodline)
            {
            case Bloodline.Unknown:
            case Bloodline.Amarr:
                tags = new Ancestry[]
                {
                    Ancestry.Liberal_Holders, Ancestry.Wealthy_Commoners,
                    Ancestry.Religious_Reclaimers
                };
                break;

            case Bloodline.Ni_Kunni:
                index = 3;
                tags  = new Ancestry[]
                {
                    Ancestry.Free_Merchants, Ancestry.Border_Runners,
                    Ancestry.Navy_Veterans
                };
                break;

            case Bloodline.Khanid:
                index = 6;
                tags  = new Ancestry[]
                {
                    Ancestry.Cyber_Knights, Ancestry.Unionists, Ancestry.Zealots
                };
                break;

            case Bloodline.Deteis:
                index = 9;
                tags  = new Ancestry[]
                {
                    Ancestry.Merchandisers, Ancestry.Scientists, Ancestry.Tube_Child
                };
                break;

            case Bloodline.Civire:
                index = 12;
                tags  = new Ancestry[]
                {
                    Ancestry.Entrepreneurs, Ancestry.Mercs, Ancestry.Dissenters
                };
                break;

            case Bloodline.Achura:
                index = 15;
                tags  = new Ancestry[]
                {
                    Ancestry.Inventors, Ancestry.Monks, Ancestry.Stargazers
                };
                break;

            case Bloodline.Gallente:
                index = 18;
                tags  = new Ancestry[]
                {
                    Ancestry.Activists, Ancestry.Miners, Ancestry.Immigrants
                };
                break;

            case Bloodline.Intaki:
                index = 21;
                tags  = new Ancestry[]
                {
                    Ancestry.Artists, Ancestry.Diplomats, Ancestry.Reborn
                };
                break;

            case Bloodline.Jin_Mei:
                index = 24;
                tags  = new Ancestry[]
                {
                    Ancestry.Sang_Do_Caste, Ancestry.Saan_Go_Caste, Ancestry.Jing_Ko_Caste
                };
                break;

            case Bloodline.Sebiestor:
                index = 27;
                tags  = new Ancestry[]
                {
                    Ancestry.Tinkerers, Ancestry.Traders, Ancestry.Rebels
                };
                break;

            case Bloodline.Brutor:
                index = 30;
                tags  = new Ancestry[]
                {
                    Ancestry.Workers, Ancestry.Tribal_Traditionalists, Ancestry.Slave_Child
                };
                break;

            case Bloodline.Vherokior:
                index = 33;
                tags  = new Ancestry[]
                {
                    Ancestry.Drifters, Ancestry.Mystics, Ancestry.Retailers
                };
                break;

            default:
                throw new NotImplementedException();
            }

            pbAncestry1.Image = ilAncestry.Images[index];
            pbAncestry2.Image = ilAncestry.Images[index + 1];
            pbAncestry3.Image = ilAncestry.Images[index + 2];
            lblAncestry1.Text = tags[0].ToString().ToUpper(CultureConstants.DefaultCulture).
                                UnderscoresToSpaces();
            lblAncestry2.Text = tags[1].ToString().ToUpper(CultureConstants.DefaultCulture).
                                UnderscoresToSpaces();
            lblAncestry3.Text = tags[2].ToString().ToUpper(CultureConstants.DefaultCulture).
                                UnderscoresToSpaces();
            lblAncestry1.Tag = tags[0];
            lblAncestry2.Tag = tags[1];
            lblAncestry3.Tag = tags[2];

            if (rbAncestry1.Checked)
            {
                BlankCharacterUIHelper.Ancestry = tags[0];
            }
            if (rbAncestry2.Checked)
            {
                BlankCharacterUIHelper.Ancestry = tags[1];
            }
            if (rbAncestry3.Checked)
            {
                BlankCharacterUIHelper.Ancestry = tags[2];
            }
        }