Skip to content

Commit

Permalink
Update modo.py
Browse files Browse the repository at this point in the history
Get_Winner: Now checks entire list of Game Actions for a concession string before checking if any lose conditions exist.
  • Loading branch information
cderickson committed Jan 19, 2022
1 parent fb2479e commit 1b2948b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modo.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,17 @@ def get_winner(curr_game_list,p1,p2):
# Input: [Game Actions],String,String,
# Output: String

# Look for a concession string.
for index,i in enumerate(curr_game_list):
if i.find("has conceded") != -1:
if i.split()[0] == p1:
return "P2"
elif i.split()[0] == p2:
return "P1"

lastline = curr_game_list[-1]
# Add more lose conditions
if lastline.find("has conceded") != -1 or \
lastline.find("is being attacked") != -1 or \
if lastline.find("is being attacked") != -1 or \
lastline.find("has lost the game") != -1 or \
lastline.find("loses because of drawing a card") != -1:
if lastline.split()[0] == p1:
Expand All @@ -357,6 +364,7 @@ def get_winner(curr_game_list,p1,p2):
elif lastline.split()[0] == p2:
return "P2"
# Could not determine a winner.
#print(curr_game_list)
return "NA"
def get_cards(play):
# Input: String
Expand Down

0 comments on commit 1b2948b

Please sign in to comment.