mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-07 08:39:07 +00:00
Fixed stuff related to shop trading (#202)
> Refactored stuff to facilitate resolving an issue regarding sellnig item to a full shop > Removed double value message in shop
This commit is contained in:
@@ -391,6 +391,8 @@ public class Client extends Player {
|
|||||||
return food;
|
return food;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int TotalShopItems;
|
||||||
|
|
||||||
public void startCurrentTask(int ticksBetweenExecution, CycleEvent event) {
|
public void startCurrentTask(int ticksBetweenExecution, CycleEvent event) {
|
||||||
endCurrentTask();
|
endCurrentTask();
|
||||||
currentTask = CycleEventHandler.getSingleton().addEvent(this, event, ticksBetweenExecution);
|
currentTask = CycleEventHandler.getSingleton().addEvent(this, event, ticksBetweenExecution);
|
||||||
|
|||||||
@@ -66,27 +66,34 @@ public class ShopAssistant {
|
|||||||
|
|
||||||
public void resetShop(int ShopID) {
|
public void resetShop(int ShopID) {
|
||||||
synchronized (player) {
|
synchronized (player) {
|
||||||
int TotalItems = 0;
|
player.TotalShopItems = 0;
|
||||||
for (int i = 0; i < ShopHandler.MaxShopItems; i++) { //adds items in store when items are sold until max value.
|
for (int i = 0; i < ShopHandler.MaxShopItems; i++)
|
||||||
if (ShopHandler.ShopItems[ShopID][i] > 0) {
|
{ //adds items in store when items are sold until max value.
|
||||||
TotalItems++;
|
if (ShopHandler.ShopItems[ShopID][i] > 0)
|
||||||
|
{
|
||||||
|
player.TotalShopItems++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TotalItems > ShopHandler.MaxShopItems) {
|
if (player.TotalShopItems > 40){
|
||||||
TotalItems = ShopHandler.MaxShopItems; //sets the stack of item sold to max value if the resulting amount is higher than max value.
|
player.TotalShopItems = 40; //sets the number of stack of item sold to max possible value if the resulting amount is higher than max value.
|
||||||
|
//Items sold when shops are full will dissapears. Much more code would be needed if we want to restrict selling while still permitting selling items already in shops and such.
|
||||||
}
|
}
|
||||||
player.getOutStream().createFrameVarSizeWord(53);
|
player.getOutStream().createFrameVarSizeWord(53);
|
||||||
player.getOutStream().writeWord(3900);
|
player.getOutStream().writeWord(3900);
|
||||||
player.getOutStream().writeWord(TotalItems);
|
player.getOutStream().writeWord(player.TotalShopItems);
|
||||||
int TotalCount = 0;
|
int TotalCount = 0;
|
||||||
for (int i = 0; i < ShopHandler.ShopItems.length; i++) {
|
for (int i = 0; i < ShopHandler.ShopItems.length; i++)
|
||||||
|
{
|
||||||
if (ShopHandler.ShopItems[ShopID][i] > 0
|
if (ShopHandler.ShopItems[ShopID][i] > 0
|
||||||
|| i <= ShopHandler.ShopItemsStandard[ShopID]) {
|
|| i <= ShopHandler.ShopItemsStandard[ShopID])
|
||||||
|
{
|
||||||
if (ShopHandler.ShopItemsN[ShopID][i] > 254) {
|
if (ShopHandler.ShopItemsN[ShopID][i] > 254) {
|
||||||
player.getOutStream().writeByte(255);
|
player.getOutStream().writeByte(255);
|
||||||
player.getOutStream().writeDWord_v2(
|
player.getOutStream().writeDWord_v2(
|
||||||
ShopHandler.ShopItemsN[ShopID][i]);
|
ShopHandler.ShopItemsN[ShopID][i]);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
player.getOutStream().writeByte(
|
player.getOutStream().writeByte(
|
||||||
ShopHandler.ShopItemsN[ShopID][i]);
|
ShopHandler.ShopItemsN[ShopID][i]);
|
||||||
}
|
}
|
||||||
@@ -98,7 +105,7 @@ public class ShopAssistant {
|
|||||||
ShopHandler.ShopItems[ShopID][i]);
|
ShopHandler.ShopItems[ShopID][i]);
|
||||||
TotalCount++;
|
TotalCount++;
|
||||||
}
|
}
|
||||||
if (TotalCount > TotalItems) {
|
if (TotalCount > player.TotalShopItems) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,11 +335,11 @@ public class ShopAssistant {
|
|||||||
} else if (player.myShopId == CASTLE_SHOP) {
|
} else if (player.myShopId == CASTLE_SHOP) {
|
||||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + getCastleItemValue(removeId) + " castle war tickets." + ShopAdd);
|
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + getCastleItemValue(removeId) + " castle war tickets." + ShopAdd);
|
||||||
}
|
}
|
||||||
player.getActionSender().sendMessage(ItemAssistant.getItemName(removeId) + ": shop will buy for " + ShopValue + " coins." + ShopAdd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sellItem(int itemID, int fromSlot, int amount) {
|
public boolean sellItem(int itemID, int fromSlot, int amount) {
|
||||||
|
|
||||||
player.getItemAssistant();
|
player.getItemAssistant();
|
||||||
for (int i : Constants.ITEM_SELLABLE) {
|
for (int i : Constants.ITEM_SELLABLE) {
|
||||||
if (i == itemID) {
|
if (i == itemID) {
|
||||||
@@ -348,6 +355,10 @@ public class ShopAssistant {
|
|||||||
if(!player.isShopping) {
|
if(!player.isShopping) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (player.TotalShopItems >= 39)
|
||||||
|
{
|
||||||
|
player.getActionSender().sendMessage("If you sell more individuals items in this shop, they won't be displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
if (amount > 0 && itemID == (player.playerItems[fromSlot] - 1)) {
|
if (amount > 0 && itemID == (player.playerItems[fromSlot] - 1)) {
|
||||||
if (ShopHandler.ShopSModifier[player.myShopId] > 1) {
|
if (ShopHandler.ShopSModifier[player.myShopId] > 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user