Example #1
0
int
v_credit(struct command *c)
{
  int target = c->a;
  int amount = c->b;
  int item = c->c;
  int pl;
  extern int gold_times;

  if (amount) {
    if (kind(target) != T_char && kind(target) != T_player) {
      wout(c->who, "%s not a character or player.", c->parse[1]);
      return FALSE;
    }

    if (numargs(c) >= 3 && i_strcmp(c->parse[3], "np") == 0) {
      if (kind(target) != T_player) {
        wout(c->who, "%s not a player.", box_code(target));
        return FALSE;
      }

      add_np(target, amount);
      wout(c->who, "Credited %s %d NP.", box_name(target), amount);
      wout(target, "Received GM credit of %d NP.", amount);
      return TRUE;
    }

    if (item == 0)
      item = 1;

    gen_item(target, item, amount);
    wout(c->who, "Credited %s %s.", box_name(target),
         box_name_qty(item, amount));
    wout(target, "Received CLAIM credit of %s.", box_name_qty(item, amount));
    return TRUE;
  }

  if (kind(target) != T_char) {
    wout(c->who, "%s not a character.", c->parse[1]);
    return FALSE;
  }

  pl = player(target);

  if (times_paid(pl)) {
    wout(c->who, "Already paid faction %s.", box_name(pl));
    return FALSE;
  }

  p_player(pl)->times_paid = TRUE;

  wout(target, "The Times pays %s %s.", box_name(target), gold_s(25));

  gen_item(target, item_gold, 25);
  gold_times += 25;

  return TRUE;
}
Example #2
0
static int
get_command(int who, char *s)
{
  int fact;                     /* who controls us now? */
  char *order;

  if (!valid_box(who) || kind(who) == T_deadchar)
    return FALSE;

  fact = player(who);

  if (fact == 0)
    return FALSE;

  order = top_order(fact, who);

/*
 *  If we don't have any orders, then fail.
 */

  if (order == NULL)
    return FALSE;

/*
 *  Update the player's last turn field so we know if he's been
 *  playing or not.
 */

  {
    struct entity_player *p;

    p = p_player(fact);
    p->last_order_turn = sysclock.turn;
  }

  assert(strlen(order) < LEN);  /* maybe not a valid assert */

  strncpy(s, order, LEN - 1);
  s[LEN - 1] = '\0';

  pop_order(fact, who);

  return TRUE;
}
Example #3
0
char *readln(const char *prompt, playlist_player_t* player) 
{
  hre_t re_empty_line = hre_compile("^\\s*$","");
  char* line;
  el_bool stop = el_false;
  while (!stop && (line = readline(prompt)) != NULL) {
    if (hre_has_match(re_empty_line, line)) {
      // do nothing
    } else {
      stop = el_true;
    }
    p_player(player);
  }

  if (line != NULL) {
    add_history(line);
    mc_take_control(line, strlen(line)+1);
  } else {
    line = mc_strdup("");
  }
  
  return line;
}