view.c

./mudd/src/view.c · 4.0 KB

From the archive emlen.tar.gz

Download the archive   « Back to the archive contents

#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mud.h"



char *
rNAME (CHAR_DATA * to, CHAR_DATA * ch)
{
  char tmprace[150];
  static char ret[500];
  ret[0] = '\0';
  tmprace[0] = '\0';
  if (IS_PLAYER (ch) && IS_PLAYER (to) && DIFF_ALIGN(ch, to) && LEVEL(to) < IMM_LEVEL && LEVEL(ch) < IMM_LEVEL && (can_see_nextdoor (ch, to) || can_see (ch, to)))
    {
      sprintf(tmprace, "+* A %s %s *+", align_info[to->pcdata->alignment].name, race_info[to->pcdata->race].name);
      
      strcpy (ret, tmprace);
    }
  else
    strcpy (ret, PERS (to, ch));
  return ret;
}

void 
replace (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("replace", replace, POSITION_DEAD, 0, LOG_ALWAYS, "This command allows you to replace 1 learn for 10 practices or 10 practices for 1 learn.")

    if (!argy || argy[0] == '\0' || (str_cmp (argy, "learns") && str_cmp (argy, "practices")))
    {
      send_to_char ("Format is 'replace <learns>' to convert 1 learn to 10 practices.\n\r", ch);
      send_to_char ("Format is 'replace <practices>' to convert 10 practices to 1 learn.\n\r", ch);
      return;
    }
  if (!str_cmp (argy, "learns"))
    {
      if (ch->pcdata->learn < 1)
	{
	  send_to_char ("You don't have any learns to convert.\n\r", ch);
	  return;
	}
      ch->pcdata->learn--;
      ch->pcdata->practice += 10;
      send_to_char ("Done.\n\r", ch);
      return;
    }
  if (!str_cmp (argy, "practices"))
    {
      if (ch->pcdata->practice < 10)
	{
	  send_to_char ("You don't have 10 practices to convert.\n\r", ch);
	  return;
	}
      ch->pcdata->learn++;
      ch->pcdata->practice -= 10;
      send_to_char ("Done.\n\r", ch);
      return;
    }
  return;
}





void do_alliance (CHAR_DATA * ch, char *argy)
{
  char arg1[SML_LENGTH];
  char arg2[SML_LENGTH];
  char buf[500];
  char buff[100];
  int num1 = -1;
  int num2 = -1;
  
  DEFINE_COMMAND ("alliance", do_alliance, POSITION_STANDING, 1, LOG_NORMAL, "This command lists all of the current alliances and lets imms set alliances.")   
    if (IS_MOB(ch)) return;
 
  if (argy[0] == '\0' || argy == "" || LEVEL(ch) < MAX_LEVEL)
    {
      int i;
      int j;
      buf[0] = '\0';
      send_to_char("This chart tells which sides are allied with which. \n\n\r", ch);
      sprintf (buf, "                    ");
      for (j = 0; j < NUM_ALIGN; j ++)
	{
	  sprintf(buff, "%2d   ", j);
	  strcat(buf, buff);
	}
      strcat(buf, "\n\r");
      send_to_char(buf, ch);
      for (i = 0; i < NUM_ALIGN; i++)
	{
	  sprintf(buf, "\x1b[0;37m%2d. %-15s  ", i, align_info[i].name);
	  for (j = 0; j < NUM_ALIGN; j++)
	    {
	      if (alliance[i][j] == TRUE)
		strcat(buf, "\x1b[1;37mY    ");
	      else
		strcat(buf, "\x1b[1;30mN    ");
	    }
	  strcat(buf, "\x1b[0;37m\n\r");
	  send_to_char(buf, ch);
	}
      return;
    }
  argy = one_argy(argy, arg1);
  argy = one_argy(argy, arg2);
  if (!is_number(arg1) || !is_number(arg2))
    {
      send_to_char ("Syntax: alliance <num1> <num2>\n\r", ch);
      return;
    }
  num1 = atoi(arg1);
  num2 = atoi(arg2);
  if (num1 < 0 || num1 >= NUM_ALIGN || num2 <0 || num2 >= NUM_ALIGN)
    {
      send_to_char("The numbers you pick for the alignments must be at least 0 and less than the number of alignments.\n\r", ch);
      return;
    }
  if (num1 == num2)
    {
      send_to_char("A side cannot be set against itself\n\r", ch);
      alliance[num1][num2] = TRUE;
      fwrite_alliance_data();
    }
  if (alliance[num1][num2] && alliance[num2][num1])
    {
      sprintf(buf, "Ok, ending the alliance between the %s and the %s\n\r", align_info[num1].name, align_info[num2].name);
      send_to_char(buf, ch);
      alliance[num1][num2] = FALSE;
      alliance[num2][num1] = FALSE;
      fwrite_alliance_data();
      return;
    }
  else
    {
       sprintf(buf, "Ok, creating an alliance between the %s and the %s\n\r", align_info[num1].name, align_info[num2].name);
      send_to_char(buf, ch);
      alliance[num1][num2] = TRUE;
      alliance[num2][num1] = TRUE;
      fwrite_alliance_data();
      return;
    }
  return;
}

Site Stats

Snippets: 1791
Codebases: 571