mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +12:00
Fix sort order in shop inventories
This commit is contained in:
parent
2d234bdc1c
commit
f61811d1b7
3 changed files with 30 additions and 3 deletions
|
@ -53,10 +53,10 @@ namespace HISP.Game.Events
|
||||||
{
|
{
|
||||||
revengeTimeout = new Timer(new TimerCallback(revengeTimedOut), null, REVENGE_TIMEOUT * 60 * 1000, REVENGE_TIMEOUT * 60 * 1000);
|
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
|
// Give Splatterballs
|
||||||
int[] allUsers = Database.GetUsers();
|
int[] allUsers = Database.GetModeratorUsers();
|
||||||
foreach (int userid in allUsers)
|
foreach (int userid in allUsers)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < TOTAL_SPLATTERBALLS; i++)
|
for (int i = 0; i < TOTAL_SPLATTERBALLS; i++)
|
||||||
|
|
|
@ -110,9 +110,17 @@ namespace HISP.Game.Inventory
|
||||||
}
|
}
|
||||||
throw new KeyNotFoundException("random id: " + randomId + " not found in shop 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()
|
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)
|
public bool HasItem(int randomId)
|
||||||
|
|
|
@ -4171,6 +4171,25 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
return userList.ToArray();
|
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)
|
public static void AddItemToInventory(int playerId, ItemInstance instance)
|
||||||
{
|
{
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
|
Loading…
Add table
Reference in a new issue