Exemple #1
0
        public PyDataType SetCloneTypeID(PyInteger cloneTypeID, CallInformation call)
        {
            int callerCharacterID = call.Client.EnsureCharacterIsSelected();
            int stationID         = call.Client.EnsureCharacterIsInStation();

            Character character    = this.ItemFactory.GetItem <Character>(callerCharacterID);
            Type      newCloneType = this.TypeManager[cloneTypeID];

            if (newCloneType.Group.ID != (int)Groups.Clone)
            {
                throw new CustomError("Only clone types allowed!");
            }
            if (character.ActiveClone.Type.BasePrice > newCloneType.BasePrice)
            {
                throw new MedicalThisCloneIsWorse();
            }

            Station station = this.ItemFactory.GetStaticStation(stationID);

            using Wallet wallet = this.WalletManager.AcquireWallet(character.ID, 1000);
            {
                wallet.EnsureEnoughBalance(newCloneType.BasePrice);
                wallet.CreateTransactionRecord(TransactionType.Buy, this.ItemFactory.LocationSystem.ID, newCloneType.ID, 1, newCloneType.BasePrice, station.ID);
            }

            // update active clone's information
            character.ActiveClone.Type = newCloneType;
            character.ActiveClone.Name = newCloneType.Name;
            character.ActiveClone.Persist();
            character.Persist();

            return(null);
        }
Exemple #2
0
 public int CreateSkill(Type skill, Character character)
 {
     return (int) this.ItemDB.CreateItem(
         null, skill, character, character, Flags.Skill,
         false, true, 1, null, null, null, null
     );
 }
Exemple #3
0
        public PyInteger LeaveShip(CallInformation call)
        {
            int callerCharacterID = call.Client.EnsureCharacterIsSelected();

            Character character = this.ItemFactory.GetItem <Character>(callerCharacterID);
            // get the item type
            Type capsuleType = this.TypeManager[Types.Capsule];
            // create a pod for this character
            ItemInventory capsule = this.ItemFactory.CreateShip(capsuleType, this.Location, character);

            // update capsule's name
            capsule.Name = character.Name + "'s Capsule";
            // change character's location to the pod
            character.LocationID = capsule.ID;
            // notify the client about the item changes
            call.Client.NotifyMultiEvent(OnItemChange.BuildLocationChange(capsule, Flags.Capsule, capsule.LocationID));
            call.Client.NotifyMultiEvent(OnItemChange.BuildLocationChange(character, Flags.Pilot, call.Client.ShipID));
            // update session
            call.Client.ShipID = capsule.ID;

            // persist changes!
            capsule.Persist();
            character.Persist();

            // TODO: CHECKS FOR IN-SPACE LEAVING!

            return(capsule.ID);
        }
Exemple #4
0
        public PyDataType InstallCloneInStation(CallInformation call)
        {
            int callerCharacterID = call.Client.EnsureCharacterIsSelected();
            int stationID         = call.Client.EnsureCharacterIsInStation();

            Character character = this.ItemFactory.GetItem <Character>(callerCharacterID);

            // check the maximum number of clones the character has assigned
            long maximumClonesAvailable = character.GetSkillLevel(Types.InfomorphPsychology);

            // the skill is not trained
            if (maximumClonesAvailable == 0)
            {
                throw new JumpCharStoringMaxClonesNone();
            }

            // get list of clones (excluding the medical clone)
            Rowset clones = this.ItemDB.GetClonesForCharacter(character.ID, (int)character.ActiveCloneID);

            // ensure we don't have more than the allowed clones
            if (clones.Rows.Count >= maximumClonesAvailable)
            {
                throw new JumpCharStoringMaxClones(clones.Rows.Count, maximumClonesAvailable);
            }

            // ensure that the character has enough money
            int cost = this.GetPriceForClone(call);

            // get character's station
            Station station = this.ItemFactory.GetStaticStation(stationID);

            using Wallet wallet = this.WalletManager.AcquireWallet(character.ID, 1000);
            {
                wallet.EnsureEnoughBalance(cost);
                wallet.CreateJournalRecord(
                    MarketReference.JumpCloneInstallationFee, null, station.ID, -cost, $"Installed clone at {station.Name}"
                    );
            }

            // create an alpha clone
            Type cloneType = this.TypeManager[Types.CloneGradeAlpha];

            // create a new clone on the itemDB
            Clone clone = this.ItemFactory.CreateClone(cloneType, station, character);

            // finally create the jump clone and invalidate caches
            this.OnCloneUpdate(callerCharacterID);

            // persist the character information
            character.Persist();

            return(null);
        }
Exemple #5
0
 public void CreateSkillHistoryRecord(Type skill, Character character, SkillHistoryReason reason, double skillPoints)
 {
     Database.PrepareQuery(
         "INSERT INTO chrSkillHistory(characterID, skillTypeID, eventID, logDateTime, absolutePoints)VALUES(@characterID, @skillTypeID, @eventID, @logDateTime, @skillPoints)",
         new Dictionary<string, object>()
         {
             {"@characterID", character.ID},
             {"@skillTypeID", skill.ID},
             {"@eventID", (int) reason},
             {"@logDateTime", DateTime.UtcNow.ToFileTimeUtc()},
             {"@skillPoints", skillPoints}
         }
     );
 }
Exemple #6
0
        private void CreateCmd(string[] argv, CallInformation call)
        {
            if (argv.Length < 2)
            {
                throw new SlashError("create takes at least one argument");
            }

            int typeID   = int.Parse(argv[1]);
            int quantity = 1;

            if (argv.Length > 2)
            {
                quantity = int.Parse(argv[2]);
            }

            if (call.Client.StationID == null)
            {
                throw new SlashError("Creating items can only be done at station");
            }
            // ensure the typeID exists
            if (this.TypeManager.ContainsKey(typeID) == false)
            {
                throw new SlashError("The specified typeID doesn't exist");
            }

            // create a new item with the correct locationID
            Station   location  = this.ItemFactory.GetStaticStation((int)call.Client.StationID);
            Character character = this.ItemFactory.GetItem <Character>(call.Client.EnsureCharacterIsSelected());

            Type       itemType = this.TypeManager[typeID];
            ItemEntity item     = this.ItemFactory.CreateSimpleItem(itemType, character, location, Flags.Hangar, quantity);

            item.Persist();

            // send client a notification so they can display the item in the hangar
            call.Client.NotifyMultiEvent(OnItemChange.BuildNewItemChange(item));
        }
Exemple #7
0
        public int CreateCharacter(Type from, string name, ItemEntity owner, int accountID, double balance, double securityRating,
                                   int corporationID, int corpRole, int rolesAtAll, int rolesAtBase, int rolesAtHQ, int rolesAtOther,
                                   long corporationDateTime, long startDateTime, long createDateTime, int ancestryID, int careerID, int schoolID,
                                   int careerSpecialityID, int gender, int?accessoryID, int?beardID, int costumeID, int?decoID, int eyebrowsID,
                                   int eyesID, int hairID, int?lipstickID, int?makeupID, int skinID, int backgroundID, int lightID,
                                   double headRotation1, double headRotation2, double headRotation3, double eyeRotation1, double eyeRotation2,
                                   double eyeRotation3, double camPos1, double camPos2, double camPos3, double?morph1E, double?morph1N,
                                   double?morph1S, double?morph1W, double?morph2E, double?morph2N, double?morph2S, double?morph2W,
                                   double?morph3E, double?morph3N, double?morph3S, double?morph3W, double?morph4E, double?morph4N,
                                   double?morph4S, double?morph4W, int stationID, int solarSystemID, int constellationID, int regionID)
        {
            // create the item first
            int itemID = (int)this.ItemDB.CreateItem(name, from.ID, owner.ID, stationID, Flags.Connected, false,
                                                     true, 1, 0, 0, 0, "");

            // now create the character record in the database
            Database.PrepareQuery(
                "INSERT INTO chrInformation(" +
                "characterID, accountID, title, description, bounty, balance, securityRating, petitionMessage, " +
                "logonMinutes, corporationID, corpRole, rolesAtAll, rolesAtBase, rolesAtHQ, rolesAtOther, " +
                "corporationDateTime, startDateTime, createDateTime, ancestryID, careerID, schoolID, careerSpecialityID, " +
                "gender, 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, online" +
                ")VALUES(" +
                "@characterID, @accountID, @title, @description, @bounty, @balance, @securityRating, @petitionMessage, " +
                "@logonMinutes, @corporationID, @corpRole, @rolesAtAll, @rolesAtBase, @rolesAtHQ, @rolesAtOther, " +
                "@corporationDateTime, @startDateTime, @createDateTime, @ancestryID, @careerID, @schoolID, @careerSpecialityID, " +
                "@gender, @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, @online" +
                ")"
                ,
                new Dictionary <string, object>()
            {
                { "@characterID", itemID },
                { "@accountID", accountID },
                { "@title", "" },
                { "@description", "" },
                { "@bounty", 0 },
                { "@balance", balance },
                { "@securityRating", securityRating },
                { "@petitionMessage", "" },
                { "@logonMinutes", 0 },
                { "@corporationID", corporationID },
                { "@corpRole", corpRole },
                { "@rolesAtAll", rolesAtAll },
                { "@rolesAtBase", rolesAtBase },
                { "@rolesAtHQ", rolesAtHQ },
                { "@rolesAtOther", rolesAtOther },
                { "@corporationDateTime", corporationDateTime },
                { "@startDateTime", startDateTime },
                { "@createDateTime", createDateTime },
                { "@ancestryID", ancestryID },
                { "@careerID", careerID },
                { "@schoolID", schoolID },
                { "@careerSpecialityID", careerSpecialityID },
                { "@gender", gender },
                { "@accessoryID", accessoryID },
                { "@beardID", beardID },
                { "@costumeID", costumeID },
                { "@decoID", decoID },
                { "@eyebrowsID", eyebrowsID },
                { "@eyesID", eyesID },
                { "@hairID", hairID },
                { "@lipstickID", lipstickID },
                { "@makeupID", makeupID },
                { "@skinID", skinID },
                { "@backgroundID", backgroundID },
                { "@lightID", lightID },
                { "@headRotation1", headRotation1 },
                { "@headRotation2", headRotation2 },
                { "@headRotation3", headRotation3 },
                { "@eyeRotation1", eyeRotation1 },
                { "@eyeRotation2", eyeRotation2 },
                { "@eyeRotation3", eyeRotation3 },
                { "@camPos1", camPos1 },
                { "@camPos2", camPos2 },
                { "@camPos3", camPos3 },
                { "@morph1e", morph1E },
                { "@morph1n", morph1N },
                { "@morph1s", morph1S },
                { "@morph1w", morph1W },
                { "@morph2e", morph2E },
                { "@morph2n", morph2N },
                { "@morph2s", morph2S },
                { "@morph2w", morph2W },
                { "@morph3e", morph3E },
                { "@morph3n", morph3N },
                { "@morph3s", morph3S },
                { "@morph3w", morph3W },
                { "@morph4e", morph4E },
                { "@morph4n", morph4N },
                { "@morph4s", morph4S },
                { "@morph4w", morph4W },
                { "@stationID", stationID },
                { "@solarSystemID", solarSystemID },
                { "@constellationID", constellationID },
                { "@regionID", regionID },
                { "@online", false }
            }
                );

            this.CreateEmploymentRecord(itemID, corporationID, createDateTime);

            // return the character's item id
            return(itemID);
        }
Exemple #8
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.ItemFactory.GetStaticStation(character.StationID);

            // TODO: CREATE DEFAULT STANDINGS FOR THE CHARACTER
            // 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 ((int skillTypeID, int level) in skills)
            {
                Type skillType = this.TypeManager[skillTypeID];

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

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

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

            ItemEntity tritanium =
                this.ItemFactory.CreateSimpleItem(tritaniumType, character,
                                                  station, Flags.Hangar);

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

            ItemEntity damageControl =
                this.ItemFactory.CreateSimpleItem(damageControlType, character,
                                                  station, Flags.Hangar);

            // create an alpha clone
            Type cloneType = this.TypeManager[Types.CloneGradeAlpha];

            Clone clone = this.ItemFactory.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.ItemFactory.UnloadItem(clone);
            this.ItemFactory.UnloadItem(damageControl);
            this.ItemFactory.UnloadItem(tritanium);
            this.ItemFactory.UnloadItem(ship);
            this.ItemFactory.UnloadItem(character);

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