当前位置: 首页>>代码示例>>C++>>正文


C++ Thing::Move方法代码示例

本文整理汇总了C++中Thing::Move方法的典型用法代码示例。如果您正苦于以下问题:C++ Thing::Move方法的具体用法?C++ Thing::Move怎么用?C++ Thing::Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thing的用法示例。


在下文中一共展示了Thing::Move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Run

const void Get::Run( Character* character, const string& cmd, const string& arg ) const
{
    Thing* object = NULL;
    Thing* target = NULL;
    string args, sobj, star;

    if ( character )
    {
        args = arg;
        sobj = Utils::Argument( args );
        star = Utils::Argument( args );

        if ( sobj.empty() )
        {
            character->Send( "Get what?" CRLF );
            return;
        }

        // No 'from' target specified, so search the room
        if ( star.empty() )
        {
            object = Handler::FindThing( sobj, THING_TYPE_OBJECT, HANDLER_SCOPE_LOCATION, character );

            if ( object )
            {
                character->Send( "You get " + object->gDescription( THING_DESCRIPTION_SHORT ) + "." + CRLF );
                character->gContainer()->Send( character->gName() + " gets " + object->gDescription( THING_DESCRIPTION_SHORT ) + "." + CRLF, character );
                object->Move( character->gContainer(), character );
            }
            else
            {
                character->Send( "There is no " + arg + " here." CRLF );
                return;
            }
        }
        else
        {
            target = Handler::FindThing( star, THING_TYPE_OBJECT, HANDLER_SCOPE_LOC_INV, character );

            if ( !target )
            {
                character->Send( "There is no " + star + " here." CRLF );
                return;
            }

            object = Handler::FindThing( sobj, THING_TYPE_OBJECT, HANDLER_SCOPE_INVENTORY, target );

            if ( object )
            {
                character->Send( "You get " + object->gDescription( THING_DESCRIPTION_SHORT ) + " from " + target->gDescription( THING_DESCRIPTION_SHORT ) + "." CRLF );
                character->gContainer()->Send(  character->gName() + " gets " + object->gDescription( THING_DESCRIPTION_SHORT ) + " from " + target->gDescription( THING_DESCRIPTION_SHORT )+ "." CRLF, character );
                object->Move( target, character );
            }
            else
            {
                character->Send( "There is no " + sobj + " inside the " + target->gDescription( THING_DESCRIPTION_SHORT ) + "." CRLF );
                return;
            }
        }
    }

    return;
}
开发者ID:Igdra,项目名称:NAMS,代码行数:63,代码来源:get.cpp


注:本文中的Thing::Move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。