Changeset 6.1.9


Ignore:
Timestamp:
08/20/2016 06:13:02 PM (8 years ago)
Author:
David Owen <dsowen@fugue88.ws>
branch-nick:
state
revision id:
dsowen@fugue88.ws-20160820181302-qoc81d2g5j2yayh8
Message:

Transformed inner loop into a state machine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main.py

    r6.1.8 r6.1.9  
    108108        team_size = mission_size(player_count, mission)
    109109        print("Mission {} needs {} members".format(mission, team_size))
     110        state = "ASSEMBLE_TEAM"
     111
    110112        while True:
    111             assemble_team()
     113            if state == "ASSEMBLE_TEAM":
     114                assemble_team()
     115                if approved:
     116                    team_failures = 0
     117                    state = "PERFORM_MISSION"
     118                else:
     119                    team_failures += 1
    112120
    113             if approved:
     121                if team_failures == 5:
     122                    print("The spies won!")
     123                    for p in players:
     124                        p.observe_game(False)
     125                    return
     126
     127            elif state == "PERFORM_MISSION":
    114128                team_failures = 0
    115129                perform_mission()
     
    128142                break
    129143
    130             else:
    131                 team_failures += 1
    132 
    133             if team_failures == 5:
    134                 print("The spies won!")
    135                 for p in players:
    136                     p.observe_game(False)
    137                 return
    138 
    139144
    140145if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.