Skip to content

Commit

Permalink
Added new fields from Communication Mod 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ForgottenArbiter committed Aug 24, 2019
1 parent aa289e2 commit 2911af1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions spirecomm/spire/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self):
self.discard_pile = []
self.exhaust_pile = []
self.hand = []
self.limbo = []

# Current Screen

Expand Down Expand Up @@ -105,6 +106,7 @@ def from_json(cls, json_state, available_commands):
game.discard_pile = [spirecomm.spire.card.Card.from_json(json_card) for json_card in combat_state.get("discard_pile")]
game.exhaust_pile = [spirecomm.spire.card.Card.from_json(json_card) for json_card in combat_state.get("exhaust_pile")]
game.hand = [spirecomm.spire.card.Card.from_json(json_card) for json_card in combat_state.get("hand")]
game.limbo = [spirecomm.spire.card.Card.from_json(json_card) for json_card in combat_state.get("limbo", [])]

# Available Commands

Expand Down
20 changes: 18 additions & 2 deletions spirecomm/spire/power.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import spirecomm.spire.card


class Power:

def __init__(self, power_id, name, amount):
def __init__(self, power_id, name, amount, damage=0, misc=0, just_applied=False, card=None):
self.power_id = power_id
self.power_name = name
self.amount = amount
self.damage = damage
self.misc = misc
self.just_applied = just_applied
self.card = card

@classmethod
def from_json(cls, json_object):
return cls(json_object["id"], json_object["name"], json_object["amount"])
power_id = json_object["id"]
name = json_object["name"]
amount = json_object["amount"]
damage = json_object.get("damage", 0)
misc = json_object.get("misc", 0)
just_applied = json_object.get("just_applied", False)
card = json_object.get("card", None)
if card is not None:
card = spirecomm.spire.card.Card.from_json(card)
return cls(power_id, name, amount, damage, misc, just_applied, card)

def __eq__(self, other):
return self.power_id == other.power_id and self.amount == other.amount

0 comments on commit 2911af1

Please sign in to comment.