Skip to content

Commit

Permalink
ExpUp for guild checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
kOchirasu committed Jun 10, 2024
1 parent 42b8565 commit 49cf0d8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
10 changes: 7 additions & 3 deletions Maple2.Server.Core/PacketHandlers/LogSendHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ private enum Command : byte {
if (message.Contains("exception")) {
// Read remaining string
string debug = packet.ReadUnicodeString();
SockExceptionInfo exceptionInfo = ErrorParserHelper.Parse(debug);
Logger.Error("[{message}] [SendOp: {sendOp}] [Offset: {offset}] [Hint: {hint}]",
message, exceptionInfo.SendOp, exceptionInfo.Offset, exceptionInfo.Hint);
try {
SockExceptionInfo exceptionInfo = ErrorParserHelper.Parse(debug);
Logger.Error("[{message}] [SendOp: {sendOp}] [Offset: {offset}] [Hint: {hint}]",
message, exceptionInfo.SendOp, exceptionInfo.Offset, exceptionInfo.Hint);
} catch (ArgumentException) {
Logger.Error("[{Message}] {Debug}", message, debug);
}

session.OnError?.Invoke(session, debug);
return;
Expand Down
8 changes: 4 additions & 4 deletions Maple2.Server.Game/Manager/GuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GuildManager : IDisposable {
public long Id => Guild?.Id ?? 0;
public long LeaderId => Guild?.LeaderCharacterId ?? 0;

private GuildTable.Property properties;
public GuildTable.Property Properties { get; private set; }
private readonly CancellationTokenSource tokenSource;

private readonly ILogger logger = Log.Logger.ForContext<GuildManager>();
Expand Down Expand Up @@ -300,16 +300,16 @@ public class GuildManager : IDisposable {
return null;
}

[MemberNotNull(nameof(properties))]
[MemberNotNull(nameof(Properties))]
private void UpdateProperties() {
int experience = Guild?.Experience ?? 0;
KeyValuePair<short, GuildTable.Property> result = session.TableMetadata.GuildTable.Properties
.OrderBy(entry => entry.Value.Experience)
.MinBy(entry => entry.Value.Experience > experience);
properties = result.Value;
Properties = result.Value;

if (Guild != null) {
Guild.Capacity = properties.Capacity;
Guild.Capacity = Properties.Capacity;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Maple2.Server.Game/PacketHandlers/GuildHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ private enum Command : byte {
}

session.Send(GuildPacket.CheckedIn());
// TODO: Send EXP
session.Exp.AddExp(session.Guild.Properties.Experience);
// TODO: Guild coins
// TODO: Achievement 22400001, 22400002
} catch (RpcException) { /* ignored */ }
Expand Down
5 changes: 5 additions & 0 deletions Maple2.Server.Web/Controllers/GuildController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Maple2.Server.Web.Controllers;

public class GuildController {

}
14 changes: 4 additions & 10 deletions Maple2.Server.World/Containers/GuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,9 @@ public class GuildManager : IDisposable {
}

private GuildTable.Property GuildProperty() {
long exp = Guild.Experience;
foreach (GuildTable.Property property in TableMetadata.GuildTable.Properties.Values) {
if (exp > property.Experience) {
continue;
}

return property;
}

return TableMetadata.GuildTable.Properties.Values.First();
return TableMetadata.GuildTable.Properties.Values
.OrderBy(entry => entry.Experience)
.MinBy(entry => entry.Experience > Guild.Experience)
?? TableMetadata.GuildTable.Properties.Values.First();
}
}

0 comments on commit 49cf0d8

Please sign in to comment.