Skip to content

Instantly share code, notes, and snippets.

@jeena
Last active March 12, 2016 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeena/9d9b00581a8b064a6426 to your computer and use it in GitHub Desktop.
Save jeena/9d9b00581a8b064a6426 to your computer and use it in GitHub Desktop.
A script to copy the next random Call of Duty map into the c&p buffer.
#!/usr/bin/env python3
# A script to copy the next random Call of Duty map into the c&p buffer.
import os
import random
def is_map(str):
return str.startswith("mp_")
CURSOR_UP_ONE = '\x1b[1A'
ERASE_LINE = '\x1b[2K'
usermaps_dir = os.environ['HOME'] + "/Library/Application Support/Call of Duty 4/usermaps/"
usermaps = list(filter(is_map, os.listdir(usermaps_dir)))
while len(usermaps) > 0:
l = len(usermaps)
usermap = random.choice(usermaps)
usermaps.remove(usermap)
input(l.__str__() + " maps left, next: " + usermap + " ")
print(CURSOR_UP_ONE + ERASE_LINE + CURSOR_UP_ONE)
os.system("echo 'map " + usermap + "' | pbcopy")
os.system("open -a /Applications/Call\ of\ Duty\ 4.app/Contents/Call\ of\ Duty\ 4\ Multiplayer.app")
print("All maps done.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment