two minor bugfixes

- the remaining turn time now properly is zero when there are no users in the queue
- the chat history is now in the correct order
This commit is contained in:
Elijah R 2024-01-03 19:38:24 -05:00
parent 48e2ece306
commit 8d809c66ba
3 changed files with 6 additions and 2 deletions

View file

@ -56,6 +56,9 @@ public class TurnQueue
if (!queue.TryPeek(out var u)) return; if (!queue.TryPeek(out var u)) return;
Utilities.Log(LogLevel.DEBUG, $"It is now {u.Username}'s turn"); Utilities.Log(LogLevel.DEBUG, $"It is now {u.Username}'s turn");
currentTurnRemainingTime = turnTime; currentTurnRemainingTime = turnTime;
} else {
timer.Stop();
currentTurnRemainingTime = 0;
} }
SendTurnUpdate(); SendTurnUpdate();
} }
@ -116,6 +119,7 @@ public class TurnQueue
if (queue.Count == 0) if (queue.Count == 0)
{ {
timer.Stop(); timer.Stop();
currentTurnRemainingTime = 0;
} }
SendTurnUpdate(); SendTurnUpdate();
} }

View file

@ -166,7 +166,7 @@ public class User
await this.vm.AddUser(this); await this.vm.AddUser(this);
List<string> chatmsg = new(); List<string> chatmsg = new();
chatmsg.Add("chat"); chatmsg.Add("chat");
foreach (ChatMessage msg in vm.ChatHistory) foreach (ChatMessage msg in vm.ChatHistory.ToArray())
{ {
chatmsg.Add(msg.Username); chatmsg.Add(msg.Username);
chatmsg.Add(msg.Message); chatmsg.Add(msg.Message);

View file

@ -160,7 +160,7 @@ public class VM
else else
await u.SendChat(user.Username!, messageSanitized); await u.SendChat(user.Username!, messageSanitized);
} }
ChatHistory.PushFront(new ChatMessage {Username = user.Username!, Message = messageSanitized}); ChatHistory.PushBack(new ChatMessage {Username = user.Username!, Message = messageSanitized});
} }
public async Task SendMouse(int x, int y, int mask) public async Task SendMouse(int x, int y, int mask)