Add silly tile debug feature

This commit is contained in:
Li 2022-11-15 04:07:40 +13:00
parent 7f635d5fdd
commit 393dc147da
8 changed files with 108 additions and 19 deletions

View file

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.30.0")] [assembly: AssemblyVersion("1.8.32.0")]
[assembly: AssemblyFileVersion("1.8.30.0")] [assembly: AssemblyFileVersion("1.8.32.0")]

View file

@ -1,5 +1,5 @@
Package: hisp Package: hisp
Version: 1.8.30 Version: 1.8.32
Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev
Maintainer: Li Maintainer: Li
Homepage: https://islehorse.com Homepage: https://islehorse.com

View file

@ -1,4 +1,6 @@
using HISP.Game; using HISP.Game;
using HISP.Game.Horse;
using HISP.Game.Items;
using HISP.Player; using HISP.Player;
using HISP.Security; using HISP.Security;
using HISP.Server; using HISP.Server;
@ -104,6 +106,17 @@ namespace HISP.Tests.UnitTests
user.Hunger = -8000; user.Hunger = -8000;
results.Add(Test("HungerMinimumEnforcement", user.Hunger, 0)); results.Add(Test("HungerMinimumEnforcement", user.Hunger, 0));
user.Thirst = 8000;
results.Add(Test("ThirstMaximumEnforcement", user.Thirst, 1000));
user.Thirst = -8000;
results.Add(Test("ThirstMinimumEnforcement", user.Thirst, 0));
user.Tiredness = 8000;
results.Add(Test("TirednessMaximumEnforcement", user.Tiredness, 1000));
user.Tiredness = -8000;
results.Add(Test("TirednessMinimumEnforcement", user.Tiredness, 0));
user.BankMoney = 9999999999.9999; user.BankMoney = 9999999999.9999;
user.BankMoney += 1000.0; user.BankMoney += 1000.0;
results.Add(Test("BankMoneyMaximumEnforcement", user.BankMoney, 9999999999.9999)); results.Add(Test("BankMoneyMaximumEnforcement", user.BankMoney, 9999999999.9999));
@ -154,6 +167,72 @@ namespace HISP.Tests.UnitTests
results.Add(Test("GenerateSecCode", gotSecCode.SequenceEqual(expectedSecCodeResult), true)); results.Add(Test("GenerateSecCode", gotSecCode.SequenceEqual(expectedSecCodeResult), true));
// Check max horses count
user.Subscribed = false;
results.Add(Test("UnsubbedMaxHorses", user.MaxHorses, 7));
user.Subscribed = true;
results.Add(Test("SubbedMaxHorses", user.MaxHorses, 11));
HorseInstance horse = new HorseInstance(HorseInfo.GetBreedById(170));
horse.BasicStats.Thirst = 0;
horse.BasicStats.Hunger = 0;
int horseId = horse.RandomId;
user.HorseInventory.AddHorse(horse);
/*
* Test Ranches
*/
// Give player ranch id 10
Ranch.GetRanchById(37).OwnerId = user.Id;
// Check ranch is now owned by that player, and propagates to user object.
results.Add(Test("GiveRanchTest", user.OwnedRanch.Id, 37));
results.Add(Test("HaveDorothyShoes", user.Inventory.HasItemId(Item.DorothyShoes), true));
// Ranch upgrade test
foreach(Ranch.RanchUpgrade upgrade in Ranch.RanchUpgrade.RanchUpgrades)
{
int id = upgrade.Id;
results.Add(Test("RanchUpgradeLevel" + id, user.OwnedRanch.UpgradedLevel, id));
user.OwnedRanch.UpgradedLevel = id;
}
// Test swf
results.Add(Test("RanchSwfMine", user.OwnedRanch.GetSwf(true), "ranchviewer.swf?H=10&B1=11&B2=&B3=&B4=&B5=&B6=&B7=&B8=&B9=&B10=&B11=&B12=&B13=&B14=&B15=&B16=&MINE=1"));
results.Add(Test("RanchSwf", user.OwnedRanch.GetSwf(false), "ranchviewer.swf?H=10&B1=11&B2=&B3=&B4=&B5=&B6=&B7=&B8=&B9=&B10=&B11=&B12=&B13=&B14=&B15=&B16="));
// Test Ranch Building Functionality
// Test Barn
user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(1)); // Barn
results.Add(Test("RanchBarnMaxHorses", user.MaxHorses, 11 + 4));
// Test Water Well
user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(2)); // Water Well
user.Teleport(user.OwnedRanch.X, user.OwnedRanch.Y);
results.Add(Test("RanchWaterWellWatering", user.HorseInventory.GetHorseById(horseId).BasicStats.Thirst, 1000));
// Test Grain Silo
user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(3)); // Grain Silo
user.Teleport(user.OwnedRanch.X, user.OwnedRanch.Y);
results.Add(Test("RanchGrainSiloFeeding", user.HorseInventory.GetHorseById(horseId).BasicStats.Hunger, 1000));
// Set building id 0 to a big barn
user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(10)); // Big Barn
results.Add(Test("RanchBigBarnMaxHorses", user.MaxHorses, 11 + 8));
// Set building id 0 to a gold barn
user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(11)); // Gold Barn
results.Add(Test("RanchGoldBarnMaxHorses", user.MaxHorses, 11 + 12));
foreach (bool result in results) foreach (bool result in results)
if (!result) if (!result)

View file

@ -30,10 +30,10 @@ namespace HISP.Game
} }
public static RanchUpgrade GetRanchUpgradeById(int id) public static RanchUpgrade GetRanchUpgradeById(int id)
{ {
foreach (RanchUpgrade rachUpgrade in RanchUpgrades) foreach (RanchUpgrade ranchUpgrade in RanchUpgrades)
{ {
if (rachUpgrade.Id == id) if (ranchUpgrade.Id == id)
return rachUpgrade; return ranchUpgrade;
} }
throw new KeyNotFoundException("No ranch found."); throw new KeyNotFoundException("No ranch found.");
} }
@ -168,7 +168,7 @@ namespace HISP.Game
} }
else else
{ {
if(Database.IsRanchOwned(this.Id)) if (Database.IsRanchOwned(this.Id))
{ {
Database.SetRanchOwner(this.Id, ownerId); Database.SetRanchOwner(this.Id, ownerId);
removeDorothyShoes(ownerId); removeDorothyShoes(ownerId);
@ -180,6 +180,17 @@ namespace HISP.Game
} }
} }
if (GameServer.IsUserOnline(value))
{
User user = GameServer.GetUserById(value);
user.OwnedRanch = this;
user.Inventory.AddIgnoringFull(new ItemInstance(Item.DorothyShoes));
}
else
{
Database.AddItemToInventory(value, new ItemInstance(Item.DorothyShoes));
}
ownerId = value; ownerId = value;
} }
} }

View file

@ -284,10 +284,10 @@ namespace HISP.Player
if (Administrator) if (Administrator)
return true; return true;
int Timestamp = Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()); int timestamp = Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds());
if(Timestamp > subscribedUntil && subscribed) // sub expired. if(timestamp > subscribedUntil && subscribed) // sub expired.
{ {
Logger.InfoPrint(Username + "'s Subscription expired. (timestamp now: " + Timestamp + " exp date: " + subscribedUntil+" )"); Logger.InfoPrint(Username + "'s Subscription expired. (timestamp now: " + timestamp + " exp date: " + subscribedUntil+" )");
Database.SetUserSubscriptionStatus(this.Id, false); Database.SetUserSubscriptionStatus(this.Id, false);
subscribed = false; subscribed = false;
} }

View file

@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.8.30.0")] [assembly: AssemblyVersion("1.8.32.0")]
[assembly: AssemblyFileVersion("1.8.30.0")] [assembly: AssemblyFileVersion("1.8.32.0")]

View file

@ -5680,8 +5680,6 @@ namespace HISP.Server
sender.LoggedinUser.TakeMoney(ranch.Value); sender.LoggedinUser.TakeMoney(ranch.Value);
ranch.OwnerId = sender.LoggedinUser.Id; ranch.OwnerId = sender.LoggedinUser.Id;
ranch.InvestedMoney += ranch.Value; ranch.InvestedMoney += ranch.Value;
sender.LoggedinUser.OwnedRanch = ranch;
sender.LoggedinUser.Inventory.AddIgnoringFull(new ItemInstance(Item.DorothyShoes));
UpdateAreaForAll(sender.LoggedinUser.X, sender.LoggedinUser.Y, true); UpdateAreaForAll(sender.LoggedinUser.X, sender.LoggedinUser.Y, true);
} }
@ -6124,9 +6122,10 @@ namespace HISP.Server
} }
returnedMsg = Messages.FormatPlayerHereMessage(usernameStr); returnedMsg = Messages.FormatPlayerHereMessage(usernameStr);
} }
// TODO: REMEMBER TO CHANGE THIS BACK
byte[] tileInfoPacket = PacketBuilder.CreateTileClickInfo(returnedMsg); //byte[] tileInfoPacket = PacketBuilder.CreateTileClickInfo(returnedMsg);
byte[] tileInfoPacket = PacketBuilder.CreateTileClickInfo("ground: "+Map.GetTileId(x, y, false)+ ", overlay: "+ Map.GetTileId(x, y, true))
sender.SendPacket(tileInfoPacket); sender.SendPacket(tileInfoPacket);
} }
} }

View file

@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.8.30.0")] [assembly: AssemblyVersion("1.8.32.0")]
[assembly: AssemblyFileVersion("1.8.30.0")] [assembly: AssemblyFileVersion("1.8.32.0")]