mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-22 20:55:52 +12:00
Weirest bug ever happened, it said "Item.ItemInformation" is higher protection level than Item.Tack even though both were public, i eventurally found that it was because Item was "class" where as "Item.Tack" was "public class" so i made everything be "public class"
This commit is contained in:
parent
6a620f4be5
commit
3c25795188
50 changed files with 186 additions and 60 deletions
|
@ -1,154 +0,0 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
class Item
|
||||
{
|
||||
public struct Effects
|
||||
{
|
||||
public string EffectsWhat;
|
||||
public int EffectAmount;
|
||||
}
|
||||
|
||||
public struct SpawnRules
|
||||
{
|
||||
public int SpawnCap;
|
||||
public string SpawnInZone;
|
||||
public string SpawnOnTileType;
|
||||
public string SpawnOnSpecialTile;
|
||||
public string SpawnNearSpecialTile;
|
||||
}
|
||||
public class ItemInformation
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string PluralName;
|
||||
public string Description;
|
||||
|
||||
public int IconId;
|
||||
public int SortBy;
|
||||
public int SellPrice;
|
||||
|
||||
public string EmbedSwf;
|
||||
public bool WishingWell;
|
||||
public string Type;
|
||||
public int[] MiscFlags;
|
||||
public Effects[] Effects;
|
||||
|
||||
public SpawnRules SpawnParamaters;
|
||||
|
||||
}
|
||||
|
||||
public struct ThrowableItem
|
||||
{
|
||||
public int Id;
|
||||
public string Message;
|
||||
}
|
||||
|
||||
public static List<ItemInformation> Items = new List<ItemInformation>();
|
||||
public static List<ThrowableItem> ThrowableItems = new List<ThrowableItem>();
|
||||
|
||||
public static int Present;
|
||||
public static int MailMessage;
|
||||
public static int DorothyShoes;
|
||||
public static int PawneerOrder;
|
||||
public static int Telescope;
|
||||
public static int Pitchfork;
|
||||
public static int WishingCoin;
|
||||
public static int FishingPole;
|
||||
public static int Earthworm;
|
||||
|
||||
public static ItemInformation[] GetAllWishableItems()
|
||||
{
|
||||
List<ItemInformation> itemInfo = new List<ItemInformation>();
|
||||
foreach(ItemInformation item in Items)
|
||||
{
|
||||
if (item.WishingWell)
|
||||
itemInfo.Add(item);
|
||||
}
|
||||
return itemInfo.ToArray();
|
||||
}
|
||||
|
||||
public static bool ConsumeItem(User user, ItemInformation itmInfo)
|
||||
{
|
||||
|
||||
bool toMuch = false;
|
||||
foreach (Item.Effects effect in itmInfo.Effects)
|
||||
{
|
||||
switch (effect.EffectsWhat)
|
||||
{
|
||||
case "TIREDNESS":
|
||||
if (user.Tiredness + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Tiredness += effect.EffectAmount;
|
||||
break;
|
||||
case "THIRST":
|
||||
if (user.Thirst + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Thirst += effect.EffectAmount;
|
||||
break;
|
||||
case "HUNGER":
|
||||
if (user.Hunger + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Hunger += effect.EffectAmount;
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint("Unknown effect: " + effect.EffectsWhat);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return toMuch;
|
||||
}
|
||||
public static bool IsThrowable(int id)
|
||||
{
|
||||
foreach(ThrowableItem itm in ThrowableItems)
|
||||
{
|
||||
if(itm.Id == id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ThrowableItem GetThrowableItem(int id)
|
||||
{
|
||||
foreach (ThrowableItem itm in ThrowableItems)
|
||||
{
|
||||
if (itm.Id == id)
|
||||
{
|
||||
return itm;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("id: " + id + " is not a throwable item.");
|
||||
}
|
||||
|
||||
public static bool ItemIdExist(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetItemById(id);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemInformation GetItemById(int id)
|
||||
{
|
||||
foreach(ItemInformation item in Items)
|
||||
{
|
||||
if(item.Id == id)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Item id " + id + " Not found!");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue