additional sorting

added sorting out of lands and sorting each catagory by CMC
This commit is contained in:
reimannsum 2016-06-14 15:13:12 -04:00
parent 7056035719
commit 595d636490
2 changed files with 29 additions and 4 deletions

View file

@ -89,8 +89,10 @@ def main(fname, oname = None, verbose = True, encoding = 'std',
# have to preapend html info
writer.write(utils.html_prepend)
# seperate the write function to allow for writing smaller chunks of cards at a time
segments = sort_cards(cards)
segments = sort_colors(cards)
for i in range(len(segments)):
# sort color by CMC
segments[i] = sort_cmc(segments[i])
# this allows card boxes to be colored for each color
# for coloring of each box seperately cardlib.Card.format() must change non-minimaly
writer.write('<div id="' + utils.segment_ids[i] + '">')
@ -162,7 +164,8 @@ def main(fname, oname = None, verbose = True, encoding = 'std',
writer.write('\n'.encode('utf-8'))
def sort_cards(card_set):
# Sorting by colors
def sort_colors(card_set):
# Initialize sections
red_cards = []
blue_cards = []
@ -171,6 +174,7 @@ def main(fname, oname = None, verbose = True, encoding = 'std',
white_cards = []
multi_cards = []
colorless_cards = []
lands = []
for card in card_set:
if len(card.get_colors())>1:
multi_cards += [card]
@ -191,9 +195,26 @@ def main(fname, oname = None, verbose = True, encoding = 'std',
white_cards += [card]
continue
else:
if "land" in card.get_types():
lands += [card]
continue
colorless_cards += [card]
return[white_cards, blue_cards, black_cards, red_cards, green_cards, multi_cards, colorless_cards]
return[white_cards, blue_cards, black_cards, red_cards, green_cards, multi_cards, colorless_cards, lands]
def sort_cmc(card_set):
sorted_cards = []
sorted_set = []
for card in card_set:
# make sure there is an empty set for each CMC
while len(sorted_cards)-1 < card.get_cmc():
sorted_cards += []
# add card to correct set of CMC values
sorted_cards[card.get_cmc()] += [card]
# combine each set of CMC valued cards together
for value in sorted_cards:
for card in value:
sorted_set += [card]
return sorted_set
if oname:

View file

@ -1,5 +1,5 @@
box_width = 350
id_lables = ["white", "blue", "black", "red", "green", "multi", "colorless"]
id_lables = ["white", "blue", "black", "red", "green", "multi", "colorless", "lands"]
html_prepend = """<!DOCTYPE html>
<head>
<style>
@ -46,6 +46,9 @@ html_prepend = """<!DOCTYPE html>
#colorless > div{
border-color:lightgrey;
}
#colorless > div{
border-color:darkgoldenrod;
}
div.hover_img {
position: relative;
@ -496,5 +499,6 @@ html_prepend = """<!DOCTYPE html>
<li style="background-color:green;"><a href="#green">Green Cards</a></li>
<li style="background-color:gold;"><a href="#multi" style="color:black">Multi-colored Cards</a></li>
<li style="background-color:lightgrey;"><a href="#colorless" style="color:black">Colorless Cards</a></li>
<li style="background-color:darkgoldenrod;"><a href="#lands" style="color:black">lands Cards</a></li>
</ul>
"""