def testParseOldDeckWithParen(self): parsed_deck = parse_game.parse_deck( u"""<b>Jeremy (BaconSnake): 66 points</b> (8 <span class=card-victory>Provinces</span>, 4 <span class=card-victory>Duchies</span>, and 6 <span class=card-victory>Estates</span>); 28 turns opening: <span class=card-none>Smithy</span> / <span class=card-treasure>Silver</span> [38 cards] 2 <span class=card-none>Smithies</span>, 7 <span class=card-treasure>Coppers</span>, 5 <span class=card-treasure>Silvers</span>, 6 <span class=card-treasure>Golds</span>, 6 <span class=card-victory>Estates</span>, 4 <span class=card-victory>Duchies</span>, 8 <span class=card-victory>Provinces</span> """ ) self.assertEquals(parsed_deck['name'], 'Jeremy (BaconSnake)')
def testDeckWithVP3(self): parsed_deck = parse_game.parse_deck( u"""<b>Chrome: 12 points</b> (a <span class=card-victory>Province</span> and 26 ▼); 13 turns opening: <span class=card-none>Ironworks</span> / <span class=card-none>Black Market</span> [25 cards] 5 <span class=card-duration>Merchant Ships</span>, 5 <span class=card-none>Universities</span>, 2 <span class=card-none>Apprentices</span>, 2 <span class=card-none>Warehouses</span>, 1 <span class=card-none>Bishop</span>, 1 <span class=card-none>Black Market</span>, 1 <span class=card-none>Explorer</span>, 1 <span class=card-none>Worker's Village</span>, 6 <span class=card-treasure>Coppers</span>, 1 <span class=card-victory>Province</span>""" ) self.assertEquals(parsed_deck['vp_tokens'], 26)
def test20101213StyleDeckWithParenName(self): parsed_deck = parse_game.parse_deck( u"""<b>#1 Foo (Bar)</b>: 43 points (4 <span class=card-victory>Provinces</span>, 3 <span class=card-victory>Duchies</span>, 2 <span class=card-victory>Dukes</span>, and 2 <span class=card-victory-treasure>Harems</span>); 21 turns opening: <span class=card-none>Upgrade</span> / <span class=card-duration>Lighthouse</span> [25 cards] 2 <span class=card-victory>Dukes</span>, 2 <span class=card-victory-treasure>Harems</span>, 2 <span class=card-none>Upgrades</span>, 1 <span class=card-none>Expand</span>, 1 <span class=card-duration>Lighthouse</span>, 4 <span class=card-treasure>Silvers</span>, 6 <span class=card-treasure>Golds</span>, 3 <span class=card-victory>Duchies</span>, 4 <span class=card-victory>Provinces</span> """ ) self.assertEquals(parsed_deck['name'], 'Foo (Bar)')
def testDeckWithVP(self): parsed_deck = parse_game.parse_deck( u"""<b>Jon: 19 points</b> (16 ▼ and a <span class=card-victory>Duchy</span>); 20 turns opening: <span class=card-none>Salvager</span> / <span class=card-none>Black Market</span> [7 cards] 2 <span class=card-none>Bishops</span>, 1 <span class=card-duration>Tactician</span>, 1 <span class=card-treasure>Silver</span>, 2 <span class=card-treasure>Golds</span>, 1 <span class=card-victory>Duchy</span>""" ) self.assertEquals(parsed_deck['vp_tokens'], 16)
def testDeckWithResign(self): parsed_deck = parse_game.parse_deck( u"""<b>#1 kiwi</b>: resigned (1st); 13 turns opening: <span class=card-none>Shanty Town</span> / <span class=card-none>Baron</span> [23 cards] 8 <span class=card-none>Shanty Towns</span>, 5 <span class=card-none>Rabbles</span>, 2 <span class=card-none>Expands</span>, 1 <span class=card-none>Market</span>, 6 <span class=card-treasure>Coppers</span>, 1 <span class=card-victory>Estate</span> """ ) self.assertEquals(parsed_deck['resigned'], True)
def testParseEmptyDeck(self): # it's random BS like this that makes writing a dominion log parser # a pain. parsed_deck = parse_game.parse_deck(u"""<b>torchrat: 0 points</b> (nothing); 24 turns opening: <span class=card-none>Moneylender</span> / <span class=card-treasure>Silver</span> [0 cards] """) self.assertEquals(parsed_deck['vp_tokens'], 0) self.assertEquals(parsed_deck['deck'], {})
def testParseEmptyDeck(self): # it's random BS like this that makes writing a dominion log parser # a pain. parsed_deck = parse_game.parse_deck( u"""<b>torchrat: 0 points</b> (nothing); 24 turns opening: <span class=card-none>Moneylender</span> / <span class=card-treasure>Silver</span> [0 cards] """) self.assertEquals(parsed_deck['vp_tokens'], 0) self.assertEquals(parsed_deck['deck'], {})
def testDeck(self): parsed_deck = parse_game.parse_deck(u"""<b>Snead: 75 points</b> (7 <span class=card-victory>Colonies</span>, 2 <span class=card-victory-action>Islands</span>, and an <span class=card-victory>Estate</span>); 22 turns opening: <span class=card-victory-action>Island</span> / <span class=card-treasure>Silver</span> [15 cards] 2 <span class=card-victory-action>Islands</span>, 1 <span class=card-none>Chapel</span>, 1 <span class=card-duration>Tactician</span>, 1 <span class=card-treasure>Silver</span>, 2 <span class=card-treasure>Platinums</span>, 1 <span class=card-victory>Estate</span>, 7 <span class=card-victory>Colonies</span>""") self.assertEquals(parsed_deck['name'], 'Snead') self.assertEquals(parsed_deck['points'], 75) self.assertEquals(parsed_deck['vp_tokens'], 0) self.assertEquals(parsed_deck['deck'], {'Island': 2, 'Chapel': 1, 'Tactician': 1, 'Silver': 1, 'Platinum': 2, 'Estate': 1, 'Colony': 7})
def testDeck(self): parsed_deck = parse_game.parse_deck( u"""<b>Snead: 75 points</b> (7 <span class=card-victory>Colonies</span>, 2 <span class=card-victory-action>Islands</span>, and an <span class=card-victory>Estate</span>); 22 turns opening: <span class=card-victory-action>Island</span> / <span class=card-treasure>Silver</span> [15 cards] 2 <span class=card-victory-action>Islands</span>, 1 <span class=card-none>Chapel</span>, 1 <span class=card-duration>Tactician</span>, 1 <span class=card-treasure>Silver</span>, 2 <span class=card-treasure>Platinums</span>, 1 <span class=card-victory>Estate</span>, 7 <span class=card-victory>Colonies</span>""" ) self.assertEquals(parsed_deck['name'], 'Snead') self.assertEquals(parsed_deck['points'], 75) self.assertEquals(parsed_deck['vp_tokens'], 0) self.assertEquals( parsed_deck['deck'], { 'Island': 2, 'Chapel': 1, 'Tactician': 1, 'Silver': 1, 'Platinum': 2, 'Estate': 1, 'Colony': 7 })
def testDeckWithVP3(self): parsed_deck = parse_game.parse_deck(u"""<b>Chrome: 12 points</b> (a <span class=card-victory>Province</span> and 26 ▼); 13 turns opening: <span class=card-none>Ironworks</span> / <span class=card-none>Black Market</span> [25 cards] 5 <span class=card-duration>Merchant Ships</span>, 5 <span class=card-none>Universities</span>, 2 <span class=card-none>Apprentices</span>, 2 <span class=card-none>Warehouses</span>, 1 <span class=card-none>Bishop</span>, 1 <span class=card-none>Black Market</span>, 1 <span class=card-none>Explorer</span>, 1 <span class=card-none>Worker's Village</span>, 6 <span class=card-treasure>Coppers</span>, 1 <span class=card-victory>Province</span>""") self.assertEquals(parsed_deck['vp_tokens'], 26)
def testParseOldDeckWithParen(self): parsed_deck = parse_game.parse_deck(u"""<b>Jeremy (BaconSnake): 66 points</b> (8 <span class=card-victory>Provinces</span>, 4 <span class=card-victory>Duchies</span>, and 6 <span class=card-victory>Estates</span>); 28 turns opening: <span class=card-none>Smithy</span> / <span class=card-treasure>Silver</span> [38 cards] 2 <span class=card-none>Smithies</span>, 7 <span class=card-treasure>Coppers</span>, 5 <span class=card-treasure>Silvers</span>, 6 <span class=card-treasure>Golds</span>, 6 <span class=card-victory>Estates</span>, 4 <span class=card-victory>Duchies</span>, 8 <span class=card-victory>Provinces</span> """) self.assertEquals(parsed_deck['name'], 'Jeremy (BaconSnake)')
def testDeckWithVP(self): parsed_deck = parse_game.parse_deck(u"""<b>Jon: 19 points</b> (16 ▼ and a <span class=card-victory>Duchy</span>); 20 turns opening: <span class=card-none>Salvager</span> / <span class=card-none>Black Market</span> [7 cards] 2 <span class=card-none>Bishops</span>, 1 <span class=card-duration>Tactician</span>, 1 <span class=card-treasure>Silver</span>, 2 <span class=card-treasure>Golds</span>, 1 <span class=card-victory>Duchy</span>""") self.assertEquals(parsed_deck['vp_tokens'], 16)
def test20101226EvilFingName(self): parsed_deck = parse_game.parse_deck(u"""<b>#1 20 points</b>: 43 points (4 <span class=card-victory>Provinces</span>, 3 <span class=card-victory>Duchies</span>, 2 <span class=card-victory>Dukes</span>, and 2 <span class=card-victory-treasure>Harems</span>); 21 turns opening: <span class=card-none>Upgrade</span> / <span class=card-duration>Lighthouse</span> [25 cards] 2 <span class=card-victory>Dukes</span>, 2 <span class=card-victory-treasure>Harems</span>, 2 <span class=card-none>Upgrades</span>, 1 <span class=card-none>Expand</span>, 1 <span class=card-duration>Lighthouse</span>, 4 <span class=card-treasure>Silvers</span>, 6 <span class=card-treasure>Golds</span>, 3 <span class=card-victory>Duchies</span>, 4 <span class=card-victory>Provinces</span> """) self.assertEquals(parsed_deck['name'], '20 points') self.assertEquals(parsed_deck['points'], 43)
def testDeckWithResign(self): parsed_deck = parse_game.parse_deck(u"""<b>#1 kiwi</b>: resigned (1st); 13 turns opening: <span class=card-none>Shanty Town</span> / <span class=card-none>Baron</span> [23 cards] 8 <span class=card-none>Shanty Towns</span>, 5 <span class=card-none>Rabbles</span>, 2 <span class=card-none>Expands</span>, 1 <span class=card-none>Market</span>, 6 <span class=card-treasure>Coppers</span>, 1 <span class=card-victory>Estate</span> """) self.assertEquals(parsed_deck['resigned'], True)