// File: /workspace/github_cpp_makefile_star2_O3/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:
movl (%rdi), %eax
decl %eax
cmpl $0x9, %eax
ja 0x501a8
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1cd37(%rip), %rcx     # 0x6cc80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x10(%r14), %eax
movq 0x38(%rbx), %rcx
subl 0x194(%rcx), %eax
cvtsi2sd %eax, %xmm0
ucomisd 0x8(%rbx), %xmm0
jb 0x50434
movq 0x3404a(%rip), %r15     # 0x83fc0
leaq 0x1ce90(%rip), %rsi     # 0x6ce0d
movl $0x19, %edx
jmp 0x50130
movsd 0x40(%r14), %xmm1
movsd 0x8(%rbx), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x4ff9e
cmpb $0x1, 0x54(%rbx)
jne 0x4ffc7
xorpd %xmm2, %xmm2
cmpeqsd %xmm2, %xmm1
movsd 0x190a9(%rip), %xmm2    # 0x69058
andpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jbe 0x50434
cmpb $0x1, 0x54(%rbx)
jne 0x50434
movq 0x33ff2(%rip), %r15     # 0x83fc0
leaq 0x1ceaa(%rip), %rsi     # 0x6ce7f
jmp 0x50055
movq 0x18(%rbx), %r15
cmpq 0x20(%rbx), %r15
je 0x50434
movq %r15, %rdi
movq %r14, %rsi
callq 0x4ff24
testb %al, %al
jne 0x50436
addq $0x58, %r15
cmpq 0x20(%rbx), %r15
jne 0x4ffe5
jmp 0x50436
movsd 0x38(%r14), %xmm1
movsd 0x8(%rbx), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5001e
cmpb $0x1, 0x54(%rbx)
jne 0x50047
xorpd %xmm2, %xmm2
cmpeqsd %xmm2, %xmm1
movsd 0x19029(%rip), %xmm2    # 0x69058
andpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jbe 0x50434
cmpb $0x1, 0x54(%rbx)
jne 0x50434
movq 0x33f72(%rip), %r15     # 0x83fc0
leaq 0x1cdf0(%rip), %rsi     # 0x6ce45
movl $0x1b, %edx
jmp 0x50130
movsd 0x40(%r14), %xmm1
movsd 0x8(%rbx), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x50076
cmpb $0x1, 0x54(%rbx)
jne 0x5009f
xorpd %xmm2, %xmm2
cmpeqsd %xmm2, %xmm1
movsd 0x18fd1(%rip), %xmm2    # 0x69058
andpd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
jbe 0x50434
cmpb $0x1, 0x54(%rbx)
jne 0x50434
movq 0x33f1a(%rip), %r15     # 0x83fc0
leaq 0x1cdb4(%rip), %rsi     # 0x6ce61
jmp 0x5012b
cmpl $0x1, 0x1c(%r14)
je 0x50434
movq 0x33eff(%rip), %r15     # 0x83fc0
leaq 0x1ce21(%rip), %rsi     # 0x6cee9
movl $0x11, %edx
movq %r15, %rdi
callq 0x9560
movq (%r15), %rax
jmp 0x503e3
movsd 0x38(%r14), %xmm1
movsd 0x8(%rbx), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x500f4
cmpb $0x1, 0x54(%rbx)
jne 0x5011d
xorpd %xmm2, %xmm2
cmpeqsd %xmm2, %xmm1
movsd 0x18f53(%rip), %xmm2    # 0x69058
andpd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
jbe 0x50434
cmpb $0x1, 0x54(%rbx)
jne 0x50434
movq 0x33e9c(%rip), %r15     # 0x83fc0
leaq 0x1ccfc(%rip), %rsi     # 0x6ce27
movl $0x1d, %edx
movq %r15, %rdi
jmp 0x503cb
movsd 0x10(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5014d
jnp 0x501df
cvttsd2si %xmm0, %eax
testl %eax, %eax
jle 0x502c7
decl %eax
imulq $0x178, %rax, %rax      # imm = 0x178
addq %r14, %rax
addq $0xa8, %rax
jmp 0x502db
movsd 0x10(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x50185
jnp 0x50253
cvttsd2si %xmm0, %eax
testl %eax, %eax
jle 0x50348
decl %eax
imulq $0x178, %rax, %rax      # imm = 0x178
addq %r14, %rax
addq $0xa8, %rax
jmp 0x5035c
xorl %eax, %eax
retq
movq 0x18(%rbx), %r15
cmpq 0x20(%rbx), %r15
je 0x50434
movq %r15, %rdi
movq %r14, %rsi
callq 0x4ff24
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x50436
addq $0x58, %r15
cmpq 0x20(%rbx), %r15
jne 0x501b9
jmp 0x50436
movsd 0x38(%r14), %xmm0
movsd 0x40(%r14), %xmm1
movsd 0x8(%rbx), %xmm2
movl $0x1, %r15d
xorl %ecx, %ecx
xorl %eax, %eax
cmpb $0x1, 0x11e2(%r14,%rcx)
jne 0x5023b
movsd 0x10d8(%r14,%rcx), %xmm3
subsd %xmm0, %xmm3
movsd 0x10e0(%r14,%rcx), %xmm4
subsd %xmm1, %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm3
addsd %xmm4, %xmm3
sqrtsd %xmm3, %xmm3
ucomisd %xmm2, %xmm3
ja 0x5043f
incl %r15d
addq $0x178, %rcx            # imm = 0x178
cmpq $0x1028, %rcx           # imm = 0x1028
jne 0x501fa
jmp 0x50436
movsd 0x38(%r14), %xmm0
movsd 0x40(%r14), %xmm1
movsd 0x8(%rbx), %xmm2
movl $0x1, %r15d
xorl %ecx, %ecx
xorl %eax, %eax
cmpb $0x1, 0x11e2(%r14,%rcx)
jne 0x502af
movsd 0x10d8(%r14,%rcx), %xmm3
subsd %xmm0, %xmm3
movsd 0x10e0(%r14,%rcx), %xmm4
subsd %xmm1, %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm3
addsd %xmm4, %xmm3
sqrtsd %xmm3, %xmm3
ucomisd %xmm3, %xmm2
ja 0x50476
incl %r15d
addq $0x178, %rcx            # imm = 0x178
cmpq $0x1028, %rcx           # imm = 0x1028
jne 0x5026e
jmp 0x50436
notl %eax
cltq
imulq $0x178, %rax, %rax      # imm = 0x178
addq %r14, %rax
addq $0x10d0, %rax           # imm = 0x10D0
movsd 0x38(%r14), %xmm0
movsd 0x40(%r14), %xmm1
subsd 0x8(%rax), %xmm0
subsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
ucomisd 0x8(%rbx), %xmm0
jbe 0x50434
movq 0x33cad(%rip), %r15     # 0x83fc0
leaq 0x1cb81(%rip), %rsi     # 0x6ce9b
movl $0x11, %edx
movq %r15, %rdi
callq 0x9560
movsd 0x10(%rbx), %xmm0
movq %r15, %rdi
callq 0x97d0
movq %rax, %r15
leaq 0x1cb6f(%rip), %rsi     # 0x6cead
movl $0x1e, %edx
jmp 0x503c8
notl %eax
cltq
imulq $0x178, %rax, %rax      # imm = 0x178
addq %r14, %rax
addq $0x10d0, %rax           # imm = 0x10D0
movsd 0x38(%r14), %xmm0
movsd 0x40(%r14), %xmm1
subsd 0x8(%rax), %xmm0
subsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd 0x8(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x50434
movq 0x33c28(%rip), %r15     # 0x83fc0
leaq 0x1cafc(%rip), %rsi     # 0x6ce9b
movl $0x11, %edx
movq %r15, %rdi
callq 0x9560
movsd 0x10(%rbx), %xmm0
movq %r15, %rdi
callq 0x97d0
movq %rax, %r15
leaq 0x1cb09(%rip), %rsi     # 0x6cecc
movl $0x1c, %edx
movq %rax, %rdi
callq 0x9560
movsd 0x8(%rbx), %xmm0
movq %r15, %rdi
callq 0x97d0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r15, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
movl 0x10(%r14), %eax
movq 0x38(%rbx), %rdx
movl %eax, %ecx
subl 0x194(%rdx), %ecx
cmpl 0x40(%rbx), %ecx
jle 0x50422
movl %ecx, 0x40(%rbx)
movl %eax, 0x4c(%rbx)
cmpl 0x44(%rbx), %ecx
jge 0x5042d
movl %ecx, 0x44(%rbx)
movl %eax, 0x48(%rbx)
incl 0x50(%rbx)
movb $0x1, %al
jmp 0x50436
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x33b7a(%rip), %r12     # 0x83fc0
leaq 0x1ca4e(%rip), %rsi     # 0x6ce9b
movl $0x11, %edx
movq %r12, %rdi
callq 0x9560
movq %r12, %rdi
movl %r15d, %esi
callq 0x9880
movq %rax, %r15
leaq 0x1ca3e(%rip), %rsi     # 0x6cead
movl $0x1e, %edx
jmp 0x504ab
movq 0x33b43(%rip), %r12     # 0x83fc0
leaq 0x1ca17(%rip), %rsi     # 0x6ce9b
movl $0x11, %edx
movq %r12, %rdi
callq 0x9560
movq %r12, %rdi
movl %r15d, %esi
callq 0x9880
movq %rax, %r15
leaq 0x1ca26(%rip), %rsi     # 0x6cecc
movl $0x1c, %edx
movq %rax, %rdi
callq 0x9560
movsd 0x8(%rbx), %xmm0
movq %r15, %rdi
callq 0x97d0
movq %rax, %rdi
callq 0x9240
jmp 0x50407
nop