-
Notifications
You must be signed in to change notification settings - Fork 0
/
id_card.py
155 lines (122 loc) · 5.26 KB
/
id_card.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import arcade
import assets
import math
import random
class IdCard():
"""
Container and checker of validity.
"""
def __init__(self, person, false_id):
"""
Init the card
"""
self.false_id = false_id
self.incorrect_elem = None
self.person = person
# Generate a set of valid elemements
self.id_texture = assets.backgrounds["idcard"]
self.texture = self.person.texture
self.name = self.person.name
self.birthdate = "{day}-{month}-{year}".format(
day = str(random.randint(1,28)),
month = str(random.randint(1,12)),
year = str (random.randint(1950, 2010)))
self.exp_date = "{day}-{month}-{year}".format(
day = str(random.randint(1,28)),
month = str(random.randint(1,12)),
year = str (random.randint(2022, 2024)))
self.iss_city = random.choice(["Malmo","Stockholm",
"Goteborg","Linkoping",
"Norrkoping","Koping"])
self.gender = random.choice(["Boi","Grill",
"Microwave","Wolf",
"Attack Helicopter", "Mayonnaise",
"Gopnik", "Stockholmare",
"Lost soul"])
if false_id:
self.incorrect_elem = random.randint(0,5)
self.invalid_element_generator()
def draw(self):
"""
Draw current ID-Card
"""
self.x, self.y = 1550, 850
self.x_to = - 70
self.y_tos = 150
arcade.draw_scaled_texture_rectangle(self.x, self.y, self.id_texture, 1)
arcade.draw_scaled_texture_rectangle(self.x-235, self.y+75, self.texture, 0.4)
arcade.draw_text("Name: " + self.name.capitalize().replace("_", " "),
self.x + self.x_to,
self.y + self.y_tos,
arcade.color.BLACK, 20,
font_name="res/font/Hand_Power.ttf")
arcade.draw_text("Birthday: " + self.birthdate,
self.x + self.x_to,
self.y + self.y_tos -70,
arcade.color.BLACK, 20,
font_name="res/font/Hand_Power.ttf")
arcade.draw_text("Expiration Date: " + self.exp_date,
self.x + self.x_to,
self.y + self.y_tos -155,
arcade.color.BLACK, 20,
font_name="res/font/Hand_Power.ttf")
arcade.draw_text("Issuing City: " + self.iss_city,
self.x + self.x_to,
self.y + self.y_tos -235,
arcade.color.BLACK, 20,
font_name="res/font/Hand_Power.ttf")
arcade.draw_text("Gender: " + self.gender,
self.x + self.x_to,
self.y + self.y_tos -310,
arcade.color.BLACK, 20,
font_name="res/font/Hand_Power.ttf")
def is_false(self):
"""
Check if valid
"""
return self.false_id
def invalidity_reason(self):
"""
Do not call if valid
"""
if self.incorrect_elem != None:
reasons = ["Incorrect Watermark", "incorrect Image",
"Incorrect Name", "Incorrect Birthdate",
"Incorrect Expiration Date", "Incorrect Issuing City"]
return reasons[self.incorrect_elem]
return ""
def invalid_element_generator(self):
"""
Generate an invalid element
"""
if self.incorrect_elem == 0:
self.id_texture = assets.backgrounds["idcard_wrong"]
elif self.incorrect_elem == 1:
name = self.name
while self.name == name:
name = random.choice(list(assets.persons))
self.texture = assets.persons[name]
elif self.incorrect_elem == 2:
name = self.name
while self.name == name:
name = random.choice(list(assets.persons))
self.name = name
elif self.incorrect_elem == 3:
self.birthdate = "{day}-{month}-{year}" .format(
day = str(random.randint(1,28)),
month = str(random.randint(1,12)),
year = random.choice([str(random.randint(0, 1700)),
str(random.randint(2030, 2200))]))
elif self.incorrect_elem == 4:
self.exp_date = "{day}-{month}-{year}".format(
day = str(random.randint(1,28)),
month = str(random.randint(1,12)),
year = str (random.randint(0, 2020)))
elif self.incorrect_elem == 5:
self.iss_city = random.choice(["Mordor","Camelot",
"Caladan","Giedi Prime",
"Hell","Demacia", "Vogsphere",
"Tenochtitlan", "Alderaan",
"Winterfell", "Hogwarts",
"Ankh-Morpork", "Ogion",
"Miraz's Castle"])