示例#1
0
        public static string Repair(int shipId, int userId)
        {
            SpacegameServer.Core.Core core = SpacegameServer.Core.Core.Instance;
            //moveShip
            SpacegameServer.Core.Ship ship = core.ships[shipId];
            SpacegameServer.Core.User user = core.users[userId];

            Core.Colony colony     = null;
            var         IsRepaired = ship.Repair(user, ref colony);

            //core.colonize(ship, user, newname, ref ret);
            //do the action
            //ship.colonize(user, newname, ref ret);

            //calc the xml result
            XMLGroups.MoveResultTree scan = new XMLGroups.MoveResultTree();
            scan.ships    = new List <Core.Ship>();
            scan.stars    = new List <Core.SystemMap>();
            scan.colonies = new List <Core.Colony>();

            scan.ships.Add(ship);
            scan.colonies.Add(colony);

            string ret = "";

            BusinessConnector.Serialize <BC.XMLGroups.MoveResultTree>(scan, ref ret);

            return(ret);
        }
示例#2
0
        public static string Abandon(int colonyId, int userId)
        {
            SpacegameServer.Core.Core core = SpacegameServer.Core.Core.Instance;
            //moveShip
            SpacegameServer.Core.Colony colony = core.colonies[colonyId];

            //prepare output
            string ret = "";

            XMLGroups.MoveResultTree scan = new XMLGroups.MoveResultTree();
            scan.ships    = new List <Core.Ship>();
            scan.stars    = new List <Core.SystemMap>();
            scan.colonies = new List <Core.Colony>();

            //call abandon
            if (!colony.Abandon(userId, ref scan.ships))
            {
                return(ret);
            }
            scan.colonies.Add(colony);

            //create xml
            BusinessConnector.Serialize <BC.XMLGroups.MoveResultTree>(scan, ref ret);
            return(ret);
        }
示例#3
0
        public static string constructSpaceStation(int shipId, int userId)
        {
            SpacegameServer.Core.Core core = SpacegameServer.Core.Core.Instance;
            //moveShip
            SpacegameServer.Core.Ship ship = core.ships[shipId];
            SpacegameServer.Core.User user = core.users[userId];

            int newShipId = 0;

            var FinishedConstruction = ship.createSpaceStation(user, ref newShipId);

            //core.colonize(ship, user, newname, ref ret);
            //do the action
            //ship.colonize(user, newname, ref ret);

            //calc the xml result
            XMLGroups.MoveResultTree scan = new XMLGroups.MoveResultTree();
            scan.ships    = new List <Core.Ship>();
            scan.stars    = new List <Core.SystemMap>();
            scan.colonies = new List <Core.Colony>();
            if (FinishedConstruction)
            {
                core.getUserScans(ship.userid, core.ships[newShipId], ref scan.ships, ref scan.stars, ref scan.colonies);

                //ship.userid = -1;
                scan.ships.Add(ship);

                //if the scan range of the new base is 0, it is not included so add it to the result manually
                if (!scan.ships.Any(e => e.id == newShipId))
                {
                    scan.ships.Add(core.ships[newShipId]);
                }
            }

            string ret = "";

            BusinessConnector.Serialize <BC.XMLGroups.MoveResultTree>(scan, ref ret);

            return(ret);
        }
示例#4
0
        public static string transcensionAdd(int shipId, int userId)
        {
            SpacegameServer.Core.Core core = SpacegameServer.Core.Core.Instance;
            //break if the elements
            if ((!core.ships.ContainsKey(shipId)) ||
                (!core.users.ContainsKey(userId)))
            {
                return("");
            }

            //moveShip
            SpacegameServer.Core.Ship ship = core.ships[shipId];
            SpacegameServer.Core.User user = core.users[userId];
            int stationId;

            ship.transcensionAdd(user, out stationId);


            //calc the xml result
            XMLGroups.MoveResultTree scan = new XMLGroups.MoveResultTree();
            scan.ships    = new List <Core.Ship>();
            scan.stars    = new List <Core.SystemMap>();
            scan.colonies = new List <Core.Colony>();

            ship.userid = -1;
            scan.ships.Add(ship);

            if (stationId != 0 && core.ships.ContainsKey(stationId))
            {
                scan.ships.Add(core.ships[stationId]);
            }

            string ret = "";

            BusinessConnector.Serialize <BC.XMLGroups.MoveResultTree>(scan, ref ret);

            return(ret);
        }
示例#5
0
        public static string refit(int userId, string refitXml)
        {
            SpacegameServer.Core.Core core = SpacegameServer.Core.Core.Instance;
            SpacegameServer.Core.User user = core.users[userId];

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(refitXml);
            string shipString = doc.DocumentElement.SelectSingleNode("/Ship/ShipId").InnerText;
            int    shipId;

            if (!Int32.TryParse(shipString, out shipId))
            {
                return("");
            }

            SpacegameServer.Core.Ship ship = core.ships[shipId];
            if (!ship.refit(refitXml))
            {
                return("");
            }



            //calc the xml result
            XMLGroups.MoveResultTree scan = new XMLGroups.MoveResultTree();
            scan.ships    = new List <Core.Ship>();
            scan.stars    = new List <Core.SystemMap>();
            scan.colonies = new List <Core.Colony>();
            scan.ships.Add(ship);

            string ret = "";

            BusinessConnector.Serialize <BC.XMLGroups.MoveResultTree>(scan, ref ret);

            return(ret);
        }
示例#6
0
        public string colonize()
        {
            SpacegameServer.Core.Core core = SpacegameServer.Core.Core.Instance;

            //fetch user and ship objects
            SpacegameServer.Core.Ship ship = core.ships[shipId];
            SpacegameServer.Core.User user = core.users[userId];

            //create result data sctructure
            string ret = "";

            XMLGroups.MoveResultTree scan = new XMLGroups.MoveResultTree();
            scan.ships    = new List <Core.Ship>();
            scan.stars    = new List <Core.SystemMap>();
            scan.colonies = new List <Core.Colony>();

            //fetch planet
            if (!core.stars.ContainsKey((int)ship.systemid))
            {
                return(ret);
            }
            Core.SolarSystemInstance planet = core.stars[(int)ship.systemid].getPlanet(ship.getSystemCoords());
            if (planet == null)
            {
                return(ret);
            }
            if (!user.CanColonize(planet))
            {
                return(ret);
            }
            //var MajorColony =

            //create Colony
            Core.Colony newColony = null;
            if (!ship.colonize(user, newname, ref scan.ships, ref newColony, planet))
            {
                return(ret);
            }

            scan.ships.Add(ship);

            string shipRet = "";

            /*
             * BusinessConnector.Serialize<List<SpacegameServer.Core.Ship>>(scan.ships, ref shipRet, true);
             * //shipRet += ret;
             *
             * // remove </ArrayOfShip> , add ret , add </ArrayOfShip>
             * shipRet = shipRet.Substring(0, shipRet.Length - "</ArrayOfShip>".Length);
             * shipRet = shipRet + ret + "</ArrayOfShip>";
             */
            SpacegameServer.BC.XMLGroups.Colonize response = new XMLGroups.Colonize();
            response.respCode = 1;
            response.Colony   = newColony;
            response.ships    = scan.ships;
            //response.planet = planet;

            response.ColonyPlanet = new XMLGroups.ColonyPlanet(planet.id, planet, planet.surfaceFields);
            //response.planet2 = new XMLGroups.ColonyPlanets();
            //response.planet2
            //response.planets.AddRange(core.planets.Where(e => e.Value.colonyId == colonyId).Select(e => new XMLGroups.ColonyPlanet(e.Value.id, e.Value, e.Value.surfaceFields)));


            BusinessConnector.Serialize <SpacegameServer.BC.XMLGroups.Colonize>(response, ref shipRet, true);

            return(shipRet);
        }