// Gets permissions from a MOO object for client-side scripting. This is used for editing. public JsonResult GetPerms( string objectId ) { if( !_user.inGame ) return null; Permissions result; using( var world = Game.WorldData.GetShadow() ) { MooCore.Mob obj = MooCore.InputParser.MatchName(objectId, world.findObject( _user.player.id ) ); if (obj == MooCore.Mob.None) { result = new Permissions() { success = false, message = "Unknown object" }; } else if (obj == MooCore.Mob.Ambiguous) { result = new Permissions() { success = false, message = "Ambiguous object" }; } else { MooCore.Perm[] perms = obj.permissions; if (perms == null) result = new Permissions() { success = true, message = "No permissions", objectId = obj.id, perms = new Permission[0] }; else { result = new Permissions() { success = true, message = "", objectId = obj.id, perms = perms .Select( x => new Permission() { actorId = x.actorId, permBits = x.permBits, specificString = x.specificString, type = x.typeString } ) .ToArray() }; } } } return Json( result, JsonRequestBehavior.AllowGet ); }
public JsonResult SetPerms( int objectId, Permissions perms ) { if( !_user.inGame ) return null; if( !ModelState.IsValid ) { return Json( new Permissions() { success = false, message = "Inputs were not valid" } ); } object result = new {}; /*using( var world = Game.WorldData.GetShadow() ) { MooCore.Mob obj = world.findObject( objectId ); if (obj == null) { result = new { valid = false, message = "Unknown object" }; } else { string message = ""; bool valid = true; try { MooCore.Verb v = new MooCore.Verb() { name = verb, code = code }; obj.verbSet(verb, v); } catch (System.Exception ex) { message = "<span class=\"error\">Exception: {0}</span>".FormatI(ex.Message); valid = false; } result = new { valid = valid, message = message }; } } */ return Json(result, JsonRequestBehavior.DenyGet); }