Closed courageousillumination closed 9 years ago
So imagine we're making magic and I have Doomblade. As it stands now we would need to do something like this
doomblade = Card()
doomblade.color = black
doomblade.cost = ...
doomblade.type = 'instant'
doomblade.effect = doomblade_effect
def doomblade_effect(target):
# Make sure target is nonblack creature
# destroy target
This would be a huge pain if you're doing this for a couple hundred cards. Now imagine instead you could write a simple yaml file like this
name: "Doomblade"
type: "Instant"
color: "black"
cost: "1B"
effect: "destroy target non-black creature"
And you could also have specific rules in a python file somewhere that does the following
@effect("destroy target (.*)")
def destroy_target(target):
# Destroy target
@card_type("non-black")
def is_non_black(card):
return card.color == 'black'
@card_type("creature")
def is_creature(card):
return card.type == 'creature'
If we did this we could reuse our code for a bunch of different cards and it would be really easy to type up new cards (all you need is a little YAML).
Dammit Tristan! Stop making commits before the rest of us are even awake :P
On Sunday, November 23, 2014, Tristan Rasmussen notifications@github.com wrote:
54 https://github.com/courageousillumination/deckr/pull/54
— Reply to this email directly or view it on GitHub https://github.com/courageousillumination/deckr/issues/31#issuecomment-64124753 .
Jennifer Ma Computer Science, English 2015 jcma@uchicago.edu
Having to hard code cards kind of sucks. Make it suck less.