예제 #1
0
        public async Task <Quest> TakeQuest(Guid id, QuestTakeInfo info)
        {
            var filter = IdFilter(id);
            var update = Builders <Quest> .Update
                         .Set(quest => quest.Taker, info.Taker)
                         .Set(quest => quest.Status, QuestStatus.Taken);

            return(await collection.FindOneAndUpdateAsync(filter, update));
        }
        public async Task <Quest> Take(Guid id, [FromBody] QuestTakeInfo info)
        {
            ValidateTakeAction(id, (QuestTakeAction)info.Action);

            switch (info.Action)
            {
            case QuestTakeAction.Take:
                return(await repository.TakeQuest(id, info));

            case QuestTakeAction.Quit:
                return(await repository.QuitQuest(id));

            case QuestTakeAction.Complete:
                return(await repository.CompleteQuest(id));
            }

            // Note(Leo): We should never get here, since 'info.Action' is validated.
            throw new InvalidActionException();
        }
예제 #3
0
 public void Take(QuestTakeInfo info)
 {
     Taker  = info.Taker;
     Status = QuestStatus.Taken;
 }