#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emprcs/lib/commands/mora.c,v 2.2 1995/10/24 04:43:24 empire Exp $";
#endif

/*
 * rang.c
 *
 * Edit morale of a land unit
 *
 * Jeff Bailey
 */

#include "misc.h"
#include "player.h"
#include "var.h"
#include "xy.h"
#include "land.h"
#include "nsc.h"
#include "file.h"
#include "nat.h"
#include "deity.h"

morale()
{
	struct nstr_item np;
	struct lndstr land;
	struct natstr *natp;
	int	i,min;
	s_char	*p;
	s_char	mess[128];
	double	techfact();
	s_char	buf[1024];

	if (!snxtitem(&np, EF_LAND, player->argp[1]))
		return RET_SYN;
	while (!player->aborted && nxtitem(&np, (s_char *)&land)) {
		if (!player->owner || land.lnd_own == 0)
			continue;
		natp=getnatp(land.lnd_own);
		min = 75-(int)natp->nat_level[NAT_HLEV];
		sprintf(mess, "New retreat percentage for %s (min %d%%)? ",
			prland(&land), min);
		p = getstarg(player->argp[2], mess, buf);
		if (player->aborted)
			continue;
		if (!p || (i = atoi(p)) < 0)
			continue;
		land.lnd_retreat = ((i < min) ? min : i);
		if (land.lnd_retreat > 100)
			land.lnd_retreat = 100;
		pr("Unit %d retreat percentage changed to %d\n",
			land.lnd_uid, land.lnd_retreat);
		putland(land.lnd_uid,&land);
	}

	return RET_OK;
}
