Changeset 5 for main.py


Ignore:
Timestamp:
08/16/2016 03:18:54 AM (8 years ago)
Author:
David Owen <dsowen@fugue88.ws>
branch-nick:
resistance
revision id:
dsowen@fugue88.ws-20160816031854-39ocjsoyqvn0lzin
Message:

Split Player into different module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main.py

    r4 r5  
    11from random import shuffle
    22
    3 
    4 class Player(object):
    5 
    6     def __init__(self, player_count, player_num, role):
    7         self.count = player_count
    8         self.num = player_num
    9         self.role = role
    10 
    11     def reveal_spies(self, spies):
    12         """If this player is a spy, this method will be called to reveal the identities
    13         of *all* the spies (including this player).
    14 
    15         It is passed as an array of IDs.
    16 
    17         """
    18         pass
    19 
    20     def propose_team(self, count):
    21         """Asks the player to propose a team as a team-lead.
    22 
    23         Must return an array of `count` unique IDs.  The proposed team may
    24         include the player, but does not need to.
    25 
    26         """
    27         team = list(range(self.count))
    28         shuffle(team)
    29         return team[:count]
    30 
    31     def approve_team(self, team):
    32         """Asks the player to vote on a proposed team.
    33 
    34         True indicates approval, False disapproval.  The player will be asked
    35         to vote on all teams, even one that it proposes.
    36 
    37         """
    38         return True
    39 
    40     def observe_team_vote(self, approved, votes):
    41         """Allows the player to observe the outcome of a vote to approve a proposed
    42         team.
    43 
    44         The final result is given as `approved`, and individual votes (ordered
    45         by player ID) are given as an array as `votes`.
    46 
    47         """
    48         pass
    49 
    50     def perform_mission(self):
    51         """If this player is a spy, called to ask the player whether to fail the
    52         mission.
    53 
    54         True indicates that this player will not cause a failure, False that it
    55         will cause a failure.
    56 
    57         Note that some missions require 2 players to attempt a mission failure
    58         to actually fail the mission.
    59 
    60         """
    61         return False
    62 
    63     def observe_mission(self, success, failures):
    64         """Allows the player to observe the outcome of a mission.
    65 
    66         The final result is given as `success`.  The number of failures is
    67         given (as an integer) as `failures`.
    68 
    69         """
    70         pass
    71 
    72     def observe_game(self, success):
    73         """Allows the player to observe the outcome of the game.
    74 
    75         True indicates the Resistance won, False the Government (spies).
    76 
    77         """
    78         pass
     3from player import Player
    794
    805
Note: See TracChangeset for help on using the changeset viewer.