-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (39 loc) · 1.17 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# import the pygame module, so you can use it
import pygame
import csv
from typing import List
from base import *
from random import shuffle
from pregame import pregame
from game import game
from postgame import postgame
# TODO all card images should be made the same size
def init(tags: List[str]) -> List[Card]:
with open('cards.csv', newline='') as f:
f.readline()
reader = csv.reader(f)
cards = [Card(*row[:5]) for row in reader if row[5] in tags]
return cards
# initialize the pygame module
pygame.init()
# load and set the logo
logo = pygame.image.load("logo.png")
pygame.display.set_icon(logo)
# set caption
pygame.display.set_caption("Timeline")
# create a surface on screen
screen = pygame.display.set_mode((0, 0))
restart = False
try:
while True:
if not restart:
# choose game mode
players, permadeath, n_cards, tags = pregame(screen)
# init cards
cards = init(tags)
shuffle(cards)
shuffle(players)
scores, timeline = game(screen, players, permadeath, n_cards, cards)
restart = postgame(screen, scores, timeline, cards)
except SystemExit:
pygame.quit()