Created
June 29, 2022 10:58
-
-
Save bolverk/80aedb3a241621d84c8d3d11753fb031 to your computer and use it in GitHub Desktop.
A demonstration of pdb's interact command with the Dormammu scene from Dr. Strange
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fake_typing import fake_typing | |
class Dormammu: | |
def __init__(self): | |
self.name = 'Dormammu' | |
self.counter = 0 | |
def consider(self): | |
responses = [ | |
'You’ve come to die. Your world is now my world, like all worlds.', | |
'You’ve come to die. Your world is now my world...What is this? Illusion?', | |
'You cannot do this forever.', | |
'End this!', | |
'You will never win.', | |
'STOP! MAKE THIS STOP!!!!' | |
'...what do you want?'] | |
fake_typing(f'{self.name}: {responses[self.counter]}') | |
satisfied = self.counter==len(responses)-1 | |
self.counter += 1 | |
assert satisfied, f"Killed by {self.name}" | |
dormammu = Dormammu() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from time import sleep | |
sys.tracebacklimit = 0 | |
def fake_typing(text): | |
for char in text: | |
sleep(0.1) | |
sys.stdout.write(char) | |
sys.stdout.flush() | |
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fake_typing import fake_typing | |
class DrStrange: | |
def __init__(self): | |
pass | |
def bargain_with(self, opponent): | |
fake_typing(f'Dr Strange: {opponent.name}! I\'ve come to bargain!') | |
opponent.consider() | |
dr_strange = DrStrange() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kamar_taj import dr_strange | |
from dark_dimension import dormammu | |
print('Scenario started\n') | |
dr_strange.bargain_with(dormammu) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment