www.pudn.com > Product_Submit2004.rar > Penalty.cc, change:2004-10-12,size:3872b


#include "Penalty.h" 
#include "../Common/Common.h" 
#include "../TOOLS/BallTricks.h" 
#include "../TOOLS/BasicTricks.h" 
#include "../TOOLS/HeadTricks.h" 
#include "../TOOLS/ComplexTricks.h" 
#include "../TOOLS/MovementTricks.h" 
 
 
// Penalty player from who knows when. Pre JetLi I think, so very old (pre 2003 competition) 
Penalty::Penalty() { 
 
  debugOutput = configuration_.GetAsBool("DebugOutput"); 
 
  currentTrick = new BasicTricks::NullBody(); 
  headTrick = new BasicTricks::NullHead(); 
  inPlaying = false; 
} 
 
Penalty::~Penalty() { 
  delete currentTrick; 
  delete headTrick; 
} 
 
void Penalty::NewGoHomeModel() { 
  if (inPlaying) { 
    delete headTrick; 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
    delete currentTrick; 
    currentTrick = new BasicTricks::NullBody(); 
    currentTrick->Start(); 
  } 
 
  int hC = headTrick->Continue(); 
  if (hC < 1) { 
    delete headTrick; 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
  } 
  inPlaying = false; 
 
/*  if (frame_ % 300 == 0) { 
    delete headTrick; 
    headTrick = new HeadTricks::FixateOnBeacon(75); 
    headTrick->Start(); 
  }*/ 
} 
 
void Penalty::NewReadyModel() { 
  if (inPlaying) { 
    delete headTrick; 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
    delete currentTrick; 
    currentTrick = new BasicTricks::NullBody(); 
    currentTrick->Start(); 
  } 
 
  int hC=headTrick->Continue(); 
//char* hMsg = headTrick->GetErrorMsg(hC); 
  if (!currentTrick->IsUsingHead() && (hC < 1)) { 
    headTrick = new HeadTricks::HeadPan(85,-85,3,50);   // MQ 19/6 .. changed from (70,-70,0,12) 
    headTrick->Start(); 
  } else if (vo_ball_ != NULL && strcmp(headTrick->GetName(),"HeadPan")==0) { 
    delete headTrick; 
    headTrick = new HeadTricks::FollowBallWithHeadSticky(10); 
    headTrick->Start(); 
  } 
 
  inPlaying = false; 
} 
 
void Penalty::NewPlayingModel() { 
  if (!inPlaying) { 
    delete headTrick; 
    headTrick = new BasicTricks::NullHead(); 
    headTrick->Start(); 
 
    delete currentTrick; 
    currentTrick = new BasicTricks::NullBody(); 
    currentTrick->Start(); 
  } 
  inPlaying=true; 
 
  int hC = headTrick->Continue(); 
  if (hC < 1) { 
    delete headTrick; 
    headTrick = new BasicTricks::NullHead(); 
    headTrick->Start(); 
  } 
 
  int cC = currentTrick->Continue(); 
  if (cC < 1) { 
    if (vo_ball_ != NULL) { 
      if (debugOutput) 
        cout << "Penalty: Ball visible. Chase !" << endl << flush; 
      delete currentTrick; 
      currentTrick = new ComplexTricks::AdvancedChaseWithKick(); 
      currentTrick->Start(); 
 
      headTrick->Abort(); 
      delete headTrick; 
      headTrick = new BasicTricks::NullHead(); 
      headTrick->Start(); 
    } else if (strcmp(currentTrick->GetName(),"AdvancedChaseWithKick") == 0){ 
      if (debugOutput) 
        cout << "Penalty: Ball not visible, and was chasing/kicking. PostKickSearch !" << endl << flush; 
 
      delete currentTrick; 
     // if (cC == 0) currentTrick = new ComplexTricks::PostChaseSearchForBall(true,60.0); 
    //  else currentTrick = new ComplexTricks::PostChaseSearchForBall(false,60.0); 
      currentTrick = new BasicTricks::NullBody(); 
      currentTrick->Start(); 
 
      delete headTrick; 
      headTrick = new BasicTricks::NullHead(); 
      headTrick->Start(); 
    } else { 
      if (debugOutput) 
        cout << "Penalty: Ball not visible" << endl << flush; 
 
      delete currentTrick; 
      currentTrick = new MovementTricks::SearchForBall(360.0); 
      currentTrick->Start(); 
 
      delete headTrick; 
      headTrick = new BasicTricks::NullHead(); 
      headTrick->Start(); 
    } 
  } 
 
}