コード例 #1
0
        /*
         *
         *
         * Research of "Space Travel" allows shipyard and scout hull
         * -> Returns the two follow up researhces with "researchable" set
         * -> Returns old quests (which is wrong)
         + current quest (which might be set to completed)
         + 2 new quests (which will be loaded and shown)
         *
         * <ResearchDone>
         *  <Researches>
         *      <PlayerResearch>
         *          <id>501</id>
         *          <label>585</label>
         *          <descriptionLabel>585</descriptionLabel>
         *          <objectimageUrl>1.gif</objectimageUrl>
         *          <cost>15</cost>
         *          <researchable>1</researchable>
         *          <isCompleted>0</isCompleted>
         *          <investedResearchpoints>0</investedResearchpoints>
         *          <researchPriority>0</researchPriority>
         *      </PlayerResearch>
         *      <PlayerResearch>
         *          <id>4002</id>
         *          <label>553</label>
         *          <descriptionLabel>558</descriptionLabel>
         *          <objectimageUrl>1.gif</objectimageUrl>
         *          <cost>11</cost>
         *          <researchable>1</researchable>
         *          <isCompleted>0</isCompleted>
         *          <investedResearchpoints>0</investedResearchpoints>
         *          <researchPriority>0</researchPriority>
         *      </PlayerResearch>
         *  </Researches>
         *  <Quest>
         *      <userId>1400</userId>
         *      <questId>1</questId>
         *      <isRead>1</isRead>
         *      <isCompleted>1</isCompleted>
         *      <hasScript>1</hasScript>
         *      <script>Welcome.js</script>
         *      <label>103</label>
         *  </Quest>
         *  <Quest>
         *      <userId>1400</userId>
         *      <questId>2</questId>
         *      <isRead>1</isRead>
         *      <isCompleted>1</isCompleted>
         *      <hasScript>1</hasScript>
         *      <script>ShortOverview.js</script>
         *      <label>104</label>
         *  </Quest>
         *  <Quest>
         *      <userId>1400</userId>
         *      <questId>3</questId>
         *      <isRead>1</isRead>
         *      <isCompleted>0</isCompleted>
         *      <hasScript>1</hasScript>
         *      <script>Movement.js</script>
         *      <label>116</label>
         *  </Quest>
         *  <Quest>
         *      <userId>1400</userId>
         *      <questId>21</questId>
         *      <isRead>0</isRead>
         *      <isCompleted>0</isCompleted>
         *      <hasScript>1</hasScript>
         *      <script>ShipModulePlant.js</script>
         *      <label>254</label>
         *  </Quest>
         *  <Quest>
         *      <userId>1400</userId>
         *      <questId>22</questId>
         *      <isRead>0</isRead>
         *      <isCompleted>0</isCompleted>
         *      <hasScript>1</hasScript>
         *      <script>Spaceport.js</script>
         *      <label>112</label>
         *  </Quest>
         *  <allowedBuildings>
         *      <allowedBuilding>
         *          <allowedBuildingId>17</allowedBuildingId>
         *      </allowedBuilding>
         *  </allowedBuildings>
         *  <ShipHulls>
         *      <ShipHull>
         *          <shipHullId>1</shipHullId>
         *      </ShipHull>
         *  </ShipHulls>
         *  <allowedModules />
         * </ResearchDone>
         *
         * */

        /*
         *
         * <ResearchDone>
         * <Researches>
         *  <PlayerResearch>
         *    <id>501</id>
         *    <researchable>1</researchable>
         *    <isCompleted>1</isCompleted>
         *    <investedResearchpoints>0</investedResearchpoints>
         *    <researchPriority>0</researchPriority>
         *  </PlayerResearch>
         *  <PlayerResearch>
         *    <id>4002</id>
         *    <researchable>1</researchable>
         *    <isCompleted>1</isCompleted>
         *    <investedResearchpoints>0</investedResearchpoints>
         *    <researchPriority>0</researchPriority>
         *  </PlayerResearch>
         * </Researches>
         * <Quest>
         *  <UserQuest>
         *    <userId>1</userId>
         *    <questId>21</questId>
         *    <isRead>false</isRead>
         *    <isCompleted>false</isCompleted>
         *    <hasScript>1</hasScript>
         *    <script>ShipModulePlant.js</script>
         *    <label>254</label>
         *  </UserQuest>
         *  <UserQuest>
         *    <userId>1</userId>
         *    <questId>22</questId>
         *    <isRead>false</isRead>
         *    <isCompleted>false</isCompleted>
         *    <hasScript>1</hasScript>
         *    <script>Spaceport.js</script>
         *    <label>112</label>
         *  </UserQuest>
         * </Quest>
         * <allowedBuildings>
         *  <allowedBuilding>
         *    <allowedBuildingId>17</allowedBuildingId>
         *  </allowedBuilding>
         * </allowedBuildings>
         * <ShipHulls>
         *  <ShipHull>
         *    <shipHullId>1</shipHullId>
         *  </ShipHull>
         * </ShipHulls>
         * </ResearchDone>
         *
         * */
        public string doResearch2(int researchId)
        {
            SpacegameServer.Core.User             user      = core.users[this.userId];
            List <SpacegameServer.Core.UserQuest> NewQuests = new List <SpacegameServer.Core.UserQuest>();

            user.doResearch2(researchId, ref NewQuests);

            string ret = "";

            //fetch all things now available by the new research
            var AllNewItems = Core.ResearchQuestPrerequisite.AvailableQRB(user, 1, researchId);

            SpacegameServer.BC.XMLGroups.ResearchDone ResearchDone = SpacegameServer.BC.XMLGroups.ResearchDone.createResearchDone(user, AllNewItems, ref NewQuests);

            BusinessConnector.Serialize <SpacegameServer.BC.XMLGroups.ResearchDone>(ResearchDone, ref ret, true);

            return(ret);
        }
コード例 #2
0
        public string ChooseSpecialization(string[] researchs)
        {
            SpacegameServer.Core.User             user      = core.users[this.userId];
            List <SpacegameServer.Core.UserQuest> NewQuests = new List <SpacegameServer.Core.UserQuest>();

            List <SpacegameServer.Core.Research> researchIds = new List <SpacegameServer.Core.Research>();

            //check that all researchs are Id of spececializationResearchs
            foreach (var entry in researchs)
            {
                if (entry == "")
                {
                    continue;
                }
                int result;
                if (!Int32.TryParse(entry, out result))
                {
                    return("");
                }
                if (!SpacegameServer.Core.Core.Instance.Researchs.sparseContainsIndex(result))
                {
                    return("");
                }

                var Research = Core.Core.Instance.Researchs[result];
                if (Research.researchType != 10)
                {
                    return("");
                }
                researchIds.Add(Research);
            }

            if (!user.ChooseSpecialization(researchIds))
            {
                return("");
            }

            string ret = "";

            //create a list of all possible follow-up researches. These might not fulfill other requirements...
            List <Core.ResearchQuestPrerequisite> AllNewResearchs = Core.Core.Instance.ResearchQuestPrerequisites.Where(e => e.SourceType == 1 && researchIds.Any(rId => rId.id == e.SourceId) && e.TargetType == 1).ToList();

            // Prüfe Vorbedingungen (andere Forschungen, Quests, Rohstoffe) ob diese Forschung erlaubt ist
            List <Core.ResearchQuestPrerequisite> FilteredNewResearchs = new List <Core.ResearchQuestPrerequisite>();

            foreach (Core.ResearchQuestPrerequisite Follower in AllNewResearchs)
            {
                Core.Research TargetResearch = Core.Core.Instance.Researchs[Follower.TargetId];
                if (!user.canResearch(TargetResearch))
                {
                    continue;
                }
                FilteredNewResearchs.Add(Follower);
            }

            SpacegameServer.BC.XMLGroups.ResearchDone ResearchDone = SpacegameServer.BC.XMLGroups.ResearchDone.createResearchDone(user, FilteredNewResearchs, ref NewQuests);

            BusinessConnector.Serialize <SpacegameServer.BC.XMLGroups.ResearchDone>(ResearchDone, ref ret, true);

            return(ret);
        }