我一直試圖做一個劊子手遊戲,如果命令!「劊子手」是iniated,這個代碼將執行:的Python - Sikuli與劊子手遊戲
def cmdHangman(event):
print("!hangman") #this print works
type("Game: Hangman")
type(Key.ENTER, Key.SHIFT)
Hangman.Playing()
凡Hangman.Playing()
導致:
listOfWords = ["example", "says", "python", "rocks"]
guessWord = random.choice(listOfWords)
board = [" * " for char in guessWord]
alreadySaid = ""
class Hangman():
def Playing():
print("Playing") #print not showing
global guessWord, board, alreadySaid
whatplayersaid = hangmanRegion.text()
hangmanRegion.stopObserver()
if whatplayersaid in guessWord:
board = [char if char == whatplayersaid or char in alreadySaid else " * " for char in guessWord]
board = "".join(board)
type(board)
type(Key.ENTER)
else:
type("Nope")
type(Key.ENTER)
alreadySaid = alreadySaid + whatplayersaid
Hangman.PlayBuffer()
def gotoPlaying(event):
print("gotoPlaying") #print not showing
Hangman.Playing()
def PlayBuffer():
print("PlayBuffer") #print not showing
wait(1)
hangmanRegion.onChange(Hangman.gotoPlaying)
hangmanRegion.observe(FOREVER)
應該掃描下聊天輸入使用hangmanRegion.text()字母,所以如果有人在羣聊類型:「A」,whatplayersaid
應該等於「A」
怪異的事情,它甚至沒有工作。完全一樣。 沒有錯誤日誌或任何東西。我試圖在class Hangman()
的任何地方放置打印件,並且在日誌中沒有看到任何打印件。
有人能找到我的代碼中的缺陷嗎?它沒有被執行或者Sikuli IDE出現問題嗎?還是我真的很累?鍵入命令後
登錄:
!hangman
[log] TYPE "Game: Hangman"
[log] (Shift) TYPE "#ENTER."
神聖的廢話,非常感謝!我每天都在不斷學習! :)它終於有效!太糟糕了,我還不能投票給你。 – SikuliXUser