Skip to content

NotifyServerLevelProcessingComplete GameMessage #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Uchu.World/Handlers/GameMessages/GeneralHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,43 @@ public async Task PlayEmoteHandler(PlayEmoteMessage message, Player player)
await message.Target.OnEmoteReceived.InvokeAsync(message.EmoteId, player);
}
}

[PacketHandler]
public async Task NotifyServerLevelProcessingCompleteHandler(NotifyServerLevelProcessingCompleteMessage message, Player player)
{
await using var ctx = new UchuContext();
await using var cdClient = new CdClientContext();

var character = await ctx.Characters.FirstAsync(c => c.Id == player.Id);

var lookup_val = 0;

foreach (var levelProgressionLookup in cdClient.LevelProgressionLookupTable)
{
if (levelProgressionLookup.RequiredUScore > character.UniverseScore) break;

lookup_val = levelProgressionLookup.Id.Value;
}

Logger.Debug($"Attempting to assign level {lookup_val} to {character.Name} (They are currently level {character.Level})");

if (lookup_val > character.Level)
{
character.Level = lookup_val;
GameObject.Serialize(player);
await ctx.SaveChangesAsync();

player.Zone.BroadcastMessage(new PlayFXEffectMessage
{
Associate = player,
EffectId = 7074,
EffectType = "create",
Name = "levelup_body_glow"
});

player.Zone.BroadcastChatMessage($"{character.Name} has reached Level {character.Level}!");
Logger.Debug($"Assigned level {lookup_val} to {character.Name} (They are now currently level {character.Level})");
}
}
}
}
9 changes: 0 additions & 9 deletions Uchu.World/Objects/GameObjects/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,6 @@ private async Task SetUniverseScoreAsync(long score)

character.UniverseScore = score;

foreach (var levelProgressionLookup in cdClient.LevelProgressionLookupTable)
{
if (levelProgressionLookup.RequiredUScore > score) break;

Debug.Assert(levelProgressionLookup.Id != null, "levelProgressionLookup.Id != null");

character.Level = levelProgressionLookup.Id.Value;
}

Message(new ModifyLegoScoreMessage
{
Associate = this,
Expand Down
11 changes: 11 additions & 0 deletions Uchu.World/Objects/Zone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,17 @@ public void BroadcastMessage(IGameMessage message)
foreach (var player in Players) player.Message(message);
}

public void BroadcastChatMessage(string message, Player author = null)
{
foreach (var player in Players) player.Message(new ChatMessagePacket
{
Message = $"{message}\0",
Sender = author,
IsMythran = author?.GameMasterLevel > 0,
Channel = World.ChatChannel.Public
});
}

#endregion

#region Object Finder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Uchu.World
{
public class NotifyServerLevelProcessingCompleteMessage : ClientGameMessage
{
public override GameMessageId GameMessageId => GameMessageId.NotifyServerLevelProcessingComplete;
}
}