예제 #1
0
파일: ew.py 프로젝트: seaniman/endless-war
	def change_slimes(self, n = 0, source = None):
		change = int(n)
		self.slimes += change
		response = ""

		if n >= 0:
			ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimes, n = change)
			ewstats.track_maximum(user = self, metric = ewcfg.stat_max_slimes, value = self.slimes)

			if source == ewcfg.source_mining:
				ewstats.change_stat(user = self, metric = ewcfg.stat_slimesmined, n = change)
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimesmined, n = change)

			if source == ewcfg.source_killing:
				ewstats.change_stat(user = self, metric = ewcfg.stat_slimesfromkills, n = change)
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimesfromkills, n = change)

			if source == ewcfg.source_farming:
				ewstats.change_stat(user = self, metric = ewcfg.stat_slimesfarmed, n = change)
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimesfarmed, n = change)

			if source == ewcfg.source_scavenging:
				ewstats.change_stat(user = self, metric = ewcfg.stat_slimesscavenged, n = change)
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimesscavenged, n = change)

		else:
			change *= -1 # convert to positive number
			if source != ewcfg.source_spending and source != ewcfg.source_ghostification:
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimeloss, n = change)

			if source == ewcfg.source_damage or source == ewcfg.source_bleeding:
				self.totaldamage += change
				ewstats.track_maximum(user = self, metric = ewcfg.stat_max_hitsurvived, value = change)

			if source == ewcfg.source_self_damage:
				self.totaldamage += change
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_selfdamage, n = change)

			if source == ewcfg.source_decay:
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimesdecayed, n = change)

			if source == ewcfg.source_haunter:
				ewstats.track_maximum(user = self, metric = ewcfg.stat_max_hauntinflicted, value = change)
				ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimeshaunted, n = change)

		# potentially level up
		new_level = ewutils.level_byslime(self.slimes)
		if new_level > self.slimelevel:
			if self.life_state != ewcfg.life_state_corpse:
				response += "You have been empowered by slime and are now a level {} slimeboi.".format(new_level)
			for level in range(self.slimelevel+1, new_level+1):
				current_mutations = self.get_mutations()
				
				if (level in ewcfg.mutation_milestones) and (self.life_state not in [ewcfg.life_state_corpse, ewcfg.life_state_shambler]) and (len(current_mutations) < 10):
					
					new_mutation = random.choice(list(ewcfg.mutation_ids))
					while new_mutation in current_mutations:
						new_mutation = random.choice(list(ewcfg.mutation_ids))

					add_success = self.add_mutation(new_mutation)
					if add_success:
						response += "\n\nWhat’s this? You are mutating!! {}".format(ewcfg.mutations_map[new_mutation].str_acquire)
						
			self.slimelevel = new_level
			if self.life_state == ewcfg.life_state_corpse:
				ewstats.track_maximum(user = self, metric = ewcfg.stat_max_ghost_level, value = self.slimelevel)
			else:
				ewstats.track_maximum(user = self, metric = ewcfg.stat_max_level, value = self.slimelevel)

		return response
예제 #2
0
    def change_slimes(self, n=0, source=None):
        change = int(n)
        self.slimes += change

        if n >= 0:
            ewstats.change_stat(user=self,
                                metric=ewcfg.stat_lifetime_slimes,
                                n=change)
            ewstats.track_maximum(user=self,
                                  metric=ewcfg.stat_max_slimes,
                                  value=self.slimes)

            if source == ewcfg.source_mining:
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_slimesmined,
                                    n=change)
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_lifetime_slimesmined,
                                    n=change)

            if source == ewcfg.source_killing:
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_slimesfromkills,
                                    n=change)
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_lifetime_slimesfromkills,
                                    n=change)

            # todo add source from farming
        else:
            change *= -1  # convert to positive number
            if source != ewcfg.source_spending and source != ewcfg.source_ghostification:
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_lifetime_slimeloss,
                                    n=change)

            if source == ewcfg.source_damage:
                self.totaldamage += change
                ewstats.track_maximum(user=self,
                                      metric=ewcfg.stat_max_hitsurvived,
                                      value=change)

            if source == ewcfg.source_self_damage:
                self.totaldamage += change
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_lifetime_selfdamage,
                                    n=change)

            if source == ewcfg.source_decay:
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_lifetime_slimesdecayed,
                                    n=change)

            if source == ewcfg.source_haunter:
                ewstats.track_maximum(user=self,
                                      metric=ewcfg.stat_max_hauntinflicted,
                                      value=change)
                ewstats.change_stat(user=self,
                                    metric=ewcfg.stat_lifetime_slimeshaunted,
                                    n=change)

        # potentially level up
        new_level = ewutils.level_byslime(self.slimes)
        if new_level > self.slimelevel:
            self.slimelevel = new_level
            if self.life_state == ewcfg.life_state_corpse:
                ewstats.track_maximum(user=self,
                                      metric=ewcfg.stat_max_ghost_level,
                                      value=self.slimelevel)
            else:
                ewstats.track_maximum(user=self,
                                      metric=ewcfg.stat_max_level,
                                      value=self.slimelevel)