Skip to content

Commit

Permalink
Corrected some order input weirdness.
Browse files Browse the repository at this point in the history
Update the local order map based on main province instead of first order word.
Used the SrcProvince option type correctly, which makes the arrows prettier when giving orders to coastal units.
  • Loading branch information
Martin Bruse committed Dec 23, 2016
1 parent dca218d commit c6eff18
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/src/main/java/se/oort/diplicity/game/GameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void send(SingleContainer<Order> orderSingleContainer) {
order.Nation = member.Nation;
order.PhaseOrdinal = phaseMeta.PhaseOrdinal;
order.Parts = parts;
orders.put(parts.get(0), order);
orders.put(province, order);
handleReq(
orderService.OrderCreate(order, game.ID, phaseMeta.PhaseOrdinal.toString()),
handler, getResources().getString(R.string.saving_order));
Expand Down Expand Up @@ -370,6 +370,9 @@ public void run() {
String newSrcProvince = srcProvince;
if (newSrcProvince == null) {
newSrcProvince = s;
if (newSrcProvince.indexOf('/') != -1) {
newSrcProvince = newSrcProvince.substring(0, newSrcProvince.indexOf('/'));
}
}
completeOrder(prefix, next, newSrcProvince);
}
Expand Down Expand Up @@ -405,6 +408,10 @@ public void onCancel(DialogInterface dialogInterface) {
}
}).show();
} else if (optionType.equals("SrcProvince")) {
if (optionValues.size() != 1) {
throw new RuntimeException("Multiple SrcProvince options: " + optionValues);
}
prefix.set(0, optionValues.iterator().next());
Map<String, OptionsService.Option> next = opts.get(optionValues.iterator().next()).Next;
if (next == null || next.isEmpty()) {
setOrder(srcProvince, prefix);
Expand Down Expand Up @@ -858,7 +865,11 @@ public Object call(SingleContainer<Map<String, OptionsService.Option>> opts, Mul
options = opts.Properties;
orders.clear();
for (SingleContainer<Order> orderContainer : ords.Properties) {
orders.put(orderContainer.Properties.Parts.get(0), orderContainer.Properties);
String srcProvince = orderContainer.Properties.Parts.get(0);
if (srcProvince.indexOf('/') != -1) {
srcProvince = srcProvince.substring(0, srcProvince.indexOf('/'));
}
orders.put(srcProvince, orderContainer.Properties);
}
return null;
}
Expand Down

0 comments on commit c6eff18

Please sign in to comment.