[ogs-changes] dist/c++/ogs/skills CommonSkills.cpp,NONE,1.1 CommonSkills.h,NONE,1.1 SkillFactory.h,N
Status: Alpha
Brought to you by:
elemings
Update of /cvsroot/ogs/dist/c++/ogs/skills
In directory sc8-pr-cvs1:/tmp/cvs-serv9203
Modified Files:
Makefile.am Spot.cpp Spot.h
Added Files:
CommonSkills.cpp CommonSkills.h SkillFactory.h
Removed Files:
Appraise.h Bluff.h Climb.h Craft.h Diplomacy.cpp Diplomacy.h
DisableDevice.h Disguise.h EscapeArtist.h Forgery.h
GatherInformation.h HandleAnimal.h Hide.h Intimidate.h Jump.h
Knowledge.h Listen.h MoveSilently.h Profession.h Ride.h
Search.h SenseMotive.h SpeakLanguage.h Swim.h Tumble.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
--- NEW FILE: CommonSkills.cpp ---
/*
* CommonSkills.cpp -- class implementation for common skills
* Copyright (C) 2003 Eric Lemings <ele...@us...>
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA
*
* RCS: $Id: CommonSkills.cpp,v 1.1 2003/04/13 05:26:28 elemings Exp $
*/
#include "ogs/core/Ability.h"
#include "ogs/core/Skill.h"
#include "ogs/skills/CommonSkills.h"
#include "ogs/skills/SkillFactory.h"
#include "ogs/skills/Spot.h"
using ogs::core::Ability;
using ogs::core::Skill;
using ogs::skills::CommonSkills;
using ogs::skills::SkillFactory;
using ogs::skills::Spot;
/**
* Create a new common skill of a specified type. If the skill type is
* unknown, this function will return an empty pointer.
*
* @param skillType Type of skill to create.
* @return A skill pointer or an empty pointer.
*/
SkillFactory::SkillPtr
CommonSkills::createSkill (Skill::Type skillType) {
SkillFactory::SkillPtr skillPtr;
const bool trainedOnly = false;
const bool useUntrained = true;
const bool noArmorPenalty = false;
const bool useArmorPenalty = true;
switch (skillType) {
case APPRAISE:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case BLUFF:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case CLIMB:
skillPtr.reset (new Skill (skillType, Ability::STR,
useUntrained, useArmorPenalty));
break;
case CRAFT:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case DIPLOMACY:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case DISABLE_DEVICE:
skillPtr.reset (new Skill (skillType, Ability::INT,
trainedOnly, noArmorPenalty));
break;
case DISGUISE:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case ESCAPE_ARTIST:
skillPtr.reset (new Skill (skillType, Ability::DEX,
useUntrained, useArmorPenalty));
break;
case FORGERY:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case GATHER_INFORMATION:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case HANDLE_ANIMAL:
skillPtr.reset (new Skill (skillType, Ability::CHA,
trainedOnly, noArmorPenalty));
break;
case HIDE:
skillPtr.reset (new Skill (skillType, Ability::WIS,
useUntrained, useArmorPenalty));
break;
case INTIMIDATE:
skillPtr.reset (new Skill (skillType, Ability::CHA,
useUntrained, noArmorPenalty));
break;
case JUMP:
skillPtr.reset (new Skill (skillType, Ability::STR,
useUntrained, useArmorPenalty));
break;
case KNOWLEDGE:
skillPtr.reset (new Skill (skillType, Ability::INT,
trainedOnly, noArmorPenalty));
break;
case LISTEN:
skillPtr.reset (new Skill (skillType, Ability::WIS,
useUntrained, noArmorPenalty));
break;
case MOVE_SILENTLY:
skillPtr.reset (new Skill (skillType, Ability::DEX,
useUntrained, useArmorPenalty));
break;
case PROFESSION:
skillPtr.reset (new Skill (skillType, Ability::WIS,
trainedOnly, noArmorPenalty));
break;
case RIDE:
skillPtr.reset (new Skill (skillType, Ability::DEX,
useUntrained, noArmorPenalty));
break;
case SEARCH:
skillPtr.reset (new Skill (skillType, Ability::INT,
useUntrained, noArmorPenalty));
break;
case SENSE_MOTIVE:
skillPtr.reset (new Skill (skillType, Ability::WIS,
useUntrained, noArmorPenalty));
break;
case SPEAK_LANGUAGE:
skillPtr.reset (new Skill (skillType, Ability::INT,
trainedOnly, noArmorPenalty));
break;
case SPOT:
skillPtr.reset (new Spot ());
break;
case SWIM:
skillPtr.reset (new Skill (skillType, Ability::STR,
useUntrained, noArmorPenalty));
break;
case TUMBLE:
skillPtr.reset (new Skill (skillType, Ability::DEX,
trainedOnly, useArmorPenalty));
break;
default:
break;
}
return (skillPtr);
}
--- NEW FILE: CommonSkills.h ---
/*
* CommonSkills.h -- class interface for common skills
* Copyright (C) 2003 Eric Lemings <ele...@us...>
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA
*
* RCS: $Id: CommonSkills.h,v 1.1 2003/04/13 05:26:28 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_SKILLS_COMMON_SKILLS_H
# define OGS_SKILLS_COMMON_SKILLS_H
# include <ogs/core/Skill.h>
# include <ogs/skills/Namespace.h>
# include <ogs/skills/SkillFactory.h>
OGS_BEGIN_SKILLS_NAMESPACE
/**
* A skill factory that creates common skill objects.
*/
struct CommonSkills: public SkillFactory {
/** A skill for appraising the value of rare and exotic items. */
static const ogs::core::Skill::Type APPRAISE = 3;
/** A skill for deceiving and fooling other creatures. */
static const ogs::core::Skill::Type BLUFF = 5;
/** A skill for scaling all types of vertical surfaces. */
static const ogs::core::Skill::Type CLIMB = 6;
/** A skill for creating and repairing specific types of items. */
static const ogs::core::Skill::Type CRAFT = 8;
/** A skill for relating and negotiating with foreign creatures. */
static const ogs::core::Skill::Type DIPLOMACY = 10;
/** A skill for circumventing the function of items and devices. */
static const ogs::core::Skill::Type DISABLE_DEVICE = 11;
/** A skill for altering appearances with makeup and other items. */
static const ogs::core::Skill::Type DISGUISE = 12;
/** A skill for escaping from ropes, grapples, and other bonds. */
static const ogs::core::Skill::Type ESCAPE_ARTIST = 13;
/** A skill for forging documents and other items. */
static const ogs::core::Skill::Type FORGERY = 14;
/** A skill for collecting and analyzing rumors and information. */
static const ogs::core::Skill::Type GATHER_INFORMATION = 15;
/** A skill for gaining and maintaining control of animals. */
static const ogs::core::Skill::Type HANDLE_ANIMAL = 16;
/** A skill for concealing items and creatures in plain sight. */
static const ogs::core::Skill::Type HIDE = 18;
/** A skill for threatening and interrogating other creatures. */
static const ogs::core::Skill::Type INTIMIDATE = 20;
/** A skill for jumping over objects and across distances. */
static const ogs::core::Skill::Type JUMP = 22;
/** A skill for testing knowledge on a particular subject. */
static const ogs::core::Skill::Type KNOWLEDGE = 23;
/** A skill for hearing faint sounds. */
static const ogs::core::Skill::Type LISTEN = 27;
/** A skill for moving without making a noise. */
static const ogs::core::Skill::Type MOVE_SILENTLY = 28;
/** A skill for checking within a particular profession. */
static const ogs::core::Skill::Type PROFESSION = 32;
/** A skill that determines riding ability. */
static const ogs::core::Skill::Type RIDE = 34;
/** A skill for physically locating hidden or concealed objects. */
static const ogs::core::Skill::Type SEARCH = 36;
/** A skill for detecting real intent and hidden agenda. */
static const ogs::core::Skill::Type SENSE_MOTIVE = 37;
/** A skill for communicating orally with a specific language. */
static const ogs::core::Skill::Type SPEAK_LANGUAGE = 38;
/** A skill for visually locating hidden or concealed objects. */
static const ogs::core::Skill::Type SPOT = 40;
/* A skill for moving through varying currents of water. */
static const ogs::core::Skill::Type SWIM = 41;
/** A skill for maneuvering and recovering from falls. */
static const ogs::core::Skill::Type TUMBLE = 42;
SkillPtr createSkill (ogs::core::Skill::Type skillType);
};
OGS_END_SKILLS_NAMESPACE
# endif /* !defined OGS_SKILLS_COMMON_SKILLS_H */
#endif /* defined __cplusplus */
--- NEW FILE: SkillFactory.h ---
/*
* SkillFactory.h -- class interface for skill factory
* Copyright (C) 2003 Eric Lemings <ele...@us...>
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA
*
* RCS: $Id: SkillFactory.h,v 1.1 2003/04/13 05:26:29 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_SKILLS_SKILL_FACTORY_H
# define OGS_SKILLS_SKILL_FACTORY_H
# include <boost/shared_ptr.hpp>
# include <ogs/core/Skill.h>
# include <ogs/skills/Namespace.h>
OGS_BEGIN_SKILLS_NAMESPACE
/**
* An object that creates skill objects.
*/
struct SkillFactory {
/** A smart pointer for a skill object. */
typedef boost::shared_ptr<ogs::core::Skill> SkillPtr;
/**
* Create a new skill of a specified type.
*
* @param skillType Type of skill to create.
* @return A new skill of the specified type.
*/
virtual SkillPtr createSkill (ogs::core::Skill::Type skillType) = 0;
};
OGS_END_SKILLS_NAMESPACE
# endif /* !defined OGS_SKILLS_SKILL_FACTORY_H */
#endif /* defined __cplusplus */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/skills/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Makefile.am 4 Mar 2003 03:24:42 -0000 1.2
--- Makefile.am 13 Apr 2003 05:26:28 -0000 1.3
***************
*** 24,53 ****
pkginclude_HEADERS = \
! Appraise.h \
! Bluff.h \
! Climb.h \
! Craft.h \
! Diplomacy.h \
! DisableDevice.h \
! Disguise.h \
! EscapeArtist.h \
! Forgery.h \
! GatherInformation.h \
! HandleAnimal.h \
! Hide.h \
! Intimidate.h \
! Jump.h \
! Knowledge.h \
! Listen.h \
! MoveSilently.h \
Namespace.h \
! Profession.h \
! Ride.h \
! Search.h \
! SenseMotive.h \
! SpeakLanguage.h \
! Spot.h \
! Swim.h \
! Tumble.h
INCLUDES = \
--- 24,31 ----
pkginclude_HEADERS = \
! CommonSkills.h \
Namespace.h \
! SkillFactory.h \
! Spot.h
INCLUDES = \
***************
*** 60,64 ****
libogs_skills_la_DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
libogs_skills_la_SOURCES = \
! Diplomacy.cpp \
Spot.cpp
--- 38,42 ----
libogs_skills_la_DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
libogs_skills_la_SOURCES = \
! CommonSkills.cpp \
Spot.cpp
Index: Spot.cpp
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/skills/Spot.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Spot.cpp 25 Mar 2003 06:13:14 -0000 1.2
--- Spot.cpp 13 Apr 2003 05:26:29 -0000 1.3
***************
*** 21,42 ****
*/
#include "ogs/core/Modifier.h"
#include "ogs/skills/Spot.h"
using ogs::core::Modifier;
using ogs::skills::Spot;
! Modifier Spot::distractedModifier (-5);
/**
! * Create a new Spot skill.
*
! * @param distance Distance of the target from the spotter (default less
! * than 10 feet).
! * @param distracted True if the spotter is distracted (default false).
*/
! Spot::Spot (float distance, bool distracted) {
! this->distance = distance;
! this->distracted = distracted;
}
--- 21,54 ----
*/
+ #include <algorithm>
+
+ #include "ogs/core/Ability.h"
#include "ogs/core/Modifier.h"
+ #include "ogs/core/Modifiers.h"
+ #include "ogs/skills/CommonSkills.h"
#include "ogs/skills/Spot.h"
+ using ogs::core::Ability;
using ogs::core::Modifier;
+ using ogs::core::Modifiers;
+ using ogs::skills::CommonSkills;
using ogs::skills::Spot;
! Modifier Spot::_distractedModifier (-5);
/**
! * Create a new Spot skill. The default distance of a new Spot skill is
! * 10 feet or less. The user of the new Spot skill is not distracted by
! * default.
*
! * @param distance Distance of the target from the spotter.
! * @param distracted True if the spotter is distracted.
*/
! Spot::Spot (float distance, bool distracted):
! Skill (CommonSkills::SPOT, Ability::WIS, true, false),
! _distance (distance),
! _distanceModifier (),
! _distracted (distracted) {
! (this->getModifiers ()).addModifier (this->_distanceModifier);
}
***************
*** 49,61 ****
*/
void Spot::setDistance (float distance) {
if (distance >= 10.0) {
// TODO: Make the 10 feet increment locale dependent.
! this->distanceModifier.setValue (int (distance / 10.0));
! // TODO: Add modifier to skill check if not already added.
} else {
! // TODO: Remove modifier from skill check if already added.
}
-
- this->distance = distance;
}
--- 61,72 ----
*/
void Spot::setDistance (float distance) {
+ this->_distance = distance;
+
if (distance >= 10.0) {
// TODO: Make the 10 feet increment locale dependent.
! this->_distanceModifier.setValue (- (int (distance / 10.0)));
} else {
! this->_distanceModifier.setValue (0);
}
}
***************
*** 70,81 ****
void Spot::setDistracted (bool distracted) {
// Do nothing unless distracted is changed.
! if ((!this->distracted) && distracted) {
// Changing from not distracted to distracted.
! // TODO: Add distractedModifier to skill check.
! this->distracted = distracted;
! } else if (this->distracted && (!distracted)) {
// Changing from distracted to not distracted.
! // TODO: Remove distractedModifier to skill check.
! this->distracted = distracted;
}
}
--- 81,92 ----
void Spot::setDistracted (bool distracted) {
// Do nothing unless distracted is changed.
! if ((!this->_distracted) && distracted) {
// Changing from not distracted to distracted.
! this->_distracted = distracted;
! (this->getModifiers ()).addModifier (this->_distractedModifier);
! } else if (this->_distracted && (!distracted)) {
// Changing from distracted to not distracted.
! this->_distracted = distracted;
! (this->getModifiers ()).removeModifier (this->_distractedModifier);
}
}
Index: Spot.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/skills/Spot.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Spot.h 29 Mar 2003 02:10:39 -0000 1.3
--- Spot.h 13 Apr 2003 05:26:29 -0000 1.4
***************
*** 28,32 ****
# include <ogs/core/Modifier.h>
# include <ogs/core/Skill.h>
! # include <ogs/core/Ability.h>
# include <ogs/skills/Namespace.h>
--- 28,32 ----
# include <ogs/core/Modifier.h>
# include <ogs/core/Skill.h>
! # include <ogs/skills/CommonSkills.h>
# include <ogs/skills/Namespace.h>
***************
*** 38,45 ****
class Spot: public ogs::core::Skill {
public:
- ogs::core::Ability::Type getKeyAbility () const;
- bool useUntrained () const;
- bool useArmorCheckPenalty () const;
-
Spot (float distance = 0.0, bool distracted = false);
--- 38,41 ----
***************
*** 50,88 ****
private:
! float distance;
! ogs::core::Modifier distanceModifier;
! bool distracted;
! static ogs::core::Modifier distractedModifier;
};
/**
- * The key ability of the Spot skill is Wisdom.
- *
- * @return Wisdom
- */
- inline ogs::core::Ability::Type
- Spot::getKeyAbility () const {
- return (ogs::core::Ability::WIS);
- }
-
- /**
- * The Spot skill can be used untrained.
- *
- * @return True.
- */
- inline bool Spot::useUntrained () const {
- return (true);
- }
-
- /**
- * The Spot skill does not use armor check penalties.
- *
- * @return False
- */
- inline bool Spot::useArmorCheckPenalty () const {
- return (false);
- }
-
- /**
* Determine the distance of the target from the spotter.
*
--- 46,56 ----
private:
! float _distance;
! ogs::core::Modifier _distanceModifier;
! bool _distracted;
! static ogs::core::Modifier _distractedModifier;
};
/**
* Determine the distance of the target from the spotter.
*
***************
*** 90,94 ****
*/
inline float Spot::getDistance () const {
! return (this->distance);
}
--- 58,62 ----
*/
inline float Spot::getDistance () const {
! return (this->_distance);
}
***************
*** 99,103 ****
*/
inline bool Spot::isDistracted () const {
! return (this->distracted);
}
--- 67,71 ----
*/
inline bool Spot::isDistracted () const {
! return (this->_distracted);
}
--- Appraise.h DELETED ---
--- Bluff.h DELETED ---
--- Climb.h DELETED ---
--- Craft.h DELETED ---
--- Diplomacy.cpp DELETED ---
--- Diplomacy.h DELETED ---
--- DisableDevice.h DELETED ---
--- Disguise.h DELETED ---
--- EscapeArtist.h DELETED ---
--- Forgery.h DELETED ---
--- GatherInformation.h DELETED ---
--- HandleAnimal.h DELETED ---
--- Hide.h DELETED ---
--- Intimidate.h DELETED ---
--- Jump.h DELETED ---
--- Knowledge.h DELETED ---
--- Listen.h DELETED ---
--- MoveSilently.h DELETED ---
--- Profession.h DELETED ---
--- Ride.h DELETED ---
--- Search.h DELETED ---
--- SenseMotive.h DELETED ---
--- SpeakLanguage.h DELETED ---
--- Swim.h DELETED ---
--- Tumble.h DELETED ---
|