Changeset 6.1.38


Ignore:
Timestamp:
08/20/2016 09:21:54 PM (8 years ago)
Author:
David Owen <dsowen@fugue88.ws>
branch-nick:
state
revision id:
dsowen@fugue88.ws-20160820212154-horha1cy20jzv10x
Message:

Copied players to shared state

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main.py

    r6.1.37 r6.1.38  
    3838class Shared(object):
    3939
    40     def __init__(self, player_count):
     40    def __init__(self, player_count, players):
    4141        self.player_count = player_count
     42        self.players = players
    4243        self.mission = 0
    4344        self.captain = 0
     
    8889            players[i].reveal_spies(spy_nums)
    8990
    90     shared = Shared(player_count)
     91    shared = Shared(player_count, players)
    9192
    9293    wins = 0
     
    9596    def assemble_team():
    9697        print("Captain is {}".format(state.shared.captain))
    97         team = players[state.shared.captain].propose_team(state.team_size)
     98        team = state.shared.players[state.shared.captain].propose_team(state.team_size)
    9899        print("He proposed {}".format(team))
    99100
    100         votes = [p.approve_team(team) for p in players]
     101        votes = [p.approve_team(team) for p in state.shared.players]
    101102        approvals = sum(votes)
    102103        approved = approvals > state.team_size / 2
     
    107108        ))
    108109
    109         for p in players:
     110        for p in state.shared.players:
    110111            p.observe_team_vote(approved, votes)
    111112
     
    125126        for i in state.team:
    126127            if role_deck[i] == "SPY":
    127                 if not players[i].perform_mission():
     128                if not state.shared.players[i].perform_mission():
    128129                    failures = failures + 1
    129130
    130131        success = failures < required_failures(state.shared.player_count, state.shared.mission)
    131132
    132         for p in players:
     133        for p in state.shared.players:
    133134            p.observe_mission(success, failures)
    134135
     
    154155        if shared.team_failures == 5:
    155156            print("The spies won!")
    156             for p in players:
     157            for p in shared.players:
    157158                p.observe_game(False)
    158159            return
    159160        elif wins >= 3:
    160161            print("The Resistance won!")
    161             for p in players:
     162            for p in shared.players:
    162163                p.observe_game(True)
    163164            return
    164165        elif losses >= 3:
    165166            print("The Spies won!")
    166             for p in players:
     167            for p in shared.players:
    167168                p.observe_game(False)
    168169            return
Note: See TracChangeset for help on using the changeset viewer.