@@ -588,11 +588,12 @@ public void bite(MapLocation loc, int cheeseConsumed) {
588588 damage += (int ) Math .ceil (Math .sqrt (cheeseConsumed ));
589589 }
590590
591+ this .gameWorld .getMatchMaker ().addBiteAction (targetRobot .ID );
592+
591593 targetRobot .addHealth (-damage );
592594 if (targetRobot .getType () == UnitType .CAT ) {
593595 this .gameWorld .getTeamInfo ().addDamageToCats (team , damage );
594596 }
595- this .gameWorld .getMatchMaker ().addBiteAction (this .getID ());
596597
597598 if (targetRobot .getType () != UnitType .CAT ) {
598599 this .gameWorld .isCooperation = false ;
@@ -616,7 +617,6 @@ public void scratch(MapLocation loc) {
616617
617618 public void grabRobot (MapLocation loc ) {
618619 this .robotBeingCarried = this .gameWorld .getRobot (loc );
619- System .out .println ("Robot " + this .ID + " grabbed robot " + this .robotBeingCarried );
620620 this .robotBeingCarried .getGrabbed (this ); // Notify the grabbed robot that it has been picked up
621621 this .gameWorld .getMatchMaker ().addRatNapAction (this .robotBeingCarried .getID ());
622622
@@ -673,7 +673,12 @@ private void getGrabbed(InternalRobot grabber) {
673673 }
674674
675675 public void throwRobot () {
676+ this .gameWorld .getMatchMaker ().endTurn (this .ID , this .health , this .cheeseAmount , this .movementCooldownTurns ,
677+ this .actionCooldownTurns , this .turningCooldownTurns , this .bytecodesUsed , this .location , this .dir , this .gameWorld .isCooperation );
676678 this .robotBeingCarried .getThrown (this .dir );
679+ this .gameWorld .getMatchMaker ().endTurn (this .robotBeingCarried .ID , this .robotBeingCarried .health , this .robotBeingCarried .cheeseAmount , this .robotBeingCarried .movementCooldownTurns ,
680+ this .robotBeingCarried .actionCooldownTurns , this .robotBeingCarried .turningCooldownTurns , this .robotBeingCarried .bytecodesUsed , this .robotBeingCarried .location , this .robotBeingCarried .dir , this .gameWorld .isCooperation );
681+ this .gameWorld .addHasTraveledRobot (this .robotBeingCarried .getID ());
677682 this .gameWorld .getMatchMaker ().addThrowAction (this .robotBeingCarried .getID (),
678683 this .getLocation ().add (this .dir ));
679684 this .robotBeingCarried = null ;
@@ -687,7 +692,6 @@ private void getThrown(Direction dir) {
687692 this .remainingThrowDuration = 4 ;
688693
689694 this .setInternalLocationOnly (this .getLocation ());
690- this .gameWorld .removeRobot (this .getLocation ());
691695
692696 this .travelFlying (true );
693697 this .travelFlying (false );
@@ -708,8 +712,10 @@ public void getDropped(MapLocation loc) {
708712
709713 this .gameWorld .getMatchMaker ().addRatNapAction (this .getID ());
710714
711- if (this .getHealth () > 0 )
715+ if (this .getHealth () > 0 ){
712716 this .gameWorld .addRobot (this .getLocation (), this );
717+ this .controller .processTrapsAtLocation (this .location );
718+ }
713719 else
714720 this .gameWorld .destroyRobot (this .getID ());
715721 }
@@ -727,6 +733,10 @@ public void hitGround() {
727733
728734 if (this .health > 0 ) {
729735 this .gameWorld .addRobot (this .location , this );
736+ this .controller .processTrapsAtLocation (this .location );
737+ }
738+ else {
739+ this .gameWorld .destroyRobot (this .getID ());
730740 }
731741
732742 setMovementCooldownTurns (this .movementCooldownTurns + GameConstants .HIT_GROUND_COOLDOWN );
@@ -748,9 +758,14 @@ public void hitTarget(boolean isSecondMove) {
748758 this .remainingThrowDuration = 0 ;
749759
750760 this .addHealth (-damage );
751- if (this .health > 0 ){
761+ if (this .health > 0 ) {
752762 this .gameWorld .addRobot (this .location , this );
763+ this .controller .processTrapsAtLocation (this .location );
753764 }
765+ else {
766+ this .gameWorld .destroyRobot (this .getID ());
767+ }
768+
754769 setMovementCooldownTurns (this .movementCooldownTurns + GameConstants .HIT_TARGET_COOLDOWN );
755770 setActionCooldownTurns (this .actionCooldownTurns + GameConstants .HIT_TARGET_COOLDOWN );
756771 setTurningCooldownTurns (this .turningCooldownTurns + GameConstants .HIT_TARGET_COOLDOWN );
@@ -776,7 +791,6 @@ public void travelFlying(boolean isSecondMove) {
776791 this .addHealth (-this .getHealth ()); // rat dies :(
777792 // put cat to sleep
778793 this .gameWorld .getRobot (newLoc ).sleepTimeRemaining = GameConstants .CAT_SLEEP_TIME ;
779- this .gameWorld .getMatchMaker ().addCatFeedAction (this .getID ());
780794 return ;
781795 } else if (this .gameWorld .getRobot (newLoc ) != null || !this .gameWorld .isPassable (newLoc )) {
782796 this .hitTarget (isSecondMove );
@@ -1083,8 +1097,10 @@ public void processBeginningOfTurn() {
10831097 if (this .remainingThrowDuration == 0 ) { // max throw time reached
10841098 this .hitGround ();
10851099 } else {
1086- this .travelFlying (false );
1087- this .travelFlying (true ); // This will call hitTarget or hitGround if we hit something
1100+ if (!this .gameWorld .getHasTraveledRobot (this .ID )){
1101+ this .travelFlying (false );
1102+ this .travelFlying (true ); // This will call hitTarget or hitGround if we hit something
1103+ }
10881104 }
10891105 }
10901106
@@ -1113,13 +1129,11 @@ public void processEndOfTurn() {
11131129 }
11141130
11151131 // cat algo
1116-
1117- if (this .type == UnitType .CAT ) {
1118- if (this .sleepTimeRemaining > 0 ) {
1119- this .sleepTimeRemaining -= 1 ;
1120- return ;
1121- }
1122-
1132+ if (this .type == UnitType .CAT && this .sleepTimeRemaining > 0 ){
1133+ this .gameWorld .getMatchMaker ().addCatFeedAction (this .getID ());
1134+ this .sleepTimeRemaining -= 1 ;
1135+ }
1136+ else if (this .type == UnitType .CAT ) {
11231137 int [] pounceTraj = null ;
11241138
11251139 switch (this .catState ) {
@@ -1196,11 +1210,9 @@ public void processEndOfTurn() {
11961210 if (isStuck ){
11971211 if (this .controller .canTurn ()) {
11981212 try {
1199- Direction newDirection = this .dir .rotateRight ();
1200- if (this .chirality == 0 ) this .controller .turn (newDirection );
1201- else this .controller .turn (this .gameWorld .flipDirBySymmetry (newDirection ));
1202- } catch (GameActionException e ) {
1203- }
1213+ if (this .chirality == 0 ) this .controller .turn (this .dir .rotateRight ());
1214+ else this .controller .turn (this .dir .rotateLeft ());
1215+ } catch (GameActionException e ) {}
12041216 }
12051217 }
12061218 }
@@ -1225,8 +1237,7 @@ public void processEndOfTurn() {
12251237 } else if (this .controller .canMove (this .dir )) {
12261238 try {
12271239 this .controller .move (this .dir );
1228- } catch (GameActionException e ) {
1229- }
1240+ } catch (GameActionException e ) {}
12301241 } else {
12311242 boolean isStuck = true ;
12321243 for (MapLocation partLoc : this .getAllPartLocations ()) {
@@ -1253,9 +1264,8 @@ else if (this.controller.canAttack(nextLoc)) {
12531264 if (isStuck ){
12541265 if (this .controller .canTurn ()) {
12551266 try {
1256- Direction newDirection = this .dir .rotateRight ();
1257- if (this .chirality == 0 ) this .controller .turn (newDirection );
1258- else this .controller .turn (this .gameWorld .flipDirBySymmetry (newDirection ));
1267+ if (this .chirality == 0 ) this .controller .turn (this .dir .rotateRight ());
1268+ else this .controller .turn (this .dir .rotateLeft ());
12591269 } catch (GameActionException e ) {
12601270 continue ;
12611271 }
@@ -1353,13 +1363,10 @@ else if (this.controller.canAttack(nextLoc)) {
13531363 } catch (GameActionException e ) {
13541364 continue ;
13551365 }
1356-
1357- }
1358- else if (this .controller .canAttack (nextLoc )) {
1366+ } else if (this .controller .canAttack (nextLoc )) {
13591367 try {
1360- Direction newDirection = this .dir .rotateRight ();
1361- if (this .chirality == 0 ) this .controller .turn (newDirection );
1362- else this .controller .turn (this .gameWorld .flipDirBySymmetry (newDirection ));
1368+ if (this .chirality == 0 ) this .controller .turn (this .dir .rotateRight ());
1369+ else this .controller .turn (this .dir .rotateLeft ());
13631370 } catch (GameActionException e ) {
13641371 continue ;
13651372 }
@@ -1368,11 +1375,9 @@ else if (this.controller.canAttack(nextLoc)) {
13681375
13691376 if (isStuck ){
13701377 try {
1371- Direction newDirection = this .dir .rotateRight ();
1372- if (this .chirality == 0 ) this .controller .turn (newDirection );
1373- else this .controller .turn (this .gameWorld .flipDirBySymmetry (newDirection ));
1374- } catch (GameActionException e ) {
1375- }
1378+ if (this .chirality == 0 ) this .controller .turn (this .dir .rotateRight ());
1379+ else this .controller .turn (this .dir .rotateLeft ());
1380+ } catch (GameActionException e ) {}
13761381 }
13771382 }
13781383 break ;
0 commit comments