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); }
public object FetchShip(int shipId, int scannerId, int scannerType) { try { User user = _game.UserHandler.GetUser(Context.ConnectionId); int UserId = user.RegistrationTicket.UserId; if (!SpacegameServer.Core.Core.Instance.ships.ContainsKey(shipId)) { return new { } } ; SpacegameServer.Core.Ship Ship = SpacegameServer.Core.Core.Instance.ships[shipId]; //take care that the ships is either seen by the user, or did belong to the user before having been destroyed var CanSeeCheck = false; if (scannerType == 0) { if (!SpacegameServer.Core.Core.Instance.ships.ContainsKey(scannerId)) { return new { } } ; SpacegameServer.Core.Ship ScanShip = SpacegameServer.Core.Core.Instance.ships[scannerId]; if (Ship.FormerOwner == UserId) { CanSeeCheck = true; } else { CanSeeCheck = ScanShip.ScansPosition(new Tuple <int, int>(Ship.posX, Ship.posY)); } } if (scannerType == 1) { if (!SpacegameServer.Core.Core.Instance.colonies.ContainsKey(scannerId)) { return new { } } ; SpacegameServer.Core.Colony ScanColony = SpacegameServer.Core.Core.Instance.colonies[scannerId]; CanSeeCheck = ScanColony.ScansPosition(new Tuple <int, int>(Ship.posX, Ship.posY)); } if (!CanSeeCheck) { return new { } } ; string ShipJSON = _game.bc.getShip(UserId, shipId); return(new { Ship = ShipJSON }); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(new { }); //return new { Ship = _game.bc.getShipData(user.RegistrationTicket.UserId, shipId) }; }