// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/Trainer.cpp
// Function: Trainer::Condition::CheckState(WorldState const&)
bool Trainer::Condition::CheckState(const WorldState &state) {
  //检测当前状态的条件
  bool result = false;
  switch (mType) {
  case ET_ANDComplex:
    if (!mSubCondition.empty()) {
      for (std::vector<Trainer::Condition>::iterator it = mSubCondition.begin();
           it != mSubCondition.end(); it++) {
        if (!it->CheckState(state)) {
          return false; //有一个不满足就不满足
        }
      }
    }
    break;
  case ET_ORComplex:
    if (!mSubCondition.empty()) {
      for (std::vector<Trainer::Condition>::iterator it = mSubCondition.begin();
           it != mSubCondition.end(); it++) {
        if (it->CheckState(state)) {
          return true; //有一个满足就满足
        }
      }
    }
    break;
  case ET_Time: //过x个周期自然终止
    if (state.CurrentTime().T() - mpTrainer->GetLastStopTime() >= mArg1) {
      std::cout << "Trigger time longer than " << mArg1 << std::endl;
      result = true;
    }
    break;
  case ET_BallXbt: //球的x坐标大于某值停止
    if ((state.GetBall().GetPos().X() > mArg1 && !mConverse) ||
        (!state.GetBall().GetPos().X() > mArg1 && mConverse)) {
      std::cout << "Trigger Ball's X larger than " << mArg1 << std::endl;
      result = true;
    }
    break;
  case ET_BallXlt: //球的x坐标小于某值停止
    if ((state.GetBall().GetPos().X() < mArg1 && !mConverse) ||
        (!state.GetBall().GetPos().X() < mArg1 && mConverse)) {
      std::cout << "Trigger Ball's X less than " << mArg1 << std::endl;
      result = true;
    }
    break;
  case ET_BallYbt: //球的y坐标。。
    if ((state.GetBall().GetPos().Y() > mArg1 && !mConverse) ||
        (!state.GetBall().GetPos().Y() > mArg1 && mConverse)) {
      std::cout << "Trigger Ball's Y larger than " << mArg1 << std::endl;
      result = true;
    }
    break;
  case ET_BallYlt: //。。
    if ((state.GetBall().GetPos().Y() < mArg1 && !mConverse) ||
        (!state.GetBall().GetPos().Y() < mArg1 && mConverse)) {
      std::cout << "Trigger Ball's Y less than " << mArg1 << std::endl;
      result = true;
    }
    break;
  case ET_Ball2Playerbt: //球到某人的距离大于某值
    if (!mArg2) {
      for (int i = 1; i <= TEAMSIZE; i++) {
        if (state.GetOpponent(i).IsAlive())
          if (state.GetOpponent(i).GetPos().Dist(state.GetBall().GetPos()) >
              mArg1) {
            std::cout << "Trigger Ball to #" << i
                      << "Player's distance longer than " << mArg1 << std::endl;
            result = true;
            break;
          }
      }
      break;
    }
    if (state.GetBall().GetPos().Dist(state.GetPlayer(mArg2).GetPos()) >
        mArg1) {
      std::cout << "Trigger Ball to #" << mArg2
                << "Player's distance longer than " << mArg1 << std::endl;
      result = true;
    }
    break;
  case ET_Ball2Playerlt: //球到某人的距离小于某值
    if (!mArg2) {
      for (int i = 1; i <= TEAMSIZE; i++) {
        if (state.GetOpponent(i).IsAlive())
          if (state.GetOpponent(i).GetPos().Dist(state.GetBall().GetPos()) <
              mArg1) {
            std::cout << "Trigger Ball to #" << i
                      << "Player's distance less than " << mArg1 << std::endl;
            result = true;
            break;
          }
      }
      break;
    }
    if (state.GetBall().GetPos().Dist(state.GetPlayer(mArg2).GetPos()) <
        mArg1) {
      std::cout << "Trigger Ball to #" << mArg2
                << "Player's distance less than " << mArg1 << std::endl;
      result = true;
    }
    break;
  case ET_NonPlayOn:
    if (state.GetPlayMode() != PM_Play_On) {
      result = true;
      std::cout << "Trigger NonPlayOn" << std::endl;
    }
    break;
  case ET_Null:
    break;
  }

  if (result) //满足终止条件了
  {
    int intervalCycle = state.CurrentTime().T() - mpTrainer->GetLastStopTime();
    if (intervalCycle > mMaxInterval) {
      mMaxInterval = intervalCycle;
      mMaxTime = state.CurrentTime().T();
    }
    if (intervalCycle < mMinInterval) {
      mMinInterval = intervalCycle;
      mMinTime = state.CurrentTime().T();
    }
    mCount++;
  }

  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movb $0x0, -0x19(%rbp)
movl (%rax), %eax
movq %rax, -0x70(%rbp)
subq $0xa, %rax
ja 0x94475
movq -0x70(%rbp), %rax
leaq 0x3116e(%rip), %rcx     # 0xc4d68
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x97fe0
testb $0x1, %al
jne 0x93c80
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x98020
movq %rax, -0x28(%rbp)
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x98090
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x98050
testb $0x1, %al
jne 0x93c49
jmp 0x93c7e
leaq -0x28(%rbp), %rdi
callq 0x980c0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x93bc0
testb $0x1, %al
jne 0x93c6b
movb $0x0, -0x1(%rbp)
jmp 0x94527
jmp 0x93c6d
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x980e0
movq %rax, -0x38(%rbp)
jmp 0x93c25
jmp 0x93c80
jmp 0x94475
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x97fe0
testb $0x1, %al
jne 0x93d04
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x98020
movq %rax, -0x40(%rbp)
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x98090
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x98050
testb $0x1, %al
jne 0x93ccb
jmp 0x93d02
leaq -0x40(%rbp), %rdi
callq 0x980c0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x93bc0
testb $0x1, %al
jne 0x93ce6
jmp 0x93cef
movb $0x1, -0x1(%rbp)
jmp 0x94527
jmp 0x93cf1
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x980e0
movq %rax, -0x50(%rbp)
jmp 0x93ca7
jmp 0x93d04
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x12100
movq %rax, %rdi
callq 0x13040
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, -0x7c(%rbp)
movq 0x38(%rax), %rdi
callq 0x98120
movl -0x7c(%rbp), %ecx
movl %eax, %edx
movq -0x78(%rbp), %rax
subl %edx, %ecx
cvtsi2sd %ecx, %xmm0
ucomisd 0x8(%rax), %xmm0
jb 0x93d79
movq 0x6a277(%rip), %rdi     # 0xfdfc0
leaq 0x3117c(%rip), %rsi     # 0xc4ecc
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x6a240(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x176f0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0x8(%rax), %xmm0
jbe 0x93db7
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x93e0c
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x176f0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setne %cl
setp %dl
orb %dl, %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
cvtsi2sd %ecx, %xmm0
ucomisd 0x8(%rax), %xmm0
jbe 0x93e43
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x93e43
movq 0x6a1ad(%rip), %rdi     # 0xfdfc0
leaq 0x310cc(%rip), %rsi     # 0xc4ee6
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x6a176(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x176f0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm1
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x93e85
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x93ede
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x176f0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setne %cl
setp %dl
orb %dl, %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x93f15
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x93f15
movq 0x6a0db(%rip), %rdi     # 0xfdfc0
leaq 0x31018(%rip), %rsi     # 0xc4f04
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x6a0a4(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x17700
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0x8(%rax), %xmm0
jbe 0x93f53
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x93fa8
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x17700
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setne %cl
setp %dl
orb %dl, %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
cvtsi2sd %ecx, %xmm0
ucomisd 0x8(%rax), %xmm0
jbe 0x93fdf
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x93fdf
movq 0x6a011(%rip), %rdi     # 0xfdfc0
leaq 0x30f6a(%rip), %rsi     # 0xc4f20
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x69fda(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x17700
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm1
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x94021
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x9407a
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rdi
callq 0x17700
movq %rax, %rcx
movq -0x78(%rbp), %rax
movsd (%rcx), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setne %cl
setp %dl
orb %dl, %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x940b1
movq -0x78(%rbp), %rax
testb $0x1, 0x54(%rax)
je 0x940b1
movq 0x69f3f(%rip), %rdi     # 0xfdfc0
leaq 0x30eb6(%rip), %rsi     # 0xc4f3e
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x69f08(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x94475
movq -0x78(%rbp), %rax
movsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x941ba
jp 0x941ba
movl $0x1, -0x54(%rbp)
cmpl $0xb, -0x54(%rbp)
jg 0x941b5
movq -0x18(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x1d480
movq %rax, %rdi
callq 0x23f20
testb $0x1, %al
jne 0x94101
jmp 0x941a5
movq -0x18(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x1d480
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x1d6d0
movq -0x78(%rbp), %rax
ucomisd 0x8(%rax), %xmm0
jbe 0x941a3
movq 0x69e69(%rip), %rdi     # 0xfdfc0
leaq 0x30dfc(%rip), %rsi     # 0xc4f5a
callq 0xa5a0
movq %rax, %rdi
movl -0x54(%rbp), %esi
callq 0xaa40
movq %rax, %rdi
leaq 0x30df4(%rip), %rsi     # 0xc4f6c
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x69e18(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x941b5
jmp 0x941a5
jmp 0x941a7
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x940d9
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x90(%rbp)
movq -0x18(%rbp), %rdi
cvttsd2si 0x10(%rax), %eax
movl %eax, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
callq 0x23eb0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x1d6d0
movq -0x78(%rbp), %rax
ucomisd 0x8(%rax), %xmm0
jbe 0x9426f
movq 0x69da1(%rip), %rdi     # 0xfdfc0
leaq 0x30d34(%rip), %rsi     # 0xc4f5a
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
leaq 0x30d26(%rip), %rsi     # 0xc4f6c
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x69d4a(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x94475
movq -0x78(%rbp), %rax
movsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x9437f
jp 0x9437f
movl $0x1, -0x5c(%rbp)
cmpl $0xb, -0x5c(%rbp)
jg 0x9437a
movq -0x18(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x1d480
movq %rax, %rdi
callq 0x23f20
testb $0x1, %al
jne 0x942bf
jmp 0x9436a
movq -0x18(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x1d480
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x1d6d0
movq -0x78(%rbp), %rax
movaps %xmm0, %xmm1
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x94368
movq 0x69ca4(%rip), %rdi     # 0xfdfc0
leaq 0x30c37(%rip), %rsi     # 0xc4f5a
callq 0xa5a0
movq %rax, %rdi
movl -0x5c(%rbp), %esi
callq 0xaa40
movq %rax, %rdi
leaq 0x30c4e(%rip), %rsi     # 0xc4f8b
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x69c53(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x9437a
jmp 0x9436a
jmp 0x9436c
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x94297
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x10570
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
cvttsd2si 0x10(%rax), %eax
movl %eax, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x23eb0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x1d6d0
movq -0x78(%rbp), %rax
movaps %xmm0, %xmm1
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9443b
movq 0x69bd5(%rip), %rdi     # 0xfdfc0
leaq 0x30b68(%rip), %rsi     # 0xc4f5a
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
leaq 0x30b79(%rip), %rsi     # 0xc4f8b
callq 0xa5a0
movq %rax, %rdi
movq -0x78(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0xab60
movq %rax, %rdi
movq 0x69b7e(%rip), %rsi     # 0xfdfb0
callq 0xa630
movb $0x1, -0x19(%rbp)
jmp 0x94475
movq -0x18(%rbp), %rdi
callq 0x10ed0
cmpl $0x1, %eax
je 0x94471
movb $0x1, -0x19(%rbp)
movq 0x69b6a(%rip), %rdi     # 0xfdfc0
leaq 0x30b4b(%rip), %rsi     # 0xc4fa8
callq 0xa5a0
movq %rax, %rdi
movq 0x69b44(%rip), %rsi     # 0xfdfb0
callq 0xa630
jmp 0x94475
jmp 0x94475
testb $0x1, -0x19(%rbp)
je 0x9451f
movq -0x18(%rbp), %rdi
callq 0x12100
movq %rax, %rdi
callq 0x13040
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, -0xa4(%rbp)
movq 0x38(%rax), %rdi
callq 0x98120
movq -0x78(%rbp), %rcx
movl %eax, %edx
movl -0xa4(%rbp), %eax
subl %edx, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl 0x40(%rcx), %eax
jle 0x944e2
movq -0x78(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, 0x40(%rax)
movq -0x18(%rbp), %rdi
callq 0x12100
movq %rax, %rdi
callq 0x13040
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x78(%rbp), %rcx
movl -0x64(%rbp), %eax
cmpl 0x44(%rcx), %eax
jge 0x94512
movq -0x78(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, 0x44(%rax)
movq -0x18(%rbp), %rdi
callq 0x12100
movq %rax, %rdi
callq 0x13040
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x78(%rbp), %rax
movl 0x50(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x50(%rax)
movb -0x19(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)