private static void SetCharacterColorByItemType(CharacterInstance ch, IList <int> pitShow, int i) { var itemType = EnumerationExtensions.GetEnum <ItemTypes>(pitShow[i]); var attrib = itemType.GetAttribute <CharacterColorAttribute>(); ch.SetColor(attrib?.ATType ?? ATTypes.AT_OBJECT); }
public static void reset_colors(PlayerInstance ch) { var path = SystemConstants.GetSystemDirectory(SystemDirectoryTypes.Color) + "default"; using (var proxy = new TextReaderProxy(new StreamReader(path))) { IEnumerable <string> lines = proxy.ReadIntoList(); foreach (var line in lines.Where(l => !l.EqualsIgnoreCase("#colortheme") && !l.StartsWithIgnoreCase("name") && !l.EqualsIgnoreCase("maxcolors"))) { var tuple = line.FirstArgument(); switch (tuple.Item1.ToLower()) { case "colors": var colors = tuple.Item2.Split(' '); for (var i = 0; i < colors.Length; i++) { ch.Colors[EnumerationExtensions.GetEnum <ATTypes>(i)] = (char)colors[i].ToInt32(); } break; case "end": return; } } } }
private static WearLocations GetRandomWearLocation() { var min = WearLocations.About.GetMinimum(); var max = WearLocations.WieldMissile.GetMaximum(); var loc = EnumerationExtensions.GetEnum <WearLocations>(SmaugRandom.Between(min, max)); return(loc == WearLocations.None ? GetRandomWearLocation() : loc); }
public static string color_str(ATTypes attype, CharacterInstance ch) { if (ch.IsNpc() || ch.Act.IsSet((int)PlayerFlags.Ansi)) { return(string.Empty); } var code = EnumerationExtensions.GetEnum <AnsiCodes>((int)attype); return(code.GetName()); }
public static void show_colors(CharacterInstance ch) { ch.SendToPager("&BSyntax: color [color type] [color] | default\r\n"); ch.SendToPager("&BSyntax: color _reset_ (Resets all colors to default set)\r\n"); ch.SendToPager("&BSyntax: color _all_ [color] (Sets all color types to [color])\r\n\r\n"); ch.SendToPager("&BSyntax: color theme [name] (Sets all color types to a defined theme)\r\n\r\n"); ch.SendToPager("&W********************************[ COLORS ]*********************************\r\n"); for (var count = 0; count < 16; ++count) { if (count % 8 == 0 && count != 0) { ch.SendToPager("\r\n"); } var atType = EnumerationExtensions.GetEnum <ATTypes>(count); ch.PagerPrintf("%s%-10s", color_str(atType, ch), LookupConstants.pc_displays[count]); } ch.SendToPager("\r\n\r\n&W******************************[ COLOR TYPES ]******************************\r\n"); // todo foreach through colors instead of using MAX_COLORS //for (var count = 32; count < (int)ATTypes.MAX_COLORS; ++count) //{ // if ((count % 8) == 0 && count != 32) // ch.SendToPager("\r\n"); // var atType = EnumerationExtensions.GetEnum<ATTypes>(count); // ch.PagerPrintf("%s%-10s%s", color_str(atType, ch), LookupConstants.pc_displays[count], AnsiCodes.Reset); //} ch.SendToPager("\r\n\r\n"); ch.SendToPager("&YAvailable colors are:\r\n"); var numColors = 0; foreach (var color in LookupManager.Instance.GetLookups("ValidColors")) { if (numColors % 8 == 0 && numColors != 0) { ch.SendToPager("\r\n"); } ch.PagerPrintf("%s%-10s", color_str(ATTypes.AT_PLAIN, ch), color); numColors++; } ch.SendToPager("\r\n"); show_colorthemes(ch); }
public static string random_ansi(int type) { switch (type) { default: return(EnumerationExtensions.GetEnum <AnsiCodes>(SmaugRandom.Between(1, 15)).GetName()); case 2: var code = EnumerationExtensions.GetEnum <AnsiCodes>(SmaugRandom.Between(1, 15)); return(code.MakeBlink()); case 3: return(EnumerationExtensions.GetEnum <AnsiCodes>(SmaugRandom.Between(16, 31)).GetName()); } }
/*public static void delete_room(RoomTemplate room) * { * RoomTemplate limbo = RepositoryManager.Instance.ROOMS.CastAs<Repository<long, RoomTemplate>>().Get(VnumConstants.ROOM_VNUM_LIMBO); * * CharacterInstance ch; * while ((ch = room.Persons.FirstOrDefault()) != null) * { * if (!ch.IsNpc()) * { * room.RemoveFrom(ch); * limbo.AddTo(ch); * } * else * CharacterInstanceExtensions.Extract(ch, true); * } * * foreach (CharacterInstance och in RepositoryManager.Instance.CHARACTERS.CastAs<Repository<long, CharacterInstance>>().Values) * { * if (och.PreviousRoom == room) * och.PreviousRoom = och.CurrentRoom; * if (och.SubState == CharacterSubStates.RoomDescription * && och.DestinationBuffer == room) * { * ch.SetColor("The room is no more.\r\n", och); * build.stop_editing(och); * och.SubState = CharacterSubStates.None; * och.DestinationBuffer = null; * } * else if (och.SubState == CharacterSubStates.RoomExtra * && och.DestinationBuffer != null) * { * if (room.ExtraDescriptions.Any(e => e == och.DestinationBuffer)) * { * ch.SetColor("The room is no more.\r\n", och); * build.stop_editing(och); * och.SubState = CharacterSubStates.None; * och.DestinationBuffer = null; * } * } * } * * room.Contents.ForEach(handler.extract_obj); * reset.wipe_resets(room); * room.ExtraDescriptions.Clear(); * room.Affects.Clear(); * room.PermanentAffects.Clear(); * room.Exits.ForEach(x => handler.extract_exit(room, x)); * room.MudProgActs.Clear(); * room.MudProgs.Clear(); * RepositoryManager.Instance.ROOMS.CastAs<Repository<long, RoomTemplate>>().Delete(room.Vnum); * * // TODO: Room hash stuff here, but can be removed? * } * * public static void delete_obj(ObjectTemplate obj) * { * RepositoryManager.Instance.OBJECTS.CastAs<Repository<long, ObjectInstance>>().Values.Where(x => x.ObjectIndex == obj).ToList().ForEach(handler.extract_obj); * obj.ExtraDescriptions.Clear(); * obj.Affects.Clear(); * obj.MudProgs.Clear(); * RepositoryManager.Instance.OBJECT_INDEXES.CastAs<Repository<long, ObjectTemplate>>().Delete(obj.Vnum); * * // TODO Object hash stuff here, but can be removed? * } * * public static void delete_mob(MobTemplate mob) * { * foreach (CharacterInstance ch in RepositoryManager.Instance.CHARACTERS.CastAs<Repository<long, CharacterInstance>>().Values) * { * if (ch.MobIndex == mob) * CharacterInstanceExtensions.Extract(ch, true); * else if (ch.SubState == CharacterSubStates.MProgEditing * && ch.DestinationBuffer != null) * { * if (mob.MudProgs.Any(mp => mp == ch.DestinationBuffer)) * { * ch.SetColor("Your victim has departed.\r\n", ch); * build.stop_editing(ch); * ch.DestinationBuffer = null; * ch.SubState = CharacterSubStates.MProgEditing; * } * } * } * * mob.MudProgs.Clear(); * if (mob.Shop != null) * SHOP.Remove(mob.Shop); * if (mob.RepairShop != null) * REPAIR.Remove(mob.RepairShop); * RepositoryManager.Instance.MOBILE_INDEXES.CastAs<Repository<long, MobTemplate>>().Delete(mob.Vnum); * * // TODO Mob hash stuff here, but can be removed? * }*/ public static ExitData make_exit(RoomTemplate room, RoomTemplate to_room, int door) { var newExit = new ExitData(door, "An exit") { Direction = EnumerationExtensions.GetEnum <DirectionTypes>(door), Room_vnum = room.ID, Destination = to_room.ID, Distance = 1, Key = -1 }; var reverseExit = to_room.GetExitTo(LookupConstants.rev_dir[door], room.ID); if (reverseExit != null) { reverseExit.Reverse = newExit.ID; newExit.Reverse = reverseExit.ID; } var broke = room.Exits.Any(exit => door < (int)exit.Direction); if (room.Exits == null) { room.Exits.Add(newExit); } else { if (broke && reverseExit != null) { room.Exits.ToList().Insert(room.Exits.First() == reverseExit ? 0 : 1, newExit); return(newExit); } } return(newExit); }
public static string affect_loc_name(int location) { var type = EnumerationExtensions.GetEnum <ApplyTypes>(location); return(type.GetName()); }
/// <summary> /// Handlers to tell the victim which spell is being effected /// </summary> public static int dispel_casting(AffectData paf, CharacterInstance ch, CharacterInstance victim, int affect, bool dispel) { var isMage = false; var hasDetect = false; if (ch.IsNpc() || ch.CurrentClass == ClassTypes.Mage) { isMage = true; } if (ch.IsAffected(AffectedByTypes.DetectMagic)) { hasDetect = true; } string spell; if (paf != null) { var skill = RepositoryManager.Instance.GetEntity <SkillData>((int)paf.Type); if (skill == null) { return(0); } spell = skill.Name; } else { spell = EnumerationExtensions.GetEnum <AffectedByTypes>(affect).GetName().ToLower(); } ch.SetColor(ATTypes.AT_MAGIC); victim.SetColor(ATTypes.AT_HITME); var buffer = !ch.CanSee(victim) ? "Someone" : (victim.IsNpc() ? victim.ShortDescription : victim.Name).CapitalizeFirst(); if (dispel) { victim.Printf("Your %s vanishes.", spell); if (isMage && hasDetect) { ch.Printf("%s's %s vanishes.", buffer, spell); } else { return(0); } } else { if (isMage && hasDetect) { ch.Printf("%s's %s wavers but holds.", buffer, spell); } else { return(0); } } return(1); }
public static void show_char_to_char_1(CharacterInstance victim, PlayerInstance ch) { if (victim.CanSee(ch) && !ch.IsNpc() && !ch.Act.IsSet((int)PlayerFlags.WizardInvisibility)) { comm.act(ATTypes.AT_ACTION, "$n looks at you.", ch, null, victim, ToTypes.Victim); comm.act(ATTypes.AT_ACTION, victim != ch ? "$n looks at $N." : "$n looks at $mself.", ch, null, victim, ToTypes.NotVictim); } if (!string.IsNullOrEmpty(victim.Description)) { ch.SendTo(victim.CurrentMorph?.Morph != null ? victim.CurrentMorph.Morph.Description : victim.Description); } else { if (victim.CurrentMorph?.Morph != null) { ch.SendTo(victim.CurrentMorph.Morph.Description); } else if (victim.IsNpc()) { comm.act(ATTypes.AT_PLAIN, "You see nothing special about $M.", ch, null, victim, ToTypes.Character); } else if (ch != victim) { comm.act(ATTypes.AT_PLAIN, "$E isn't much to look at...", ch, null, victim, ToTypes.Character); } else { comm.act(ATTypes.AT_PLAIN, "You're not much to look at...", ch, null, null, ToTypes.Character); } } ch.ShowRaceOf(victim); ch.ShowConditionTo(victim); var found = false; for (var i = 0; i < GameConstants.MaximumWearLocations; i++) { var wearLoc = EnumerationExtensions.GetEnum <WearLocations>(i); var obj = victim.GetEquippedItem(wearLoc); if (obj != null && ch.CanSee(obj)) { if (!found) { ch.SendTo("\r\n"); if (victim != ch) { comm.act(ATTypes.AT_PLAIN, "$n is using:", ch, null, victim, ToTypes.Character); } else { comm.act(ATTypes.AT_PLAIN, "You are using:", ch, null, null, ToTypes.Character); } found = true; } if (!victim.IsNpc()) { var race = RepositoryManager.Instance.GetRace(victim.CurrentRace); ch.SendTo(race.WhereNames.ToList()[i]); } else { ch.SendTo(LookupManager.Instance.GetLookup("WhereNames", i)); } ch.SendTo(obj.GetFormattedDescription(ch, true)); ch.SendTo("\r\n"); } } if (ch.IsNpc() || victim == ch) { return; } if (ch.IsImmortal()) { if (victim.IsNpc()) { ch.Printf("\r\nMobile #%d '%s' ", ((MobileInstance)victim).MobIndex.ID, victim.Name); } else { ch.Printf("\r\n%s ", victim.Name); } ch.Printf("is a level %d %s %s.\r\n", victim.Level, RepositoryManager.Instance.GetRace(victim.CurrentRace).Name, RepositoryManager.Instance.GetClass(victim.CurrentClass).Name); } var skill = RepositoryManager.Instance.GetEntity <SkillData>("peek"); if (skill == null) { throw new ObjectNotFoundException("Skill 'peek' not found"); } if (SmaugRandom.D100() < Macros.LEARNED(ch, (int)skill.ID)) { ch.Printf("\r\nYou peek at %s inventory:\r\n", victim.Gender.PossessivePronoun()); show_list_to_char(victim.Carrying.ToList(), ch, true, true); skill.LearnFromSuccess(ch); } else if (ch.PlayerData.GetSkillMastery(skill.ID) > skill.GetMasteryLevel(ch)) { skill.LearnFromFailure(ch); } }