public ServerPlayerActiveTask( IPlayerTask playerTask, PlayerTaskState playerTaskState, IPlayerActiveTasksHolder playerTaskTarget, ICharacter character) { this.PlayerTask = playerTask; this.PlayerTaskState = playerTaskState; this.PlayerTaskTarget = playerTaskTarget; this.Character = character; }
public bool SharedHasCompletedTask(IPlayerTask task) { if (!(task.TaskTarget is IProtoQuest quest)) { throw new Exception("Task must have an associated quest"); } var questEntry = this.SharedFindQuestEntry(quest, out _); if (questEntry is null) { // no such entry return(false); } if (questEntry.IsCompleted || questEntry.AreAllTasksCompleted) { // all tasks are/were completed return(true); } // find a state for this task and check whether it's completed var indexOfTask = -1; var tasks = quest.Tasks; if (tasks is null) { return(false); } for (var index = 0; index < tasks.Count; index++) { var r = tasks[index]; if (r != task) { continue; } indexOfTask = index; break; } Api.Assert(indexOfTask >= 0, "Task not exist in quest"); var taskState = questEntry.TaskStates[indexOfTask]; return(taskState.IsCompleted); }
public ViewModelQuestRequirement( IPlayerTask requirement, // can be null when the quest is completed [CanBeNull] PlayerTaskState taskState, bool showIcon) { this.requirement = requirement; this.taskState = taskState; this.showIcon = showIcon; this.taskState?.ClientSubscribe( _ => _.IsCompleted, isCompletedNow => { this.NotifyPropertyChanged(nameof(this.IsCompleted)); if (!isCompletedNow) { return; } // play requirement satisfied sound (not more often than once per frame) if (lastTaskFinishedFrameNumber != Client.CurrentGame.ServerFrameNumber) { lastTaskFinishedFrameNumber = Client.CurrentGame.ServerFrameNumber; Api.Client.Audio.PlayOneShot(SoundResourceQuestRequirementSatisfied, volume: 0.5f); } }, this); if (requirement is IPlayerTaskWithCount questRequirementWithCount) { this.CountRequired = questRequirementWithCount.RequiredCount; if (taskState != null) { // requirement state can be null if the quest is already completed this.taskStateWithCount = (PlayerTaskStateWithCount)taskState; this.taskStateWithCount.ClientSubscribe( _ => _.CountCurrent, _ => this.NotifyPropertyChanged(nameof(this.CountCurrent)), this); } } }
public GetOutOfJailCard(string name, IPlayerTask task, DeckType type) : base(name, task, type) { }
public Card(string name, IPlayerTask task, DeckType deckType) { Name = name; Tasks = new List<IPlayerTask>(){ {task} }; Type = deckType; }