Commits

Jonas Erixon  committed fece892

target selection and other tweaks

  • Participants
  • Parent commits 6504c67

Comments (0)

Files changed (29)

File nbproject/project.xml

     <type>org.netbeans.modules.python.project</type>
     <configuration>
         <data xmlns="http://nbpython.dev.java.net/ns/php-project/1">
-            <name>EarthBot2</name>
+            <name>Earthbot</name>
             <sources>
                 <root id="src.dir"/>
             </sources>

File src/__init__.pyc

Binary file modified.

File src/bot.pyc

Binary file modified.

File src/config/debug_conf.py

 
 # Directories to load user modules from
 # e.g. /path/to/my/modules
-extra = ['/Users/zzzarka/Programmering/Personal/CLI_tools/EarthBot2/src/earthmods']
+extra = ['./earthmods']
 
 # Services to load: maps channel names to white or black lists
 external = {

File src/config/debug_conf.pyc

Binary file modified.

File src/config/live_conf.py

 
 # Directories to load user modules from
 # e.g. /path/to/my/modules
-extra = ['/Users/zzzarka/Programmering/Personal/CLI_tools/EarthBot2/src/earthmods']
+extra = ['./earthmods']
 
 # Services to load: maps channel names to white or black lists
 external = {

File src/config/live_conf.pyc

Binary file modified.

File src/earthinf.db

Binary file modified.

File src/earthmods/__init__.pyc

Binary file modified.

File src/earthmods/chemrush.pyc

Binary file modified.

File src/earthmods/member.pyc

Binary file modified.

File src/earthmods/newssniffer.py

 import earthtools.input_tools as inp
 import earthtools.db_tools as db
 import earthtools.newsreader as news
-import earthmods.target as target
+import earthtools.newsreader as news
+import earthtools.earthcalc as calc
 import time
+import locale
+import math
+
+def number_format(num, places=0):
+	"""Format a number according to locality and given places"""
+	locale.setlocale(locale.LC_ALL, "EN_US")
+	return locale.format("%.*f", (places, num), True)
 
 class TargetSystem:
 	cur_target=None
 	cur_attack_type='GS'
 	cur_multiplier=0.95
 	timer=0
+	announcing_time=2
 	def checkTarget(self, bot):
-		print self.cur_target
+		bot.msg(bot.config.warchan, "Current target is "+self.cur_target['spy_name']+" (#"+str(self.cur_target['spy_cou'])+") break is: "+number_format(self.cur_break, 0)+' '+self.cur_attack_type)
+		
 	def setTarget(self,target, attack_type, bot):
-		print "ST"
 		self.cur_target=db.SpyOp().get(target)
 		self.cur_attack_type=attack_type
 		if self.cur_target:
-			print "YAY"
 			self.setBreakStrength()
 			bot.say("Set target to "+self.cur_target['spy_name']+" (#"+str(self.cur_target['spy_cou'])+") starting pop: "+self.cur_target['spy_pop']);
-			bot.msg(bot.config.warchan, "BREAK! "+self.cur_target['spy_name']+" (#"+str(self.cur_target['spy_cou'])+") "+str(self.cur_break)+' '+self.cur_attack_type)
+			bot.msg(bot.config.warchan, "BREAK! "+self.cur_target['spy_name']+" (#"+str(self.cur_target['spy_cou'])+") "+number_format(self.cur_break, 0)+' '+self.cur_attack_type)
 			return True;
 		self.cur_target=None
-		print "BOO"
 		return False
 
 	def clearTarget(self):
 
 	def newsupdate(self, newsdata, bot):
 		if self.cur_target is not None and int(self.cur_target['spy_cou'])==int(newsdata['def_num']):
-			self.cur_break = ceil(self.cur_break*self.cur_multiplier)
-			if self.cur_break < 5000:
-				self.cur_break=5000
-			if int(time.time())>self.timer+2:
-				bot.msg(bot.config.warchan, 'BREAK! '+str(self.cur_break)+' '+self.cur_attack_type)
-				self.timer=int(time.time())
+			if newsdata['type']==self.cur_attack_type:
+				self.cur_break = math.ceil(self.cur_break*self.cur_multiplier)
+				if self.cur_break < 5000:
+					self.cur_break=5000
+				if int(time.time())>self.timer+self.announcing_time:
+					bot.msg(bot.config.warchan, 'BREAK! # '+number_format(self.cur_break, 0)+' '+self.cur_attack_type)
+					self.timer=int(time.time())
+			elif newsdata['type'] not in ['CM','NM', 'EM']:
+				has=db.Member().getMember(newsdata['att_num']).fetchone()
+				if has is not None:
+					bot.msg(has['mem_nick']+' is attacking with: '+newsdata['type']+' but target is set to: '+self.cur_attack_type)
+				else:
+					bot.msg(newsdata['att_cou']+' (#'+newsdata['att_num']+') is attacking with: '+newsdata['type']+' but target is set to: '+self.cur_attack_type)
 
 	def setBreakStrength(self):
+		readiness=1
+		defbonus=1
 		if not self.cur_target: return
+
+		self.cur_break, self.cur_multiplier = self.getBreak(self.cur_target, self.cur_attack_type, readiness, defbonus)
+		"""
+		gov = self.cur_target['spy_gov']
+
+		med_tech = calc.Tech.medical(int(self.cur_target['spy_tech']['med'].replace(',','')), int(self.cur_target['spy_land'].replace(',','')), gov)
+		self.cur_multiplier = 1-((5*med_tech)/100);
+
+		
+		mil=0
 		if 'GS'==self.cur_attack_type.upper():
-			self.cur_break = int(self.cur_target['spy_mil']['troops'].replace(',',''))
+			mil = int(self.cur_target['spy_mil']['troops'].replace(',',''))
 		elif 'BR'==self.cur_attack_type.upper():
-			self.cur_break = int(self.cur_target['spy_mil']['turrets'].replace(',',''))
+			mil = int(self.cur_target['spy_mil']['turrets'].replace(',',''))
+
+		weap_tech = calc.Tech.weapons(int(self.cur_target['spy_tech']['wep'].replace(',','')), int(self.cur_target['spy_land'].replace(',','')), gov)
+		weap_tech = weap_tech/100
+		#print weap_tech
+		multip = weap_tech*calc.Gov.milStr(gov)*defbonus*max(readiness, 0.7)
+		self.cur_break = (mil*multip)*1.1
+		"""
+	def getBreak(self, spyinf, attack_type, readiness, defense_bonus):
+		print spyinf
+		gov = spyinf['spy_gov']
+
+		med_tech = calc.Tech.medical(int(spyinf['spy_tech']['med'].replace(',','')), int(spyinf['spy_land'].replace(',','')), gov)
+		loss = 1-((5*med_tech)/100);
+
+
+		mil=0
+		if 'GS'==attack_type.upper():
+			mil = int(spyinf['spy_mil']['troops'].replace(',',''))
+		elif 'BR'==attack_type.upper():
+			mil = int(spyinf['spy_mil']['turrets'].replace(',',''))
+
+		weap_tech = calc.Tech.weapons(int(spyinf['spy_tech']['wep'].replace(',','')), int(spyinf['spy_land'].replace(',','')), gov)
+		weap_tech = weap_tech/100
+		#print weap_tech
+		mil_bonuses = weap_tech*calc.Gov.milStr(gov)*defense_bonus*max(readiness, 0.7)
+		cur_break = (mil*mil_bonuses)*1.1
+		return (cur_break, loss, mil_bonuses, mil)
 
 target_sys=None;
 def getTargetSystem():
 checkTarget.commands = ['checkTarget', 'ct']
 checkTarget.priority='high'
 
+def breakCalcSpec(bot, input):
+	if input.sender not in bot.config.activein: return
+	type,cou =(input.split(' ')[1], input.split(' ')[2])
+	target = db.SpyOp().get(cou)
+	if target is not None:
+		cur_break,medmultip,mult,mil = getTargetSystem().getBreak(target, type, 1, 1)
+		bot.say("Need "+number_format(cur_break,0)+" to break #"+cou+" Using "+type+" attack multiplier is: "+str(mult)+" mil is: "+str(mil))
+	else:
+		bot.say("Sorry can not find specified country number")
+breakCalcSpec.commands = ['break']
+breakCalcSpec.priority='high'
 
-printchan='#zzztest'
+
 def warningsystem(newsdata, bot):
-	global printchan
 	con=db.Member()
 	defender=con.getMember({'-c':newsdata['def_num']}).fetchall()
 	curtime = time.time()
 		for d in defender:
 			alertedAt = float(con.alertedAt(d['mem_nick']))
 			if curtime-alertedAt > 60*5:
-				bot.msg(printchan, d['mem_nick']+" Is under attack! ("+newsdata['type']+")")
+				bot.msg(bot.config.warchan, d['mem_nick']+" Is under attack! ("+newsdata['type']+")")
 				con.setAlert(d['mem_nick'])
 
 

File src/earthmods/newssniffer.pyc

Binary file modified.

File src/earthmods/spyop.pyc

Binary file modified.

File src/earthmods/target.py

-import earthtools.db_tools as db
-
-
-if __name__ == "__main__":
-	print __doc__.strip()

File src/earthtools/__init__.pyc

Binary file modified.

File src/earthtools/db_tools.pyc

Binary file modified.

File src/earthtools/earthcalc.py

 			return (1, 90)
 		elif 'wep' == techname:
 			return (100, 150)
+		elif 'med' == techname:
+			return (100, 66.667)
 		raise "Implement more techs!"
 		return (0, 0)
 	@staticmethod
 	def sdi(points, land, gov): return Tech.calc('sdi', points, land, gov)
 	@staticmethod
 	def weapons(points, land, gov): return Tech.calc('wep', points, land, gov)
+	@staticmethod
+	def medical(points, land, gov): return Tech.calc('med', points, land, gov)
+class Break():
+	@staticmethod
+	def GS():
+		pass
 
-
-
+class Gov():
+	@staticmethod
+	def milStr(gov):
+		if 'I'==gov:
+			return 1.25
+		if 'R'==gov:
+			return 0.9
+		return 1
 
 if __name__ == "__main__":
     print __doc__.strip()

File src/earthtools/earthcalc.pyc

Binary file modified.

File src/earthtools/input_tools.pyc

Binary file modified.

File src/earthtools/newsreader.pyc

Binary file modified.

File src/earthtools/spyop_rip.pyc

Binary file modified.

File src/irc.pyc

Binary file modified.

File src/modules/admin.pyc

Binary file modified.

File src/modules/reload.pyc

Binary file modified.

File src/modules/remind.pyc

Binary file modified.

File src/modules/seen.pyc

Binary file modified.

File src/modules/startup.pyc

Binary file modified.

File src/tools.pyc

Binary file modified.