Fix sort order in shop inventories

This commit is contained in:
Bluzume 2021-11-09 20:24:57 -05:00
parent 2d234bdc1c
commit f61811d1b7
3 changed files with 30 additions and 3 deletions

View file

@ -53,10 +53,10 @@ namespace HISP.Game.Events
{
revengeTimeout = new Timer(new TimerCallback(revengeTimedOut), null, REVENGE_TIMEOUT * 60 * 1000, REVENGE_TIMEOUT * 60 * 1000);
int TOTAL_SPLATTERBALLS = 8; // I dont know the actural amount t-t
int TOTAL_SPLATTERBALLS = 50; // Thanks MayDay!
// Give Splatterballs
int[] allUsers = Database.GetUsers();
int[] allUsers = Database.GetModeratorUsers();
foreach (int userid in allUsers)
{
for (int i = 0; i < TOTAL_SPLATTERBALLS; i++)

View file

@ -110,9 +110,17 @@ namespace HISP.Game.Inventory
}
throw new KeyNotFoundException("random id: " + randomId + " not found in shop inventory");
}
public int GetSortPos(InventoryItem item)
{
int bias = 1000;
int sortBy = Item.GetItemById(item.ItemId).SortBy;
if (item.Infinite)
sortBy += bias;
return sortBy;
}
public InventoryItem[] GetItemList()
{
return inventoryItems.OrderBy(o => o.ItemInstances[0].GetItemInfo().SortBy).OrderBy(o => o.Infinite).ToArray();
return inventoryItems.OrderBy(o => GetSortPos(o)).ToArray();
}
public bool HasItem(int randomId)

View file

@ -4171,6 +4171,25 @@ namespace HISP.Server
}
return userList.ToArray();
}
public static int[] GetModeratorUsers()
{
List<int> userList = new List<int>();
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT id FROM Users WHERE Moderator=\"YES\" OR Admin=\"YES\"";
MySqlDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read())
{
userList.Add(reader.GetInt32(0));
}
}
return userList.ToArray();
}
public static void AddItemToInventory(int playerId, ItemInstance instance)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))