/*     File:         moons.c
 *     Description:  This file contains a really tiny code snip
 *                   I did a while back. Its extremely simple,
 *                   What it does, is add a moon to the mud.
 *                   The moon is very simple. it changes phase
 *                   once every 24 hours, goes through the standard
 *                   phases.
 *     Ideas:        Magic. Have a class or two that are dependant
 *                   on the current moon's phase to work their magic
 *                   well. Like class wiccan, their spell, flame strike?..
 *                   if (weather_info.xalaiaix_phase == XALIAIAX_FULL_MOON)
 *                       dam *= 2;
 *                   or something.. its up to you ;) Just dont let it sit there heh
 *
 *     Conditions
 *     of use:       This snip is so small, and so not advanced, i dont require anything.
 *                   Though.. it would be nice to have an email saying you like it
 *                   and are using it.. my ego needs inflating.
 *
 *     Additional
 *     credits:      JGS for the artwork. (I was unable to get ahold of her for
 *                   some reason, the email on her website did not work, ive tried
 *                   over 30 times in the last 6 months. *i had a few other emails
 *                   none of which have worked*)
 *
 *                   KaVir for enlightning me on the ways of Switch statements,
 *                   and creating godwars, of which has been a source of ideas,
 *                   and what to do and what NOT to do when both running a mud
 *                   and designing it. (Btw kavir, put the lost city code up
 *                   on a server somewhere, I loved playing that :P even with
 *                   no players on!)
 *
 *                   The diku team for creating the orginal mud diku mud, which
 *                   spawned everything we use today.
 *
 *
 *     Orginal idea: I don't think i borrowed this idea from anywhere, I just
 *                   wanted a moon (actually i have 4 moons, each with their
 *                   own rotation speeds, and affects on the world, each
 *                   associated with a diety) I mean come on.. we have
 *                   a sun, we have rain, wind, fireballs, elves, dragons,
 *                   why not a moon? Come on now.
 *
 *     -Thri
 *     AIM: CalibanL
 *     ICQ: 5335308
 *     email: cyhawk@comcast.net
 *     Mud homepage: http://soulblight.slayn.net
 *     Mud telnet: telnet://soulblight.slayn.net:5500 (down for repairs)
 *
 *     Code.. (not the ascii pictures) are copyright 2004 Thri.
 *     Or something, just dont say you did it when you didnt, ok? =)
 */

STEP 1:
// Ok first we put in the function, act_info.c is good, somewhere
// near the bottom.

/* Function: do_xalaiaix_phase
 * Associated Command: 'look moon'
 * Description:
 * Shows the current status of the Moon Xalaiaix's phase.
 *
 * Note: The moon Xalaiaix changes Phase once per day, thus
 * a full cycle of the Xalaiaix moon is 8 days.
 */

void
do_xalaiaix_phase (CHAR_DATA * ch, char *argument)
{

  char buf[MAX_STRING_LENGTH];


  if (weather_info.xalaiaix_phase == XALIAIAX_NEW_MOON)
    {
      send_to_char
	("{xThe moon Xalaiaix is current in the 'New moon' Phase\n\r\n\r",
	 ch);
      send_to_char ("{x         _..._           \n\r", ch);
      send_to_char ("{x       .:::::::.         \n\r", ch);
      send_to_char ("{x      :::::::::::        \n\r", ch);
      send_to_char ("{x      :::::::::::        \n\r", ch);
      send_to_char ("{x,     `:::::::::'        \n\r", ch);
      send_to_char ("{x        `':::''          \n\r\n\r", ch);
      return;
    }


  else if (weather_info.xalaiaix_phase == XALIAIAX_WAXING_CRESCENT)
    {
      send_to_char
	("{xThe moon Xalaiaix is current in the 'Waxing Crescent' Phase\n\r\n\r",
	 ch);
      send_to_char ("{x        _..._		\n\r", ch);
      send_to_char ("{x      .::::. `.		\n\r", ch);
      send_to_char ("{x     :::::::.  : 	\n\r", ch);
      send_to_char ("{x     ::::::::  :	\n\r", ch);
      send_to_char ("{x     `::::::' .'	\n\r", ch);
      send_to_char ("{x      `'::'-'		\n\r\n\r", ch);
      return;

    }


  else if (weather_info.xalaiaix_phase == XALIAIAX_FIRST_QUARTER)
    {
      sprintf (buf,
	       "The moon Xalaiaix is currently in the 'Waxing first quarter' Phase.\n\r");
      send_to_char (buf, ch);
      send_to_char ("{x        _..._		\n\r", ch);
      send_to_char ("{x      .::::  `.		\n\r", ch);
      send_to_char ("{x     ::::::    :	\n\r", ch);
      send_to_char ("{x     ::::::    :	\n\r", ch);
      send_to_char ("{x     `:::::   .'	\n\r", ch);
      send_to_char ("{x       `'::.-'		\n\r\n\r", ch);
      return;
    }


  else if (weather_info.xalaiaix_phase == XALIAIAX_WAXING_GIBBOUS)
    {
      sprintf (buf,
	       "The moon Xalaiaix is currently in the 'Waxing Gibbous' Phase.\n\r");
      send_to_char (buf, ch);
      send_to_char ("{x        _..._		\n\r", ch);
      send_to_char ("{x      .::'   `.		\n\r", ch);
      send_to_char ("{x     :::       :	\n\r", ch);
      send_to_char ("{x     :::       :	\n\r", ch);
      send_to_char ("{x     `::.     .'	\n\r", ch);
      send_to_char ("{x      `':..-'		\n\r\n\r", ch);
      return;
    }


  else if (weather_info.xalaiaix_phase == XALIAIAX_FULL_MOON)
    {
      sprintf (buf, "The moon Xalaiaix is currently Full\n\r");
      send_to_char (buf, ch);
      send_to_char ("{x        _..._		\n\r", ch);
      send_to_char ("{x      .'     `.		\n\r", ch);
      send_to_char ("{x     :         :	\n\r", ch);
      send_to_char ("{x     :         :	\n\r", ch);
      send_to_char ("{x     `.       .'	\n\r", ch);
      send_to_char ("{x      `-...-'		\n\r\n\r", ch);
      return;
    }


  else if (weather_info.xalaiaix_phase == XALIAIAX_WANING_GIBBOUS)
    {
      sprintf (buf,
	       "The moon Xalaiaix is currently in the 'Waning Gibbous' Phase.\n\r");
      send_to_char (buf, ch);
      send_to_char ("{x        _..._		\n\r", ch);
      send_to_char ("{x      .'   `::.		\n\r", ch);
      send_to_char ("{x     :       ::: 	\n\r", ch);
      send_to_char ("{x     :       :::	\n\r", ch);
      send_to_char ("{x     `.     .::'	\n\r", ch);
      send_to_char ("{x       `-..:''		\n\r\n\r", ch);
      return;
    }

  else if (weather_info.xalaiaix_phase == XALIAIAX_LAST_QUARTER)
    {
      sprintf (buf,
	       "The moon Xalaiaix is currently in the 'Last Quarter' Phase.\n\r");
      send_to_char (buf, ch);
      send_to_char ("{x        _..._		\n\r", ch);
      send_to_char ("{x      .'  ::::.		\n\r", ch);
      send_to_char ("{x     :    ::::::	\n\r", ch);
      send_to_char ("{x     :    ::::::	\n\r", ch);
      send_to_char ("{x     `.   :::::'	\n\r", ch);
      send_to_char ("{x       `-.::''		\n\r\n\r", ch);
      return;
    }

  else if (weather_info.xalaiaix_phase == XALIAIAX_WANING_CRESCENT)
    {
      sprintf (buf,
	       "The moon Xalaiaix is currently in the 'Waning Crescent' Phase.\n\r");
      send_to_char (buf, ch);
      send_to_char ("{x        _..._		\n\r", ch);
      send_to_char ("{x      .' .::::.		\n\r", ch);
      send_to_char ("{x     :  ::::::::	\n\r", ch);
      send_to_char ("{x     :  ::::::::	\n\r", ch);
      send_to_char ("{x     `. '::::::'	\n\r", ch);
      send_to_char ("{x       `-.::''		\n\r\n\r", ch);
      return;
    }

  else
    {
      sprintf (buf,
	       "Serious bug in weather.info.xalaiaix_phase, report to Thri : Moon Phase is %d \n\r",
	       weather_info.xalaiaix_phase);
      send_to_char (buf, ch);
    }

  return;
}


STEP 2:
// Next we handle look 'moon'
// inside of do_look, below the strcmp for auto, and before 'i'
// put
            send_to_char ("\n\r", ch);
            do_function (ch, &do_exits, "auto");
        }

        show_list_to_char (ch->in_room->contents, ch, FALSE, FALSE);
        show_char_to_char (ch->in_room->people, ch);
        return;
    }

+   if (!str_cmp (arg1, "moon"))          // Start here - Thri
+   {
+	do_function(ch, &do_xalaiaix_phase, "");
+      return;
+   }  // End here - Thri

   if (!str_cmp (arg1, "i") || !str_cmp (arg1, "in")
        || !str_cmp (arg1, "on"))
    {
        /* 'look in' */

STEP 3:
// In interp.h declare it like..
DECLARE_DO_FUN( do_xalaiaix_phase		);

STEP 3.2:
// Yes, you can also add this as a stand alone function.
// Ive just been in the mood to use the do_function wrapper
// for all commands like this, since its safer IMHO ;)

STEP 4:
// Ok, all the commands are setup, SO.. we need to define everything
// in merc.h, find weather_data
// add.. into it somewhere, anywhere, last is good
struct    weather_data
{
    .....
    int        sky;
    int        sunlight;
+   int        xalaiaix_phase;     // Moon function - Thri
};

STEP 4.5:
// Below that, we need to define what the numbers mean in terms
// of moon phase
// So add below weather_data...

#define XALIAIAX_NEW_MOON          0
#define XALIAIAX_WAXING_CRESCENT   1
#define XALIAIAX_FIRST_QUARTER     2
#define XALIAIAX_WAXING_GIBBOUS    3
#define XALIAIAX_FULL_MOON         4
#define XALIAIAX_WANING_GIBBOUS    5
#define XALIAIAX_LAST_QUARTER      6
#define XALIAIAX_WANING_CRESCENT   7

STEP 5:
// Ok we got everything defined, we can see the moon's phase,
// Now.. to prevent some extremely high number bug
// open up db.c, in boot_db()
// after all the weather_info stuff, add
            weather_info.sunlight = SUN_SET;
        else
            weather_info.sunlight = SUN_DARK;

+       weather_info.xalaiaix_phase = number_range(0, 7);      // Moon function -Thri

        weather_info.change = 0;
        weather_info.mmhg = 960;


Step 6:
// Ok the moon is initialized on startup, it has a phase, but
// now we have to make it change phases during the day.
// In update.c find weather_update()
// and add..

        case 24:
            time_info.hour = 0;
            time_info.day++;

+           weather_info.xalaiaix_phase++;       // Moon function - Thri

            break;
    }

    if (time_info.day >= 35)

Step 7:

    And were done!
    The moon is set up, changes phases, and you can look 'moon' to see what phase its in.
    Now start adding cool affects with spells and such. And remember, I like my ego
    inflated from time to time. ;)

-Thri