Ejemplo n.º 1
0
    def _load_powerplants(self, num_players):
        with open(CARDS_FILE, 'r') as f:
            plants = json.load(f)
        for card in plants:
            card["resource_type"] = RType(card["resource_type"])
        dark = [card for card in plants if card["type"] == "dark"]
        light = [card for card in plants if card["type"] == "light"]

        # Step 1: set up market
        dealt = []
        for x in range(CURRENT_MARKET_SIZE + FUTURES_MARKET_SIZE):
            idx = random.randint(0, len(dark) - 1)
            dealt.append(dark[idx])
            dark = dark[0:idx] + dark[idx + 1:]
        self._sort_market(dealt)

        # Step 2: random removal
        for x in range(NUM_DISCARD_LIGHT[num_players]):
            idx = random.randint(0, len(light) - 1)
            light = light[0:idx] + light[idx + 1:]
        for x in range(NUM_DISCARD_DARK[num_players]):
            idx = random.randint(0, len(dark) - 1)
            dark = dark[0:idx] + dark[idx + 1:]

        # Step 3: shuffle all cards together
        cards = light + dark
        random.shuffle(cards)

        # Step 4: place stage 3 'card' at bottom of deck
        stage3 = [{"type": "stage3"}]
        self.deck = cards + stage3
Ejemplo n.º 2
0
    def _load_slots(self):
        with open(RESOURCE_SLOTS, 'r') as f:
            data = json.load(f)

        new_slots = []
        for slot in data:
            new_capacity = {}
            for r_type in slot:
                new_capacity[RType(int(r_type))] = slot[r_type]
            new_slots.append(new_capacity)
        return new_slots
Ejemplo n.º 3
0
	def _load_refresh_rate(self, board_type, num_players):
		'''
		loads in a dictionary of the format
		{
		  RType : { phase_int : rate_int, phase_int: rate_int, phase_int: rate_int},
		  ....
		}
		returns dictionary of 
		{
		  phase_int : { RType : rate_int, RType : rate_int, ...},
		  ....
		}
		'''
		with open(REFILL_RATE, 'r') as f:
			data = json.load(f)

		rates = data[board_type][str(num_players)]
		processed = {1 : {}, 2 : {}, 3 : {}}
		for r_type in rates:
			for phase in rates[r_type]:
				processed[int(phase)].update({RType(int(r_type)): rates[r_type][phase]})
		return processed