File tree Expand file tree Collapse file tree
engine/src/main/battlecode Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -792,6 +792,18 @@ public interface RobotController {
792792 */
793793 void pickUpCheese (MapLocation loc ) throws GameActionException ;
794794
795+ /**
796+ * Picks up the (non-negative) specified amount of cheese
797+ * from the given location.
798+ *
799+ * @param loc the location to pick up cheese from
800+ * @param pickUpAmount the amount of cheese to pick up
801+ * @throws GameActionException
802+ *
803+ * @battlecode.doc.costlymethod
804+ */
805+ void pickUpCheese (MapLocation loc , int pickUpAmount ) throws GameActionException ;
806+
795807 // ****************************
796808 // ***** ATTACK / HEAL ********
797809 // ****************************
Original file line number Diff line number Diff line change @@ -476,6 +476,21 @@ public void pickUpCheese(MapLocation loc) throws GameActionException {
476476 this .gameWorld .getTeamInfo ().addCheeseCollected (this .getTeam (), amountCheeseAvail );
477477 }
478478
479+ @ Override
480+ public void pickUpCheese (MapLocation loc , int pickUpAmount ) throws GameActionException {
481+ assertCanPickUpCheese (loc );
482+ int amountCheeseAvail = this .gameWorld .getCheeseAmount (loc );
483+
484+ // bound pickup amount above by the amount of cheese available and below by 0
485+ // (can't pick up negative amounts of cheese)
486+ pickUpAmount = Math .max (Math .min (pickUpAmount , amountCheeseAvail ), 0 );
487+
488+ this .gameWorld .addCheese (loc , -pickUpAmount );
489+ this .robot .addCheese (pickUpAmount );
490+ this .gameWorld .getMatchMaker ().addCheesePickUpAction (loc );
491+ this .gameWorld .getTeamInfo ().addCheeseCollected (this .getTeam (), pickUpAmount );
492+ }
493+
479494 @ Override
480495 public boolean canSenseLocation (MapLocation loc ) {
481496 try {
You can’t perform that action at this time.
0 commit comments