package main.java.engine.objects.tower;

import java.awt.geom.Point2D;
import java.util.Map;
import main.java.schema.TowerSchema;

public class MoneyTower extends Tower {

    /**
     * Create a new tower from a map of attributes. Should be called by factory.
     * 
     * @param attributes key value map of attributes as defined by TowerSchema
     */
    public MoneyTower (Map<String, Object> attributes) {
            this(
                            (Point2D) getValueOrDefault(attributes, TowerSchema.LOCATION, new Point2D.Double(0,0)),
                            (double) getValueOrDefault(attributes, TowerSchema.HEALTH, DEFAULT_HEALTH),
                            (double) getValueOrDefault(attributes, TowerSchema.DAMAGE, DEFAULT_DAMAGE),
                            (double) getValueOrDefault(attributes, TowerSchema.RANGE, DEFAULT_RANGE),
                            (double) getValueOrDefault(attributes, TowerSchema.COST, DEFAULT_COST),
                            (double) getValueOrDefault(attributes, TowerSchema.BUILDUP, DEFAULT_BUILDUPTIME),
                            (String) attributes.get(TowerSchema.NAME));
    }

    /**
     * The normal constructor. Should not be called directly by factory.
     * 
     * @param x
     * @param y
     * @param health
     * @param damage
     * @param range
     * @param cost
     * @param buildup buildup time for this tower's construction
     * @param imageName
     */
    public MoneyTower (Point2D location,
                    double health,
                    double damage,
                    double range,
                    double cost,
                    double buildup,
                    String imageName) {

            super(location,
                            imageName,
                            damage,
                            range,
                            cost,
                            buildup);
    }

    @Override
    void fireProjectile (Point2D target) {
        // do nothing,
        // money tower does not fire
    }

}

@@ -86,16 +86,62 @@
 il.Map;%0A
+import main.java.engine.EnvironmentKnowledge;%0A
 import m
@@ -170,16 +170,17 @@
 chema;%0A%0A
+%0A
 public c
@@ -208,24 +208,117 @@
 ds Tower %7B%0A%0A
+    public static final int DEFAULT_MONEY_GRANTED = 100;%0A    //TODO: Add to schema%0A    %0A    %0A
     /**%0A    
@@ -558,33 +558,14 @@
     
-    
 this(%0A
-               
     
@@ -656,16 +656,17 @@
 ouble(0,
+ 
 0)),%0A   
@@ -671,39 +671,24 @@
             
-      
-         
 (double) get
@@ -760,39 +760,24 @@
             
-    
-           
 (double) get
@@ -836,39 +836,24 @@
 LT_DAMAGE),%0A
-               
             
@@ -936,39 +936,24 @@
             
-           
-    
 (double) get
@@ -1025,31 +1025,16 @@
         
-         
-      
 (double)
@@ -1120,31 +1120,16 @@
         
-      
-         
 (String)
@@ -1527,24 +1527,27 @@
             
+   
 double healt
@@ -1549,16 +1549,19 @@
 health,%0A
+   
         
@@ -1603,24 +1603,27 @@
             
+   
 double range
@@ -1616,32 +1616,35 @@
   double range,%0A
+   
                 
@@ -1676,24 +1676,27 @@
             
+   
 double build
@@ -1699,16 +1699,19 @@
 uildup,%0A
+   
         
@@ -1751,20 +1751,16 @@
         
-    
 super(lo
@@ -1781,30 +1781,16 @@
         
- 
-             
 imageNam
@@ -1806,30 +1806,16 @@
         
-          
-    
 damage,%0A
@@ -1828,30 +1828,16 @@
         
-        
-      
 range,%0A 
@@ -1853,42 +1853,14 @@
     
-     
-         cost,%0A              
+cost,%0A
     
@@ -1882,24 +1882,25 @@
 up);%0A    %7D%0A%0A
+%0A
     @Overrid
@@ -1909,106 +1909,479 @@
     
-void fireProjectile (Point2D target) %7B
+public void callTowerActions (EnvironmentKnowledge environ) %7B%0A        super.callTowerActions(environ);%0A        // in addition to build up time logic, also give player money at the appropriate interval%0A        grantPlayerMoney(environ);
 %0A    
+%7D%0A%0A
     
-// do nothing,%0A        // money tower does not fire
+private void grantPlayerMoney (EnvironmentKnowledge environ) %7B%0A        //TODO: remove magic number timing value%0A        if (myTimingCounter %25 100 == 0) %7B%0A            environ.grantPlayerMoney(DEFAULT_MONEY_GRANTED);%0A        %7D
 %0A   

Update MoneyTower to grant player money through EnvironmentKnowledge