-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.py
51 lines (43 loc) · 1.29 KB
/
profile.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
'''
Created on Aug 14, 2012
@author: Jami
'''
import consts
import pygame
class Profile(dict):
'''
Contains all the information necessary for a profile
'''
shiplist = None
def __init__(self):
self.shiplist = {}
def create_profile_from_attrs(attrs, default_id = -1):
keys = attrs.keys()
profile = Profile()
for key in keys:
profile[key] = attrs.get(key)
if int(profile['id']) == default_id:
profile['active'] = True
return profile
def create_fresh_profile(**kwargs):
list = kwargs.get('profiles', None)
id = kwargs.get('id', -1)
if id == -1 and list:
for p in list:
if 'id' in p and int(p['id']) > id:
id = int(p['id'])
id += 1
profile = Profile()
profile['id'] = id
profile['name'] = 'newbie'
profile['ship'] = 0
profile['credits'] = 0
disp = pygame.display.get_surface()
if disp:
profile['width'] = pygame.display.get_surface().get_width()
profile['height'] = pygame.display.get_surface().get_height()
else:
profile['width'] = consts.DEFAULT_WINDOW_WIDTH
profile['height'] = consts.DEFAULT_WINDOW_HEIGHT
profile['fullscreen'] = False
return profile