Example #1
0
	def realHandle(self, command):
		command = command.strip()
		cmdList = command.split(' ')
		if self.place == "Welcome":
			self.username = command
			self.place = "Password"
			self.look()
		elif self.place == "Password":
			password = SI.getPasswordHash(self.cursor, self.username)
			if password == sha.new(command).hexdigest():
				thread = SI.getThreadID(self.cursor, self.username)
				if thread:
					self.write("Sorry, You are already logged in.")
					print "User tried to log in who was already "\
							"connected on thread %s'" % repr(thread)
					self.finish()
					return
				self.fullname = \
					SI.getUserData(self.cursor, self.username, DC.FullName)
				self.nickname = \
					SI.getUserData(self.cursor, self.username, DC.NickName)
				self.userlevel = \
					SI.getUserData(self.cursor, self.username, DC.UserLevel)
				self.place = "InGame"
				SI.setThreadID(self.cursor, self.username, self.threadid)
				room = SI.getLocation(self.cursor, self.username)
				area = SI.getArea(self.cursor, room)
				self.realMove(area, room, DBUpdate = 0)
				self.sendToSelf(SI.motd())
				self.look()
				return
			self.username = ""
			self.write("Incorrect username or password. Please try again.")
			self.place = "Welcome"
			self.look()
		else:
			firstCommand = lower(cmdList[0])
			if firstCommand in valid_commands.keys():
				function = getattr(self, valid_commands[firstCommand])
				function(cmdList)
			elif firstCommand in combatActions.keys():
				# Combat actions need a target.
				self.server.performAction(self.username, firstCommand,\
						(self.username, cmdList[1], self.threadid, self.room,\
						None))
			elif firstCommand in skillActions.keys():
				# Skill actions need a target, potentially.
				if len(cmdList) == 2:
					target = cmdList[1]
				else:
					target = None
				self.server.performAction(self.username, firstCommand,\
						(self.username, target, self.room, None))
			elif firstCommand in self.exits.keys():
				self.move(["go", firstCommand])
			elif not firstCommand.strip():
				# User just hit enter.
				return
			else:
				self.write("Unknown command.")
Example #2
0
	def start(self):
		self.attacker, self.target, self.threadid, self.room,\
				other = self.params
		self.realName = getUserData(self.server.cursor, self.attacker,\
				DC.NickName)
		# FIXME: this has to change for mobs
		# FIXME: text defined by weapon type
		self.targetName = getUserData(self.server.cursor, self.target,\
				DC.NickName)
		self.publicPrint("`@%s whips out their weapon." % self.realName)
		self.privatePrint("`@You whip out your weapon.")
		return True
Example #3
0
 def start(self):
     self.attacker, self.target, self.threadid, self.room,\
       other = self.params
     self.realName = getUserData(self.server.cursor, self.attacker,\
       DC.NickName)
     # FIXME: this has to change for mobs
     # FIXME: text defined by weapon type
     self.targetName = getUserData(self.server.cursor, self.target,\
       DC.NickName)
     self.publicPrint("`@%s whips out their weapon." % self.realName)
     self.privatePrint("`@You whip out your weapon.")
     return True
Example #4
0
	def think(self):
		targetDef, targetEnd, wounds = getUserData(self.server.cursor, self.target,
				(DC.RealDefence, DC.RealEndurance, DC.Wounds))
		attackSkill = int(getUserData(self.server.cursor, self.target, DC.RealAttack))
		targetDef = int(targetDef)

		info = {
			"attackerAttackSkill": attackSkill,
			"defenderDefenceSkill": targetDef,
			# FIXME hack
			"attackerDamage": d10,
			"attackerDamageType": DAMAGE_BLUDGEONING,
		}
		
		"""
Example #5
0
	def start(self):
		self.player, self.target, self.room, other = self.params
		self.realName = getUserData(self.server.cursor, self.player,\
				DC.NickName)
		self.server.display("", self.room, "`9%s strikes up a pose."\
				% self.realName)
		return True
Example #6
0
    def think(self):
        targetDef, targetEnd, wounds = getUserData(
            self.server.cursor, self.target,
            (DC.RealDefence, DC.RealEndurance, DC.Wounds))
        attackSkill = int(
            getUserData(self.server.cursor, self.target, DC.RealAttack))
        targetDef = int(targetDef)

        info = {
            "attackerAttackSkill": attackSkill,
            "defenderDefenceSkill": targetDef,
            # FIXME hack
            "attackerDamage": d10,
            "attackerDamageType": DAMAGE_BLUDGEONING,
        }
        """
Example #7
0
	def start(self):
		self.player, self.target, self.room, other = self.params
		self.realName = getUserData(self.server.cursor, self.player,\
				DC.NickName)
		self.server.display("", self.room, "`9%s strikes up a pose."\
				% self.realName)
		return True
Example #8
0
    def realHandle(self, command):
        """
		Grunt work is done here. This is called every time a complete line
		(terminating in a \r\n) is received by the handler loop. 'command' is
		a full-line string, with no trailing newline characters.
		"""
        command = command.strip()
        cmdList = command.split(' ')
        if self.state == USERNAME:
            # No username as yet, let's get one.
            self.username = command
            self.state = PASSWORD
            self.look()

        elif self.state == PASSWORD:
            # No password, let's get one.
            password = SI.getPasswordHash(self.cursor, self.username)
            if password == sha.new(command).hexdigest():
                thread = SI.getThreadID(self.cursor, self.username)
                if thread:
                    self.write("Sorry, You are already logged in.")
                    print "User tried to log in who was already "\
                      "connected on thread %s'" % repr(thread)
                    self.finish()
                    return
                self.fullname = \
                 SI.getUserData(self.cursor, self.username, DC.FullName)
                self.nickname = \
                 SI.getUserData(self.cursor, self.username, DC.NickName)
                self.userlevel = \
                 SI.getUserData(self.cursor, self.username, DC.UserLevel)
                self.state = INGAME
                SI.setThreadID(self.cursor, self.username, self.threadid)
                room = SI.getUserLocation(self.cursor, self.username)
                area = SI.getArea(self.cursor, room)
                self.realMove(area, room, DBUpdate=0)
                self.look()
                return
            self.username = ""
            self.write("Incorrect username or password. Please try again.")
            self.state = USERNAME
            self.look()
        elif self.state == INGAME:
            # We are in-game. Process the full command.
            firstCommand = lower(cmdList[0])
            if firstCommand in valid_commands.keys():
                function = getattr(self, valid_commands[firstCommand])
                function(cmdList)
            elif firstCommand in combatActions.keys():
                # Combat actions need a target.
                self.server.performAction(self.username, firstCommand,\
                  (self.username, cmdList[1], self.threadid, self.room,\
                  None))
            elif firstCommand in skillActions.keys():
                # Skill actions need a target, potentially.
                if len(cmdList) == 2:
                    target = cmdList[1]
                else:
                    target = None
                self.server.performAction(self.username, firstCommand,\
                  (self.username, target, self.room, None))
            elif firstCommand in self.exits.keys():
                self.move(["go", firstCommand])
            elif not firstCommand.strip():
                # User just hit enter.
                return
            else:
                self.write("Unknown command.")