def test_is_valid_food(self): json_trait1 = [5, CARNIVORE] json_trait2 = [2, LONG_NECK] bad_trait1 = [-9, CARNIVORE] bad_trait2 = [4, AMBUSH] self.assertTrue(TraitCard.is_valid_food(json_trait1)) self.assertTrue(TraitCard.is_valid_food(json_trait2)) self.assertFalse(TraitCard.is_valid_food(bad_trait1)) self.assertFalse(TraitCard.is_valid_food(bad_trait2))
def testDiscardFromHand(self): self.assertEqual(len(self.playerWithCards.hand), 4) self.assertEqual(self.playerWithCards.hand[0], TraitCard("foraging", 2)) self.assertEqual(self.playerWithCards.hand[2], TraitCard("scavenger", 3)) self.playerWithCards.discardFromHand([0, 1, 3]) self.assertEqual(len(self.playerWithCards.hand), 1) self.assertEqual(self.playerWithCards.hand[0], TraitCard("scavenger", 3))
def setUp(self): self.t1 = TraitCard("horns", 3) self.t2 = TraitCard("ambush", 1) self.t3 = TraitCard("carnivore", 2) self.t4 = TraitCard("fat-tissue", 0) self.t5 = TraitCard("foraging", 3) self.vegHorns = Species(1, 2, 3, ["horns"], 0) self.vegCoop = Species(1, 2, 3, ["cooperation"], 0) self.fat = Species(4, 3, 4, ["fat-tissue"], 3) self.fatScav = Species(2, 3, 4, ["fat-tissue", "scavenger"], 1) self.fatFor = Species(4, 3, 4, ["fat-tissue", "foraging"], 1) self.carnCoop = Species(3, 4, 5, ["carnivore", "cooperation"], 0) self.carnForage = Species(3, 4, 5, ["carnivore", "foraging"], 0) self.carnForage1 = Species(3, 4, 5, ["carnivore", "foraging"], 0) self.extinct = Species(0, 0, 0, [], 0) self.p1 = PlayerState(1, 0, [self.vegCoop, self.fat, self.carnForage], []) self.p2 = PlayerState(2, 0, [self.vegHorns, self.fatScav, self.carnCoop], []) self.p3 = PlayerState(3, 0, [self.vegCoop, self.carnCoop, self.carnForage1], []) self.p4 = PlayerState(4, 0, [self.vegCoop], []) self.p5 = PlayerState(5, 0, [self.vegHorns], []) self.p6 = PlayerState(6, 0, [self.carnCoop], []) self.p7 = PlayerState(7, 0, [self.fatScav], []) self.p8 = PlayerState(8, 0, [self.fatFor, self.extinct], []) self.dealer = Dealer([self.p1, self.p2, self.p3], 3, [self.t1, self.t2, self.t3, self.t4, self.t5]) self.p2dealer = Dealer([self.p6, self.p5], 3, []) self.p3dealer = Dealer([self.p8], 3, [self.t1, self.t2, self.t3, self.t4, self.t5]) self.xstep3spec = Species(0, 5, 2, ["foraging"], 0) self.xstep3p = PlayerState(1, 0, [self.xstep3spec], []) self.xstep3deal = Dealer([self.xstep3p], 5, []) # 8949-0357-4 self.pCFS1 = PlayerState(1, 3, [ Species(4, 2, 5, ["carnivore", "cooperation"], 0), Species(1, 3, 4, ["foraging", "carnivore", "scavenger"], 0) ], []) self.pCFS2 = PlayerState(2, 4, [Species(2, 3, 3, ["burrowing"], 0)], []) self.pCFS3 = PlayerState(3, 5, [], []) self.dCFS = Dealer([self.pCFS1, self.pCFS2, self.pCFS3], 10, [])
def from_json_state(json_state): """ Takes in a json 'state' of a Player, converting it into a new PlayerState object :param json_state: JSON List - [Natural, [Species+, ..., Species+], Cards] :return: PlayerState - the new PlayerState object created from the json representation """ food_bag = json_state[0] species_list = [Species.convertSpecies(species) for species in json_state[1]] trait_cards = [TraitCard.from_json(trait) for trait in json_state[2]] return PlayerState(bag=food_bag, speciesList=species_list, trait_cards=trait_cards)
def testScavengeFeed(self): self.assertEqual(self.fatScav.food, 2) self.assertEqual(self.dealer.wateringHole, 3) self.dealer.scavengeFeed(self.p1) self.assertEqual(self.fatScav.food, 3) self.assertEqual(self.dealer.wateringHole, 2) self.dealer.scavengeFeed(self.p1) self.dealer.scavengeFeed(self.p1) self.dealer.scavengeFeed(self.p1) self.assertEqual(self.fatScav.food, 4) self.assertEqual(self.dealer.wateringHole, 1) self.carnCoop.traits.append(TraitCard("scavenger")) self.vegCoop.traits.append(TraitCard("scavenger")) self.assertEqual(self.vegCoop.food, 1) self.assertEqual(self.carnCoop.food, 3) self.dealer.scavengeFeed(self.p1) self.assertEqual(self.vegCoop.food, 2) self.assertEqual(self.carnCoop.food, 3) self.assertEqual(self.dealer.wateringHole, 0)
def testReplaceTraits(self): playerForReplacingTraits = PlayerState(1, 0, [ Species(0, 0, 1, [TraitCard("foraging"), TraitCard("herding")], 0) ], [TraitCard("carnivore"), TraitCard("horns")]) dealerForReplacingTraits = Dealer([playerForReplacingTraits], 0, []) dealerForReplacingTraits.replaceTraits(0, self.actRT) # the card is still in hand -- it will be removed in the step4 method, not here self.assertEqual(dealerForReplacingTraits.players[0].hand, [TraitCard("carnivore"), TraitCard("horns")]) self.assertEqual( dealerForReplacingTraits.players[0].species[0].traits, [TraitCard("foraging"), TraitCard("horns")])
def setUp(self): self.t1 = TraitCard("horns", 3) self.t2 = TraitCard("ambush", 1) self.t3 = TraitCard("carnivore", 2) self.t4 = TraitCard("fat-tissue", 0) self.t5 = TraitCard("foraging", 3) self.t6 = TraitCard("herding", 0) self.defSpec = Species(0, 0, 1, [], 0) self.specWGrownBody = Species(0, 1, 1, [], 0) self.specW3t = Species(0, 0, 1, [self.t3, self.t4, self.t5], 0) self.specWAll = Species(0, 1, 2, [self.t4], 0) self.playerWithManyCards = PlayerState( 1, 0, [], [self.t1, self.t2, self.t3, self.t4, self.t5, self.t6]) self.playerForAll = PlayerState(1, 0, [self.specWAll], []) self.playerFor3t = PlayerState(1, 0, [self.specW3t], [self.t6]) self.playerForDefSpec = PlayerState(1, 0, [self.defSpec], [self.t5, self.t6]) self.playerForBodyNewspec = PlayerState( 1, 0, [self.specWGrownBody], [self.t3, self.t4, self.t5, self.t6]) self.noAct = Action4(0, [], [], [], []) self.actGP = Action4(0, [GainPopulation(0, 1)], [], [], []) self.actGB = Action4(0, [], [GainBodySize(0, 1)], [], []) self.actRT = Action4(0, [], [], [ReplaceTrait(0, 1, 1)], []) self.actBT0t = Action4(0, [], [], [], [BuySpeciesBoard(1, [])]) self.actBT1t = Action4(0, [], [], [], [BuySpeciesBoard(1, [2])]) self.actBT2t = Action4(0, [], [], [], [BuySpeciesBoard(1, [2, 3])]) self.actBT3t = Action4(0, [], [], [], [BuySpeciesBoard(1, [2, 3, 4])]) self.actBT4t = Action4(0, [], [], [], [BuySpeciesBoard(1, [2, 3, 4, 5])]) self.addBodyToNewSpec = Action4(0, [GainPopulation(1, 1)], [], [], [BuySpeciesBoard(2, [3])]) self.actAll = Action4(0, [GainPopulation(0, 1)], [GainBodySize(0, 2)], [ReplaceTrait(0, 0, 3)], [BuySpeciesBoard(4, [5])])
def testFromJson(self): json_trait1 = [3, CARNIVORE] trait1 = TraitCard(CARNIVORE, 3) self.assertEquals(TraitCard.from_json(json_trait1), trait1) with self.assertRaises(Exception): TraitCard.from_json([CARNIVORE, 3]) with self.assertRaises(Exception): TraitCard.from_json([3, CARNIVORE, 2]) with self.assertRaises(Exception): TraitCard.from_json([3, "nonsense"])
def get_hand(json_trait_cards): """ Parse a json trait hand into a list of TraitCards :param json_trait_cards: JSON list of [traitValue, traitName] :return: listOf(TraitCard) - The Dealer's hand from configuration """ list_of_species_cards = [] found_traits = {} for trait_card in json_trait_cards: if len(trait_card) == 2: list_of_species_cards.append(TraitCard.from_json(trait_card)) if trait_card[1] in found_traits: found_traits[trait_card[1]] += 1 else: found_traits[trait_card[1]] = 1 Dealer.validate_hand(found_traits) return list_of_species_cards
def convertPlayerState(state): """ Creates a PlayerState from from the given JSON representation :param state: JSON list - represents the playerState :return: PlayerState - with attributes contained in 'state' """ playerTraitCards = [] if state[0][0] == ID_LABEL and state[1][0] == SPECIES_LABEL and state[2][0] == BAG_LABEL: id = state[0][1] speciesList = [Species.convertSpecies(species) for species in state[1][1]] bag = state[2][1] if len(state) == 4 and state[3][0] == CARDS_LABEL: playerTraitCards = [TraitCard.from_json(card) for card in state[3][1]] if id < 1 or bag < 0: raise Exception("Bad JSON PlayerState Data") return PlayerState(id, bag, speciesList, playerTraitCards) else: raise Exception("Bad JSON PlayerState input")
def testFeed1(self): self.assertEqual(self.vegCoop.food, 1) self.dealer.feed1() self.assertEqual(self.vegCoop.food, 2) self.assertEqual(self.dealer.wateringHole, 2) self.assertEqual(self.carnCoop.population, 5) self.assertEqual(self.carnCoop.food, 3) self.assertEqual(self.vegHorns.population, 3) self.p2dealer.feed1() self.assertEqual(self.carnCoop.population, 4) self.assertEqual(self.carnCoop.food, 4) self.assertEqual(self.vegHorns.population, 2) self.assertEqual(self.fatFor.fatFood, 1) self.assertEqual(self.fatFor.food, 4) self.p3dealer.feed1() self.assertEqual(self.fatFor.fatFood, 3) self.assertEqual(self.fatFor.food, 4) self.assertEqual(self.p3dealer.wateringHole, 1) # a user without any species should not be deleted from players # but should be deleted from currentlyFeeding # 0067-2657-1 pNoSpecies1 = PlayerState(1, 0, [], []) pNoSpecies2 = PlayerState(2, 0, [], []) pNoSpecies3 = PlayerState(3, 0, [], []) dNoSpecies = Dealer([pNoSpecies1, pNoSpecies2, pNoSpecies3], 5, []) self.assertEqual(len(dNoSpecies.players), 3) self.assertEqual(len(dNoSpecies.currentlyFeeding), 3) dNoSpecies.feed1() self.assertEqual(len(dNoSpecies.players), 3) self.assertEqual(len(dNoSpecies.currentlyFeeding), 2) self.assertFalse(pNoSpecies1 in dNoSpecies.currentlyFeeding) # a user who can no longer attack/feed should not be deleted from players # but should be deleted from currentlyFeeding # 0067-2657-7 pNoAtkSpecies1 = PlayerState(1, 0, [ Species(0, 1, 1, [TraitCard("carnivore")], 0), Species(1, 1, 1, [TraitCard("horns"), TraitCard("cooperation")], 0), Species(1, 1, 1, [], 0) ], []) pNoAtkSpecies2 = PlayerState( 2, 0, [Species(0, 1, 1, [TraitCard("hard-shell")], 0)], []) pNoAtkSpecies3 = PlayerState(3, 0, [ Species(0, 1, 1, [ TraitCard("cooperation"), TraitCard("scavenger"), TraitCard("climbing") ], 0), Species(0, 1, 2, [ TraitCard("cooperation"), TraitCard("scavenger"), TraitCard("climbing") ], 0), Species(0, 1, 4, [TraitCard("foraging"), TraitCard("hard-shell")], 0) ], []) dNoAtkSpecies = Dealer( [pNoAtkSpecies1, pNoAtkSpecies2, pNoAtkSpecies3], 5, []) self.assertEqual(len(dNoAtkSpecies.players), 3) self.assertEqual(len(dNoAtkSpecies.currentlyFeeding), 3) dNoAtkSpecies.feed1() self.assertEqual(len(dNoAtkSpecies.players), 3) self.assertEqual(len(dNoAtkSpecies.currentlyFeeding), 2) self.assertFalse(pNoAtkSpecies1 in dNoAtkSpecies.currentlyFeeding) # successfully extincting someone else's species should give two cards to loser # 2598-3830-8 pExtinction1 = PlayerState( 3, 2, [Species(3, 4, 4, [TraitCard("carnivore")], 0)], [TraitCard("burrowing", -3)]) pExtinction2 = PlayerState(2, 42, [ Species(0, 3, 4, [TraitCard("climbing")], 0), Species(4, 2, 4, [TraitCard("climbing")], 0), Species(4, 1, 4, [TraitCard("climbing")], 0) ], [TraitCard("climbing", 3)]) pExtinction3 = PlayerState(4, 100, [Species(0, 7, 1, [], 0)], []) dExtinction = Dealer([pExtinction1, pExtinction2, pExtinction3], 9, [ TraitCard("burrowing", 3), TraitCard("horns", 3), TraitCard("climbing", 1) ]) self.assertEqual(len(dExtinction.deck), 3) dExtinction.feed1() self.assertEqual(len(dExtinction.deck), 1) self.assertEqual(pExtinction3.hand, [TraitCard("burrowing", 3), TraitCard("horns", 3)]) self.assertEqual(len(pExtinction3.species), 0) self.assertEqual(pExtinction1.species[0].food, 4) self.assertEqual(dExtinction.wateringHole, 8)
def testPrelimAutoFeedings(self): self.dealerForAutoFeeds = Dealer([ PlayerState(1, 0, [ Species(0, 2, 3, [TraitCard("fertile"), TraitCard("fat-tissue")], 2) ], []), PlayerState(1, 0, [Species(0, 2, 3, [TraitCard("fat-tissue")], 0)], []), PlayerState(3, 0, [ Species(0, 2, 3, [TraitCard("fertile"), TraitCard("long-neck")], 0) ], []) ], 10, []) self.assertEqual(len(self.dealerForAutoFeeds.discard), 0) self.assertEqual(self.dealerForAutoFeeds.wateringHole, 10) self.assertEqual( self.dealerForAutoFeeds.players[0].species[0].population, 3) self.assertEqual(self.dealerForAutoFeeds.players[0].species[0].fatFood, 2) self.assertEqual(self.dealerForAutoFeeds.players[0].species[0].food, 0) self.assertEqual(self.dealerForAutoFeeds.players[0].species[0].body, 2) self.assertEqual( self.dealerForAutoFeeds.players[1].species[0].population, 3) self.assertEqual(self.dealerForAutoFeeds.players[1].species[0].fatFood, 0) self.assertEqual(self.dealerForAutoFeeds.players[1].species[0].food, 0) self.assertEqual(self.dealerForAutoFeeds.players[1].species[0].body, 2) self.assertEqual( self.dealerForAutoFeeds.players[2].species[0].population, 3) self.assertEqual(self.dealerForAutoFeeds.players[2].species[0].fatFood, 0) self.assertEqual(self.dealerForAutoFeeds.players[2].species[0].food, 0) self.assertEqual(self.dealerForAutoFeeds.players[2].species[0].body, 2) self.dealerForAutoFeeds.prelimAutoFeedings() self.assertEqual(len(self.dealerForAutoFeeds.discard), 0) self.assertEqual(self.dealerForAutoFeeds.wateringHole, 9) self.assertEqual( self.dealerForAutoFeeds.players[0].species[0].population, 4) self.assertEqual(self.dealerForAutoFeeds.players[0].species[0].fatFood, 0) self.assertEqual(self.dealerForAutoFeeds.players[0].species[0].food, 2) self.assertEqual(self.dealerForAutoFeeds.players[0].species[0].body, 2) self.assertEqual( self.dealerForAutoFeeds.players[1].species[0].population, 3) self.assertEqual(self.dealerForAutoFeeds.players[1].species[0].fatFood, 0) self.assertEqual(self.dealerForAutoFeeds.players[1].species[0].food, 0) self.assertEqual(self.dealerForAutoFeeds.players[1].species[0].body, 2) self.assertEqual( self.dealerForAutoFeeds.players[2].species[0].population, 4) self.assertEqual(self.dealerForAutoFeeds.players[2].species[0].fatFood, 0) self.assertEqual(self.dealerForAutoFeeds.players[2].species[0].food, 1) self.assertEqual(self.dealerForAutoFeeds.players[2].species[0].body, 2)
def setUp(self): self.t1 = TraitCard("horns", 3) self.t2 = TraitCard("ambush", 1) self.t3 = TraitCard("carnivore", 2) self.t4 = TraitCard("fat-tissue", 0) self.t5 = TraitCard("foraging", 3) self.vegHorns = Species(1, 2, 3, [TraitCard("horns")], 0) self.vegCoop = Species(1, 2, 3, [TraitCard("cooperation")], 0) self.fat = Species(4, 3, 4, [TraitCard("fat-tissue")], 3) self.fatScav = Species( 2, 3, 4, [TraitCard("fat-tissue"), TraitCard("scavenger")], 1) self.fatFor = Species(4, 3, 4, [TraitCard("fat-tissue"), TraitCard("foraging")], 1) self.carnCoop = Species( 3, 4, 5, [TraitCard("carnivore"), TraitCard("cooperation")], 0) self.carnForage = Species( 3, 4, 5, [TraitCard("carnivore"), TraitCard("foraging")], 0) self.carnForage1 = Species( 3, 4, 5, [TraitCard("carnivore"), TraitCard("foraging")], 0) self.extinct = Species(0, 0, 0, [], 0) self.p1 = PlayerState(1, 0, [self.vegCoop, self.fat, self.carnForage], []) self.p2 = PlayerState(2, 0, [self.vegHorns, self.fatScav, self.carnCoop], []) self.p3 = PlayerState(3, 0, [self.vegCoop, self.carnCoop, self.carnForage1], []) self.p4 = PlayerState(4, 0, [self.vegCoop], []) self.p5 = PlayerState(5, 0, [self.vegHorns], []) self.p6 = PlayerState(6, 0, [self.carnCoop], []) self.p7 = PlayerState(7, 0, [self.fatScav], []) self.p8 = PlayerState(8, 0, [self.fatFor, self.extinct], []) self.dealer = Dealer([self.p1, self.p2, self.p3], 3, [self.t1, self.t2, self.t3, self.t4, self.t5]) self.p2dealer = Dealer([self.p6, self.p5], 3, []) self.p3dealer = Dealer([self.p8], 3, [self.t1, self.t2, self.t3, self.t4, self.t5]) self.xstep3spec = Species(0, 5, 2, [TraitCard("foraging")], 0) self.xstep3p = PlayerState(1, 0, [self.xstep3spec], []) self.xstep3deal = Dealer([self.xstep3p], 5, []) # 8949-0357-4 self.pCFS1 = PlayerState(1, 3, [ Species(4, 2, 5, [TraitCard("carnivore"), TraitCard("cooperation")], 0), Species(1, 3, 4, [ TraitCard("foraging"), TraitCard("carnivore"), TraitCard("scavenger") ], 0) ], []) self.pCFS2 = PlayerState( 2, 4, [Species(2, 3, 3, [TraitCard("burrowing")], 0)], []) self.pCFS3 = PlayerState(3, 5, [], []) self.dCFS = Dealer([self.pCFS1, self.pCFS2, self.pCFS3], 10, []) # for step4 self.t6 = TraitCard("herding", 0) self.defSpec = Species(0, 0, 1, [], 0) self.specWGrownBody = Species(0, 1, 1, [], 0) self.specW3t = Species(0, 0, 1, [self.t3, self.t4, self.t5], 0) self.specWAll = Species(2, 1, 2, [self.t4], 1) self.playerWithManyCards = PlayerState( 1, 0, [], [self.t1, self.t2, self.t3, self.t4, self.t5, self.t6]) self.playerForAll = PlayerState(1, 0, [self.specWAll], []) self.playerFor3t = PlayerState(1, 0, [self.specW3t], [self.t6]) self.playerForDefSpec = PlayerState(1, 0, [self.defSpec], [self.t5, self.t6]) self.playerForBodyNewSpec = PlayerState( 1, 0, [self.specWGrownBody], [self.t3, self.t4, self.t5, self.t6]) self.noAct = Action4(0, [], [], [], []) self.actGP = Action4(0, [GainPopulation(0, 0)], [], [], []) self.actGB = Action4(0, [], [GainBodySize(0, 1)], [], []) self.actRT = Action4(0, [], [], [], [ReplaceTrait(0, 1, 1)]) self.actBT0t = Action4(0, [], [], [BuySpeciesBoard(1, [])], []) self.actBT1t = Action4(0, [], [], [BuySpeciesBoard(1, [2])], []) self.actBT2t = Action4(0, [], [], [BuySpeciesBoard(1, [2, 3])], []) self.actBT3t = Action4(0, [], [], [BuySpeciesBoard(1, [2, 3, 4])], []) self.actBT4t = Action4(0, [], [], [BuySpeciesBoard(1, [2, 3, 4, 5])], []) self.addBodyToNewSpec = Action4(0, [GainPopulation(1, 1)], [], [BuySpeciesBoard(2, [3])], []) self.actAll = Action4(0, [GainPopulation(0, 1)], [GainBodySize(0, 2)], [BuySpeciesBoard(4, [5])], [ReplaceTrait(0, 0, 3)]) self.simpleDealerForStep4 = Dealer([self.playerWithManyCards], 0, []) self.dealerForRevokingCards = Dealer([ PlayerState(1, 0, [], [self.t1, self.t2]), PlayerState(2, 0, [], [self.t3, self.t4, self.t5]), PlayerState(3, 0, [], [self.t6]) ], 0, []) self.dealerManyActions = Dealer([ PlayerState(1, 0, [self.defSpec], [self.t1, self.t2]), PlayerState(2, 0, [self.vegHorns, self.fatScav, self.carnCoop], [self.t3, self.t4, self.t5, self.t6, self.t1]), PlayerState(3, 0, [self.vegCoop, self.carnCoop, self.carnForage1], [self.t6]) ], 0, [])
def traitCardFromJson(card): return TraitCard(card[1], card[0])
def setUp(self): self.noTraits = Species(0, 1, 3, [], 0) self.vegHorns = Species(1, 2, 3, [TraitCard("horns")], 0) self.vegCoop = Species(1, 2, 3, [TraitCard("cooperation")], 0) self.fat = Species(4, 3, 4, [TraitCard("fat-tissue")], 3) self.fertileCoop = Species( 0, 3, 4, [TraitCard("fertile"), TraitCard("cooperation")], 0) self.fertileLongNeck = Species(0, 3, 4, [ TraitCard("fertile"), TraitCard("long-neck"), TraitCard("cooperation") ], 0) self.full = Species(2, 2, 2, [], 0) self.fatScav = Species( 2, 3, 4, [TraitCard("fat-tissue"), TraitCard("scavenger")], 1) self.fatFor = Species(4, 3, 4, [TraitCard("fat-tissue"), TraitCard("foraging")], 1) self.carnCoop = Species( 3, 4, 5, [TraitCard("carnivore"), TraitCard("cooperation")], 0) self.carnForage = Species( 3, 4, 5, [TraitCard("carnivore"), TraitCard("foraging")], 0) self.carnForage1 = Species( 3, 4, 5, [TraitCard("carnivore"), TraitCard("foraging")], 0) self.forCoop = Species( 1, 3, 5, [TraitCard("foraging"), TraitCard("cooperation")], 0) self.extinct = Species(0, 0, 0, [], 0) self.p1 = PlayerState(1, 0, [self.vegCoop, self.fat, self.carnForage], []) self.p2 = PlayerState(2, 0, [self.vegHorns, self.fatScav, self.carnCoop], []) self.p3 = PlayerState(3, 0, [self.vegCoop, self.carnCoop, self.carnForage1], []) self.p4 = PlayerState(4, 0, [self.forCoop, self.noTraits], []) self.p5 = PlayerState(5, 0, [self.full, self.fat], []) self.p6 = PlayerState(6, 0, [self.extinct], []) self.p7 = PlayerState(7, 0, [], []) self.p8 = PlayerState(8, 0, [self.carnCoop], []) self.p9 = PlayerState(9, 0, [self.vegHorns], []) self.playerWithCards = PlayerState( 1, 0, [self.vegCoop, self.fat, self.carnForage], [ TraitCard("foraging", 2), TraitCard("carnivore", -7), TraitCard("scavenger", 3), TraitCard("horns", 1) ]) self.playerWithFertileLong = PlayerState( 1, 0, [self.fertileCoop, self.fertileLongNeck, self.carnForage], [ TraitCard("foraging", 2), TraitCard("carnivore", -7), TraitCard("scavenger", 3), TraitCard("horns", 1) ]) self.playerWithFat = PlayerState(1, 0, [self.fatScav, self.fatFor], [])
def testEqAndMutability(self): self.assertNotEqual(self.p1, self.p2) self.assertEqual(self.p1, self.otherp1) self.p1.hand.append(TraitCard("carnivore", 1)) self.assertNotEqual(self.p1.hand, self.p2.hand) self.assertNotEqual(self.p1, self.otherp1)
def testToJson(self): json_trait1 = [3, CARNIVORE] trait1 = TraitCard(CARNIVORE, 3) self.assertEquals(trait1.to_json(), json_trait1)
def testReplaceTrait(self): self.climbing.replaceTrait(0, TraitCard("hard-shell")) self.assertEqual(self.climbing, self.smallHardShell) self.bigHardShell.replaceTrait(0, TraitCard("herding")) self.assertNotEqual(self.bigHardShell, self.smallHerding)
def setUp(self): self.someTraits = [TraitCard("carnivore"), TraitCard("ambush")] self.defaultSpecies = Species(0, 0, 0, [], 0) self.aSpecies = Species(3, 3, 5, self.someTraits, 0) self.anotherSpecies = Species(2, 5, 7, self.someTraits, 0) self.yetAnotherSpecies = Species(1, 5, 7, self.someTraits, 0) self.yetAnotherYetAnotherSpecies = Species(2, 5, 7, self.someTraits, 0) self.fatNoFood = Species(0, 2, 2, [TraitCard("fat-tissue")], 2) self.foodNoFat = Species(2, 2, 2, [TraitCard("fat-tissue")], 0) self.fedUp = Species(2, 2, 2, [TraitCard("fat-tissue")], 2) self.carnivore = Species(3, 5, 5, [TraitCard("carnivore")], 0) self.carnivoreAmbush = Species(3, 3, 5, self.someTraits, 0) self.carnivoreClimber = Species(3, 3, 5, [TraitCard("carnivore"), TraitCard("climbing")], 0) self.smallCarnivorePackHunter = Species(3, 1, 5, [TraitCard("carnivore"), TraitCard("pack-hunting")], 0) self.warningCall = Species(1, 1, 2, [TraitCard("warning-call")], 0) self.vulnerable = Species(1, 1, 2, [], 0) self.burrowSuccess = Species(2, 1, 2, [TraitCard("burrowing")], 0) self.burrowFail = Species(0, 1, 2, [TraitCard("burrowing")], 0) self.climbing = Species(1, 1, 2, [TraitCard("climbing")], 0) self.smallHardShell = Species(1, 1, 2, [TraitCard("hard-shell")], 0) self.bigHardShell = Species(1, 4, 2, [TraitCard("hard-shell")], 0) self.smallHerding = Species(1, 1, 3, [TraitCard("herding")], 0) self.bigHerding = Species(1, 5, 5, [TraitCard("herding")], 0) self.herdingHorns = Species(1, 3, 4, [TraitCard("herding"), TraitCard("horns")], 0) self.smallSymbiosis = Species(1, 1, 2, [TraitCard("symbiosis")], 0) self.bigSymbiosis = Species(1, 5, 5, [TraitCard("symbiosis")], 0)