build: Report missing stuff more nicely for ship, plane, land units

If both materials and avail are missing, report missing avail instead
of materials, to avoid tempting the player to move in materials only
to discover avail is lacking, too.

Report what materials are missing instead of just "Not enough
materials".  Does not yet include military for planes, but that's
next.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-01-12 18:33:13 +01:00
parent 1227d2c931
commit e2d176fd8a
3 changed files with 29 additions and 22 deletions

View file

@ -34,6 +34,7 @@
#include <config.h> #include <config.h>
#include <limits.h> #include <limits.h>
#include <math.h>
#include "chance.h" #include "chance.h"
#include "commands.h" #include "commands.h"
#include "game.h" #include "game.h"
@ -714,7 +715,7 @@ static int
sector_can_build(struct sctstr *sp, short mat[], int work, sector_can_build(struct sctstr *sp, short mat[], int work,
int effic, char *what) int effic, char *what)
{ {
int i, avail; int i, avail, ret;
double needed; double needed;
if (sp->sct_effic < 60 && !player->god) { if (sp->sct_effic < 60 && !player->god) {
@ -723,16 +724,6 @@ sector_can_build(struct sctstr *sp, short mat[], int work,
return 0; return 0;
} }
for (i = I_NONE + 1; i <= I_MAX; i++) {
needed = mat[i] * (effic / 100.0);
if (sp->sct_item[i] < needed) {
pr("Not enough materials in %s\n",
xyas(sp->sct_x, sp->sct_y, player->cnum));
return 0;
}
mat[i] = roundavg(needed);
}
avail = (work * effic + 99) / 100; avail = (work * effic + 99) / 100;
if (sp->sct_avail < avail) { if (sp->sct_avail < avail) {
pr("Not enough available work in %s to build a %s\n", pr("Not enough available work in %s to build a %s\n",
@ -741,7 +732,19 @@ sector_can_build(struct sctstr *sp, short mat[], int work,
return 0; return 0;
} }
return 1; ret = 1;
for (i = I_NONE + 1; i <= I_MAX; i++) {
needed = mat[i] * (effic / 100.0);
if (sp->sct_item[i] < needed) {
pr("Not enough %s in %s (need %g more)\n",
ichr[i].i_name, xyas(sp->sct_x, sp->sct_y, player->cnum),
ceil(needed - sp->sct_item[i]));
ret = 0;
}
mat[i] = roundavg(needed);
}
return ret;
} }
static void static void

View file

@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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 0 9 1 0 0 0 0 0 0 0 0 0 0 9 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0

View file

@ -61,7 +61,8 @@
Play#1 output Play#1 6 0 635 Play#1 output Play#1 6 0 635
Play#1 input build s 4:6,0 pt Play#1 input build s 4:6,0 pt
Play#1 command build Play#1 command build
Play#1 output Play#1 1 Not enough materials in 4,0 Play#1 output Play#1 1 Not enough light products in 4,0 (need 4 more)
Play#1 output Play#1 1 Not enough heavy products in 4,0 (need 2 more)
Play#1 output Play#1 1 Sector 6,0 is not 60% efficient. Play#1 output Play#1 1 Sector 6,0 is not 60% efficient.
Play#1 output Play#1 6 0 634 Play#1 output Play#1 6 0 634
Play#1 input move l 0,0 4 jh Play#1 input move l 0,0 4 jh
@ -86,8 +87,8 @@
Play#1 output Play#1 6 0 630 Play#1 output Play#1 6 0 630
Play#1 input build s 2:4,0 pt Play#1 input build s 2:4,0 pt
Play#1 command build Play#1 command build
Play#1 output Play#1 1 Not enough materials in 2,0 Play#1 output Play#1 1 Not enough heavy products in 2,0 (need 1 more)
Play#1 output Play#1 1 Not enough materials in 4,0 Play#1 output Play#1 1 Not enough light products in 4,0 (need 1 more)
Play#1 output Play#1 6 0 629 Play#1 output Play#1 6 0 629
Play#1 input move l 0,0 12 jh Play#1 input move l 0,0 12 jh
Play#1 command move Play#1 command move
@ -268,7 +269,8 @@
Play#2 output Play#2 6 0 635 Play#2 output Play#2 6 0 635
Play#2 input build p 3:5,1 f2 Play#2 input build p 3:5,1 f2
Play#2 command build Play#2 command build
Play#2 output Play#2 1 Not enough materials in 3,1 Play#2 output Play#2 1 Not enough light products in 3,1 (need 1 more)
Play#2 output Play#2 1 Not enough heavy products in 3,1 (need 1 more)
Play#2 output Play#2 1 Sector 5,1 is not 60% efficient. Play#2 output Play#2 1 Sector 5,1 is not 60% efficient.
Play#2 output Play#2 6 0 634 Play#2 output Play#2 6 0 634
Play#2 input move m -1,1 1 jh Play#2 input move m -1,1 1 jh
@ -288,7 +290,8 @@
Play#2 output Play#2 6 0 631 Play#2 output Play#2 6 0 631
Play#2 input build p 1:3,1 f2 Play#2 input build p 1:3,1 f2
Play#2 command build Play#2 command build
Play#2 output Play#2 1 Not enough materials in 1,1 Play#2 output Play#2 1 Not enough light products in 1,1 (need 1 more)
Play#2 output Play#2 1 Not enough heavy products in 1,1 (need 1 more)
Play#2 output Play#2 1 Not enough military for crew in 3,1 Play#2 output Play#2 1 Not enough military for crew in 3,1
Play#2 output Play#2 6 0 630 Play#2 output Play#2 6 0 630
Play#2 input move m -1,1 3 jh Play#2 input move m -1,1 3 jh
@ -372,7 +375,7 @@
Play#2 output Play#2 1 COMMODITIES deliver-- distribute Play#2 output Play#2 1 COMMODITIES deliver-- distribute
Play#2 output Play#2 1 sect sgpidbolhr sgpidbolhr sh gun pet iron dust bar oil lcm hcm rad Play#2 output Play#2 1 sect sgpidbolhr sgpidbolhr sh gun pet iron dust bar oil lcm hcm rad
Play#2 output Play#2 1 1,1 * .......... .......... 0 0 0 0 0 0 0 2 2 0 Play#2 output Play#2 1 1,1 * .......... .......... 0 0 0 0 0 0 0 2 2 0
Play#2 output Play#2 1 3,1 * .......... .......... 0 0 0 0 0 0 0 3 4 0 Play#2 output Play#2 1 3,1 * .......... .......... 0 0 0 0 0 0 0 3 3 0
Play#2 output Play#2 1 5,1 * .......... .......... 0 0 0 0 0 0 500 500 500 500 Play#2 output Play#2 1 5,1 * .......... .......... 0 0 0 0 0 0 500 500 500 500
Play#2 output Play#2 1 3 sectors Play#2 output Play#2 1 3 sectors
Play#2 output Play#2 6 0 621 Play#2 output Play#2 6 0 621
@ -428,7 +431,8 @@
Play#3 output Play#3 6 0 635 Play#3 output Play#3 6 0 635
Play#3 input build l 4:6,2 linf Play#3 input build l 4:6,2 linf
Play#3 command build Play#3 command build
Play#3 output Play#3 1 Not enough materials in 4,2 Play#3 output Play#3 1 Not enough light products in 4,2 (need 1 more)
Play#3 output Play#3 1 Not enough heavy products in 4,2 (need 1 more)
Play#3 output Play#3 1 Sector 6,2 is not 60% efficient. Play#3 output Play#3 1 Sector 6,2 is not 60% efficient.
Play#3 output Play#3 6 0 634 Play#3 output Play#3 6 0 634
Play#3 input move l 0,2 1 jjh Play#3 input move l 0,2 1 jjh
@ -443,8 +447,8 @@
Play#3 output Play#3 6 0 632 Play#3 output Play#3 6 0 632
Play#3 input build l 2:4,2 linf Play#3 input build l 2:4,2 linf
Play#3 command build Play#3 command build
Play#3 output Play#3 1 Not enough materials in 2,2 Play#3 output Play#3 1 Not enough light products in 2,2 (need 1 more)
Play#3 output Play#3 1 Not enough materials in 4,2 Play#3 output Play#3 1 Not enough heavy products in 4,2 (need 1 more)
Play#3 output Play#3 6 0 631 Play#3 output Play#3 6 0 631
Play#3 input move l 0,2 4 jh Play#3 input move l 0,2 4 jh
Play#3 command move Play#3 command move