本文整理汇总了C#中MUDEngine.CharData.FindShopkeeper方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.FindShopkeeper方法的具体用法?C# CharData.FindShopkeeper怎么用?C# CharData.FindShopkeeper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MUDEngine.CharData
的用法示例。
在下文中一共展示了CharData.FindShopkeeper方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Value
/// <summary>
/// Value: Find out how much a shopkeeper will pay for an item.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Value(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj;
CharData keeper;
int cost;
if (str.Length == 0)
{
ch.SendText("Value what?\r\n");
return;
}
if (!(keeper = ch.FindShopkeeper("")))
return;
if (!(obj = ch.GetObjCarrying(str[0])))
{
SocketConnection.Act("$n&n tells you 'You don't have that item'.",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if (!ch.CanDropObject(obj))
{
ch.SendText("That's not something you can sell.\r\n");
return;
}
if (!CharData.CanSeeObj(keeper, obj))
{
SocketConnection.Act("$n&+W tells you 'You are offering me an imaginary object!?!?'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if ((cost = Object.GetCost(ch, keeper, obj, false)) <= 0)
{
SocketConnection.Act("$n&n looks uninterested in $p&n.", keeper, obj, ch, SocketConnection.MessageTarget.victim);
return;
}
if (obj.HasFlag(ObjTemplate.ITEM_POISONED))
{
SocketConnection.Act("$n&+W tells you 'I won't buy that! It's poisoned!'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
string buf = String.Format("$n&+W tells you 'I'll give you {0} &n&+ycopper&+W coins for $p&n.'", cost);
SocketConnection.Act(buf, keeper, obj, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
示例2: Sell
/// <summary>
/// Sell an item.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Sell(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj;
CharData keeper;
string arg2 = String.Empty;
int cost;
if (str.Length == 0)
{
ch.SendText("Sell what?\r\n");
return;
}
if (!(keeper = ch.FindShopkeeper(arg2)))
{
return;
}
if (!ch.IsNPC())
{
// Won't buy from bottom 25% of faction range.
if (((PC)ch).GetFaction(keeper) < (Limits.MIN_FACTION / 2))
{
SocketConnection.Act("$n&+W tells you 'I won't do business with scum like you.'&n", keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
}
if (!(obj = ch.GetObjCarrying(str[0])))
{
SocketConnection.Act("$n&+W tells you 'You don't have that item.'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if (!ch.CanDropObject(obj))
{
ch.SendText("You couldn't possibly part with that.\r\n");
return;
}
if (!CharData.CanSeeObj(keeper, obj))
{
SocketConnection.Act("$n&+W tells you 'I can't see that item.'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if ((cost = Object.GetCost(ch, keeper, obj, false)) <= 0 || obj.HasFlag(ObjTemplate.ITEM_NOSELL))
{
SocketConnection.Act("$n&n looks uninterested in $p&n.", keeper, obj, ch, SocketConnection.MessageTarget.victim);
return;
}
if (cost > obj.Cost)
{
Log.Error("Shopkeeper with index number {0} buys for more than 100 percent of value.\r\n",
keeper.MobileTemplate.IndexNumber);
cost = obj.Cost;
}
if (cost < 1)
cost = 1;
if (obj.HasFlag(ObjTemplate.ITEM_POISONED))
{
SocketConnection.Act("$n&+W tells you 'I won't buy that! It's poisoned!'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
string buf = String.Format("You sell $p&n for {0}.", StringConversion.CoinString(cost));
SocketConnection.Act(buf, ch, obj, null, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n sells $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
ch.ReceiveCash(cost);
if (obj.ItemType == ObjTemplate.ObjectType.trash)
{
obj.RemoveFromWorld();
}
else
{
obj.RemoveFromChar();
obj.ObjToChar(keeper);
// Selling an object decreases its scarcity.
--obj.ObjIndexData.Scarcity;
}
return;
//.........这里部分代码省略.........
示例3: Buy
/// <summary>
/// Purchase something in a shop.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Buy(CharData ch, string[] str)
{
if( ch == null ) return;
string arg2 = String.Empty;
string arg3 = String.Empty;
string text;
bool fPerm = false;
if (str.Length == 0)
{
ch.SendText("Buy what?\r\n");
return;
}
if (ch.InRoom.HasFlag(RoomTemplate.ROOM_PET_SHOP))
{
if (ch.IsNPC())
return;
Room nextRoom = Room.GetRoom(ch.InRoom.IndexNumber + 1);
if (nextRoom == null)
{
Log.Error("Buy: bad pet shop at index number {0}.", ch.InRoom.IndexNumber);
ch.SendText("Sorry, you can't buy that here.\r\n");
return;
}
Room inRoom = ch.InRoom;
ch.InRoom = nextRoom;
CharData pet = ch.GetCharRoom(str[0]);
ch.InRoom = inRoom;
if (pet && ch.MaxPets())
{
ch.SendText("Sorry, you can't keep track of that many pets.\r\n");
return;
}
if (pet == null || !pet.HasActionBit(MobTemplate.ACT_PET))
{
ch.SendText("Sorry, you can't buy that here.\r\n");
return;
}
// Altered Pricing to match the ones that were given in the list
// command below... original was set to 500 * pet.level * pet.level
// Xangis tweaked it to 100 * pet level squared
if (ch.GetCash() < ((100 * pet.Level) * pet.Level))
{
ch.SendText("You can't afford it.\r\n");
return;
}
ch.SpendCash(((100 * pet.Level) * pet.Level));
pet = Database.CreateMobile(pet.MobileTemplate);
pet.SetActionBit(MobTemplate.ACT_PET);
pet.SetActionBit(MobTemplate.ACT_NOEXP);
pet.SetAffectBit(Affect.AFFECT_CHARM);
if (!String.IsNullOrEmpty(str[0]))
{
text = String.Format("{0} {1}", pet.Name, str[0]);
pet.Name = text;
}
text = String.Format("{0}&+LA neck tag says '&+RI belong to {1}&+L'.&n\r\n",
pet.Description, ch.Name);
pet.Description = text;
pet.AddToRoom(ch.InRoom);
CharData.AddFollower(pet, ch);
ch.SendText("Enjoy your pet.\r\n");
SocketConnection.Act("$n&n just purchased $N&n.", ch, null, pet, SocketConnection.MessageTarget.room);
return;
}
ObjTemplate objTemplate;
Object obj = null;
CharData keeper;
int itemCount = 1; /* buy only one by default */
if (MUDString.IsNumber(str[0]))
{
Int32.TryParse(str[0], out itemCount);
str[0] = arg2;
arg2 = arg3;
}
if (!(keeper = ch.FindShopkeeper(arg2)))
{
return;
}
if (!ch.IsNPC())
{
// Won't sell to bottom 25% of faction range.
//.........这里部分代码省略.........
示例4: ListCommand
/// <summary>
/// Shows the items that a shop has for sale.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void ListCommand(CharData ch, string[] str)
{
if( ch == null ) return;
string text;
string buf1 = String.Empty;
if (ch.InRoom.HasFlag(RoomTemplate.ROOM_PET_SHOP))
{
if (!ch.InRoom)
{
ch.SendText("Nothing to list here.\r\n");
return;
}
Room nextRoom = Room.GetRoom(ch.InRoom.IndexNumber + 1);
if (!nextRoom)
{
Log.Error("ListCommand: bad pet shop at index number {0}.", ch.InRoom.IndexNumber);
ch.SendText("You can't do that here.\r\n");
return;
}
bool found = false;
foreach (CharData pet in nextRoom.People)
{
if (pet.HasActionBit(MobTemplate.ACT_PET))
{
// I set this here so as to list a nicer and more comprehensive
// pet shop stock/price list. I *think* I got it right.
int cost = ((100 * pet.Level) * pet.Level);
if (cost <= 0)
{
cost = 1;
}
if (!found)
{
found = true;
buf1 += "&+LPets for sale&n&+r:&n\r\n";
}
text = String.Format("{0}&n for {1}.\r\n", pet.ShortDescription, StringConversion.CoinString(cost));
buf1 += text;
}
}
if (!found)
{
ch.SendText("Sorry, we're out of pets right now.\r\n");
}
ch.SendText(buf1);
return;
}
else
{
ObjTemplate objTemplate;
CharData keeper;
string arg2 = String.Empty;
int cost;
if (!(keeper = ch.FindShopkeeper(arg2)))
{
return;
}
if (ch.IsImmortal())
{
buf1 = String.Format("Shop sell profit: {0} percent Shop buy profit: {1} percent\r\n",
keeper.MobileTemplate.ShopData.PercentSell,
keeper.MobileTemplate.ShopData.PercentBuy);
}
bool found = false;
foreach (Object obj in keeper.Carrying)
{
if (obj.WearLocation != ObjTemplate.WearLocation.none)
continue;
cost = Object.GetCost(ch, keeper, obj, true);
if (cost <= 0)
cost = 1;
if (CharData.CanSeeObj(ch, obj) && (str.Length == 0 || str[0] == "all"
|| MUDString.NameContainedIn(str[0], obj.Name)))
{
if (!found)
{
found = true;
buf1 += "&+LYou can buy&n&+r:&n\r\n";
}
text = String.Format("{0}&n for {1}.\r\n",
obj.ShortDescription, StringConversion.CoinString(cost));
buf1 += text;
}
//.........这里部分代码省略.........