當前位置: 首頁>>代碼示例>>Python>>正文


Python Ball.setPostion方法代碼示例

本文整理匯總了Python中Ball.Ball.setPostion方法的典型用法代碼示例。如果您正苦於以下問題:Python Ball.setPostion方法的具體用法?Python Ball.setPostion怎麽用?Python Ball.setPostion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ball.Ball的用法示例。


在下文中一共展示了Ball.setPostion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: CurrentField

# 需要導入模塊: from Ball import Ball [as 別名]
# 或者: from Ball.Ball import setPostion [as 別名]
class CurrentField(object):
    def __init__(self):
        self.score = 0
        self.outs = 0

        self.fieldingTeam = Team()

        self.home = Base()
        self.one = Base()
        self.two = Base()
        self.three = Base()

        self.ball = Ball()

        """ Fielding Array (x marks plate, P is pitcher square)
    ________________
    | 0  | 1  |  2 |
    ________________
    | 3  | 4x |  5 |
    ________________
    | 6x | 7P | 8x |
    ________________
    |    | 9x |    |
    ---------------- """

        self.rows = 5
        self.columns = 4

        self.gridFieldArray = [[0 for x in range(self.rows)] for x in range(self.columns)]
        self.one.setNextBase(self.two)
        self.two.setNextBase(self.three)
        self.three.setNextBase(self.home)

        for x in range(0, 4):
            for y in range(0, 5):
                self.gridFieldArray[x][y] = FieldSquare()

        self.gridFieldArray[0][0].setKey("LF", 15)
        self.gridFieldArray[0][2].setKey("CF", 15)
        self.gridFieldArray[0][4].setKey("RF", 15)
        self.gridFieldArray[2][1].setKey("SS", 8)
        self.gridFieldArray[2][2].setKey("P", 8)
        self.gridFieldArray[2][3].setKey("2B", 8)
        self.gridFieldArray[3][0].setKey("3B", 8)
        self.gridFieldArray[3][2].setKey("C", 8)
        self.gridFieldArray[3][4].setKey("1B", 5)

    def reset(self):
        self.score = 0
        self.resetOuts()
        self.home.removePlayerFromBase()
        self.one.removePlayerFromBase()
        self.two.removePlayerFromBase()
        self.three.removePlayerFromBase()

    def resetOuts(self):
        self.outs = 0

    def start(self, FieldingTeam):
        self.score = 0
        self.outs = 0
        self.home.removePlayerFromBase()
        self.one.removePlayerFromBase()
        self.two.removePlayerFromBase()
        self.three.removePlayerFromBase()
        self.fieldingTeam = FieldingTeam

        self.gridFieldArray[0][0].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("LF"))
        self.gridFieldArray[0][2].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("CF"))
        self.gridFieldArray[0][4].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("RF"))
        self.gridFieldArray[2][1].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("SS"))
        self.gridFieldArray[2][2].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("P"))
        self.gridFieldArray[2][3].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("2B"))
        self.gridFieldArray[3][0].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("3B"))
        self.gridFieldArray[3][2].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("C"))
        self.gridFieldArray[3][4].setFielder(self.fieldingTeam.getPlayerInFieldingPostion("1B"))

    def putBallIntoRandomSquare(self):
        self.ball.setPostion(0, randint(0, 5))

    # ball.setPostion(0, 0);

    def putBallIntoRandomInFieldSquare(self):
        self.ball.setPostion(randint(2, 3), randint(0, 4))

    def wasBallCaught(self, x, y):
        return self.gridFieldArray[x][y].wasBallCaught()

    def getScore(self):
        return self.score

    def addScore(self):
        self.score = self.score + 1

    def getOuts(self):
        return self.outs

    def addOneToOuts(self):
        self.outs = self.outs + 1

#.........這裏部分代碼省略.........
開發者ID:wendyzz,項目名稱:PythonBaseballSim,代碼行數:103,代碼來源:CurrentField.py


注:本文中的Ball.Ball.setPostion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。