Skip to content
Permalink
Browse files

Initial check-in from previous repo. Alas, history is lost, but lazin…

…ess is far more important.
  • Loading branch information...
Allen B. Cummings
Allen B. Cummings committed May 6, 2017
1 parent 9084b45 commit 3e0c07093b5b3f08ee13291247a31f5753ea3d60
Showing 411 changed files with 41,515 additions and 20 deletions.
29 LICENSE
@@ -0,0 +1,29 @@
Copyright (c) 2017, Allen Cummings, RealmsMUD
All rights reserved.

Redistribution and use in source and forms, with or without modification, are
permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer and must retain the copyright
notice as noted within each source file.

- Redistributions in any other form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

- Neither the name of RealmsMUD nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

10 README
@@ -0,0 +1,10 @@
WARNING: These files are automatically copied over here from revision
control.

Whenever a publish occurs, ANYTHING done here will be removed. If you do
wish to make any alterations, you MUST do it through the proper, controlled
means. If you don't know what those are, you need to talk to Maeglin first.

You have been warned.


This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,130 @@
//*****************************************************************************
// Class: baseCommand
// File Name: baseCommand.c
//
// Copyright (c) 2017 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//
// Description: TBD
//
//*****************************************************************************
#include <mtypes.h>

private string MaterialAttributes = "lib/modules/materialAttributes.c";
private string MessageParser = "/lib/core/messageParser.c";

/////////////////////////////////////////////////////////////////////////////
private nomask object messageParser()
{
return load_object(MessageParser);
}

/////////////////////////////////////////////////////////////////////////////
private nomask int isValidLiving(object livingCheck)
{
return (livingCheck && objectp(livingCheck) &&
(member(inherit_list(livingCheck), MaterialAttributes) > -1));
}

/////////////////////////////////////////////////////////////////////////////
private nomask string formatText(string text, int colorInfo, object viewer)
{
return color(viewer->query("term"), viewer, colorInfo, format(text, 78));
}

/////////////////////////////////////////////////////////////////////////////
private nomask string parseTemplate(string template, string perspective,
object initiator, object target)
{
string message = template;
// ##Infinitive::verb##
// ##InitiatorName## - Initiator's name
// ##InitiatorPossessive[::Name]## - Initiator possessive / your / Name's
// ##InitiatorObjective## - Initiator's objective / you
// ##InitiatorSubjective## - Initiator's subjective/pronoun / you
// ##Target[NPOS]## - Target's (one of above 4)
// ##HitDictionary## - random word from the hit dictionary (slash/slashes,
// chop/chops)
// ##SimileDictionary## - random word from the simile dictionary

// dictionary calls must be done first!
int isSecondPerson = (perspective == "initiator");

if(initiator && objectp(initiator))
{
message = messageParser()->parseSimileDictionary(message, initiator);
message = messageParser()->parseVerbDictionary(message,
"HitDictionary", initiator);

message = messageParser()->parseVerbs(message, isSecondPerson);
}

if(isValidLiving(initiator))
{
message = messageParser()->parseTargetInfo(message, "Initiator",
initiator, isSecondPerson);
}

if(isValidLiving(target))
{
isSecondPerson = (perspective == "target");
message = messageParser()->parseTargetInfo(message, "Target",
target, isSecondPerson);
}

message = messageParser()->capitalizeSentences(message);
return message;
}

/////////////////////////////////////////////////////////////////////////////
protected nomask void displayMessage(string message, object initiator,
object target)
{
// This annoying loop handles the fact that everyone has different
// setting for color.
if (environment(initiator))
{
foreach(object person in all_inventory(environment(initiator)))
{
if (person && objectp(person))// && interactive(person))
{
string parsedMessage;
int colorInfo = C_EMOTES;
if (person == initiator)
{
parsedMessage = parseTemplate(message, "initiator", initiator,
target);
}
else if (person == target)
{
parsedMessage = parseTemplate(message, "target",
initiator, target);
}
else
{
parsedMessage = parseTemplate(message, "other",
initiator, target);
}
tell_object(person, formatText(message, colorInfo,
person));
}
}
}
}

/////////////////////////////////////////////////////////////////////////////
protected nomask void displayMessageToSelf(string message, object initiator)
{
if (initiator && objectp(initiator))
{
string parsedMessage;
int colorInfo = C_EMOTES;

parsedMessage = parseTemplate(message, "initiator", initiator,
initiator);

tell_object(initiator, formatText(message, colorInfo,
initiator));
}
}

@@ -0,0 +1,21 @@
//*****************************************************************************
// Copyright (c) 2017 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************

private string PlayerCommands = "/lib/commands/player";
private string WizardCommands = "/lib/commands/wizard";
private string CannedEmotes = "/lib/commands/soul.c";

/////////////////////////////////////////////////////////////////////////////
public nomask int registerCommands()
{

}

/////////////////////////////////////////////////////////////////////////////
public nomask void init()
{

}

No changes.
No changes.
No changes.
@@ -0,0 +1,181 @@
// *****************************************************************************
// Class: events
// File Name: events.c
//
// Copyright (c) 2017 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//
// Description: This is an admittedly rudimentary event handling system (for
// those who live in the software development world, it's a
// reactor pattern) that has been designed with only the
// player/NPC object model in mind. Event subscribers (those
// waiting for something to happen) can be any object, though said
// object will only find the event processing useful if it has
// implemented a method named as one of the strings listed in the
// validEventHandlers array. These are the events that the
// player/NPC will broadcast to the registered objects.
//
// *****************************************************************************

// I suspect there will be more. This, however, is a decent starting point.
private nosave string *validEventHandlers = ({ "onDeath", "onHeartBeat",
"onAttack", "onAttacked", "onMove", "onUsedAbility", "onHitPointsChanged",
"onSpellPointsChanged", "onStaminaPointsChanged", "onRunAway", "onEquip",
"onUnequip", "onRegisterItem", "onUnregisterItem", "onAdvancedLevel",
"onAdvancedRank", "onDemotedRank", "onJoinGuild", "onLeaveGuild",
"onResearchPointsAdded", "onResearchStarted", "onResearchCompleted",
"onResearchTreeOpen", "onResearchChoiceAvailable", "onResearchChoiceChosen",
"onResearchPathChosen", "onCombatDelayed", "onHit", "onTraitAdded",
"onTraitRemoved", "onQuestStarted", "onQuestAdvancedState",
"onQuestCompleted", "onQuestSucceeded", "onQuestFailed", "onQuestActivated",
"onQuestDeactivated", "onSkillAdvanced", "onSkillDecreased",
"onSkillPointsIncreased", "onSkillPointsUsed"
});

private nosave mapping eventList = ([ ]);

//-----------------------------------------------------------------------------
// Method: registerEvent
// Description: This method is used to register event handlers that will
// subscribe to a given event. The object can be of any base type.
// If an event handler as defined in validEventHandlers exists
// in this subscriber object, it will be called when the event
// of the same name occurs.
//
// Parameters: subscriber - the object that will subscribe to events
//
// Returns: true if successful.
//-----------------------------------------------------------------------------
public nomask int registerEvent(object subscriber)
{
int ret = 0;
if(subscriber && objectp(subscriber) && !member(eventList, subscriber))
{
string *eventsToAdd = ({ });
foreach(string method : functionlist(subscriber, 0x01))
{
if(method && stringp(method) &&
(member(validEventHandlers, method) > -1))
{
eventsToAdd += ({ method });
ret = 1;
}
}
if(ret)
{
eventList[subscriber] = eventsToAdd;
}
}
return ret;
}

//-----------------------------------------------------------------------------
// Method: unregisterEvent
// Description: This method is used to unregister event handlers.
//
// Parameters: subscriber - the object that will unsubscribe to events
//
// Returns: true if successful.
//-----------------------------------------------------------------------------
public nomask int unregisterEvent(object subscriber)
{
int ret = 0;
if(subscriber && objectp(subscriber) && member(eventList, subscriber))
{
m_delete(eventList, subscriber);
ret = 1;
}
return ret;
}

//-----------------------------------------------------------------------------
// Method: registerEventHandler
// Description: This method is used to register custom events that can then be
// subscribed to by event handlers. These events are then placed
// in the validEventHandlers list.
//
// Parameters: eventHandler - new event to manage
//
// Returns: true if successful.
//-----------------------------------------------------------------------------
public nomask int registerEventHandler(string eventHandler)
{
int ret = 0;
if(eventHandler && stringp(eventHandler) &&
(member(validEventHandlers, eventHandler) < 0))
{
validEventHandlers += ({ eventHandler });
ret = 1;
}
return ret;
}

//-----------------------------------------------------------------------------
// Method: unregisterEventHandler
// Description: This method is used to unregister custom events.
//
// Parameters: eventHandler - new event to manage
//
// Returns: true if successful.
//-----------------------------------------------------------------------------
public nomask int unregisterEventHandler(string eventHandler)
{
int ret = 0;
if(eventHandler && stringp(eventHandler) &&
(member(validEventHandlers, eventHandler) > -1))
{
validEventHandlers -= ({ eventHandler });
ret = 1;
}
return ret;
}

//-----------------------------------------------------------------------------
// Method: notify
// Description: This method is used to send notifications to all registered
// event handlers. Every event handler that has created a method
// of same name as the event that is passed will have that method
// called with this_object() passed as a parameter.
//
// Parameters: event - the event that subscribers will be notified of as having
// occurred. This event must be defined in
// the validEventHandlers array.
//
// Returns: true if successful.
//-----------------------------------------------------------------------------
public varargs nomask int notify(string event, mixed message)
{
int ret = 0;

if(event && stringp(event) && (member(validEventHandlers, event) > -1))
{
// delete all null handlers
m_delete(eventList, 0);

// May want/need to limit calls of this method
foreach(object handler : m_indices(eventList))
{
if(handler && objectp(handler) &&
(member(eventList[handler], event) > -1) &&
function_exists(event, handler))
{
if(message)
{
call_other(handler, event, this_object(), message);
}
else
{
call_other(handler, event, this_object());
}
ret = 1;
}
else if(handler && objectp(handler) &&
function_exists("receiveEvent", handler))
{
call_other(handler, "receiveEvent", this_object(), event);
}
}
}
return ret;
}

Oops, something went wrong.

0 comments on commit 3e0c070

Please sign in to comment.
You can’t perform that action at this time.