Ejemplo n.º 1
0
    def divide_weaponskill(self, fraction=0, weapon_type=None):
        # Save the current weapon's skill.
        if self.weapon != None and self.weapon >= 0:
            if self.weaponskill == None:
                self.weaponskill = 0

            new_weaponskill = int(self.weaponskill / fraction)

            ewutils.weaponskills_set(id_server=self.id_server,
                                     id_user=self.id_user,
                                     weapon=weapon_type,
                                     weaponskill=new_weaponskill)
Ejemplo n.º 2
0
	def add_weaponskill(self, n = 0, weapon_type = None):
		# Save the current weapon's skill
		if self.weapon != None and self.weapon >= 0:
			if self.weaponskill == None:
				self.weaponskill = 0

			self.weaponskill += int(n)
			ewstats.track_maximum(user = self, metric = ewcfg.stat_max_wepskill, value = self.weaponskill)

			ewutils.weaponskills_set(
				id_server = self.id_server,
				id_user = self.id_user,
				weapon = weapon_type,
				weaponskill = self.weaponskill
			)
Ejemplo n.º 3
0
    def persist(self, conn=None, cursor=None):
        our_cursor = False
        our_conn = False

        try:
            # Get database handles if they weren't passed.
            if (cursor == None):
                if (conn == None):
                    conn = ewutils.databaseConnect()
                    our_conn = True

                cursor = conn.cursor()
                our_cursor = True

            self.limit_fix()

            # Save the object.
            cursor.execute(
                "REPLACE INTO users({}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
                .format(ewcfg.col_id_user, ewcfg.col_id_server,
                        ewcfg.col_slimes, ewcfg.col_slimelevel,
                        ewcfg.col_stamina, ewcfg.col_totaldamage,
                        ewcfg.col_bounty, ewcfg.col_kills, ewcfg.col_weapon,
                        ewcfg.col_weaponskill, ewcfg.col_trauma,
                        ewcfg.col_slimecredit, ewcfg.col_time_lastkill,
                        ewcfg.col_time_lastrevive, ewcfg.col_id_killer,
                        ewcfg.col_time_lastspar, ewcfg.col_time_expirpvp,
                        ewcfg.col_time_lasthaunt, ewcfg.col_time_lastinvest,
                        ewcfg.col_slimepoudrins, ewcfg.col_weaponname,
                        ewcfg.col_ghostbust, ewcfg.col_inebriation,
                        ewcfg.col_faction),
                (self.id_user, self.id_server, self.slimes, self.slimelevel,
                 self.stamina, self.totaldamage, self.bounty, self.kills,
                 self.weapon, self.weaponskill, self.trauma, self.slimecredit,
                 self.time_lastkill, self.time_lastrevive, self.id_killer,
                 self.time_lastspar, self.time_expirpvp, self.time_lasthaunt,
                 self.time_lastinvest, self.slimepoudrins, self.weaponname,
                 (1 if self.ghostbust == True else 0), self.inebriation,
                 self.faction))

            # Save the current weapon's skill
            if self.weapon != None and self.weapon != "":
                if self.weaponskill == None:
                    self.weaponskill = 0
                    self.weaponname = ""

                ewutils.weaponskills_set(id_server=self.id_server,
                                         id_user=self.id_user,
                                         weapon=self.weapon,
                                         weaponskill=self.weaponskill,
                                         weaponname=self.weaponname,
                                         conn=conn,
                                         cursor=cursor)

            if our_cursor:
                conn.commit()
        finally:
            # Clean up the database handles.
            if (our_cursor):
                cursor.close()
            if (our_conn):
                conn.close()