This repository has been archived by the owner on Jul 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
New_Game.py
90 lines (84 loc) · 3.29 KB
/
New_Game.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
from ComponentManager import ComponentManager as CM
from EntityManager import EntityManager as EM
from Handle_Keys import next_level
from C_Creature import Creature
from End_Game import End_Game
from C_Attack import Attack
from Message import Message
from C_Coord import Coord
from C_Death import Death
from C_Flags import Level
from C_Tile import Tile
from Panel import Panel
from Menu import Menu
import ECS_Storage
import libtcodpy
import config
import Color
def New_Game():
get_name()
ECS_Storage.init()
CM.new_Component('Poison')
config.DungeonLevelIds = {}
config.CurrentDungeonLevel = 0
config.PlayerId = EM.new_Id()
config.PlayerAttack = EM.new_Id()
config.fov_recompute = True
config.game_msg = []
config.game_state = 'playing'
config.xptolevel = 66.6
CM.new_Component('ToLevel')
CM.add_Component(config.PlayerId, 'Tile', Tile('Player', '@', False,
True, Color.sky))
CM.add_Component(config.PlayerId, 'Coord',
Coord(config.playscreen_width / 2,
config.playscreen_height / 2))
deatheffects = [player_death]
CM.add_Component(config.PlayerId, 'Death',
Death('You have died. What a pity.' +
' Did you even manage to get any loot?',
'%', effects=deatheffects))
CM.add_Component(config.PlayerId, 'Creature', Creature(10, 0, 10,
10, 7, 0,
special={}))
CM.add_Component(config.PlayerId, 'Level', Level())
CM.add_Component(config.PlayerAttack, 'Attack', Attack(1, 4))
next_level()
Message('Welcome young adventurer! You have just entered my dungeon and' +
' through my deal with the adventurers guild you may explore my' +
' first 12 levels! Though of course everything will still try to' +
' kill you but atleast once finish there is an easy passage out!',
Color.red)
def player_death(playerid):
End_Game()
def get_name():
config.PlayerName = ''
name = ''
namepanel = Panel(0, 0, config.window_width, config.window_height)
while True:
namepanel.clear
config.gamewindow.clear
namepanel.write(config.window_width / 2 - 21,
int(config.window_height * .2),
'Please Enter a Name! (ten character limit)')
namepanel.write(config.window_width / 2 - len(name) / 2 - 2,
int(config.window_height * .3),
'( ' + name + ' )')
namepanel.blit()
config.gamewindow.flush
key = libtcodpy.console_wait_for_keypress(True)
if key.vk == libtcodpy.KEY_BACKSPACE and len(name) > 0:
name = name[:-1]
elif key.vk == libtcodpy.KEY_ENTER and len(name) > 0:
option = None
while option is None:
option = Menu('Is ' + name + ' the name you want?',
['Yes', 'No'], 20)
if option == 0:
break
else:
if len(name) < 10:
if key.c != 0:
key_char = chr(key.c)
name += key_char
config.PlayerName = name