diff --git a/BSR_Client/Logic.cs b/BSR_Client/Logic.cs index 54d08d4..40f372e 100644 --- a/BSR_Client/Logic.cs +++ b/BSR_Client/Logic.cs @@ -74,6 +74,7 @@ public void RemovePlayer(string player) Players.Remove(player); PlayerTurns.Remove(player); Playerlist.Items.Remove(player); + PlayersAlive--; int it = 0; foreach (Button b in Elements.Players) { @@ -384,8 +385,7 @@ public void SetItemData(Button slot, EItem type) slot.Visibility = type == EItem.Nothing ? Visibility.Hidden : Visibility.Visible; if (type != EItem.Nothing) { - string desc; - if (!ItemDescriptions.TryGetValue(type, out desc)) + if (!ItemDescriptions.TryGetValue(type, out string desc)) desc = "NO DESCRIPTION"; slot.ToolTip = type.ToString() + "\n\n" + desc; } @@ -722,5 +722,18 @@ public bool IsIpValid(string ip) return false; return true; } + + public string GetPlayerFromSlot(int slotId) + { + Button slot = Elements.Players[slotId]; + if (slot == null) + return null; + if (!(slot.Content is Grid)) + return null; + UIElement text = (slot.Content as Grid).Children[1]; + if (!(text is TextBlock)) + return null; + return (text as TextBlock).Text; + } } } \ No newline at end of file diff --git a/BSR_Client/MainWindow.xaml.cs b/BSR_Client/MainWindow.xaml.cs index 80923b9..49791c0 100644 --- a/BSR_Client/MainWindow.xaml.cs +++ b/BSR_Client/MainWindow.xaml.cs @@ -233,13 +233,13 @@ private void Button_Click(object sender, RoutedEventArgs e) { UsedAdrenaline = false; SaveItems(); - string target = Players[int.Parse(action.Replace("Player", "")) - 1]; + string target = GetPlayerFromSlot(int.Parse(action.Replace("Player", "")) - 1); Packet.Create(EPacket.RequestItems).Add(target).Add(MyName).Send(Sync); BlockPlayers(); } if (UsedHeroine || UsedKatana) { - string target = Players[int.Parse(action.Replace("Player", "")) - 1]; + string target = GetPlayerFromSlot(int.Parse(action.Replace("Player", "")) - 1); Packet.Create(EPacket.BlockItemUsage).Add(target).Add(UsedKatana).Send(Sync); if (UsedHeroine) Announce("Gave Heroine to " + target); @@ -249,11 +249,12 @@ private void Button_Click(object sender, RoutedEventArgs e) UsedKatana = false; Shoot.IsEnabled = true; BlockPlayers(); + UnlockItems(); } if (UsedShotgun) { UsedShotgun = false; - string target = Players[int.Parse(action.Replace("Player", "")) - 1]; + string target = GetPlayerFromSlot(int.Parse(action.Replace("Player", "")) - 1); bool you = target == MyName; if (you) Announce("Shooting yourself"); @@ -442,7 +443,7 @@ public void Receive(string message) break; case EPacket.Disconnect: if (Players.Count == 2) - Environment.Exit(0); + ShowEndscreen(); RemovePlayer(data.ReadStr(0)); break; case EPacket.UseItem: diff --git a/BSR_Client/Properties/AssemblyInfo.cs b/BSR_Client/Properties/AssemblyInfo.cs index abcb2f4..b080fa6 100644 --- a/BSR_Client/Properties/AssemblyInfo.cs +++ b/BSR_Client/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.5.0")] -[assembly: AssemblyFileVersion("1.5.0")] +[assembly: AssemblyVersion("1.5.1")] +[assembly: AssemblyFileVersion("1.5.1")]