~dax/drpc

5c6b3fbacb558ee79ca05077d12ef7a1ef3b46ea — dax 1 year, 6 months ago a594575
remove -r flag
4 files changed, 7 insertions(+), 36 deletions(-)

M README.md
M drpc.1
M drpc.1.scd
M drpc.c
M README.md => README.md +1 -4
@@ 16,7 16,7 @@ By default, this will install files into /usr/local.

## Usage

`drpc [-r] [-p platinum] [-g gold] [-s silver] [-b bronze] [-t tin] cap rate`
`drpc [-p platinum] [-g gold] [-s silver] [-b bronze] [-t tin] cap rate`

`cap` is the weekly gil cap, e.g. `20000` for 20,000 gil



@@ 24,9 24,6 @@ By default, this will install files into /usr/local.

`p`, `g`, `s`, `b`, and `t` are the available allagan pieces to donate

`s` reverses the priority to donate the cheap pieces first instead of the expensive pieces


## License

All drpc source code is distributed under the ISC license. See source files for verbatim license and copyright info.

M drpc.1 => drpc.1 +2 -13
@@ 1,4 1,4 @@
.\" Generated by scdoc 1.9.2
.\" Generated by scdoc 1.9.4
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.nh


@@ 12,7 12,7 @@ drpc - calculate donations for doman reconstruction project
.P
.SH SYNOPSIS
.P
\fBdrpc\fR [-r] [-p \fIplatinum\fR] [-g \fIgold\fR] [-s \fIsilver\fR] [-b \fIbronze\fR] [-t \fItin\fR] \fIcap\fR \fIrate\fR
\fBdrpc\fR [-p \fIplatinum\fR] [-g \fIgold\fR] [-s \fIsilver\fR] [-b \fIbronze\fR] [-t \fItin\fR] \fIcap\fR \fIrate\fR
.P
.SH DESCRIPTION
.P


@@ 30,11 30,6 @@ Number of allagan pieces available to donate:
Platinum, Gold, Silver, Bronze, and Tin
.P
.RE
\fB-r\fR
.RS 4
Reverse the priority of donation to lower-cost pieces instead of high-cost pieces
.P
.RE
.SH EXAMPLE
.P
Calculate how many pieces to donate with a 20,000 gil cap and a 200% rate, with 50 gold pieces and 20 bronze pieces:


@@ 43,12 38,6 @@ Calculate how many pieces to donate with a 20,000 gil cap and a 200% rate, with 
drpc -g 50 -b 20 20000 200
.P
.RE
Donate the cheaper pieces first:
.RS 4
.P
drpc -r -g 50 -b 20 20000 200
.P
.RE
.SH AUTHORS
.P
dax <dax@dax.moe>

M drpc.1.scd => drpc.1.scd +1 -8
@@ 6,7 6,7 @@ drpc - calculate donations for doman reconstruction project

# SYNOPSIS

*drpc* [-r] [-p _platinum_] [-g _gold_] [-s _silver_] [-b _bronze_] [-t _tin_] _cap_ _rate_
*drpc* [-p _platinum_] [-g _gold_] [-s _silver_] [-b _bronze_] [-t _tin_] _cap_ _rate_

# DESCRIPTION



@@ 22,19 22,12 @@ _rate_ is the percentage buying rate.
	Number of allagan pieces available to donate:
	Platinum, Gold, Silver, Bronze, and Tin

*-r*
	Reverse the priority of donation to lower-cost pieces instead of high-cost pieces

# EXAMPLE

Calculate how many pieces to donate with a 20,000 gil cap and a 200% rate, with 50 gold pieces and 20 bronze pieces:

	drpc -g 50 -b 20 20000 200

Donate the cheaper pieces first:
	
	drpc -r -g 50 -b 20 20000 200

# AUTHORS

dax <dax@dax.moe>

M drpc.c => drpc.c +3 -11
@@ 37,15 37,11 @@ main(int argc, char **argv)
	int donate[5] = {0,0,0,0,0};
	int cap;
	double rate;
	int reverse;
	const char *usage = "usage: drpc [-r] [-p platinum] [-g gold] [-s silver] [-b bronze] [-t tin] cap rate";
	const char *usage = "usage: drpc [-p platinum] [-g gold] [-s silver] [-b bronze] [-t tin] cap rate";

	int opt;
	while ((opt = getopt(argc, argv, "hrp:g:s:b:t:")) >= 0) {
	while ((opt = getopt(argc, argv, "hp:g:s:b:t:")) >= 0) {
		switch (opt) {
		case 'r':
			reverse = 1;
			break;
		case 'p':
			pieces[PLAT] = atoi(optarg);
			break;


@@ 82,11 78,7 @@ main(int argc, char **argv)
	cap = atoi(argv[optind]);
	rate = atof(argv[++optind]);

	for (int i = 0; i < 5; i++) {
		int type = i;
		if (reverse) {
			type = 5 - i - 1;
		}
	for (int type = PLAT; type <= TIN; type++) {
		value[type] = (int)(value[type] * (rate/100));
		donate[type] = MIN((int)(cap / value[type]), pieces[type]);
		cap -= value[type] * donate[type];