コード例 #1
0
ファイル: hack.shk.c プロジェクト: AhmadTux/DragonFlyBSD
/*       -1 if object could not be found (but was paid) */
static int
dopayobj(struct bill_x *bp)
{
	struct obj *obj;
	long ltmp;

	/* find the object on one of the lists */
	obj = bp_to_obj(bp);

	if (!obj) {
		impossible("Shopkeeper administration out of order.");
		setpaid();	/* be nice to the player */
		return (0);
	}

	if (!obj->unpaid && !bp->useup) {
		impossible("Paid object on bill??");
		return (1);
	}
	obj->unpaid = 0;
	ltmp = bp->price * bp->bquan;
	if (ANGRY(shopkeeper))
		ltmp += ltmp / 3;
	if (u.ugold < ltmp) {
		pline("You don't have gold enough to pay %s.",
		      doname(obj));
		obj->unpaid = 1;
		return (0);
	}
	pay(ltmp, shopkeeper);
	pline("You bought %s for %ld gold piece%s.",
	      doname(obj), ltmp, plur(ltmp));
	if (bp->useup) {
		struct obj *otmp = billobjs;
		if (obj == billobjs)
			billobjs = obj->nobj;
		else {
			while (otmp && otmp->nobj != obj)
				otmp = otmp->nobj;
			if (otmp)
				otmp->nobj = obj->nobj;
			else
				pline("Error in shopkeeper administration.");
		}
		free(obj);
	}
	return (1);
}
コード例 #2
0
ファイル: shk.c プロジェクト: BackupTheBerlios/paleohack
/*       -1 if object could not be found (but was paid) */
static Short dopayobj(bill_t *bp)
{
  obj_t *obj;
  Long ltmp;

  /* find the object on one of the lists */
  obj = bp_to_obj(bp);

  if (!obj) {
    message("BUG: Shopkeeper administration out of order.");
    setpaid();	/* be nice to the player */
    return 0;
  }

  if (!(obj->bitflags & O_IS_UNPAID) && !bp->useup) {
    message("BUG: Paid object on bill??");
    return 1;
  }
  obj->bitflags &= ~O_IS_UNPAID;
  ltmp = bp->price * bp->bquantity;
  if (ANGRY(shopkeeper)) ltmp += ltmp/3;
  if (you.ugold < ltmp) {
    StrPrintF(ScratchBuffer, "You don't have gold enough to pay %s.",
	      doname(obj));
    message(ScratchBuffer);
    obj->bitflags |= O_IS_UNPAID;
    return 0;
  }
  pay(ltmp, shopkeeper);
  StrPrintF(ScratchBuffer, "You bought %s for %ld gold piece%s",
	    doname(obj), ltmp, (ltmp == 1 ? "." : "s."));
  message(ScratchBuffer);
  if (bp->useup) {
    obj_t *otmp = billobjs;
    if (obj == billobjs)
      billobjs = obj->nobj;
    else {
      while (otmp && otmp->nobj != obj) otmp = otmp->nobj;
      if (otmp) otmp->nobj = obj->nobj;
      else message("BUG: Error in shopkeeper administration.");
    }
    free_me((VoidPtr) obj);
  }
  return 1;
}
コード例 #3
0
ファイル: hack.shk.c プロジェクト: AhmadTux/DragonFlyBSD
int
doinvbill(int mode)	/* 0: deliver count 1: paged */
{
	struct bill_x *bp;
	struct obj *obj;
	long totused, thisused;
	char buf[BUFSZ];

	if (mode == 0) {
		int cnt = 0;

		if (shopkeeper)
			for (bp = bill; bp - bill < ESHK(shopkeeper)->billct; bp++)
				if (bp->useup ||
				    ((obj = bp_to_obj(bp)) && obj->quan < bp->bquan))
					cnt++;
		return (cnt);
	}

	if (!shopkeeper) {
		impossible("doinvbill: no shopkeeper?");
		return (0);
	}

	set_pager(0);
	if (page_line("Unpaid articles already used up:") || page_line(""))
		goto quit;

	totused = 0;
	for (bp = bill; bp - bill < ESHK(shopkeeper)->billct; bp++) {
		obj = bp_to_obj(bp);
		if (!obj) {
			impossible("Bad shopkeeper administration.");
			goto quit;
		}
		if (bp->useup || bp->bquan > obj->quan) {
			int cnt, oquan, uquan;

			oquan = obj->quan;
			uquan = (bp->useup ? bp->bquan : bp->bquan - oquan);
			thisused = bp->price * uquan;
			totused += thisused;
			obj->quan = uquan;	/* cheat doname */
			sprintf(buf, "x -  %s", doname(obj));
			obj->quan = oquan;	/* restore value */
			for (cnt = 0; buf[cnt]; cnt++)
				; /* nothing */
			while (cnt < 50)
				buf[cnt++] = ' ';
			sprintf(&buf[cnt], " %5ld zorkmids", thisused);
			if (page_line(buf))
				goto quit;
		}
	}
	sprintf(buf, "Total:%50ld zorkmids", totused);
	if (page_line("") || page_line(buf))
		goto quit;
	set_pager(1);
	return (0);
quit:
	set_pager(2);
	return (0);
}
コード例 #4
0
ファイル: shk.c プロジェクト: BackupTheBerlios/paleohack
Short doinvbill(Short mode) /* 0: deliver count 1: paged */
{
  bill_t *bp;
  obj_t *obj;
  //  Long totused, thisused;
  //  Char buf[BUFSZ];

  if (mode == 0) {
    Short cnt = 0;

    if (shopkeeper)
      for (bp = bill ; bp - bill < ESHK(shopkeeper)->billct ; bp++)
	if (bp->useup ||
	    ((obj = bp_to_obj(bp)) && obj->quantity < bp->bquantity))
	  cnt++;
    return cnt;
  }

  if (!shopkeeper) {
    message("BUG: doinvbill: no shopkeeper?");
    return 0;
  }

  // XXXXX What one really ought to do is to pop up a form or something.
  /*
  set_pager(0);
  if (page_line("Unpaid articles already used up:") || page_line(""))
    goto quit;

  totused = 0;
  for (bp = bill; bp - bill < ESHK(shopkeeper)->billct; bp++) {
    obj = bp_to_obj(bp);
    if (!obj) {
      message("BUG: Bad shopkeeper administration.");
      return 0;
    }
    if (bp->useup || bp->bquantity > obj->quantity) {
      Short cnt, oquan, uquan;

      oquan = obj->quantity;
      uquan = (bp->useup ? bp->bquantity : bp->bquantity - oquan);
      thisused = bp->price * uquan;
      totused += thisused;
      obj->quantity = uquan;		// / * cheat doname * /
      (void) sprintf(buf, "x -  %s", doname(obj));
      obj->quantity = oquan;		// / * restore value * /
      for (cnt = 0; buf[cnt]; cnt++);
      while (cnt < 50)
	buf[cnt++] = ' ';
      (void) sprintf(&buf[cnt], " %5ld zorkmids", thisused);
      if (page_line(buf))
	goto quit;
    }
  }
  (void) sprintf(buf, "Total:%50ld zorkmids", totused);
  if (page_line("") || page_line(buf))
    goto quit;
  set_pager(1);
  return(0);
 quit:
  set_pager(2);
  */
  return(0);
}