mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 12:19:15 +12:00
Add ranches.
This commit is contained in:
parent
2e713f4fd5
commit
9f592fb51b
14 changed files with 918 additions and 159 deletions
|
@ -17,16 +17,6 @@ namespace HISP.Game.Inventory
|
|||
}
|
||||
}
|
||||
|
||||
public int MaxHorses
|
||||
{
|
||||
get
|
||||
{
|
||||
if (baseUser.Subscribed)
|
||||
return 11;
|
||||
|
||||
return 7; // will change when ranches are implemented.
|
||||
}
|
||||
}
|
||||
public HorseInventory(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
|
@ -35,7 +25,7 @@ namespace HISP.Game.Inventory
|
|||
|
||||
public void AddHorse(HorseInstance horse, bool addToDb=true)
|
||||
{
|
||||
if (HorseList.Length + 1 > MaxHorses)
|
||||
if (HorseList.Length + 1 > baseUser.MaxHorses)
|
||||
throw new InventoryFullException();
|
||||
|
||||
horse.Owner = baseUser.Id;
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace HISP.Game.Inventory
|
|||
throw new InventoryMaxStackException();
|
||||
}
|
||||
}
|
||||
else if (Count >= Messages.DefaultInventoryMax)
|
||||
else if (Count >= BaseUser.MaxItems)
|
||||
{
|
||||
throw new InventoryFullException();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,12 @@ namespace HISP.Game
|
|||
else if (overlay && Treasure.IsTilePotOfGold(x, y))
|
||||
return 186; // Pot of Gold tile.
|
||||
else if (overlay && Ranch.IsRanchHere(x, y))
|
||||
return 170 + Ranch.GetRanchAt(x, y).UpgradedLevel; // Ranch Tile + Upgraded amount
|
||||
{
|
||||
int upgradeLevel = Ranch.GetRanchAt(x, y).UpgradedLevel;
|
||||
if (upgradeLevel > 7)
|
||||
upgradeLevel = 7;
|
||||
return 170 + upgradeLevel;
|
||||
}
|
||||
else if (overlay)
|
||||
return oMapData[pos];
|
||||
else if (!overlay)
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace HISP.Game
|
|||
public class Messages
|
||||
{
|
||||
public static int RequiredChatViolations;
|
||||
public static int DefaultInventoryMax;
|
||||
|
||||
// Mod isle
|
||||
public static string ModIsleMessage;
|
||||
|
@ -17,6 +16,8 @@ namespace HISP.Game
|
|||
public static string RanchUnownedRanchFormat;
|
||||
public static string RanchYouCouldPurchaseThisRanch;
|
||||
public static string RanchYouAllreadyOwnARanch;
|
||||
public static string RanchSubscribersOnly;
|
||||
public static string RanchDescriptionOthersFormat;
|
||||
public static string RanchUnownedRanchClicked;
|
||||
public static string RanchClickMessageFormat;
|
||||
|
||||
|
@ -29,8 +30,11 @@ namespace HISP.Game
|
|||
public static string RanchDefaultRanchTitle;
|
||||
|
||||
public static string RanchEditDescriptionMetaFormat;
|
||||
public static string RanchYourRanchMetaFormat;
|
||||
public static string RanchDescriptionFormat;
|
||||
public static string RanchTitleFormat;
|
||||
public static string RanchYourDescriptionFormat;
|
||||
|
||||
public static string RanchSellAreYouSure;
|
||||
public static string RanchSoldFormat;
|
||||
|
||||
// Ranch: Build.
|
||||
public static string RanchCanBuildOneOfTheFollowingInThisSpot;
|
||||
|
@ -654,8 +658,15 @@ namespace HISP.Game
|
|||
|
||||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatUnownedRanchMeta(int price)
|
||||
public static string FormatRanchDescOthers(string description)
|
||||
{
|
||||
return RanchDescriptionOthersFormat.Replace("%DESCRIPTION%", description);
|
||||
}
|
||||
public static string FormatRanchSoldMessage(int price)
|
||||
{
|
||||
return RanchSoldFormat.Replace("%PRICE%", price.ToString("N0"));
|
||||
}
|
||||
public static string FormatRanchUnownedMeta(int price)
|
||||
{
|
||||
return RanchUnownedRanchFormat.Replace("%PRICE%", price.ToString("N0"));
|
||||
}
|
||||
|
@ -673,11 +684,11 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatRanchTitle(string username, string title)
|
||||
{
|
||||
return RanchYourRanchMetaFormat.Replace("%USERNAME%", username).Replace("%TITLE%", title);
|
||||
return RanchTitleFormat.Replace("%USERNAME%", username).Replace("%TITLE%", title);
|
||||
}
|
||||
public static string FormatRanchDescription(string description)
|
||||
public static string FormatRanchYoursDescription(string description)
|
||||
{
|
||||
return RanchDescriptionFormat.Replace("%DESCRIPTION%", description);
|
||||
return RanchYourDescriptionFormat.Replace("%DESCRIPTION%", description);
|
||||
}
|
||||
public static string FormatBuildingEntry(string name, int price, int buildingId)
|
||||
{
|
||||
|
@ -687,9 +698,9 @@ namespace HISP.Game
|
|||
{
|
||||
return RanchBuildingInformationFormat.Replace("%BUILDINGNAME%", name).Replace("%BUILINGDESCRIPTION%", description);
|
||||
}
|
||||
public static string FormatBuildingPlaced(string name, int buildingId, int price)
|
||||
public static string FormatBuildingAlreadyPlaced(string name, int buildingId, int price)
|
||||
{
|
||||
return RanchBuildingAlreadyHere.Replace("%BUILDINGNAME%", name).Replace("%BUILDINGID%", buildingId.ToString()).Replace("%PRICE%", price.ToString());
|
||||
return RanchBuildingAlreadyHere.Replace("%BUILDINGNAME%", name).Replace("%BUILDINGID%", buildingId.ToString()).Replace("%PRICE%", price.ToString("N0"));
|
||||
}
|
||||
public static string FormatBuildingTornDown(int price)
|
||||
{
|
||||
|
|
|
@ -1024,8 +1024,67 @@ namespace HISP.Game
|
|||
|
||||
return message;
|
||||
}
|
||||
public static string BuildRanchEdit(Ranch ranch)
|
||||
{
|
||||
return Messages.FormatRanchEditDescriptonMeta(ranch.Title, ranch.Description) + Messages.BackToMap + Messages.MetaTerminator;
|
||||
}
|
||||
public static string BuildRanchSellConfirmation()
|
||||
{
|
||||
return Messages.RanchSellAreYouSure + Messages.BackToMap + Messages.MetaTerminator;
|
||||
}
|
||||
public static string BuildRanchUpgrade(Ranch ranch)
|
||||
{
|
||||
string message = "";
|
||||
Ranch.RanchUpgrade currentUpgrade = ranch.GetRanchUpgrade();
|
||||
bool canUpgrade = Ranch.RanchUpgrade.RanchUpgradeExists(currentUpgrade.Id + 1);
|
||||
|
||||
string upgrade = "";
|
||||
if(canUpgrade)
|
||||
{
|
||||
Ranch.RanchUpgrade nextUpgrade = Ranch.RanchUpgrade.GetRanchUpgradeById(currentUpgrade.Id + 1);
|
||||
upgrade = Messages.FormatNextUpgrade(nextUpgrade.Title, nextUpgrade.Cost);
|
||||
}
|
||||
message += Messages.FormatCurrentUpgrade(currentUpgrade.Title, currentUpgrade.Description, upgrade, ranch.GetSellPrice());
|
||||
message += Messages.BackToMap;
|
||||
return message;
|
||||
}
|
||||
public static string BuildRanchBuildingsAvalible(Ranch ranch, int slot)
|
||||
{
|
||||
string message = "";
|
||||
if(ranch.GetBuilding(slot-1) != null)
|
||||
{
|
||||
Ranch.RanchBuilding building = ranch.GetBuilding(slot - 1);
|
||||
message += Messages.FormatBuildingAlreadyPlaced(building.Title, building.Id, building.GetTeardownPrice());
|
||||
}
|
||||
else
|
||||
{
|
||||
message += Messages.RanchCanBuildOneOfTheFollowingInThisSpot;
|
||||
foreach (Ranch.RanchBuilding building in Ranch.RanchBuilding.RanchBuildings)
|
||||
{
|
||||
message += Messages.FormatBuildingEntry(building.Title, building.Cost, building.Id);
|
||||
}
|
||||
}
|
||||
|
||||
message += Messages.BackToMap;
|
||||
return message;
|
||||
}
|
||||
public static string BuildRanchBuilding(Ranch ranch, Ranch.RanchUpgrade upgrade)
|
||||
{
|
||||
string message = "";
|
||||
message += Messages.FormatViewBuilding(upgrade.Title, upgrade.Description);
|
||||
message += Messages.BackToMap;
|
||||
return message;
|
||||
}
|
||||
public static string BuildRanchBuilding(Ranch ranch, Ranch.RanchBuilding upgrade)
|
||||
{
|
||||
string message = "";
|
||||
message += Messages.FormatViewBuilding(upgrade.Title, upgrade.Description);
|
||||
message += Messages.BackToMap;
|
||||
return message;
|
||||
}
|
||||
private static string buildRanch(User user, int ranchId)
|
||||
{
|
||||
|
||||
string message = "";
|
||||
Ranch ranch = Ranch.GetRanchById(ranchId);
|
||||
bool mine = (ranch.OwnerId == user.Id);
|
||||
|
@ -1036,17 +1095,77 @@ namespace HISP.Game
|
|||
|
||||
if (mine) // This is My DS.
|
||||
{
|
||||
user.DoRanchActions();
|
||||
|
||||
string title = ranch.Title;
|
||||
if (title == "" || title == null)
|
||||
title = Messages.RanchDefaultRanchTitle;
|
||||
message += Messages.FormatRanchTitle(Database.GetUsername(ranch.OwnerId), title);
|
||||
message += Messages.BuildingRestHere;
|
||||
|
||||
int numbBarns = ranch.GetBuildingCount(1);
|
||||
int numbWaterWell = ranch.GetBuildingCount(2);
|
||||
int numbGrainSilo = ranch.GetBuildingCount(3);
|
||||
int numbTrainingPen = ranch.GetBuildingCount(6);
|
||||
int numbWagon = ranch.GetBuildingCount(7);
|
||||
int numbWindmill = ranch.GetBuildingCount(8);
|
||||
int numbGarden = ranch.GetBuildingCount(9);
|
||||
int numbBigBarn = ranch.GetBuildingCount(10);
|
||||
int numbGoldBarn = ranch.GetBuildingCount(11);
|
||||
|
||||
|
||||
if (numbBarns > 0)
|
||||
message += Messages.FormatBuildingBarn(numbBarns, numbBarns * 4);
|
||||
if (numbBigBarn > 0)
|
||||
message += Messages.FormatBuildingBarn(numbBigBarn, numbBigBarn * 8);
|
||||
if (numbGoldBarn > 0)
|
||||
message += Messages.FormatBuildingBarn(numbGoldBarn, numbGoldBarn * 12);
|
||||
if (numbBarns > 0 || numbBigBarn > 0 || numbGoldBarn > 0)
|
||||
message += Messages.RanchHorsesFullyRested;
|
||||
if (numbWaterWell > 0)
|
||||
message += Messages.BuildingWaterWell;
|
||||
if (numbGrainSilo > 0)
|
||||
message += Messages.BuildingGrainSilo;
|
||||
if (numbWindmill > 0)
|
||||
message += Messages.FormatBuildingWindmill(numbWindmill, 5000 * numbWindmill);
|
||||
if (numbGarden > 0)
|
||||
message += Messages.BuildingVegatableGarden;
|
||||
if (numbWagon > 0)
|
||||
message += Messages.BuildingWagon;
|
||||
if (numbTrainingPen > 0)
|
||||
message += Messages.BuildingTrainingPen;
|
||||
|
||||
message += Messages.FormatRanchYoursDescription(ranch.Description);
|
||||
}
|
||||
else if(ranch.OwnerId == -1) // No mans sky
|
||||
{
|
||||
|
||||
message += Messages.FormatRanchUnownedMeta(ranch.Value);
|
||||
if (user.OwnedRanch == null)
|
||||
{
|
||||
if (user.Subscribed)
|
||||
message += Messages.RanchYouCouldPurchaseThisRanch;
|
||||
else
|
||||
message += Messages.RanchSubscribersOnly;
|
||||
}
|
||||
else
|
||||
{
|
||||
message += Messages.RanchYouAllreadyOwnARanch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string title = ranch.Title;
|
||||
if (title == "" || title == null)
|
||||
title = Messages.RanchDefaultRanchTitle;
|
||||
|
||||
message += Messages.FormatRanchTitle(Database.GetUsername(ranch.OwnerId), title);
|
||||
message += Messages.FormatRanchDescOthers(ranch.Description);
|
||||
}
|
||||
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
private static string buildWorkshop(User user)
|
||||
|
@ -1290,8 +1409,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string BuildHorseInventory(User user)
|
||||
{
|
||||
// TODO: calculate max number based on ranch barns owned.
|
||||
string message = Messages.FormatHorseHeader(user.HorseInventory.MaxHorses, user.HorseInventory.HorseList.Length);
|
||||
string message = Messages.FormatHorseHeader(user.MaxHorses, user.HorseInventory.HorseList.Length);
|
||||
|
||||
message += buildHorseList(user);
|
||||
message += Messages.ViewBaiscStats;
|
||||
|
@ -1322,7 +1440,7 @@ namespace HISP.Game
|
|||
public static string BuildInventoryInfo(PlayerInventory inv)
|
||||
{
|
||||
string message = "";
|
||||
message += Messages.FormatPlayerInventoryHeaderMeta(inv.Count, Messages.DefaultInventoryMax);
|
||||
message += Messages.FormatPlayerInventoryHeaderMeta(inv.Count, inv.BaseUser.MaxItems);
|
||||
InventoryItem[] items = inv.GetItemList();
|
||||
foreach(InventoryItem item in items)
|
||||
{
|
||||
|
@ -1335,7 +1453,7 @@ namespace HISP.Game
|
|||
message += Messages.FormatPlayerInventoryItemMeta(itemInfo.IconId, item.ItemInstances.Count, title);
|
||||
|
||||
int randomId = item.ItemInstances[0].RandomId;
|
||||
if (itemInfo.Type != "QUEST" && itemInfo.Type != "TEXT" && World.CanDropItems(inv.BaseUser.X, inv.BaseUser.Y))
|
||||
if (itemInfo.Type != "QUEST" && itemInfo.Type != "TEXT" && !(itemInfo.Id == Item.Present || itemInfo.Id == Item.DorothyShoes || itemInfo.Id == Item.Telescope) && World.CanDropItems(inv.BaseUser.X, inv.BaseUser.Y))
|
||||
message += Messages.FormatItemDropButton(randomId);
|
||||
|
||||
if (itemInfo.Id == Item.Present || itemInfo.Id == Item.DorothyShoes || itemInfo.Id == Item.Telescope)
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
using HISP.Server;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Game.Items;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
|
@ -59,6 +63,11 @@ namespace HISP.Game
|
|||
}
|
||||
throw new KeyNotFoundException("No ranch found.");
|
||||
}
|
||||
|
||||
public int GetTeardownPrice()
|
||||
{
|
||||
return (int)Math.Round((float)this.Cost / (100 / 35.0));
|
||||
}
|
||||
}
|
||||
public static List<Ranch> Ranches = new List<Ranch>();
|
||||
|
||||
|
@ -73,39 +82,81 @@ namespace HISP.Game
|
|||
private string title;
|
||||
private string description;
|
||||
|
||||
public int GetSellPrice()
|
||||
{
|
||||
return (int)Math.Round((float)this.InvestedMoney / (100 / 75.0));
|
||||
}
|
||||
private void removeDorothyShoes(int Id)
|
||||
{
|
||||
if (Id == -1)
|
||||
return;
|
||||
|
||||
if(GameServer.IsUserOnline(Id))
|
||||
{
|
||||
User user = GameServer.GetUserById(Id);
|
||||
user.OwnedRanch = null;
|
||||
InventoryItem items = user.Inventory.GetItemByItemId(Item.DorothyShoes);
|
||||
foreach (ItemInstance itm in items.ItemInstances.ToArray())
|
||||
{
|
||||
user.Inventory.Remove(itm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Database.RemoveAllItemTypesFromPlayerInventory(this.Id, Item.DorothyShoes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void deleteRanch()
|
||||
{
|
||||
Database.DeleteRanchOwner(this.Id);
|
||||
removeDorothyShoes(this.ownerId);
|
||||
resetRanch();
|
||||
}
|
||||
private void resetRanch()
|
||||
{
|
||||
title = "";
|
||||
description = "";
|
||||
investedMoney = 0;
|
||||
upgradedLevel = 0;
|
||||
ownerId = -1;
|
||||
for (int i = 0; i < 16; i++)
|
||||
buildings[i] = null;
|
||||
}
|
||||
public int OwnerId
|
||||
{
|
||||
get
|
||||
{
|
||||
if(ownerId != -1)
|
||||
{
|
||||
if (!Database.IsUserSubscribed(ownerId) && !Database.IsUserAdmin(ownerId))
|
||||
deleteRanch();
|
||||
}
|
||||
return ownerId;
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
ownerId = value;
|
||||
|
||||
if (value == -1)
|
||||
{
|
||||
Database.DeleteRanchOwner(this.Id);
|
||||
deleteRanch();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Database.IsRanchOwned(this.Id))
|
||||
{
|
||||
Database.SetRanchOwner(this.Id, ownerId);
|
||||
removeDorothyShoes(ownerId);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = "";
|
||||
description = "";
|
||||
investedMoney = 0;
|
||||
upgradedLevel = 0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
buildings[i] = null;
|
||||
|
||||
Database.AddRanch(this.Id, OwnerId, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
resetRanch();
|
||||
Database.AddRanch(this.Id, value, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
ownerId = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,8 +180,8 @@ namespace HISP.Game
|
|||
}
|
||||
set
|
||||
{
|
||||
investedMoney = 0;
|
||||
Database.SetRanchUpgradeLevel(Id, value);
|
||||
investedMoney = value;
|
||||
Database.SetRanchInvestment(Id, value);
|
||||
}
|
||||
}
|
||||
public string Title
|
||||
|
@ -160,89 +211,101 @@ namespace HISP.Game
|
|||
|
||||
|
||||
private RanchBuilding[] buildings = new RanchBuilding[16];
|
||||
|
||||
public RanchBuilding[] Buildings
|
||||
public int GetBuildingCount(int buildingId)
|
||||
{
|
||||
get
|
||||
int count = 0;
|
||||
foreach(RanchBuilding building in buildings)
|
||||
{
|
||||
return buildings;
|
||||
}
|
||||
set
|
||||
{
|
||||
buildings = value;
|
||||
if (buildings[0] != null)
|
||||
Database.SetRanchBuilding1(this.Id, buildings[0].Id);
|
||||
else
|
||||
Database.SetRanchBuilding1(this.Id, 0);
|
||||
if (buildings[1] != null)
|
||||
Database.SetRanchBuilding2(this.Id, buildings[1].Id);
|
||||
else
|
||||
Database.SetRanchBuilding2(this.Id, 0);
|
||||
if (buildings[2] != null)
|
||||
Database.SetRanchBuilding3(this.Id, buildings[2].Id);
|
||||
else
|
||||
Database.SetRanchBuilding3(this.Id, 0);
|
||||
if (buildings[3] != null)
|
||||
Database.SetRanchBuilding4(this.Id, buildings[3].Id);
|
||||
else
|
||||
Database.SetRanchBuilding4(this.Id, 0);
|
||||
if (buildings[4] != null)
|
||||
Database.SetRanchBuilding5(this.Id, buildings[4].Id);
|
||||
else
|
||||
Database.SetRanchBuilding5(this.Id, 0);
|
||||
if (buildings[5] != null)
|
||||
Database.SetRanchBuilding6(this.Id, buildings[5].Id);
|
||||
else
|
||||
Database.SetRanchBuilding6(this.Id, 0);
|
||||
if (buildings[6] != null)
|
||||
Database.SetRanchBuilding7(this.Id, buildings[6].Id);
|
||||
else
|
||||
Database.SetRanchBuilding7(this.Id, 0);
|
||||
if (buildings[7] != null)
|
||||
Database.SetRanchBuilding8(this.Id, buildings[7].Id);
|
||||
else
|
||||
Database.SetRanchBuilding8(this.Id, 0);
|
||||
if (buildings[8] != null)
|
||||
Database.SetRanchBuilding9(this.Id, buildings[8].Id);
|
||||
else
|
||||
Database.SetRanchBuilding9(this.Id, 0);
|
||||
if (buildings[9] != null)
|
||||
Database.SetRanchBuilding10(this.Id, buildings[9].Id);
|
||||
else
|
||||
Database.SetRanchBuilding10(this.Id, 0);
|
||||
if (buildings[10] != null)
|
||||
Database.SetRanchBuilding11(this.Id, buildings[10].Id);
|
||||
else
|
||||
Database.SetRanchBuilding11(this.Id, 0);
|
||||
if (buildings[11] != null)
|
||||
Database.SetRanchBuilding12(this.Id, buildings[11].Id);
|
||||
else
|
||||
Database.SetRanchBuilding12(this.Id, 0);
|
||||
if (buildings[12] != null)
|
||||
Database.SetRanchBuilding13(this.Id, buildings[12].Id);
|
||||
else
|
||||
Database.SetRanchBuilding13(this.Id, 0);
|
||||
if (buildings[13] != null)
|
||||
Database.SetRanchBuilding14(this.Id, buildings[13].Id);
|
||||
else
|
||||
Database.SetRanchBuilding14(this.Id, 0);
|
||||
if (buildings[14] != null)
|
||||
Database.SetRanchBuilding15(this.Id, buildings[14].Id);
|
||||
else
|
||||
Database.SetRanchBuilding15(this.Id, 0);
|
||||
if (buildings[15] != null)
|
||||
Database.SetRanchBuilding16(this.Id, buildings[15].Id);
|
||||
else
|
||||
Database.SetRanchBuilding16(this.Id, 0);
|
||||
if(building != null)
|
||||
if (building.Id == buildingId)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
private void updateBuildings()
|
||||
{
|
||||
if (buildings[0] != null)
|
||||
Database.SetRanchBuilding1(this.Id, buildings[0].Id);
|
||||
else
|
||||
Database.SetRanchBuilding1(this.Id, 0);
|
||||
if (buildings[1] != null)
|
||||
Database.SetRanchBuilding2(this.Id, buildings[1].Id);
|
||||
else
|
||||
Database.SetRanchBuilding2(this.Id, 0);
|
||||
if (buildings[2] != null)
|
||||
Database.SetRanchBuilding3(this.Id, buildings[2].Id);
|
||||
else
|
||||
Database.SetRanchBuilding3(this.Id, 0);
|
||||
if (buildings[3] != null)
|
||||
Database.SetRanchBuilding4(this.Id, buildings[3].Id);
|
||||
else
|
||||
Database.SetRanchBuilding4(this.Id, 0);
|
||||
if (buildings[4] != null)
|
||||
Database.SetRanchBuilding5(this.Id, buildings[4].Id);
|
||||
else
|
||||
Database.SetRanchBuilding5(this.Id, 0);
|
||||
if (buildings[5] != null)
|
||||
Database.SetRanchBuilding6(this.Id, buildings[5].Id);
|
||||
else
|
||||
Database.SetRanchBuilding6(this.Id, 0);
|
||||
if (buildings[6] != null)
|
||||
Database.SetRanchBuilding7(this.Id, buildings[6].Id);
|
||||
else
|
||||
Database.SetRanchBuilding7(this.Id, 0);
|
||||
if (buildings[7] != null)
|
||||
Database.SetRanchBuilding8(this.Id, buildings[7].Id);
|
||||
else
|
||||
Database.SetRanchBuilding8(this.Id, 0);
|
||||
if (buildings[8] != null)
|
||||
Database.SetRanchBuilding9(this.Id, buildings[8].Id);
|
||||
else
|
||||
Database.SetRanchBuilding9(this.Id, 0);
|
||||
if (buildings[9] != null)
|
||||
Database.SetRanchBuilding10(this.Id, buildings[9].Id);
|
||||
else
|
||||
Database.SetRanchBuilding10(this.Id, 0);
|
||||
if (buildings[10] != null)
|
||||
Database.SetRanchBuilding11(this.Id, buildings[10].Id);
|
||||
else
|
||||
Database.SetRanchBuilding11(this.Id, 0);
|
||||
if (buildings[11] != null)
|
||||
Database.SetRanchBuilding12(this.Id, buildings[11].Id);
|
||||
else
|
||||
Database.SetRanchBuilding12(this.Id, 0);
|
||||
if (buildings[12] != null)
|
||||
Database.SetRanchBuilding13(this.Id, buildings[12].Id);
|
||||
else
|
||||
Database.SetRanchBuilding13(this.Id, 0);
|
||||
if (buildings[13] != null)
|
||||
Database.SetRanchBuilding14(this.Id, buildings[13].Id);
|
||||
else
|
||||
Database.SetRanchBuilding14(this.Id, 0);
|
||||
if (buildings[14] != null)
|
||||
Database.SetRanchBuilding15(this.Id, buildings[14].Id);
|
||||
else
|
||||
Database.SetRanchBuilding15(this.Id, 0);
|
||||
if (buildings[15] != null)
|
||||
Database.SetRanchBuilding16(this.Id, buildings[15].Id);
|
||||
else
|
||||
Database.SetRanchBuilding16(this.Id, 0);
|
||||
}
|
||||
public RanchBuilding GetBuilding(int buildingId)
|
||||
{
|
||||
return buildings[buildingId];
|
||||
}
|
||||
public void SetBuilding(int buildingId, RanchBuilding value)
|
||||
{
|
||||
buildings[buildingId] = value;
|
||||
updateBuildings();
|
||||
}
|
||||
|
||||
|
||||
public string GetSwf(bool mine)
|
||||
{
|
||||
string swf = "ranchviewer.swf?H=" + upgradedLevel+1.ToString();
|
||||
string swf = "ranchviewer.swf?H=" + (upgradedLevel+1).ToString();
|
||||
for(int i = 0; i < buildings.Length; i++)
|
||||
{
|
||||
swf += "&B" + i.ToString() + "=";
|
||||
swf += "&B" + (i+1).ToString() + "=";
|
||||
if (buildings[i] != null)
|
||||
{
|
||||
swf += buildings[i].Id.ToString();
|
||||
|
@ -260,20 +323,20 @@ namespace HISP.Game
|
|||
Y = y;
|
||||
Id = id;
|
||||
Value = value;
|
||||
Title = "";
|
||||
Description = "";
|
||||
UpgradedLevel = 0;
|
||||
OwnerId = -1;
|
||||
InvestedMoney = 0;
|
||||
title = "";
|
||||
description = "";
|
||||
upgradedLevel = 0;
|
||||
ownerId = -1;
|
||||
investedMoney = 0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
buildings[i] = null;
|
||||
|
||||
if (Database.IsRanchOwned(id))
|
||||
bool owned = Database.IsRanchOwned(id);
|
||||
if (owned)
|
||||
{
|
||||
UpgradedLevel = Database.GetRanchUpgradeLevel(id);
|
||||
Title = Database.GetRanchTitle(id);
|
||||
Description = Database.GetRanchDescription(id);
|
||||
OwnerId = Database.GetRanchOwner(id);
|
||||
upgradedLevel = Database.GetRanchUpgradeLevel(id);
|
||||
title = Database.GetRanchTitle(id);
|
||||
description = Database.GetRanchDescription(id);
|
||||
ownerId = Database.GetRanchOwner(id);
|
||||
int b1 = Database.GetRanchBuilding1(id);
|
||||
int b2 = Database.GetRanchBuilding2(id);
|
||||
int b3 = Database.GetRanchBuilding3(id);
|
||||
|
@ -329,6 +392,10 @@ namespace HISP.Game
|
|||
}
|
||||
}
|
||||
|
||||
public RanchUpgrade GetRanchUpgrade()
|
||||
{
|
||||
return RanchUpgrade.GetRanchUpgradeById(this.upgradedLevel + 1);
|
||||
}
|
||||
public static bool IsRanchHere(int x, int y)
|
||||
{
|
||||
foreach (Ranch ranch in Ranches)
|
||||
|
|
|
@ -196,6 +196,25 @@ namespace HISP.Game
|
|||
// Periodically write time to database:
|
||||
if (ServerTime.Minutes % 10 == 0) // every 10-in-game minutes)
|
||||
Database.SetServerTime(ServerTime.Minutes, ServerTime.Days, ServerTime.Years);
|
||||
|
||||
// Ranch Windmill Payments
|
||||
if(hours % 12 == 0)
|
||||
{
|
||||
Logger.DebugPrint("Paying windmill owners . . . ");
|
||||
foreach (Ranch ranch in Ranch.Ranches)
|
||||
{
|
||||
int ranchOwner = ranch.OwnerId;
|
||||
if (ranchOwner != -1)
|
||||
{
|
||||
int moneyToAdd = 5000 * ranch.GetBuildingCount(8); // Windmill
|
||||
if (GameServer.IsUserOnline(ranchOwner))
|
||||
GameServer.GetUserById(ranchOwner).Money += moneyToAdd;
|
||||
else
|
||||
Database.SetPlayerMoney(Database.GetPlayerMoney(ranchOwner) + moneyToAdd, ranchOwner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hours == 24) // 1 day
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue