/// <summary> /// Removes your blindfold for a person, provided you are waering one. /// </summary> /// <param name="them"></param> /// <returns></returns> public IStatus <Avatar> DoffBlindfoldFor(Avatar them) { var response = new Status <Avatar>(); try { response = IsBlindfolded(response); if (response.IsSuccess()) { response = LastCruise.DoffBlindfold(response, this, them); } if (response.IsSuccess()) { AddDomainEvent(new DoffedBlindfoldDomainEvent(this)); } } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Emits a radar pulse via a PulseEmittedDomainEvent /// </summary> /// <param name="location">The center point of the pulse</param> /// <remarks> /// Emitting a pulse triggers a PulseEmittedDomainEvent. Higher layers /// in Hankies handle the PulseEmittedDomainEvent and return a /// IRadarPulse to the radar object before saving to the database /// context. /// </remarks> public IStatus <PulseEmitedDomainEvent> EmitPulse(ICoordinates location) { var resultStatus = new Status <PulseEmitedDomainEvent>(); var pulseEvent = new PulseEmitedDomainEvent(location.Lattitude, location.Longitude, Range, this); try { if (pulseEvent.IsValid) { Owner.AddDomainEvent(pulseEvent); } else { resultStatus.AddError("Invalid PulseEmitedDomainEvent, " + "could not add to domain events"); } } catch (Exception ex) { resultStatus.AddException(ex); } resultStatus.RespondWithObject(pulseEvent); return(resultStatus); }
/// <summary> /// Stop the currenly active cruise, if there is one. /// </summary> /// <returns></returns> public IStatus <Avatar> StopActiveCruise() { var response = new Status <Avatar>(); try { if (HasActiveCruise) { LastCruise.StoppedAt = DateTimeOffset.UtcNow; AddDomainEvent(new CruiseStoppedDomainEvent (LastCruise, this)); } else { response.AddError("No active cruise avalable to stop."); } } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Return an echo from a pulse this radar emited. /// </summary> /// <param name="returnedEcho">The echo to return.</param> /// <returns></returns> public IStatus <CruiseRadar> ReturnEcho(RadarEcho returnedEcho) { var response = new Status <CruiseRadar>(); try { if (_pulses.Contains(returnedEcho.OriginatingPulse)) { ContactOrClutter(returnedEcho); } else { response.AddError ("Echos can only be returned to the radars that " + "emited the original pulse. "); } } catch (Exception ex) { response.AddException(ex); } response.RespondWithObject(this); return(response); }
/// <summary> /// Recinds an excpetion granted to your hood. /// </summary> /// <param name="them"></param> /// <returns></returns> public IStatus <Avatar> ReDonHoodFor(Avatar them) { var response = new Status <Avatar>(); try { response = IsHooded(response); if (response.IsSuccess()) { response = LastCruise.DonHood(response, this, them); } if (response.IsSuccess()) { AddDomainEvent(new ReDonnedHoodDomainEvent(this, them)); } } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Removes a handkerchief from the hard no list if it was in it. /// </summary> /// <param name="handkerchief"></param> /// <returns></returns> public IStatus <Avatar> StopFlaggingHandkerchiefAsHardNo (Handkerchief handkerchief) { var response = new Status <Avatar>(); try { if (hardNoHandkerchiefs.Contains(handkerchief)) { hardNoHandkerchiefs.Remove(handkerchief); AddDomainEvent(new AvatarRemovedHardNoHandkerchiefDomainEvent (this, handkerchief)); CruiseRadar.ReEvaluateClutter(); } else { response.AddError ("specified handkerchief not found in hard no list."); } } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Extends time left in the last cruise session /// </summary> /// <returns></returns> public IStatus <Avatar> ExtendCruiseTime(TimeExtension extension) { var response = new Status <Avatar>(); try { LastCruise.ExtendTime(response, this, extension); } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Set the impression description for this Avatar. /// </summary> /// <param name="description"></param> /// <returns></returns> public IStatus <Avatar> SetImpressionDescription(string description) { var response = new Status <Avatar>(); try { ImpressionDescription = description; AddDomainEvent(new AvatarChangedDescriptionDomainEvent(this)); } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Remove the specified photo from photos. /// </summary> /// <param name="photo"></param> /// <returns></returns> public IStatus <Avatar> RemovePhoto(RatedPhoto photo) { var response = new Status <Avatar>(); try { photos.Remove(photo); AddDomainEvent(new AvatarRemovedPhotoDomainEvent (this)); } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Set or change the impression photo. /// </summary> /// <param name="photo"></param> /// <returns></returns> public IStatus <Avatar> SetImpressionPhoto(ImpressionPhoto photo) { var response = new Status <Avatar>(); try { ImpressionPhoto = photo; AddDomainEvent(new AvatarChangedImpressionPhotoDomainEvent (this)); } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
internal Status <Avatar> ExtendTime(Status <Avatar> response, Avatar sender , TimeExtension extension) { try { response = IsCorrectSender(response, sender); if (response.IsSuccess()) { TimeExtensions.Add(extension); } } catch (Exception ex) { response.AddException(ex); } return(response); }
/* Note on validation. * Not all actions require it. Only actions that are creating or * altering a setting from an unvalidated onbject, like a sring. */ /// <summary> /// Creates a new Cruise for this avatar and triggers a domain event to /// let other objects know. /// </summary> /// <returns></returns> public IStatus <Avatar> StartNewCruise(Cruise cruiseToStart) { var status = new Status <Avatar>(); try { cruises.Add(cruiseToStart); AddDomainEvent(new CruiseStartedDomainEvent(cruiseToStart , this)); } catch (Exception ex) { status.AddException(ex); } return(AvatarValidationStatus(status)); }
internal Status <Avatar> DonHood(Status <Avatar> response, Avatar sender, Avatar forAvatar) { try { response = IsCorrectSender(response, sender); if (response.IsSuccess()) { DoffedHoodFor.Remove(forAvatar); } } catch (Exception ex) { response.AddException(ex); } return(response); }
/// <summary> /// Adds a handkerchief to the Hard No list which will prevent this /// Avatar from seeing Avarats flagging with the specified handkerchief /// </summary> /// <param name="handkerchief">The valid handkerchief to be flaged</param> /// <returns></returns> public IStatus <Avatar> FlagHandkerchiefAsHardNo (Handkerchief handkerchief) { var response = new Status <Avatar>(); try { hardNoHandkerchiefs.Add(handkerchief); AddDomainEvent(new AvatarAddedHardNoHandkerchiefDomainEvent (this, handkerchief)); CruiseRadar.ReEvaluateContactsForClutter(); } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Doff a hood for an avatar if you are wearing one /// </summary> /// <param name="sender"></param> /// <param name="forAvatar"></param> /// <returns></returns> internal Status <Avatar> DoffHood(Status <Avatar> response, Avatar sender, Avatar forAvatar) { try { response = IsCorrectSender(response, sender); if (response.IsSuccess()) { if (DoffedHoodFor == null) { DoffedHoodFor = new HashSet <Avatar>(); } DoffedHoodFor.Add(forAvatar); } } catch (Exception ex) { response.AddException(ex); } return(response); }
/// <summary> /// Recive a radar pulse and return an echo. /// </summary> /// <param name="pulse"></param> /// <returns></returns> public IStatus <Avatar> Echo(RadarPulse pulse) { var response = new Status <Avatar>(); try { if (BlockedEnforcer.AvatarCreatersHaveNotBlockedEachother(this , pulse.Source.Owner)) { AddDomainEvent(new EchoDetectedDomainEvent(pulse, this)); } else { response.AddError ("Blocked customers cannot pick eachother up on radar"); } } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }
/// <summary> /// Removes the impression photo. /// </summary> /// <returns></returns> public IStatus <Avatar> RemoveImpressionPhoto() { var response = new Status <Avatar>(); try { if (ImpressionPhoto == null) { response.AddError("No Impression Photo to remove."); } else { ImpressionPhoto = null; AddDomainEvent(new AvatarChangedImpressionPhotoDomainEvent (this)); } } catch (Exception ex) { response.AddException(ex); } return(AvatarValidationStatus(response)); }