Archived
0

add time left to missions

This commit is contained in:
iMoHax
2015-11-20 16:15:10 +03:00
parent 28434db790
commit 0efba4b81b
5 changed files with 32 additions and 13 deletions

View File

@@ -24,6 +24,8 @@ public class MissionsController {
@FXML @FXML
private NumberField quantity; private NumberField quantity;
@FXML @FXML
private NumberField leftTime;
@FXML
private NumberField reward; private NumberField reward;
@FXML @FXML
private ToggleButton courierBtn; private ToggleButton courierBtn;
@@ -52,6 +54,7 @@ public class MissionsController {
starportText.setDisable(false); starportText.setDisable(false);
cargo.setDisable(true); cargo.setDisable(true);
quantity.setDisable(true); quantity.setDisable(true);
leftTime.setDisable(false);
reward.setDisable(false); reward.setDisable(false);
} else } else
if (deliveryBtn.equals(n)){ if (deliveryBtn.equals(n)){
@@ -59,6 +62,7 @@ public class MissionsController {
starportText.setDisable(false); starportText.setDisable(false);
cargo.setDisable(true); cargo.setDisable(true);
quantity.setDisable(false); quantity.setDisable(false);
leftTime.setDisable(false);
reward.setDisable(false); reward.setDisable(false);
} else } else
if (supplyBtn.equals(n)){ if (supplyBtn.equals(n)){
@@ -69,12 +73,14 @@ public class MissionsController {
starportText.setDisable(false); starportText.setDisable(false);
cargo.setDisable(false); cargo.setDisable(false);
quantity.setDisable(false); quantity.setDisable(false);
leftTime.setDisable(false);
reward.setDisable(false); reward.setDisable(false);
} else { } else {
missionType = null; missionType = null;
starportText.setDisable(true); starportText.setDisable(true);
cargo.setDisable(true); cargo.setDisable(true);
quantity.setDisable(true); quantity.setDisable(true);
leftTime.setDisable(true);
reward.setDisable(true); reward.setDisable(true);
} }
}); });
@@ -108,14 +114,15 @@ public class MissionsController {
StationModel station = starport.getValue(); StationModel station = starport.getValue();
ItemModel item = cargo.getValue(); ItemModel item = cargo.getValue();
long count = quantity.getValue().longValue(); long count = quantity.getValue().longValue();
long time = leftTime.getValue().longValue();
double profit = reward.getValue().doubleValue(); double profit = reward.getValue().doubleValue();
if (station != null && profit > 0){ if (station != null && profit > 0){
switch (missionType){ switch (missionType){
case COURIER: missions.add(new MissionModel(station, profit)); case COURIER: missions.add(new MissionModel(station, time, profit));
break; break;
case DELIVERY: if (count > 0) missions.add(new MissionModel(station, count, profit)); case DELIVERY: if (count > 0) missions.add(new MissionModel(station, count, time, profit));
break; break;
case SUPPLY: if (item != null && count > 0) missions.add(new MissionModel(station, item, count, profit)); case SUPPLY: if (item != null && count > 0) missions.add(new MissionModel(station, item, count, time,profit));
break; break;
} }
} }

View File

@@ -14,22 +14,24 @@ public class MissionModel {
private final long count; private final long count;
private final double profit; private final double profit;
private final Offer offer; private final Offer offer;
private final Long time;
private long need; private long need;
private Collection<RouteReserve> reserves; private Collection<RouteReserve> reserves;
public MissionModel(StationModel target, double profit) { public MissionModel(StationModel target, long time, double profit) {
this(target, null, 0, profit); this(target, null, 0, time, profit);
} }
public MissionModel(StationModel target, long count, double profit) { public MissionModel(StationModel target, long count, long time, double profit) {
this(target, null, count, profit); this(target, null, count, time, profit);
} }
public MissionModel(StationModel target, ItemModel item, long count, double profit) { public MissionModel(StationModel target, ItemModel item, long count, long time, double profit) {
this.target = target; this.target = target;
this.item = item; this.item = item;
this.count = count; this.count = count;
this.time = time;
this.profit = profit; this.profit = profit;
if (item != null) { if (item != null) {
offer = SimpleOffer.fakeBuy(ModelFabric.get(target), ModelFabric.get(item), profit / count, count); offer = SimpleOffer.fakeBuy(ModelFabric.get(target), ModelFabric.get(item), profit / count, count);
@@ -44,6 +46,7 @@ public class MissionModel {
this.target = mission.target; this.target = mission.target;
this.item = mission.item; this.item = mission.item;
this.count = mission.count; this.count = mission.count;
this.time = mission.time;
this.profit = mission.profit; this.profit = mission.profit;
this.offer = mission.offer; this.offer = mission.offer;
this.need = mission.need; this.need = mission.need;
@@ -93,6 +96,7 @@ public class MissionModel {
"target=" + target + "target=" + target +
", item=" + item + ", item=" + item +
", count=" + count + ", count=" + count +
", time=" + time +
", profit=" + profit + ", profit=" + profit +
"} "; "} ";
} }
@@ -100,13 +104,16 @@ public class MissionModel {
public void toSpecification(CrawlerSpecificator specificator){ public void toSpecification(CrawlerSpecificator specificator){
if (isSupply()){ if (isSupply()){
if (isCompleted()){ if (isCompleted()){
specificator.add(ModelFabric.get(target), true); if (time == 0) specificator.add(ModelFabric.get(target), true);
else specificator.add(ModelFabric.get(target), time, true);
} else { } else {
specificator.buy(offer); if (time == 0) specificator.buy(offer);
else specificator.buy(offer, time);
} }
} else } else
if (isCourier() || isDelivery()){ if (isCourier() || isDelivery()){
specificator.add(ModelFabric.get(target), true); if (time == 0) specificator.add(ModelFabric.get(target), true);
else specificator.add(ModelFabric.get(target), time, true);
} }
} }
@@ -148,6 +155,7 @@ public class MissionModel {
MissionModel that = (MissionModel) o; MissionModel that = (MissionModel) o;
return Objects.equals(count, that.count) && return Objects.equals(count, that.count) &&
Objects.equals(profit, that.profit) && Objects.equals(profit, that.profit) &&
Objects.equals(time, that.time) &&
Objects.equals(target, that.target) && Objects.equals(target, that.target) &&
Objects.equals(item, that.item); Objects.equals(item, that.item);
} }

View File

@@ -178,4 +178,5 @@ verify.content=Confirmation code:
missions.label.starport=Starport: missions.label.starport=Starport:
missions.label.cargo=Cargo: missions.label.cargo=Cargo:
missions.label.quantity=Quantity: missions.label.quantity=Quantity:
missions.label.leftTime=Time left:
missions.label.reward=Reward: missions.label.reward=Reward:

View File

@@ -179,4 +179,5 @@ verify.content=\u041A\u043E\u0434 \u0430\u043A\u0442\u0438\u0432\u0430\u0446\u04
missions.label.starport=\u041A\u043E\u0441\u043C\u043E\u043F\u043E\u0440\u0442: missions.label.starport=\u041A\u043E\u0441\u043C\u043E\u043F\u043E\u0440\u0442:
missions.label.cargo=\u0413\u0440\u0443\u0437: missions.label.cargo=\u0413\u0440\u0443\u0437:
missions.label.quantity=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E: missions.label.quantity=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:
missions.label.leftTime=\u0412\u0440\u0435\u043C\u044F:
missions.label.reward=\u041D\u0430\u0433\u0440\u0430\u0434\u0430: missions.label.reward=\u041D\u0430\u0433\u0440\u0430\u0434\u0430:

View File

@@ -42,6 +42,8 @@
</ComboBox> </ComboBox>
<Label GridPane.rowIndex="3" text="%missions.label.quantity"/> <Label GridPane.rowIndex="3" text="%missions.label.quantity"/>
<NumberField fx:id="quantity" GridPane.rowIndex="3" GridPane.columnIndex="1" value="0"/> <NumberField fx:id="quantity" GridPane.rowIndex="3" GridPane.columnIndex="1" value="0"/>
<Label GridPane.rowIndex="4" text="%missions.label.reward"/> <Label GridPane.rowIndex="4" text="%missions.label.leftTime"/>
<NumberField fx:id="reward" GridPane.rowIndex="4" GridPane.columnIndex="1" value="0" /> <NumberField fx:id="leftTime" GridPane.rowIndex="4" GridPane.columnIndex="1" value="0" />
<Label GridPane.rowIndex="5" text="%missions.label.reward"/>
<NumberField fx:id="reward" GridPane.rowIndex="5" GridPane.columnIndex="1" value="0" />
</GridPane> </GridPane>