upfront / upfront / game.py

class PersonalityCard(object):
    def __init__(self, id, nation, name, weapon, morale, panic, rank=None):
        self.id = id
        self.name = name
        self.nation = nation
        self.weapon = weapon
        self.morale = morale
        self.panic = panic
        self.rank = rank

    def __repr__(self):
        return 'PersonalityCard(%s, %s, %s, %s, %s, %s, %s)' % (self.id, repr(self.name),
            repr(self.nation), self.weapon, self.morale, self.panic, repr(self.rank))

class UpFront(object):
    def __init__(self, player1, player1nation, player2=None, player2nation=None):
        """
        Create basic setup of an Up Front game. player1 and player2 are the names
        of the players for reference.

        player1nation and player2nation should be one of: 'germany', 'america', or 'russia'.
        An exception is raised if the two values are not different or if one of the two is not
        america.
        """

        self.state = 'setup'
        self.player1 = player1
        self.player1nation = player1nation
        self.player2 = player2
        self.player2nation = player2nation

    def __validateNations(self, nation1, nation2):
        nations = ['america', 'germany', 'russia']

        if not nation1 in nations:
            raise ValueError('Invalid nation: "%s"' % (nation1))

        if not nation2 in nations:
            raise ValueError('Invalid nation: "%s"' % (nation2))

        if not nation1 == 'america' and not nation2 == 'america':
            raise ValueError('At least one player must be American')

    def getCards(nation):
        if nation == 'germany':
            pistol = {'type': 'Machine Pistol', 'name': 'MP 38',
                'firepower': {0:0, 1:0, 2:0, 3:1, 4:3, 5:5}}
            mg = {'type': 'Light Machinegun', 'name': 'MG 34',
                'firepower': {0:2, 1:3, 2:3, 3:4, 4:4, 5:5},
                'crewpower': {0:4, 1:5, 2:6, 3:7, 4:8, 5:9}}
            rifle = {'type': 'Bolt-Action Rifle', 'name': 'GewehrK98k aka "Mauser"',
                'firepower': {0:0, 1:1, 2:1, 3:2, 4:2, 5:3}}

            germans = list()

            germans.append(PersonalityCard(1, 'german', 'Sgt. Diettinger', pistol, 5, 6, 'SL'))
            germans.append(PersonalityCard(2, 'german', 'Cpl. Hessel', pistol, 4, 5, 'ASL'))
            germans.append(PersonalityCard(3, 'german', u'Pfc. Sch\u00fcssel', mg, 3, 4))
            germans.append(PersonalityCard(4, 'german', 'Pvt. Schumacher', rifle, 3, 4))
            germans.append(PersonalityCard(5, 'german', 'Pvt. Shultz', rifle, 2, 3))
            germans.append(PersonalityCard(6, 'german', 'Pvt. Bernhoff', rifle, 5, 6))
            germans.append(PersonalityCard(7, 'german', 'Pvt. Beck', rifle, 1, 2))
            germans.append(PersonalityCard(8, 'german', 'Pvt. Wollak', rifle, 2, 2))
            germans.append(PersonalityCard(9, 'german', 'Pvt. Streich', rifle, 3, 3))
            germans.append(PersonalityCard(10, 'german', 'Pvt. Wolff', rifle, 4, 4))

            return germans
        elif nation == 'america':
            m1 = {'type': 'Semi-Automatic Rifle', 'name': 'M1 Garand',
                'firepower': {0:0, 1:1, 2:1, 3:2, 4:2, 5:3}}
            bar = {'type': 'BAR', 'name': 'Bar M1918A2',
                'firepower': {0:2, 1:3, 2:3, 3:4, 4:4, 5:5}}
            pistol = {'type': 'Machine Pistol', 'name': 'M1 Thompson',
                'firepower': {0:0, 1:0, 2:0, 3:1, 4:3, 5:5}}

            americans = list()

            americans.append(PersonalityCard(1, 'america', 'Sgt. Burnett', pistol, 4, 6, 'SL'))
            americans.append(PersonalityCard(2, 'america', 'Cpl. Moores', pistol, 3, 5, 'ASL'))
            americans.append(PersonalityCard(3, 'america', 'Pfc. Fox', bar, 4, 5))
            americans.append(PersonalityCard(4, 'america', 'Pvt. McElroy', m1, 3, 5))
            americans.append(PersonalityCard(5, 'america', 'Pvt. Frattali', m1, 3, 4))
            americans.append(PersonalityCard(6, 'america', 'Pvt. Smith', m1, 1, 3))
            americans.append(PersonalityCard(7, 'america', 'Pvt. Anderson', m1, 3, 4))
            americans.append(PersonalityCard(8, 'america', 'Pvt. Burke', m1, 2, 3))
            americans.append(PersonalityCard(9, 'america', 'Pvt. Myers', m1, 5, 6))
            americans.append(PersonalityCard(10, 'america', 'Pvt. Watson', m1, 1, 2))
            americans.append(PersonalityCard(11, 'america', 'Pvt. Greenwood', m1, 3, 5))
            americans.append(PersonalityCard(12, 'america', 'Pvt. Edwards', m1, 2, 4))

            return americans
        elif nation == 'russia':
            sar = {'type': 'Semi-Automatic Rifle', 'name': 'Tookarev SVT-40',
                'firepower': {0:0, 1:0, 2:1, 3:2, 4:2, 5:3}}
            mg = {'type': 'Light Machinegun', 'name': 'DP 1928',
                'firepower': {0:2, 1:2, 2:3, 3:3, 4:4, 5:5},
                'crewpower': {0:3, 1:4, 2:5, 3:6, 4:7, 5:8}}
            rifle = {'type': 'Bolt-Action Rifle', 'name': 'Mosin Nagant M1891/30',
                'firepower': {0:0, 1:0, 2:1, 3:2, 4:2, 5:3}}

            russians = list()
            russians.append(PersonalityCard(1, 'russia', 'Sgt. Rostov', sar, 4, 5, 'SL'))
            russians.append(PersonalityCard(2, 'russia', 'Jr. Sgt. Burlak', mg, 4, 5, 'ASL'))
            russians.append(PersonalityCard(3, 'russia', 'Pvt. Petrovsky', rifle, 5, 5))
            russians.append(PersonalityCard(4, 'russia', 'Pvt. Yastreboft', rifle, 4, 4))
            russians.append(PersonalityCard(5, 'russia', 'Pvt. Storchillo', rifle, 3, 3))
            russians.append(PersonalityCard(6, 'russia', 'Pvt. Soloviev', rifle, 3, 4))
            russians.append(PersonalityCard(7, 'russia', 'Pvt. Kristov', rifle, 3, 3))
            russians.append(PersonalityCard(8, 'russia', 'Pvt. Chernenko', rifle, 5, 5))
            russians.append(PersonalityCard(9, 'russia', 'Pvt. Nosenko', rifle, 2, 2))
            russians.append(PersonalityCard(10, 'russia', 'Pvt. Kvasnikov', rifle, 1, 2))
            russians.append(PersonalityCard(11, 'russia', 'Pvt. Sokoloff', rifle, 2, 3))
            russians.append(PersonalityCard(12, 'russia', 'Pvt. Vakuta', rifle, 5, 6))
            russians.append(PersonalityCard(13, 'russia', 'Pvt. Zaharoff', rifle, 4, 5))
            russians.append(PersonalityCard(14, 'russia', 'Pvt. Zayakov', rifle, 2, 2))
            russians.append(PersonalityCard(15, 'russia', 'Pvt. Uihailoft', rifle, 3, 4))

            return russians
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.