public DC.Responses.PlayData DoAction(DC.Requests.DoActionRequest request) { DC.Responses.PlayData playData = new DC.Responses.PlayData() { Message = new DC.Responses. MessageData() { Id = -1, Text = "Nothing happens." } }; if (request.NounId.HasValue) { var results = _repository.GetActionResults(request.PlayerId, request.NounId.Value, request.VerbTypeId); if (results.Any()) { UpdateLastTimeAfterAction(request.PlayerId, request.NounId.Value, request.VerbTypeId, request.Time); results = ResultTypeDictionary.SortResultsByResultTypePriority(results); playData.Message = null; foreach (var result in results) { dynamic data = JsonConvert.DeserializeObject(result.JSONData); ResultSwitch(result.ResultType, data, request.PlayerId, ref playData); } } } return playData; }
public DC.Responses.PlayData DoMessageChoice(DC.Requests.DoMessageChoiceRequest request) { DC.Responses.PlayData playData = new DC.Responses.PlayData(); var results = _repository.GetMessageChoiceResults(request.MessageChoiceId); if (results.Any()) { results = ResultTypeDictionary.SortResultsByResultTypePriority(results); foreach (var result in results) { dynamic data = JsonConvert.DeserializeObject(result.JSONData); ResultSwitch(result.ResultType, data, request.PlayerId, ref playData); } } return playData; }
public DC.Responses.PlayData GetNounsForParagraphState(string paragraphStateId) { DC.Responses.PlayData data = new DC.Responses.PlayData(); int paragraphStateIntId; if (int.TryParse(paragraphStateId, out paragraphStateIntId)) { var result = _repository.ReadNounsForParagraphState(paragraphStateIntId); data.Message = new DC.Responses.MessageData() { Id = -1, Text = (result.Any()) ? string.Format ( "You take special notice of the {0}.", result.Select(n => n.Text).Aggregate((x, y) => string.Format("{0}; {1}", x, y)) ) : "Nothing in particular catches your eye here." }; } return data; }