using System;
using Server;
using Server.Items;
using Server.Mobiles;
namespace Server.Items
{
public class Trash4TokensBackpack : Backpack
{
[Constructable]
public Trash4TokensBackpack() : base()
{
Name = "Safe Trash 4 Tokens Backpack 2";
Movable = true; // Prevents easy movement or pickup
Hue = 1173;
}
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (from == null || dropped == null)
return false;
if (IsTrashItem(dropped)) // Checks if item is valid for trashing
{
int tokensEarned = CalculateTokens(dropped);
from.SendMessage($"You earned {tokensEarned} tokens for trashing {dropped.Name}.");
// Add Daat99Tokens directly to the player's backpack
AddDaat99TokensToBackpack(from, tokensEarned);
dropped.Delete(); // Deletes the trashed item
return true;
}
else
{
from.SendMessage("That item cannot be trashed for tokens.");
return base.OnDragDrop(from, dropped);
}
}
private bool IsTrashItem(Item item)
{
// Logic for determining if an item qualifies as trash
return true; // Placeholder, allow all items for example purposes
}
private int CalculateTokens(Item item)
{
// Determines the amount of tokens based on item properties
// return 10; // Example value, adjust as needed
// Determines the amount of tokens based on item properties
// Assuming item.Amount gives the quantity of the item trashed
int tokenAmount = item.Amount; // This will set the token amount equal to the item quantity trashed
return tokenAmount;
}
private void AddDaat99TokensToBackpack(Mobile from, int tokens)
{
if (from.Backpack != null)
{
// Looks for an existing stack of Daat99Tokens in the backpack
Item tokenItem = from.Backpack.FindItemByType(typeof(Daat99Tokens)) as Daat99Tokens;
if (tokenItem == null)
{
// No existing tokens, create a new stack
tokenItem = new Daat99Tokens(tokens);
from.Backpack.AddItem(tokenItem);
}
else
{
// Add to the existing stack of tokens
tokenItem.Amount += tokens;
}
}
}
public Trash4TokensBackpack(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // Version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}
using Server;
using Server.Items;
using Server.Mobiles;
namespace Server.Items
{
public class Trash4TokensBackpack : Backpack
{
[Constructable]
public Trash4TokensBackpack() : base()
{
Name = "Safe Trash 4 Tokens Backpack 2";
Movable = true; // Prevents easy movement or pickup
Hue = 1173;
}
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (from == null || dropped == null)
return false;
if (IsTrashItem(dropped)) // Checks if item is valid for trashing
{
int tokensEarned = CalculateTokens(dropped);
from.SendMessage($"You earned {tokensEarned} tokens for trashing {dropped.Name}.");
// Add Daat99Tokens directly to the player's backpack
AddDaat99TokensToBackpack(from, tokensEarned);
dropped.Delete(); // Deletes the trashed item
return true;
}
else
{
from.SendMessage("That item cannot be trashed for tokens.");
return base.OnDragDrop(from, dropped);
}
}
private bool IsTrashItem(Item item)
{
// Logic for determining if an item qualifies as trash
return true; // Placeholder, allow all items for example purposes
}
private int CalculateTokens(Item item)
{
// Determines the amount of tokens based on item properties
// return 10; // Example value, adjust as needed
// Determines the amount of tokens based on item properties
// Assuming item.Amount gives the quantity of the item trashed
int tokenAmount = item.Amount; // This will set the token amount equal to the item quantity trashed
return tokenAmount;
}
private void AddDaat99TokensToBackpack(Mobile from, int tokens)
{
if (from.Backpack != null)
{
// Looks for an existing stack of Daat99Tokens in the backpack
Item tokenItem = from.Backpack.FindItemByType(typeof(Daat99Tokens)) as Daat99Tokens;
if (tokenItem == null)
{
// No existing tokens, create a new stack
tokenItem = new Daat99Tokens(tokens);
from.Backpack.AddItem(tokenItem);
}
else
{
// Add to the existing stack of tokens
tokenItem.Amount += tokens;
}
}
}
public Trash4TokensBackpack(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // Version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}