/// <summary> /// Checks to see if the ability is usable by the player. /// </summary> /// <param name="player">The player to check.</param> /// <param name="response">The response to send to the player.</param> /// <returns>True if the ability is usable.</returns> public virtual bool CanUseAbility(Player player, out string response) { if (CanUseOverride != null) { response = string.Empty; return(CanUseOverride.Invoke()); } if (!LastUsed.ContainsKey(player)) { response = string.Empty; return(true); } DateTime usableTime = LastUsed[player] + TimeSpan.FromSeconds(Cooldown); if (DateTime.Now > usableTime) { response = string.Empty; return(true); } response = $"You must wait another {Math.Round((usableTime - DateTime.Now).TotalSeconds, 2)} seconds to use {Name}"; return(false); }
private void SaschasFunction() { IFolderInfo di = IOServices.GetFolderInfo(IOServices.Path.Combine(Properties.Settings.Default.SourcePath, "_RecentFiles")); IEnumerable <IFileInfo> fis = di.GetFiles("RecentFiles.*.xml"); DateTime lastUsed = LastUsed.ToUniversalTime(); DateTime undefined = (new DateTime(2000, 1, 1, 0, 0, 1)).ToUniversalTime(); if (lastUsed != undefined) { foreach (IFileInfo fi in fis) { DateTime fileTime = fi.LastWriteTime.ToUniversalTime(); if (fileTime > lastUsed) { Model.ReadXml(fi.FullName); } } } RaiseFileEntriesChanged(); }
public void Save(string fileToSave) { using (StreamWriter sw = new StreamWriter(fileToSave)) { sw.WriteLine(Description); sw.WriteLine(Results); sw.WriteLine(LastUsed.ToString()); } }
public bool Equals(Tag other) { if (other == null) { return(false); } if (Name.Equals(other.Name) && LastUsed.Equals(other.LastUsed) && Count.Equals(other.Count)) { return(true); } return(false); }
/// <summary> /// True if Added or LastUsed is more recent than the cutOff date. /// </summary> public bool UsedAfter(DateTime cutOff) { return(LastUsed.CompareTo(cutOff) > 0); }
public void Save(string path) { File.WriteAllText(path, Description + Environment.NewLine + Results + Environment.NewLine + LastUsed.ToString()); }