Skip to content

Commit

Permalink
add sell value to description
Browse files Browse the repository at this point in the history
  • Loading branch information
PrabuckiDominik committed Jan 10, 2024
1 parent 976c6c7 commit 83fec2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/xyz/magicjourney/nebulaquest/entity/Buyable.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ default boolean isDecisionRequired(Player player) {

default void sell() {
if (this.getOwner().isPresent()) {
this.getOwner().get().giveMoney(this.getValue());
this.getOwner().get().giveMoney((int) (this.getValue() * 0.7f));
this.setOwner(null);
}
}

default int getSellValue() {
return (int) (this.getValue() * 0.7f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class DescriptionInteractiveView extends AbstractInteractiveView {
protected Label description;
protected Label price;
protected Label fee;
protected Label sell;
protected Label owner;
protected Label region;

Expand All @@ -48,6 +49,7 @@ public DescriptionInteractiveView(AssetManager assets, InteractivePanel parent,
this.price = new Label("", this.skin, "small");
this.fee = new Label("", this.skin, "small");
this.owner = new Label("", this.skin, "small");
this.sell = new Label("", this.skin, "small");

this.sellButton = new ActionButton("Sell", true, assets);
this.sellButton.onClick().subscribe(handleSellClick);
Expand Down Expand Up @@ -87,6 +89,7 @@ public void display(Describable entity) {
this.price.setText("Value: " + buyable.getValue());
this.fee.setText("Residence fee: " + buyable.getFee());
this.owner.setText("Owner: " + buyable.getOwner().map((p) -> p.getName()).orElse("Free"));
this.sell.setText("Sell value: " + buyable.getSellValue());
}

if (this.icon instanceof Field field) {
Expand Down Expand Up @@ -139,6 +142,7 @@ protected void createLayout(Describable entity, boolean displayDescription) {
this.add(price).row();
this.add(fee).row();
this.add(owner).row();
this.add(sell).row();

if (buyable.isOwner(this.player)) {
this.addSpacer();
Expand Down

0 comments on commit 83fec2b

Please sign in to comment.