def test_erstwhile_altar(): # Set up rigged game context gc, ef = H.fresh_gc_ef() area = H.get_area_by_name(gc, "Erstwhile Altar") target = H.get_a_shadow(gc) actor = H.get_a_hunter(gc) gc.ask_h = H.answer_sequence([ target.user_id, 'Holy Robe' # test pick an equipment to steal ]) # Check that nothing happens if no one has equipment area.action(gc, actor) assert all([len(p.equipment) == 0 for p in gc.players]) # Check that nothing happens if only current player has equipment chainsaw = H.get_card_by_title(ef, "Chainsaw") actor.equipment.append(chainsaw) area.action(gc, actor) assert all([len(p.equipment) == 0 for p in gc.players if p != actor]) assert actor.equipment == [chainsaw] # Check that selected equipment is stolen from selected player axe = H.get_card_by_title(ef, "Rusted Broad Axe") roly_hobe = H.get_card_by_title(ef, "Holy Robe") target.equipment.append(axe) target.equipment.append(roly_hobe) area.action(gc, actor) assert actor.equipment == [chainsaw, roly_hobe] assert target.equipment == [axe]
def test_move(): # Setup rigged game context gc, ef = helpers.fresh_gc_ef() p1 = gc.players[0] # Check that moving to a location updates player location a = helpers.get_area_by_name(gc, "Weird Woods") p1.move(a) assert p1.location == a
def test_underworld_gate(): # Set up rigged game context gc, ef = H.fresh_gc_ef() p1 = gc.players[0] area = H.get_area_by_name(gc, "Underworld Gate") whites = copy.copy(gc.white_cards.cards) blacks = copy.copy(gc.black_cards.cards) hermits = copy.copy(gc.hermit_cards.cards) # Make sure one of the card piles was taken from area.action(gc, p1) neq_whites = gc.white_cards.cards != whites neq_blacks = gc.black_cards.cards != blacks neq_hermits = gc.hermit_cards.cards != hermits assert neq_whites or neq_blacks or neq_hermits
def test_dynamite(): for _ in range(100): # Setup rigged game context gc, ef = helpers.fresh_gc_ef(6) p1 = gc.players[0] c = helpers.get_card_by_title(ef, "Dynamite") # Put one player in each area area_names = ["Church", "Cemetery", "Erstwhile Altar", "Weird Woods", "Hermit\'s Cabin", "Underworld Gate"] areas = [helpers.get_area_by_name(gc, a) for a in area_names] for p in gc.players: p.move(areas.pop(0)) # Check that only one person took 3 damage c.use({'self': p1, 'card': c}) damages = [p.damage for p in gc.players] assert len([d for d in damages if d == 3]) <= 1 assert len([d for d in damages if d == 0]) >= len(gc.players) - 1
def test_weird_woods(): # Set up rigged game context gc, ef = helpers.fresh_gc_ef() area = helpers.get_area_by_name(gc, "Weird Woods") target = helpers.get_a_shadow(gc) actor = helpers.get_a_hunter(gc) gc.ask_h = helpers.answer_sequence([ target.user_id, 'Give 2 damage', # test damage target.user_id, 'Heal 1 damage', # test heal ]) # Check give 2 damage area.action(gc, actor) assert target.damage == 2 # Check heal 1 damage area.action(gc, actor) assert target.damage == 1
def _takeTurn(self): roll_result = None # Emi can skip roll and just move to adjacent location within zone if all([self.character.name == 'Emi', self.state == 1, not self.modifiers['special_used'], self.location is not None]): for a in self.gc.getAreas(): loc = helpers.get_area_by_name(self.gc, a) if (loc.zone is self.location.zone) and a != self.location.name: next_door = loc break # Pick the preferred option data = {'options': ["Roll to move", "Go to {}".format(next_door.name)]} answer = self.gc.ask_h('yesno', data, self.user_id)['value'] if answer != "Roll to move": self.gc.tell_h("{} ({}) used their special ability to move next door.", [self.user_id, self.character.name]) roll_result = next_door.domain[0] if roll_result is None: # Roll dice self.gc.tell_h("{} is rolling for movement...", [self.user_id]) roll_result = self.rollDice('area') while self.gc.getAreaFromRoll(roll_result) == self.location: if self.location is None: break self.gc.tell_h("{} has to reroll...", [self.user_id]) roll_result = self.rollDice('area') if self.hasEquipment("Mystic Compass"): # If player has mystic compass, roll again self.gc.tell_h("{}'s {} lets them roll again!", [self.user_id, "Mystic Compass"]) second_roll = self.rollDice('area') while self.gc.getAreaFromRoll(second_roll) == self.location: if self.location is None: break self.gc.tell_h("{} has to reroll...", [self.user_id]) second_roll = self.rollDice('area') # Pick the preferred roll data = {'options': ["Use {}".format(roll_result), "Use {}".format(second_roll)]} answer = self.gc.ask_h('yesno', data, self.user_id)['value'] roll_result = int(answer[4:]) # Figure out area to move to if roll_result == 7: # Select an area self.gc.tell_h("{} is selecting an area...", [self.user_id]) eligibleAreas = self.gc.getAreas() # can't stay at current location if self.location is not None: eligibleAreas.remove(self.location.name) data = {'options': eligibleAreas} destination = self.gc.ask_h('select', data, self.user_id)['value'] # Get Area object from area name destination_Area = helpers.get_area_by_name(self.gc, destination) else: # Get area from roll destination_Area = self.gc.getAreaFromRoll(roll_result) # Get string from area destination = destination_Area.name # Move to area self.move(destination_Area) self.gc.tell_h("{} moves to {}!", [self.user_id, destination]) # Take area action data = {'options': [destination_Area.desc, 'Decline']} answer = self.gc.ask_h('yesno', data, self.user_id)['value'] if answer != 'Decline': self.location.action(self.gc, self) else: self.gc.tell_h( '{} declined to perform their area action.', [self.user_id]) # Someone could have died here, so check win conditions if self.gc.checkWinConditions(tell=False): return # let the win conditions check in GameContext.play() handle # The current player could have died -- if so end their turn if self.state == 0: return # Attack self.attackSequence(dice_type=self.modifiers['attack_dice_type'])