#! /usr/bin/env python
import math

class Shooter:
    def __init__(self, offset, xpos, dpi, comms, n, field = [22.3125, 45]):
        self.offsetpx = offset
        self.xpospx = xpos

        self.leftdeg = 0
        self.centerdeg = 45
        self.rightdeg = 90

        self.theta = 45
        self.aimval = 128
        self.shot = 0
        self.comms = comms
        self.number = n
        self.fieldpx = [field[0] * dpi, field[1] * dpi]
        
    def can_hit(self, target):
        return True 

    def target2angle(self, target):
        print self.number + " in TARGET2ANGLE"
        opp = float(target[0] - self.xpospx)
        adj = float(target[1] + self.offsetpx)
        self.theta = self.centerdeg + math.degrees(math.atan(opp/adj))
        if self.theta <= self.leftdeg:
            self.theta = self.leftdeg
            self.aimval = 1
        elif self.theta >= self.rightdeg:
            self.theta = self.rightdeg
            self.aimval = 128
        else:
            self.aimval = int((17.0/6) * self.theta)
        print "shooter " + self.number + " aimed at theta " + str(self.theta)
        return self.aimval

    def get_aim_line(self, line_length = 100):
        angle = self.centerdeg - self.theta # + for cw of straight; - for ccw
        #print self.number + " in get_aim_line angle is " + str(angle)
        y1 = self.fieldpx[1]
        # triangle not visible in img. adj is offset and opposite is where
        # barrel intersects line, since point where angle measured is pivot
        x1add = int((math.tan(math.radians(angle))) * self.offsetpx)
        #print "adding " + str(x1add) + " to x1"
        x1 = self.xpospx + x1add
        # aim is hypotenuse of triangle on board, where near angle is 90 - angle
        # y is opposite from that and x is x1 + adjacent
        y2sub = int((math.sin(math.radians(90 - angle)) + .01) * line_length)
        #print "subtracting " + str(y2sub) + " from y2"
        y2 = self.fieldpx[1] - y2sub
        x2add = int((math.cos(math.radians(90 - angle)) + .01) * line_length)
        #print "adding " + str(x2add) + " to x2"
        x2 = x1 + x2add 
        return ((x1, y1), (x2, y2))

    def aim(self, target):
        self.aimval = self.target2angle(target)
        self.comms.aim(self.number, bin(self.aimval))

    def fire(self):
        self.comms.fire(self.number)

    def shoot(self, target):
        self.aim(target)
        self.fire()

@@ -541,55 +541,8 @@
 t):%0A
-        print self.number + %22 in TARGET2ANGLE%22%0A
     
@@ -987,86 +987,8 @@
 ta)%0A
-        print %22shooter %22 + self.number + %22 aimed at theta %22 + str(self.theta)%0A
     
@@ -1140,79 +1140,8 @@
 ccw%0A
-        #print self.number + %22 in get_aim_line angle is %22 + str(angle)%0A
     
@@ -1389,57 +1389,8 @@
 px)%0A
-        #print %22adding %22 + str(x1add) + %22 to x1%22%0A
     
@@ -1638,64 +1638,8 @@
 th)%0A
-        #print %22subtracting %22 + str(y2sub) + %22 from y2%22%0A
     
@@ -1753,57 +1753,8 @@
 th)%0A
-        #print %22adding %22 + str(x2add) + %22 to x2%22%0A
     

remove gratuitous print statements