def punt(): play.customKey('Punt', 'Punt') GAME.toggleStance() play.customKey('Punt Return', 'Punt Return') GAME.firstdown = GAME.yard + 10 GAME.down = 1 handleFluff()
def kickoff(): print("") # Only for CMD mode GAME.TD = False GAME.yard = 40 play.customKey('Kickoff', 'Kickoff') GAME.toggleStance() play.customKey('Kickoff Return', 'Kickoff Return') GAME.firstdown = GAME.yard + 10 GAME.down = 1
def changeQuarters(): GAME.clock[0] = QNAMES[QNAMES.index(GAME.clock[0]) + 1] if GAME.clock[0] == 'END': gameOver() GAME.clock[1] = 720 if GAME.clock[0] == QNAMES[2]: print("Halftime!") if GAME.startingstance == "Offense" and GAME.localstance == "Offense": GAME.toggleStance() kickoff()
def fumble(result): if GAME.localstance == "Offense": fum = json_reader.readJson("data/teams/" + GAME.team, attribute=FUMBLE_CHANCE_FIELD) else: fum = json_reader.readJson("data/teams/" + GAME.enemy, attribute=FUMBLE_CHANCE_FIELD) GAME.yard += (int)(result.split(" ")[1]) roll = random.random() * 100 if roll <= fum: print("Fumble recovered!") return print("Fumble lost!") GAME.toggleStance() GAME.down = 1
def roll(callout, offensePlay=None): # eg roll('Line Plunge') stats = json_reader.readJson("data/teams/" + GAME.team, attribute=GAME.localstance) numRoll = random.random() * 100 if not offensePlay: #pp(stats) #print callout #print offensePlay GAME.rolls[GAME.localstance] = stats[callout][GAME.weightedRoll( GAME.localstance, numRoll)] else: #pp(stats) #print callout #print offensePlay GAME.rolls[GAME.localstance] = stats[callout][offensePlay][ GAME.weightedRoll(GAME.localstance, numRoll)]
def customKey(ctype, key): print(ctype + "!") if GAME.localstance == 'Offense': line = json_reader.readJson("data/teams/" + GAME.team, attribute=key) else: line = json_reader.readJson("data/teams/" + GAME.enemy, attribute=key) print(line) newRoll = GAME.weightedRoll('Offense', random.random() * 100) newPlay = line[newRoll] print(ctype + " roll: %s" % newPlay) PLAYMAP[_rolltype(newPlay)](newPlay)
# CMD play for testing from pprint import pprint as pp import random import sys import traceback from src import GAME from src import turnController from src.play import play GAME.setTeam('raiders.json') GAME.setEnemy('raiders.json') GAME.turn = "dummy" GAME.down = 1 GAME.callout = 'End Run' GAME.into = "End Run" GAME.rolls = {} GAME.localstance = "Offense" GAME.end = False GAME.startingstance = "Offense" GAME.validateState() GAME.firstdown = 50 ALL_D = ["Standard", "Short Yardage", "Spread", "Pass Prevent Short", "Pass Prevent Long", "Blitz"] # 6 ALL_A = ["Line Plunge", "Off Tackle", "End Run", "Draw", "Screen", "Short", "Medium", "Long", "Sideline"] # 9 def fullGame(): for i in range(0, 150):
def turnOver(): print("Switched sides!") # Only for CMD mode GAME.down = 1 GAME.toggleStance() print("Offense is now on the %s yard line." % GAME.yard) # Only for CMD mode
def interception(result): GAME.yard += (int)(result.split(" ")[1]) GAME.toggleStance()
def chooseTeam(self, team): GAME.setTeam(team) self.parent.changeState(GAME.state)