Skip to content

Commit

Permalink
Vendor: Allow rebuy
Browse files Browse the repository at this point in the history
Added a callback QueryRebuy(int for_player, object base) in the vendor library. If an object that will be sold returns true in that function then the object will not be added to the base material of the selling player.
Currently the only objects that are sellable are Diamond, GoldBar, Nugget, Ruby. They cannot be rebought, just as in the previous implementation.
  • Loading branch information
gitMarky committed Apr 11, 2016
1 parent 43d6fcd commit 89718f3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public func Place(int amount, proplist area, ...)
} }


public func IsValuable() { return true; } public func IsValuable() { return true; }
public func QueryRebuy() { return true; }


local Name = "$Name$"; local Name = "$Name$";
local Description = "$Description$"; local Description = "$Description$";
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ protected func Hit()
public func IsFoundryProduct() { return true; } public func IsFoundryProduct() { return true; }
public func GetFuelNeed() { return 100; } public func GetFuelNeed() { return 100; }
public func IsValuable(){ return true; } public func IsValuable(){ return true; }
public func QueryRebuy(){ return true; }


local Name = "$Name$"; local Name = "$Name$";
local Description = "$Description$"; local Description = "$Description$";
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ protected func Hit(x, y)


public func IsFoundryIngredient() { return true; } public func IsFoundryIngredient() { return true; }
public func IsValuable(){ return true; } public func IsValuable(){ return true; }
public func QueryRebuy(){ return true; }




local Collectible = 1; local Collectible = 1;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func FxSparkleTimer(target, effect, effect_time)
} }


func IsValuable() { return true; } func IsValuable() { return true; }
func QueryRebuy() { return true; }


func OnSale(int to_player, object sale_base) func OnSale(int to_player, object sale_base)
{ {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func DoSell(object obj, int wealth_player)
// Give the player the cash // Give the player the cash
DoWealth(wealth_player, this->GetSellValue(obj)); DoWealth(wealth_player, this->GetSellValue(obj));
Sound("UI::Cash", {player = wealth_player}); Sound("UI::Cash", {player = wealth_player});

// Add the item to the homebase material.
if (!obj->~QueryRebuy(wealth_player, this))
{
this->ChangeBuyableAmount(wealth_player, obj, +1);
}


// OnSale callback to object e.g. for goal updates // OnSale callback to object e.g. for goal updates
obj->~OnSale(wealth_player, this); obj->~OnSale(wealth_player, this);
Expand Down

0 comments on commit 89718f3

Please sign in to comment.