Exemplo n.º 1
0
 def setUp(self):
     self.phase = setup.MakePhase(
         state.GameParams(name='testgame',
                          players=('Alice', 'Bob', 'Charly'),
                          type='short',
                          preselected_companies={8, 19, 29, 43, 60},
                          file_root='/testdir',
                          seed=42))
     self.phase.corporations[8].price = 29
     self.phase.corporations[5].price = 28
     self.phase.corporations[6].price = 26
     self.phase.corporations[8].shares = 5
     self.phase.corporations[5].shares = 6
     self.phase.corporations[6].shares = 4
     self.phase.players[1].companies = {7, 8, 17, 19}
     self.phase.players[1].money = 11
     self.phase.players[1].shares[5] = 1
     self.phase.players[1].shares[6] = 2
     self.phase.players[1].shares[8] = 3
     self.phase.players[1].presidencies[8] = True
     self.phase.players[2].shares[5] = 3
     self.phase.players[2].shares[6] = 2
     self.phase.players[2].shares[8] = 1
     self.phase.players[2].presidencies[6] = True
     self.phase.players[2].presidencies[5] = True
     self.phase.players[0].shares[1] = 4
     self.phase.players[0].presidencies[1] = True
     self.phase.corporations[1].companies = {7, 8, 19}
     self.phase.corporations[1].money = 17
     self.phase.corporations[1].companies_in_flight = {17}
     self.phase.corporations[1].money_in_flight = 13
     self.phase.corporations[1].price = 1
     self.phase.corporations[1].shares = 6
     self.phase.foreign_investor.companies = {7, 8, 17, 19}
Exemplo n.º 2
0
Arquivo: game.py Projeto: beorn7/rsmod
    def New(cls, params):
        """Creates a newly started game from the given parameters.

        Args:
          params: A state.GameParams object.
        Returns:
          The game object, ready to start the game.
        """
        game = cls()
        game.phase = setup.MakePhase(params)
        return game
Exemplo n.º 3
0
 def testSaveAndRestore(self):
     phase = setup.MakePhase(
         state.GameParams(
             name='testgame',
             players=('Alice', 'Bob', 'Charly', 'Dolly', 'Ed', 'F. F.'),
             type='training',
             preselected_companies={1,2},
             open_companies=True,
             share_redemption=True,
             file_root=self.tempdir,
             seed=42))
     state.SavePhase(phase)
     restored_phase = state.RestorePhase(
         os.path.join(self.tempdir, 't1p1.py'))
     self.assertEqual(str(phase), str(restored_phase))
Exemplo n.º 4
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import static_html
import setup
import state

phase = setup.MakePhase(
    state.GameParams(name='testgame',
                     players=('Alice', 'Bob', 'Charly', 'Dolly', 'Ed',
                              'F "bla" F.'),
                     type='short',
                     preselected_companies={8, 19, 29, 43, 60},
                     open_companies=False,
                     ascending_companies=False,
                     share_redemption=True,
                     file_root='./tdir'))
phase.actions.extend(['<b>a</b> foo', '<b>b</b> bar'])
#phase.future_actions.extend(['1 bla', '2 blubb'])

phase.foreign_investor.companies.add(1)
phase.foreign_investor.companies.add(29)
phase.foreign_investor.companies.add(20)
phase.foreign_investor.companies.add(31)

phase.corporations[0].price = 2
phase.corporations[0].shares = 2
phase.corporations[1].price = 29
phase.corporations[1].shares = 8
phase.corporations[5].price = 16
phase.corporations[5].shares = 3
Exemplo n.º 5
0
 def testSixPlayers(self):
     phase = setup.MakePhase(
         GameParams(name='testgame',
                    players=('Alice', 'Bob', 'Charly', 'Dolly', 'Ed',
                             'F. F.'),
                    type='training',
                    preselected_companies={1, 2},
                    open_companies=True,
                    ascending_companies=False,
                    share_redemption=True,
                    file_root='/home/test',
                    css_file='../test.css',
                    image_dir='../img',
                    seed=42))
     self.assertEqual(
         str(phase),
         str(
             Phase(params=GameParams(name='testgame',
                                     players=('Alice', 'Bob', 'Charly',
                                              'Dolly', 'Ed', 'F. F.'),
                                     type='training',
                                     preselected_companies={1, 2},
                                     open_companies=True,
                                     ascending_companies=False,
                                     share_redemption=True,
                                     file_root='/home/test',
                                     css_file='../test.css',
                                     image_dir='../img',
                                     seed=42),
                   turn=1,
                   phase=1,
                   last_turn=0,
                   available={1, 2, 5, 6, 7, 8},
                   unavailable=set(),
                   closed=set(),
                   deck=[
                       14, 15, 17, 19, 12, 16, 11, 13, 21, 22, 25, 24, 23,
                       29, 26, 20, 33, 30, 40, 31, 43, 32, 37
                   ],
                   foreign_investor=ForeignInvestor(money=4,
                                                    companies=set()),
                   players=[
                       Player(money=25,
                              companies=set(),
                              order=6,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ]),
                       Player(money=25,
                              companies=set(),
                              order=4,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ]),
                       Player(money=25,
                              companies=set(),
                              order=5,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ]),
                       Player(money=25,
                              companies=set(),
                              order=2,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ]),
                       Player(money=25,
                              companies=set(),
                              order=1,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ]),
                       Player(money=25,
                              companies=set(),
                              order=3,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ])
                   ],
                   corporations=[
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0)
                   ],
                   actions=[],
                   next_action=PhaseEndAction(message=''))))
Exemplo n.º 6
0
 def testThreePlayers(self):
     phase = setup.MakePhase(
         GameParams(name='testgame',
                    players=('Alice', 'Bob', 'Charly'),
                    type='short',
                    preselected_companies={8, 19, 20, 29},
                    open_companies=False,
                    ascending_companies=False,
                    share_redemption=False,
                    file_root='/home/test',
                    css_file='../test.css',
                    seed=42))
     self.assertEqual(
         str(phase),
         str(
             Phase(params=GameParams(name='testgame',
                                     players=('Alice', 'Bob', 'Charly'),
                                     type='short',
                                     preselected_companies={8, 19, 20, 29},
                                     open_companies=False,
                                     ascending_companies=False,
                                     share_redemption=False,
                                     file_root='/home/test',
                                     css_file='../test.css',
                                     image_dir='../img',
                                     seed=42),
                   turn=1,
                   phase=1,
                   last_turn=0,
                   available={8, 1, 7},
                   unavailable=set(),
                   closed=set(),
                   deck=[
                       5, 19, 16, 11, 12, 26, 20, 29, 21, 32, 31, 43, 33,
                       54, 45, 58, 47
                   ],
                   foreign_investor=ForeignInvestor(money=4,
                                                    companies=set()),
                   players=[
                       Player(money=30,
                              companies=set(),
                              order=2,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ]),
                       Player(money=30,
                              companies=set(),
                              order=3,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ]),
                       Player(money=30,
                              companies=set(),
                              order=1,
                              shares=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              presidencies=[
                                  False, False, False, False, False, False,
                                  False, False, False, False
                              ])
                   ],
                   corporations=[
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0),
                       Corporation(money=0,
                                   companies=set(),
                                   money_in_flight=0,
                                   companies_in_flight=set(),
                                   done=False,
                                   price=-1,
                                   shares=0)
                   ],
                   actions=[],
                   next_action=PhaseEndAction(message=''))))