Skip to content

Commit

Permalink
* fix /class not working
Browse files Browse the repository at this point in the history
* HS-1323: DisplayEffect should now work on reactors
  • Loading branch information
baughj committed Apr 21, 2024
1 parent 348b9e7 commit 2e33365
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
8 changes: 5 additions & 3 deletions hybrasyl/ChatCommands/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Hybrasyl.Xml.Objects;
using System;
using System.Linq;
using Hybrasyl.Utility;

namespace Hybrasyl.ChatCommands;

Expand Down Expand Up @@ -306,11 +307,12 @@ internal class ClassCommand : ChatCommand

public new static ChatCommandResult Run(User user, params string[] args)
{
var cls = args[0].ToLower();
var classId = Game.ActiveConfiguration.GetClassId(args[0].ToLower());
var cls = args[0].ToLower().Capitalize();

var classId = Game.ActiveConfiguration.GetClassId(cls);
if (classId == 254) return Fail("I know nothing about that class");
user.Class = (Class) classId;
return Success($"Class changed to {args[0]}");
return Success($"Class changed to {cls}");

}
}
Expand Down
1 change: 0 additions & 1 deletion hybrasyl/Monolith.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
using System.Drawing;
using System.Linq;
using System.Threading;
using Hybrasyl.Xml.Interfaces;
using Creature = Hybrasyl.Xml.Objects.Creature;


Expand Down
2 changes: 1 addition & 1 deletion hybrasyl/Objects/Reactor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public bool VisibleTo(IVisible obj)
var casterObj = Caster?.GetUserObject();
if (casterObj == null) return false;
if (VisibleToOwner && user.Name == Caster.Name) return true;
if (VisibleToGroup && casterObj != null && (casterObj.Group?.Contains(user) ?? false)) return true;
if (VisibleToGroup && (casterObj.Group?.Contains(user) ?? false)) return true;
if (VisibleToCookies.Any(x => user.HasCookie(x))) return true;
if (user.CurrentStatusInfo.Any(x => VisibleToStatuses.Contains(x.Name))) return true;

Expand Down
4 changes: 2 additions & 2 deletions hybrasyl/Scripting/HybrasylWorldObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public void DisplayEffect(ushort effect, short speed = 100, bool global = true)
{
if (Obj is not VisibleObject vo) return;
if (!global && Obj is User u)
u.SendEffect(u.Id, effect, speed);
u.SendEffect(vo.X, vo.Y, effect, speed);
else
vo.Effect(effect, speed);
}
Expand All @@ -467,7 +467,7 @@ public void DisplayEffectAtCoords(short x, short y, ushort effect, short speed =
if (Obj is not VisibleObject vo) return;

if (!global && Obj is User u)
u.SendEffect(x, y, effect, speed);
u.SendEffect(x, y, effect, speed);
else
vo.Effect(x, y, effect, speed);
}
Expand Down
13 changes: 4 additions & 9 deletions hybrasyl/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Hybrasyl.ChatCommands;
using Hybrasyl.Dialogs;

namespace Hybrasyl
{
Expand Down Expand Up @@ -317,15 +319,8 @@ public static class StringExtensions
public static bool Contains(this string source, string toCheck, StringComparison comparision) =>
source?.IndexOf(toCheck, comparision) >= 0;

public static string Capitalize(this string s)
{
if (string.IsNullOrEmpty(s))
return string.Empty;

var a = s.ToCharArray();
a[0] = char.ToUpper(a[0]);
return new string(a);
}
public static string Capitalize(this string s) =>
string.IsNullOrEmpty(s) ? string.Empty : string.Concat(s[0].ToString().ToUpper(), s.AsSpan(1));

public static string Normalize(string key) => Regex.Replace(key.ToLower(), @"\s+", "");
}
Expand Down

0 comments on commit 2e33365

Please sign in to comment.