Exemple #1
0
def test_tick():
    period = Period()
    clock = Clock(period)
    clock.tick()
    assert_true(clock.clock > 0)
    period = Period()
    clock = Clock(period)
    clock.tick(30)
    assert_equal(30, clock.clock)
Exemple #2
0
def test_tick():
    period = Period()
    clock = Clock(period)
    clock.tick()
    assert_true(clock.clock > 0)
    period = Period()
    clock = Clock(period)
    clock.tick(30)
    assert_equal(30, clock.clock)
Exemple #3
0
class Match(object):
    def __init__(self, show_events=False):
        self.show_events = show_events

        self.event = Event()

        self.home = Team('Calgary Flames', 'CGY')
        self.road = Team('Edmonton Oilers', 'EDM')

        self.period = Period()
        self.start_period()

    def start_period(self):
        self.period.next_period()
        self.clock = Clock(self.period)
        self.zone = Zone()
        self.possession = Possession()

        self.play = Play(self.home, self.road, self.zone, self.possession)

        self.event.add(self.period, self.clock, self.play(), self.zone)
        self.event.add(self.period, self.clock, self.play(), self.zone)

        while self.clock.running:
            self.next_event()

    def end_period(self):
        self.clock.end()
        self.event.add(self.period, self.clock, self.play.end(), self.zone)
        if self.period < 3:
            self.start_period()
        else:
            self.end_game()

    def next_event(self):
        self.clock.tick()

        self.home.lineup.lines.add_toi(self.clock.since_last_tick)
        self.road.lineup.lines.add_toi(self.clock.since_last_tick)

        if not self.clock.running:
            self.end_period()
        else:
            self.home.lineup.lines.line_change()
            self.road.lineup.lines.line_change()

            self.event.add(self.period,
                           self.clock,
                           self.play(),
                           self.zone)

    def end_game(self):
        if self.show_events:
            self.event.show()
Exemple #4
0
class Match(object):
    def __init__(self, show_events=False):
        self.show_events = show_events

        self.event = Event()

        self.home = Team('Calgary Flames', 'CGY')
        self.road = Team('Edmonton Oilers', 'EDM')

        self.period = Period()
        self.start_period()

    def start_period(self):
        self.period.next_period()
        self.clock = Clock(self.period)
        self.zone = Zone()
        self.possession = Possession()

        self.play = Play(self.home, self.road, self.zone, self.possession)

        self.event.add(self.period, self.clock, self.play(), self.zone)
        self.event.add(self.period, self.clock, self.play(), self.zone)

        while self.clock.running:
            self.next_event()

    def end_period(self):
        self.clock.end()
        self.event.add(self.period, self.clock, self.play.end(), self.zone)
        if self.period < 3:
            self.start_period()
        else:
            self.end_game()

    def next_event(self):
        self.clock.tick()

        self.home.lineup.lines.add_toi(self.clock.since_last_tick)
        self.road.lineup.lines.add_toi(self.clock.since_last_tick)

        if not self.clock.running:
            self.end_period()
        else:
            self.home.lineup.lines.line_change()
            self.road.lineup.lines.line_change()

            self.event.add(self.period, self.clock, self.play(), self.zone)

    def end_game(self):
        if self.show_events:
            self.event.show()
Exemple #5
0
def test_since_last_tick():
    period = Period()
    clock = Clock(period)
    clock.tick(30)
    assert_equal(30, clock.since_last_tick)
Exemple #6
0
def test_remaining():
    period = Period()
    clock = Clock(period)
    assert_equal('20:00', clock.remaining)
    clock.tick(30)
    assert_equal('19:30', clock.remaining)
Exemple #7
0
def test_elapsed():
    period = Period()
    clock = Clock(period)
    assert_equal('00:00', clock.elapsed)
    clock.tick(30)
    assert_equal('00:30', clock.elapsed)
Exemple #8
0
def test_since_last_tick():
    period = Period()
    clock = Clock(period)
    clock.tick(30)
    assert_equal(30, clock.since_last_tick)
Exemple #9
0
def test_remaining():
    period = Period()
    clock = Clock(period)
    assert_equal('20:00', clock.remaining)
    clock.tick(30)
    assert_equal('19:30', clock.remaining)
Exemple #10
0
def test_elapsed():
    period = Period()
    clock = Clock(period)
    assert_equal('00:00', clock.elapsed)
    clock.tick(30)
    assert_equal('00:30', clock.elapsed)