示例#1
0
def punt():
    play.customKey('Punt', 'Punt')
    GAME.toggleStance()
    play.customKey('Punt Return', 'Punt Return')
    GAME.firstdown = GAME.yard + 10
    GAME.down = 1
    handleFluff()
示例#2
0
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
示例#3
0
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()
示例#4
0
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
示例#5
0
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)]
示例#6
0
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):
示例#8
0
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
示例#9
0
def interception(result):
    GAME.yard += (int)(result.split(" ")[1])
    GAME.toggleStance()
 def chooseTeam(self, team):
     GAME.setTeam(team)
     self.parent.changeState(GAME.state)