Skip to content

Commit

Permalink
Merge pull request #240 from johnpooch/develop
Browse files Browse the repository at this point in the history
Fix bug where named_coast not set on Build
  • Loading branch information
johnpooch authored Apr 28, 2021
2 parents c2fd7a1 + b5a7bbc commit 2e8e34c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions adjudicator/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ class Build(Order):
check.SourceNamedCoastNotSpecified,
]

def __init__(self, state, id, nation, source, piece_type, named_coast=None, **kwargs):
def __init__(self, state, id, nation, source, piece_type, target_coast=None, **kwargs):
super().__init__(state, id, nation, source)
self.piece_type = piece_type
self.named_coast = named_coast
self.named_coast = target_coast

def __str__(self):
order_type = self.__class__.__name__.upper()
Expand Down
38 changes: 38 additions & 0 deletions core/tests/test_adjudicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,41 @@ def test_turkey_does_not_take_bulgaria(self):
new_bulgaria_state = new_turn.territorystates.get(territory=bulgaria)
self.assertIsNone(old_bulgaria_state.captured_by)
self.assertIsNone(new_bulgaria_state.controlled_by)

def test_build_fleet_st_petersburg_north_coast(self):
self.turn.season = Season.FALL
self.turn.phase = Phase.BUILD
self.turn.save()
st_petersburg = models.Territory.objects.get(id='standard-st-petersburg')
st_petersburg_north_coast = models.NamedCoast.objects.get(id='standard-st-petersburg-north-coast')
for nation in models.Nation.objects.all():
models.NationState.objects.create(
nation=nation,
turn=self.turn,
)
models.TerritoryState.objects.create(
controlled_by=self.russia,
territory=st_petersburg,
turn=self.turn,
)
for territory in models.Territory.objects.exclude(id=st_petersburg.id):
models.TerritoryState.objects.create(
territory=territory,
turn=self.turn,
)
order = models.Order.objects.create(
nation=self.russia,
source=st_petersburg,
piece_type=PieceType.FLEET,
target_coast=st_petersburg_north_coast,
turn=self.turn,
type=OrderType.BUILD,
)
new_turn = process_turn(self.turn)
order.refresh_from_db()
self.assertFalse(order.illegal)
new_turn.piecestates.get(
territory=st_petersburg,
named_coast=st_petersburg_north_coast,
piece__nation=self.russia
)

0 comments on commit 2e8e34c

Please sign in to comment.