As the preceding print shows that #hit contains 1 here, how can it compare as equal to the constant string Xdummy???
Presuming that Xdummy is supposed to be a constant, you can access its value with either const Xdummy or @Xdummy. By itself, Xdummy is just a string literal.
I ran two tests on your code. In one, I set hit equal to one, and I got the error message "This exposes your royal piece to capture." In the second, I set hit equal to true, and I got the error message "Trading of this piece is not allowed." Here's what's happening. The variable hit had the value of true, not the value of 1. Despite this, it prints the value of true as 1, which made things confusing. When it actually had the value of 1, the string literal Xdummy was not equal to it. But when hit had the Boolean value of true, the string literal Xdummy was evaluated as equal, because the == operator cast the string literal to its Boolean value before comparing for equality with a Boolean value.
Presuming that Xdummy is supposed to be a constant, you can access its value with either const Xdummy or @Xdummy. By itself, Xdummy is just a string literal.
I ran two tests on your code. In one, I set hit equal to one, and I got the error message "This exposes your royal piece to capture." In the second, I set hit equal to true, and I got the error message "Trading of this piece is not allowed." Here's what's happening. The variable hit had the value of true, not the value of 1. Despite this, it prints the value of true as 1, which made things confusing. When it actually had the value of 1, the string literal Xdummy was not equal to it. But when hit had the Boolean value of true, the string literal Xdummy was evaluated as equal, because the == operator cast the string literal to its Boolean value before comparing for equality with a Boolean value.