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


Python BetterMUD.region方法代码示例

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


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

示例1: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import region [as 别名]
    def Run( self, args ):
        if not args: raise PythonCommand.UsageError

        me = BetterMUD.character( self.me )
        parms = args.split( None, 1 )
        if parms[0] == "all":
            me.DoAction( "announce", 0, 0, 0, 0, "Beginning Complete Database Save" )
            self.mud.AddActionAbsolute( 0, "savedatabases", 0, 0, 0, 0, "" )
            return
        if parms[0] == "region":
            if len(parms) < 2: raise PythonCommand.UsageError
            region = BetterMUD.region( int(parms[1]) )
            me.DoAction( "announce", 0, 0, 0, 0, "Beginning Region Database Save: " + region.Name() )
            self.mud.AddActionAbsolute( 0, "saveregion", int(parms[1]), 0, 0, 0, "" )
            return
        if parms[0] == "players":
            me.DoAction( "announce", 0, 0, 0, 0, "Beginning Player Database Save" )
            self.mud.AddActionAbsolute( 0, "saveplayers", 0, 0, 0, 0, "" )
            return
        raise PythonCommand.UsageError
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:22,代码来源:admincommands.py

示例2: Run

# 需要导入模块: import BetterMUD [as 别名]
# 或者: from BetterMUD import region [as 别名]
    def Run( self, action, arg1, arg2, arg3, arg4, data ):
        me = BetterMUD.character( self.me )


        if action == "modifyattribute" and data == "experience":
            me.DoAction( "announce", 0, 0, 0, 0, "<#00FFFF>You gain " + str( arg4 ) + " experience!" )
            return

        # check for death
        if action == "modifyattribute" and data == "hitpoints":
            if arg3 <= 0:
                me.DoAction( "do", 0, 0, 0, 0, "died" )
            return

        # you killed someone... celebrate!
        if action == "do" and data == "killed":
            self.Break( me )
            return

        if action == "do" and data == "died":
            self.Break( me )
            self.mud.AddActionAbsolute( 0, "vision", me.Room(), 0, 0, 0, me.Name() + " dies!!!" )

            # calculate how much experience to give to everyone attacking you
            experience = me.GetAttribute( "giveexperience" )
            if len( self.attackedlist ) > 0:
                experience = experience / len( self.attackedlist )

            # go through everyone, tell them you died, and give them their experience

            for x in self.attackedlist[:]:
                c = BetterMUD.character( x )
                c.DoAction( "do", 0, 0, self.me, 0, "killed" )
                self.mud.DoAction( "modifyattribute", 0, x, c.GetAttribute( "experience" ) + experience, experience, "experience" )

            # clear the list
            self.attackedlist = []

            # go through all his items and force them to drop
            me.BeginItem()
            while me.IsValidItem():
                self.mud.DoAction( "dropitem", me.ID(), me.CurrentItem(), 0, 0, "" )
                me.NextItem()

            # now figure out how to kill the character
            if not me.IsPlayer():
                # just destroy non-players
                self.mud.AddActionAbsolute( 0, "destroycharacter", self.me, 0, 0, 0, "" )
            else:
                # give the player some hitpoints back
                me.SetAttribute( "hitpoints", (me.GetAttribute( "maxhitpoints" ) / 10) * 7 )

                # now spawn the player somewhere, checking the current room, current region, current character,
                # and finally giving up and sending the player to room 1.
                r = BetterMUD.room( me.Room() )
                if r.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                r = BetterMUD.region( me.Region() )
                if r.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                if me.DoAction( "do", me.ID(), 0, 0, 0, "deathtransport" ):
                    return
                self.mud.DoAction( "forcetransport", me.ID(), 1, 0, 0, "" )
            return


        # reset hp if maxhp goes down below hp.
        if action == "modifyattribute" and data == "maxhitpoints":
            if me.GetAttribute( "hitpoints" ) > me.GetAttribute( "maxhitpoints" ):
                me.SetAttribute( "hitpoints", me.GetAttribute( "maxhitpoints" ) )
            return

        # people with the combat module can be attacked
        if action == "query" and data == "canattack":
            return 1


        # add character to attacked list if he isn't there
        if action == "do" and data == "attacked":
            try:
                self.attackedlist.index( arg3 )
            except:
                self.attackedlist.append( arg3 )
            return

        # remove character from attacked list
        if action == "do" and data == "brokeattack":
            try:
                self.attackedlist.remove( arg3 )
            except:
                pass
            return


        # initiate an attack
        if action == "do" and data == "initattack":
            if arg3 == self.me: return

            # clear the old target if attacking someone else
            if self.target != 0:
#.........这里部分代码省略.........
开发者ID:JaguarMantid,项目名称:bettermud,代码行数:103,代码来源:combat.py


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